1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2001 CodeFactory AB
3 * Copyright (C) 2001, 2002 Anders Carlsson
4 * Copyright (C) 2003, 2004 Matthias Clasen <mclasen@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * Author: Anders Carlsson <andersca@gnome.org>
25 * Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
35 #include <gdk/gdkkeysyms.h>
37 #include "gtkaboutdialog.h"
38 #include "gtkbutton.h"
40 #include "gtkdialog.h"
44 #include "gtklinkbutton.h"
45 #include "gtkmarshalers.h"
46 #include "gtknotebook.h"
47 #include "gtkscrolledwindow.h"
49 #include "gtktextview.h"
51 #include "gtkiconfactory.h"
54 #include "gtkmessagedialog.h"
55 #include "gtkprivate.h"
62 * SECTION:gtkaboutdialog
63 * @Short_description: Display information about an application
64 * @Title: GtkAboutDialog
65 * @See_also:#GTK_STOCK_ABOUT
67 * The #GtkAboutDialog offers a simple way to display information about
68 * a program like its logo, name, copyright, website and license. It is
69 * also possible to give credits to the authors, documenters, translators
70 * and artists who have worked on the program. An about dialog is typically
71 * opened when the user selects the <literal>About</literal> option from
72 * the <literal>Help</literal> menu. All parts of the dialog are optional.
74 * About dialog often contain links and email addresses. #GtkAboutDialog
75 * supports this by offering global hooks, which are called when the user
76 * clicks on a link or email address, see gtk_about_dialog_set_email_hook()
77 * and gtk_about_dialog_set_url_hook(). Email addresses in the
78 * authors, documenters and artists properties are recognized by looking for
79 * <literal><user@<!-- -->host></literal>, URLs are
80 * recognized by looking for <literal>http://url</literal>, with
81 * <literal>url</literal> extending to the next space, tab or line break.
83 * <para id="gtk-about-dialog-hook-setup">
84 * Since 2.18 #GtkAboutDialog provides default website and email hooks that
88 * If you want provide your own hooks overriding the default ones, it is
89 * important to do so before setting the website and email URL properties,
91 * <informalexample><programlisting>
92 * gtk_about_dialog_set_url_hook (GTK_ABOUT_DIALOG (dialog), launch_url, NULL, NULL);
93 * gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog), app_url);
94 * </programlisting></informalexample>
95 * To disable the default hooks, you can pass %NULL as the hook func. Then,
96 * the #GtkAboutDialog widget will not display the website or the
97 * email addresses as clickable.
99 * To make constructing a #GtkAboutDialog as convenient as possible, you can
100 * use the function gtk_show_about_dialog() which constructs and shows a dialog
101 * and keeps it around so that it can be shown again.
103 * Note that GTK+ sets a default title of <literal>_("About %s")</literal>
104 * on the dialog window (where %s is replaced by the name of the
105 * application, but in order to ensure proper translation of the title,
106 * applications should set the title property explicitly when constructing
107 * a #GtkAboutDialog, as shown in the following example:
108 * <informalexample><programlisting>
109 * gtk_show_about_dialog (NULL,
110 * "program-name", "ExampleCode",
111 * "logo", example_logo,
112 * "title" _("About ExampleCode"),
114 * </programlisting></informalexample>
115 * Note that prior to GTK+ 2.12, the #GtkAboutDialog:program-name property
116 * was called "name". This was changed to avoid the conflict with the
117 * #GtkWidget:name property.
121 static GdkColor default_link_color = { 0, 0, 0, 0xeeee };
122 static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
124 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
125 struct _GtkAboutDialogPrivate
133 gchar *translator_credits;
140 GtkWidget *logo_image;
141 GtkWidget *name_label;
142 GtkWidget *comments_label;
143 GtkWidget *copyright_label;
144 GtkWidget *website_button;
145 GtkWidget *website_label;
147 GtkWidget *credits_button;
148 GtkWidget *credits_dialog;
149 GtkWidget *license_button;
150 GtkWidget *license_dialog;
152 GdkCursor *hand_cursor;
153 GdkCursor *regular_cursor;
155 GSList *visited_links;
157 guint hovering_over_link : 1;
158 guint wrap_license : 1;
161 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
176 PROP_TRANSLATOR_CREDITS,
183 static void gtk_about_dialog_finalize (GObject *object);
184 static void gtk_about_dialog_get_property (GObject *object,
188 static void gtk_about_dialog_set_property (GObject *object,
192 static void gtk_about_dialog_show (GtkWidget *widge);
193 static void update_name_version (GtkAboutDialog *about);
194 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
195 static void activate_url (GtkWidget *widget,
197 static void follow_if_link (GtkAboutDialog *about,
198 GtkTextView *text_view,
200 static void set_cursor_if_appropriate (GtkAboutDialog *about,
201 GtkTextView *text_view,
204 static void display_credits_dialog (GtkWidget *button,
206 static void display_license_dialog (GtkWidget *button,
208 static void close_cb (GtkAboutDialog *about);
209 static void default_url_hook (GtkAboutDialog *about,
212 static void default_email_hook (GtkAboutDialog *about,
213 const gchar *email_address,
216 static gboolean activate_email_hook_set = FALSE;
217 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
218 static gpointer activate_email_hook_data = NULL;
219 static GDestroyNotify activate_email_hook_destroy = NULL;
221 static gboolean activate_url_hook_set = FALSE;
222 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
223 static gpointer activate_url_hook_data = NULL;
224 static GDestroyNotify activate_url_hook_destroy = NULL;
227 default_url_hook (GtkAboutDialog *about,
229 gpointer user_data G_GNUC_UNUSED)
232 GError *error = NULL;
234 screen = gtk_widget_get_screen (GTK_WIDGET (about));
236 if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error)) {
239 dialog = gtk_message_dialog_new (GTK_WINDOW (about),
240 GTK_DIALOG_DESTROY_WITH_PARENT |
244 "%s", _("Could not show link"));
245 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
246 "%s", error->message);
247 g_error_free (error);
249 g_signal_connect (dialog, "response",
250 G_CALLBACK (gtk_widget_destroy), NULL);
252 gtk_window_present (GTK_WINDOW (dialog));
257 default_email_hook (GtkAboutDialog *about,
258 const gchar *email_address,
263 escaped = g_uri_escape_string (email_address, NULL, FALSE);
264 uri = g_strdup_printf ("mailto:%s", escaped);
267 default_url_hook (about, uri, user_data);
271 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
274 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
276 GObjectClass *object_class;
277 GtkWidgetClass *widget_class;
279 object_class = (GObjectClass *)klass;
280 widget_class = (GtkWidgetClass *)klass;
282 object_class->set_property = gtk_about_dialog_set_property;
283 object_class->get_property = gtk_about_dialog_get_property;
285 object_class->finalize = gtk_about_dialog_finalize;
287 widget_class->show = gtk_about_dialog_show;
290 * GtkAboutDialog:program-name:
292 * The name of the program.
293 * If this is not set, it defaults to g_get_application_name().
297 g_object_class_install_property (object_class,
299 g_param_spec_string ("program-name",
301 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
303 GTK_PARAM_READWRITE));
306 * GtkAboutDialog:version:
308 * The version of the program.
312 g_object_class_install_property (object_class,
314 g_param_spec_string ("version",
315 P_("Program version"),
316 P_("The version of the program"),
318 GTK_PARAM_READWRITE));
321 * GtkAboutDialog:copyright:
323 * Copyright information for the program.
327 g_object_class_install_property (object_class,
329 g_param_spec_string ("copyright",
330 P_("Copyright string"),
331 P_("Copyright information for the program"),
333 GTK_PARAM_READWRITE));
337 * GtkAboutDialog:comments:
339 * Comments about the program. This string is displayed in a label
340 * in the main dialog, thus it should be a short explanation of
341 * the main purpose of the program, not a detailed list of features.
345 g_object_class_install_property (object_class,
347 g_param_spec_string ("comments",
348 P_("Comments string"),
349 P_("Comments about the program"),
351 GTK_PARAM_READWRITE));
354 * GtkAboutDialog:license:
356 * The license of the program. This string is displayed in a
357 * text view in a secondary dialog, therefore it is fine to use
358 * a long multi-paragraph text. Note that the text is only wrapped
359 * in the text view if the "wrap-license" property is set to %TRUE;
360 * otherwise the text itself must contain the intended linebreaks.
364 g_object_class_install_property (object_class,
366 g_param_spec_string ("license",
368 _("The license of the program"),
370 GTK_PARAM_READWRITE));
373 * GtkAboutDialog:website:
375 * The URL for the link to the website of the program.
376 * This should be a string starting with "http://.
380 g_object_class_install_property (object_class,
382 g_param_spec_string ("website",
384 P_("The URL for the link to the website of the program"),
386 GTK_PARAM_READWRITE));
389 * GtkAboutDialog:website-label:
391 * The label for the link to the website of the program. If this is not set,
392 * it defaults to the URL specified in the
393 * <link linkend="GtkAboutDialog--website">website</link> property.
397 g_object_class_install_property (object_class,
399 g_param_spec_string ("website-label",
401 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
403 GTK_PARAM_READWRITE));
406 * GtkAboutDialog:authors:
408 * The authors of the program, as a %NULL-terminated array of strings.
409 * Each string may contain email addresses and URLs, which will be displayed
410 * as links, see the introduction for more details.
414 g_object_class_install_property (object_class,
416 g_param_spec_boxed ("authors",
418 P_("List of authors of the program"),
420 GTK_PARAM_READWRITE));
423 * GtkAboutDialog:documenters:
425 * The people documenting the program, as a %NULL-terminated array of strings.
426 * Each string may contain email addresses and URLs, which will be displayed
427 * as links, see the introduction for more details.
431 g_object_class_install_property (object_class,
433 g_param_spec_boxed ("documenters",
435 P_("List of people documenting the program"),
437 GTK_PARAM_READWRITE));
440 * GtkAboutDialog:artists:
442 * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
443 * Each string may contain email addresses and URLs, which will be displayed
444 * as links, see the introduction for more details.
448 g_object_class_install_property (object_class,
450 g_param_spec_boxed ("artists",
452 P_("List of people who have contributed artwork to the program"),
454 GTK_PARAM_READWRITE));
458 * GtkAboutDialog:translator-credits:
460 * Credits to the translators. This string should be marked as translatable.
461 * The string may contain email addresses and URLs, which will be displayed
462 * as links, see the introduction for more details.
466 g_object_class_install_property (object_class,
467 PROP_TRANSLATOR_CREDITS,
468 g_param_spec_string ("translator-credits",
469 P_("Translator credits"),
470 P_("Credits to the translators. This string should be marked as translatable"),
472 GTK_PARAM_READWRITE));
475 * GtkAboutDialog:logo:
477 * A logo for the about box. If this is not set, it defaults to
478 * gtk_window_get_default_icon_list().
482 g_object_class_install_property (object_class,
484 g_param_spec_object ("logo",
486 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
488 GTK_PARAM_READWRITE));
491 * GtkAboutDialog:logo-icon-name:
493 * A named icon to use as the logo for the about box. This property
494 * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
498 g_object_class_install_property (object_class,
500 g_param_spec_string ("logo-icon-name",
501 P_("Logo Icon Name"),
502 P_("A named icon to use as the logo for the about box."),
504 GTK_PARAM_READWRITE));
506 * GtkAboutDialog:wrap-license:
508 * Whether to wrap the text in the license dialog.
512 g_object_class_install_property (object_class,
514 g_param_spec_boolean ("wrap-license",
516 P_("Whether to wrap the license text."),
518 GTK_PARAM_READWRITE));
521 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
525 gtk_about_dialog_init (GtkAboutDialog *about)
527 GtkDialog *dialog = GTK_DIALOG (about);
528 GtkAboutDialogPrivate *priv;
529 GtkWidget *vbox, *hbox, *button, *close_button, *image;
532 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
533 about->private_data = priv;
536 priv->version = NULL;
537 priv->copyright = NULL;
538 priv->comments = NULL;
539 priv->website_url = NULL;
540 priv->website_text = NULL;
541 priv->translator_credits = NULL;
542 priv->license = NULL;
543 priv->authors = NULL;
544 priv->documenters = NULL;
545 priv->artists = NULL;
547 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
548 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
549 priv->hovering_over_link = FALSE;
550 priv->wrap_license = FALSE;
552 gtk_dialog_set_has_separator (dialog, FALSE);
553 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
554 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
555 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
558 gtk_widget_push_composite_child ();
560 vbox = gtk_vbox_new (FALSE, 8);
561 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
562 gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, TRUE, TRUE, 0);
564 priv->logo_image = gtk_image_new ();
565 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
567 priv->name_label = gtk_label_new (NULL);
568 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
569 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
570 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
572 priv->comments_label = gtk_label_new (NULL);
573 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
574 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
575 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
576 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
578 priv->copyright_label = gtk_label_new (NULL);
579 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
580 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
581 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
583 hbox = gtk_hbox_new (TRUE, 0);
584 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
586 priv->website_button = button = gtk_link_button_new ("");
587 gtk_widget_set_no_show_all (button, TRUE);
588 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
590 priv->website_label = button = gtk_label_new ("");
591 gtk_widget_set_no_show_all (button, TRUE);
592 gtk_label_set_selectable (GTK_LABEL (button), TRUE);
593 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
595 gtk_widget_show (vbox);
596 gtk_widget_show (priv->logo_image);
597 gtk_widget_show (priv->name_label);
598 gtk_widget_show (hbox);
600 /* Add the OK button */
601 close_button = gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE,
602 GTK_RESPONSE_CANCEL);
603 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
605 /* Add the credits button */
606 button = gtk_button_new_with_mnemonic (_("C_redits"));
607 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
608 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
609 gtk_button_set_image (GTK_BUTTON (button), image);
610 gtk_widget_set_no_show_all (button, TRUE);
611 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
612 button, FALSE, TRUE, 0);
613 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
614 g_signal_connect (button, "clicked",
615 G_CALLBACK (display_credits_dialog), about);
616 priv->credits_button = button;
617 priv->credits_dialog = NULL;
619 /* Add the license button */
620 button = gtk_button_new_from_stock (_("_License"));
621 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
622 gtk_widget_set_no_show_all (button, TRUE);
623 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
624 button, FALSE, TRUE, 0);
625 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
626 g_signal_connect (button, "clicked",
627 G_CALLBACK (display_license_dialog), about);
628 priv->license_button = button;
629 priv->license_dialog = NULL;
631 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
633 gtk_widget_pop_composite_child ();
635 gtk_widget_grab_default (close_button);
636 gtk_widget_grab_focus (close_button);
639 gtk_about_dialog_set_program_name (about, NULL);
640 gtk_about_dialog_set_logo (about, NULL);
644 gtk_about_dialog_finalize (GObject *object)
646 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
647 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
650 g_free (priv->version);
651 g_free (priv->copyright);
652 g_free (priv->comments);
653 g_free (priv->license);
654 g_free (priv->website_url);
655 g_free (priv->website_text);
656 g_free (priv->translator_credits);
658 g_strfreev (priv->authors);
659 g_strfreev (priv->documenters);
660 g_strfreev (priv->artists);
662 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
663 g_slist_free (priv->visited_links);
665 gdk_cursor_unref (priv->hand_cursor);
666 gdk_cursor_unref (priv->regular_cursor);
668 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
672 gtk_about_dialog_set_property (GObject *object,
677 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
678 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
683 gtk_about_dialog_set_program_name (about, g_value_get_string (value));
686 gtk_about_dialog_set_version (about, g_value_get_string (value));
689 gtk_about_dialog_set_comments (about, g_value_get_string (value));
692 gtk_about_dialog_set_website (about, g_value_get_string (value));
694 case PROP_WEBSITE_LABEL:
695 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
698 gtk_about_dialog_set_license (about, g_value_get_string (value));
701 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
704 gtk_about_dialog_set_logo (about, g_value_get_object (value));
707 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
709 case PROP_DOCUMENTERS:
710 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
713 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
715 case PROP_TRANSLATOR_CREDITS:
716 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
718 case PROP_LOGO_ICON_NAME:
719 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
721 case PROP_WRAP_LICENSE:
722 priv->wrap_license = g_value_get_boolean (value);
725 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
731 gtk_about_dialog_get_property (GObject *object,
736 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
737 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
742 g_value_set_string (value, priv->name);
745 g_value_set_string (value, priv->version);
748 g_value_set_string (value, priv->copyright);
751 g_value_set_string (value, priv->comments);
754 g_value_set_string (value, priv->website_url);
756 case PROP_WEBSITE_LABEL:
757 g_value_set_string (value, priv->website_text);
760 g_value_set_string (value, priv->license);
762 case PROP_TRANSLATOR_CREDITS:
763 g_value_set_string (value, priv->translator_credits);
766 g_value_set_boxed (value, priv->authors);
768 case PROP_DOCUMENTERS:
769 g_value_set_boxed (value, priv->documenters);
772 g_value_set_boxed (value, priv->artists);
775 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
776 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
778 g_value_set_object (value, NULL);
780 case PROP_LOGO_ICON_NAME:
781 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
783 const gchar *icon_name;
785 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
786 g_value_set_string (value, icon_name);
789 g_value_set_string (value, NULL);
791 case PROP_WRAP_LICENSE:
792 g_value_set_boolean (value, priv->wrap_license);
795 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
801 update_website (GtkAboutDialog *about)
803 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
805 if (priv->website_url && (!activate_url_hook_set || activate_url_hook != NULL))
807 gtk_widget_show (priv->website_button);
808 gtk_widget_hide (priv->website_label);
810 gtk_link_button_set_uri (GTK_LINK_BUTTON (priv->website_button), priv->website_url);
811 if (priv->website_text)
812 gtk_button_set_label (GTK_BUTTON (priv->website_button), priv->website_text);
814 gtk_button_set_label (GTK_BUTTON (priv->website_button), priv->website_url);
818 gtk_widget_show (priv->website_label);
819 gtk_widget_hide (priv->website_button);
821 if (priv->website_url)
822 gtk_label_set_text (GTK_LABEL (priv->website_label), priv->website_url);
823 else if (priv->website_text)
824 gtk_label_set_text (GTK_LABEL (priv->website_label), priv->website_text);
826 gtk_widget_hide (priv->website_label);
831 gtk_about_dialog_show (GtkWidget *widget)
833 update_website (GTK_ABOUT_DIALOG (widget));
835 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->show (widget);
839 * gtk_about_dialog_get_name:
840 * @about: a #GtkAboutDialog
842 * Returns the program name displayed in the about dialog.
844 * Return value: The program name. The string is owned by the about
845 * dialog and must not be modified.
849 * Deprecated: 2.12: Use gtk_about_dialog_get_program_name() instead.
851 G_CONST_RETURN gchar *
852 gtk_about_dialog_get_name (GtkAboutDialog *about)
854 return gtk_about_dialog_get_program_name (about);
858 * gtk_about_dialog_get_program_name:
859 * @about: a #GtkAboutDialog
861 * Returns the program name displayed in the about dialog.
863 * Return value: The program name. The string is owned by the about
864 * dialog and must not be modified.
868 G_CONST_RETURN gchar *
869 gtk_about_dialog_get_program_name (GtkAboutDialog *about)
871 GtkAboutDialogPrivate *priv;
873 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
875 priv = (GtkAboutDialogPrivate *)about->private_data;
881 update_name_version (GtkAboutDialog *about)
883 GtkAboutDialogPrivate *priv;
884 gchar *title_string, *name_string;
886 priv = (GtkAboutDialogPrivate *)about->private_data;
888 title_string = g_strdup_printf (_("About %s"), priv->name);
889 gtk_window_set_title (GTK_WINDOW (about), title_string);
890 g_free (title_string);
892 if (priv->version != NULL)
893 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
894 priv->name, priv->version);
896 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
899 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
901 g_free (name_string);
905 * gtk_about_dialog_set_name:
906 * @about: a #GtkAboutDialog
907 * @name: the program name
909 * Sets the name to display in the about dialog.
910 * If this is not set, it defaults to g_get_application_name().
914 * Deprecated: 2.12: Use gtk_about_dialog_set_program_name() instead.
917 gtk_about_dialog_set_name (GtkAboutDialog *about,
920 gtk_about_dialog_set_program_name (about, name);
924 * gtk_about_dialog_set_program_name:
925 * @about: a #GtkAboutDialog
926 * @name: the program name
928 * Sets the name to display in the about dialog.
929 * If this is not set, it defaults to g_get_application_name().
934 gtk_about_dialog_set_program_name (GtkAboutDialog *about,
937 GtkAboutDialogPrivate *priv;
940 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
942 priv = (GtkAboutDialogPrivate *)about->private_data;
944 priv->name = g_strdup (name ? name : g_get_application_name ());
947 update_name_version (about);
949 g_object_notify (G_OBJECT (about), "program-name");
954 * gtk_about_dialog_get_version:
955 * @about: a #GtkAboutDialog
957 * Returns the version string.
959 * Return value: The version string. The string is owned by the about
960 * dialog and must not be modified.
964 G_CONST_RETURN gchar *
965 gtk_about_dialog_get_version (GtkAboutDialog *about)
967 GtkAboutDialogPrivate *priv;
969 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
971 priv = (GtkAboutDialogPrivate *)about->private_data;
973 return priv->version;
977 * gtk_about_dialog_set_version:
978 * @about: a #GtkAboutDialog
979 * @version: the version string
981 * Sets the version string to display in the about dialog.
986 gtk_about_dialog_set_version (GtkAboutDialog *about,
987 const gchar *version)
989 GtkAboutDialogPrivate *priv;
992 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
994 priv = (GtkAboutDialogPrivate *)about->private_data;
997 priv->version = g_strdup (version);
1000 update_name_version (about);
1002 g_object_notify (G_OBJECT (about), "version");
1006 * gtk_about_dialog_get_copyright:
1007 * @about: a #GtkAboutDialog
1009 * Returns the copyright string.
1011 * Return value: The copyright string. The string is owned by the about
1012 * dialog and must not be modified.
1016 G_CONST_RETURN gchar *
1017 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
1019 GtkAboutDialogPrivate *priv;
1021 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1023 priv = (GtkAboutDialogPrivate *)about->private_data;
1025 return priv->copyright;
1029 * gtk_about_dialog_set_copyright:
1030 * @about: a #GtkAboutDialog
1031 * @copyright: the copyright string
1033 * Sets the copyright string to display in the about dialog.
1034 * This should be a short string of one or two lines.
1039 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
1040 const gchar *copyright)
1042 GtkAboutDialogPrivate *priv;
1043 gchar *copyright_string, *tmp;
1045 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1047 priv = (GtkAboutDialogPrivate *)about->private_data;
1049 tmp = priv->copyright;
1050 priv->copyright = g_strdup (copyright);
1053 if (priv->copyright != NULL)
1055 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
1057 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
1058 g_free (copyright_string);
1060 gtk_widget_show (priv->copyright_label);
1063 gtk_widget_hide (priv->copyright_label);
1065 g_object_notify (G_OBJECT (about), "copyright");
1069 * gtk_about_dialog_get_comments:
1070 * @about: a #GtkAboutDialog
1072 * Returns the comments string.
1074 * Return value: The comments. The string is owned by the about
1075 * dialog and must not be modified.
1079 G_CONST_RETURN gchar *
1080 gtk_about_dialog_get_comments (GtkAboutDialog *about)
1082 GtkAboutDialogPrivate *priv;
1084 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1086 priv = (GtkAboutDialogPrivate *)about->private_data;
1088 return priv->comments;
1092 * gtk_about_dialog_set_comments:
1093 * @about: a #GtkAboutDialog
1094 * @comments: a comments string
1096 * Sets the comments string to display in the about
1097 * dialog. This should be a short string of one or
1103 gtk_about_dialog_set_comments (GtkAboutDialog *about,
1104 const gchar *comments)
1106 GtkAboutDialogPrivate *priv;
1109 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1111 priv = (GtkAboutDialogPrivate *)about->private_data;
1113 tmp = priv->comments;
1116 priv->comments = g_strdup (comments);
1117 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
1118 gtk_widget_show (priv->comments_label);
1122 priv->comments = NULL;
1123 gtk_widget_hide (priv->comments_label);
1127 g_object_notify (G_OBJECT (about), "comments");
1131 * gtk_about_dialog_get_license:
1132 * @about: a #GtkAboutDialog
1134 * Returns the license information.
1136 * Return value: The license information. The string is owned by the about
1137 * dialog and must not be modified.
1141 G_CONST_RETURN gchar *
1142 gtk_about_dialog_get_license (GtkAboutDialog *about)
1144 GtkAboutDialogPrivate *priv;
1146 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1148 priv = (GtkAboutDialogPrivate *)about->private_data;
1150 return priv->license;
1154 * gtk_about_dialog_set_license:
1155 * @about: a #GtkAboutDialog
1156 * @license: the license information or %NULL
1158 * Sets the license information to be displayed in the secondary
1159 * license dialog. If @license is %NULL, the license button is
1165 gtk_about_dialog_set_license (GtkAboutDialog *about,
1166 const gchar *license)
1168 GtkAboutDialogPrivate *priv;
1171 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1173 priv = (GtkAboutDialogPrivate *)about->private_data;
1175 tmp = priv->license;
1178 priv->license = g_strdup (license);
1179 gtk_widget_show (priv->license_button);
1183 priv->license = NULL;
1184 gtk_widget_hide (priv->license_button);
1188 g_object_notify (G_OBJECT (about), "license");
1192 * gtk_about_dialog_get_wrap_license:
1193 * @about: a #GtkAboutDialog
1195 * Returns whether the license text in @about is
1196 * automatically wrapped.
1198 * Returns: %TRUE if the license text is wrapped
1203 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1205 GtkAboutDialogPrivate *priv;
1207 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1209 priv = (GtkAboutDialogPrivate *)about->private_data;
1211 return priv->wrap_license;
1215 * gtk_about_dialog_set_wrap_license:
1216 * @about: a #GtkAboutDialog
1217 * @wrap_license: whether to wrap the license
1219 * Sets whether the license text in @about is
1220 * automatically wrapped.
1225 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1226 gboolean wrap_license)
1228 GtkAboutDialogPrivate *priv;
1230 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1232 priv = (GtkAboutDialogPrivate *)about->private_data;
1234 wrap_license = wrap_license != FALSE;
1236 if (priv->wrap_license != wrap_license)
1238 priv->wrap_license = wrap_license;
1240 g_object_notify (G_OBJECT (about), "wrap-license");
1245 * gtk_about_dialog_get_website:
1246 * @about: a #GtkAboutDialog
1248 * Returns the website URL.
1250 * Return value: The website URL. The string is owned by the about
1251 * dialog and must not be modified.
1255 G_CONST_RETURN gchar *
1256 gtk_about_dialog_get_website (GtkAboutDialog *about)
1258 GtkAboutDialogPrivate *priv;
1260 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1262 priv = (GtkAboutDialogPrivate *)about->private_data;
1264 return priv->website_url;
1268 * gtk_about_dialog_set_website:
1269 * @about: a #GtkAboutDialog
1270 * @website: a URL string starting with "http://"
1272 * Sets the URL to use for the website link.
1274 * Note that that the hook functions need to be set up
1275 * before calling this function.
1280 gtk_about_dialog_set_website (GtkAboutDialog *about,
1281 const gchar *website)
1283 GtkAboutDialogPrivate *priv;
1286 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1288 priv = (GtkAboutDialogPrivate *)about->private_data;
1290 tmp = priv->website_url;
1291 priv->website_url = g_strdup (website);
1294 update_website (about);
1296 g_object_notify (G_OBJECT (about), "website");
1300 * gtk_about_dialog_get_website_label:
1301 * @about: a #GtkAboutDialog
1303 * Returns the label used for the website link.
1305 * Return value: The label used for the website link. The string is owned by the about
1306 * dialog and must not be modified.
1310 G_CONST_RETURN gchar *
1311 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1313 GtkAboutDialogPrivate *priv;
1315 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1317 priv = (GtkAboutDialogPrivate *)about->private_data;
1319 return priv->website_text;
1323 * gtk_about_dialog_set_website_label:
1324 * @about: a #GtkAboutDialog
1325 * @website_label: the label used for the website link
1327 * Sets the label to be used for the website link.
1328 * It defaults to the website URL.
1333 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1334 const gchar *website_label)
1336 GtkAboutDialogPrivate *priv;
1339 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1341 priv = (GtkAboutDialogPrivate *)about->private_data;
1343 tmp = priv->website_text;
1344 priv->website_text = g_strdup (website_label);
1347 update_website (about);
1349 g_object_notify (G_OBJECT (about), "website-label");
1353 * gtk_about_dialog_get_authors:
1354 * @about: a #GtkAboutDialog
1356 * Returns the string which are displayed in the authors tab
1357 * of the secondary credits dialog.
1359 * Return value: A %NULL-terminated string array containing
1360 * the authors. The array is owned by the about dialog
1361 * and must not be modified.
1365 G_CONST_RETURN gchar * G_CONST_RETURN *
1366 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1368 GtkAboutDialogPrivate *priv;
1370 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1372 priv = (GtkAboutDialogPrivate *)about->private_data;
1374 return (const gchar * const *) priv->authors;
1378 update_credits_button_visibility (GtkAboutDialog *about)
1380 GtkAboutDialogPrivate *priv = about->private_data;
1383 show = priv->authors != NULL ||
1384 priv->documenters != NULL ||
1385 priv->artists != NULL ||
1386 (priv->translator_credits != NULL &&
1387 strcmp (priv->translator_credits, "translator_credits") &&
1388 strcmp (priv->translator_credits, "translator-credits"));
1390 gtk_widget_show (priv->credits_button);
1392 gtk_widget_hide (priv->credits_button);
1396 * gtk_about_dialog_set_authors:
1397 * @about: a #GtkAboutDialog
1398 * @authors: a %NULL-terminated array of strings
1400 * Sets the strings which are displayed in the authors tab
1401 * of the secondary credits dialog.
1406 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1407 const gchar **authors)
1409 GtkAboutDialogPrivate *priv;
1412 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1414 priv = (GtkAboutDialogPrivate *)about->private_data;
1416 tmp = priv->authors;
1417 priv->authors = g_strdupv ((gchar **)authors);
1420 update_credits_button_visibility (about);
1422 g_object_notify (G_OBJECT (about), "authors");
1426 * gtk_about_dialog_get_documenters:
1427 * @about: a #GtkAboutDialog
1429 * Returns the string which are displayed in the documenters
1430 * tab of the secondary credits dialog.
1432 * Return value: A %NULL-terminated string array containing
1433 * the documenters. The array is owned by the about dialog
1434 * and must not be modified.
1438 G_CONST_RETURN gchar * G_CONST_RETURN *
1439 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1441 GtkAboutDialogPrivate *priv;
1443 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1445 priv = (GtkAboutDialogPrivate *)about->private_data;
1447 return (const gchar * const *)priv->documenters;
1451 * gtk_about_dialog_set_documenters:
1452 * @about: a #GtkAboutDialog
1453 * @documenters: a %NULL-terminated array of strings
1455 * Sets the strings which are displayed in the documenters tab
1456 * of the secondary credits dialog.
1461 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1462 const gchar **documenters)
1464 GtkAboutDialogPrivate *priv;
1467 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1469 priv = (GtkAboutDialogPrivate *)about->private_data;
1471 tmp = priv->documenters;
1472 priv->documenters = g_strdupv ((gchar **)documenters);
1475 update_credits_button_visibility (about);
1477 g_object_notify (G_OBJECT (about), "documenters");
1481 * gtk_about_dialog_get_artists:
1482 * @about: a #GtkAboutDialog
1484 * Returns the string which are displayed in the artists tab
1485 * of the secondary credits dialog.
1487 * Return value: A %NULL-terminated string array containing
1488 * the artists. The array is owned by the about dialog
1489 * and must not be modified.
1493 G_CONST_RETURN gchar * G_CONST_RETURN *
1494 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1496 GtkAboutDialogPrivate *priv;
1498 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1500 priv = (GtkAboutDialogPrivate *)about->private_data;
1502 return (const gchar * const *)priv->artists;
1506 * gtk_about_dialog_set_artists:
1507 * @about: a #GtkAboutDialog
1508 * @artists: a %NULL-terminated array of strings
1510 * Sets the strings which are displayed in the artists tab
1511 * of the secondary credits dialog.
1516 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1517 const gchar **artists)
1519 GtkAboutDialogPrivate *priv;
1522 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1524 priv = (GtkAboutDialogPrivate *)about->private_data;
1526 tmp = priv->artists;
1527 priv->artists = g_strdupv ((gchar **)artists);
1530 update_credits_button_visibility (about);
1532 g_object_notify (G_OBJECT (about), "artists");
1536 * gtk_about_dialog_get_translator_credits:
1537 * @about: a #GtkAboutDialog
1539 * Returns the translator credits string which is displayed
1540 * in the translators tab of the secondary credits dialog.
1542 * Return value: The translator credits string. The string is
1543 * owned by the about dialog and must not be modified.
1547 G_CONST_RETURN gchar *
1548 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1550 GtkAboutDialogPrivate *priv;
1552 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1554 priv = (GtkAboutDialogPrivate *)about->private_data;
1556 return priv->translator_credits;
1560 * gtk_about_dialog_set_translator_credits:
1561 * @about: a #GtkAboutDialog
1562 * @translator_credits: the translator credits
1564 * Sets the translator credits string which is displayed in
1565 * the translators tab of the secondary credits dialog.
1567 * The intended use for this string is to display the translator
1568 * of the language which is currently used in the user interface.
1569 * Using gettext(), a simple way to achieve that is to mark the
1570 * string for translation:
1572 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1574 * It is a good idea to use the customary msgid "translator-credits" for this
1575 * purpose, since translators will already know the purpose of that msgid, and
1576 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1582 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1583 const gchar *translator_credits)
1585 GtkAboutDialogPrivate *priv;
1588 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1590 priv = (GtkAboutDialogPrivate *)about->private_data;
1592 tmp = priv->translator_credits;
1593 priv->translator_credits = g_strdup (translator_credits);
1596 update_credits_button_visibility (about);
1598 g_object_notify (G_OBJECT (about), "translator-credits");
1602 * gtk_about_dialog_get_logo:
1603 * @about: a #GtkAboutDialog
1605 * Returns the pixbuf displayed as logo in the about dialog.
1607 * Return value: the pixbuf displayed as logo. The pixbuf is
1608 * owned by the about dialog. If you want to keep a reference
1609 * to it, you have to call g_object_ref() on it.
1614 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1616 GtkAboutDialogPrivate *priv;
1618 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1620 priv = (GtkAboutDialogPrivate *)about->private_data;
1622 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1623 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1629 icon_set_new_from_pixbufs (GList *pixbufs)
1631 GtkIconSet *icon_set = gtk_icon_set_new ();
1633 for (; pixbufs; pixbufs = pixbufs->next)
1635 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1637 GtkIconSource *icon_source = gtk_icon_source_new ();
1638 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1639 gtk_icon_set_add_source (icon_set, icon_source);
1640 gtk_icon_source_free (icon_source);
1647 * gtk_about_dialog_set_logo:
1648 * @about: a #GtkAboutDialog
1649 * @logo: a #GdkPixbuf, or %NULL
1651 * Sets the pixbuf to be displayed as logo in
1652 * the about dialog. If it is %NULL, the default
1653 * window icon set with gtk_window_set_default_icon ()
1659 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1662 GtkAboutDialogPrivate *priv;
1664 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1666 priv = (GtkAboutDialogPrivate *)about->private_data;
1668 g_object_freeze_notify (G_OBJECT (about));
1670 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1671 g_object_notify (G_OBJECT (about), "logo-icon-name");
1674 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1677 GList *pixbufs = gtk_window_get_default_icon_list ();
1679 if (pixbufs != NULL)
1681 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1683 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1684 icon_set, GTK_ICON_SIZE_DIALOG);
1686 gtk_icon_set_unref (icon_set);
1687 g_list_free (pixbufs);
1691 g_object_notify (G_OBJECT (about), "logo");
1693 g_object_thaw_notify (G_OBJECT (about));
1697 * gtk_about_dialog_get_logo_icon_name:
1698 * @about: a #GtkAboutDialog
1700 * Returns the icon name displayed as logo in the about dialog.
1702 * Return value: the icon name displayed as logo. The string is
1703 * owned by the dialog. If you want to keep a reference
1704 * to it, you have to call g_strdup() on it.
1708 G_CONST_RETURN gchar *
1709 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1711 GtkAboutDialogPrivate *priv;
1712 const gchar *icon_name = NULL;
1714 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1716 priv = (GtkAboutDialogPrivate *)about->private_data;
1718 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1719 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1725 * gtk_about_dialog_set_logo_icon_name:
1726 * @about: a #GtkAboutDialog
1727 * @icon_name: an icon name, or %NULL
1729 * Sets the pixbuf to be displayed as logo in
1730 * the about dialog. If it is %NULL, the default
1731 * window icon set with gtk_window_set_default_icon()
1737 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1738 const gchar *icon_name)
1740 GtkAboutDialogPrivate *priv;
1742 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1744 priv = (GtkAboutDialogPrivate *)about->private_data;
1746 g_object_freeze_notify (G_OBJECT (about));
1748 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1749 g_object_notify (G_OBJECT (about), "logo");
1751 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1752 GTK_ICON_SIZE_DIALOG);
1753 g_object_notify (G_OBJECT (about), "logo-icon-name");
1755 g_object_thaw_notify (G_OBJECT (about));
1759 activate_url (GtkWidget *widget,
1762 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1763 const gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
1764 GtkAboutDialogActivateLinkFunc url_hook;
1765 gpointer url_hook_data;
1767 if (activate_url_hook_set)
1769 url_hook = activate_url_hook;
1770 url_hook_data = activate_url_hook_data;
1774 url_hook = default_url_hook;
1775 url_hook_data = NULL;
1779 url_hook (about, url, url_hook_data);
1783 follow_if_link (GtkAboutDialog *about,
1784 GtkTextView *text_view,
1787 GSList *tags = NULL, *tagp = NULL;
1788 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1790 GtkAboutDialogActivateLinkFunc email_hook, url_hook;
1791 gpointer email_hook_data, url_hook_data;
1793 if (activate_email_hook_set)
1795 email_hook = activate_email_hook;
1796 email_hook_data = activate_email_hook_data;
1800 email_hook = default_email_hook;
1801 email_hook_data = NULL;
1804 if (activate_url_hook_set)
1806 url_hook = activate_url_hook;
1807 url_hook_data = activate_url_hook_data;
1811 url_hook = default_url_hook;
1812 url_hook_data = NULL;
1815 tags = gtk_text_iter_get_tags (iter);
1816 for (tagp = tags; tagp != NULL && !url; tagp = tagp->next)
1818 GtkTextTag *tag = tagp->data;
1820 if (email_hook != NULL)
1822 url = g_object_get_data (G_OBJECT (tag), "email");
1824 email_hook (about, url, email_hook_data);
1827 if (!url && url_hook != NULL)
1829 url = g_object_get_data (G_OBJECT (tag), "url");
1831 url_hook (about, url, url_hook_data);
1834 if (url && !g_slist_find_custom (priv->visited_links, url, (GCompareFunc)strcmp))
1836 GdkColor *style_visited_link_color;
1839 gtk_widget_ensure_style (GTK_WIDGET (about));
1840 gtk_widget_style_get (GTK_WIDGET (about),
1841 "visited-link-color", &style_visited_link_color,
1843 if (style_visited_link_color)
1845 color = *style_visited_link_color;
1846 gdk_color_free (style_visited_link_color);
1849 color = default_visited_link_color;
1851 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1853 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (url));
1858 g_slist_free (tags);
1862 text_view_key_press_event (GtkWidget *text_view,
1864 GtkAboutDialog *about)
1867 GtkTextBuffer *buffer;
1869 switch (event->keyval)
1874 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1875 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1876 gtk_text_buffer_get_insert (buffer));
1877 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1888 text_view_event_after (GtkWidget *text_view,
1890 GtkAboutDialog *about)
1892 GtkTextIter start, end, iter;
1893 GtkTextBuffer *buffer;
1894 GdkEventButton *button_event;
1897 if (event->type != GDK_BUTTON_RELEASE)
1900 button_event = (GdkEventButton *)event;
1902 if (button_event->button != 1)
1905 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1907 /* we shouldn't follow a link if the user has selected something */
1908 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1909 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1912 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1913 GTK_TEXT_WINDOW_WIDGET,
1914 button_event->x, button_event->y, &x, &y);
1916 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1918 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1924 set_cursor_if_appropriate (GtkAboutDialog *about,
1925 GtkTextView *text_view,
1929 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1930 GSList *tags = NULL, *tagp = NULL;
1932 gboolean hovering_over_link = FALSE;
1934 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1936 tags = gtk_text_iter_get_tags (&iter);
1937 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1939 GtkTextTag *tag = tagp->data;
1940 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1941 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1943 if (email != NULL || url != NULL)
1945 hovering_over_link = TRUE;
1950 if (hovering_over_link != priv->hovering_over_link)
1952 priv->hovering_over_link = hovering_over_link;
1954 if (hovering_over_link)
1955 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1957 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1961 g_slist_free (tags);
1965 text_view_motion_notify_event (GtkWidget *text_view,
1966 GdkEventMotion *event,
1967 GtkAboutDialog *about)
1971 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1972 GTK_TEXT_WINDOW_WIDGET,
1973 event->x, event->y, &x, &y);
1975 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1977 gdk_event_request_motions (event);
1984 text_view_visibility_notify_event (GtkWidget *text_view,
1985 GdkEventVisibility *event,
1986 GtkAboutDialog *about)
1988 gint wx, wy, bx, by;
1990 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1992 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1993 GTK_TEXT_WINDOW_WIDGET,
1996 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
2002 text_view_new (GtkAboutDialog *about,
2005 GtkWrapMode wrap_mode)
2008 gchar *q0, *q1, *q2, *r1, *r2;
2010 GtkTextView *text_view;
2011 GtkTextBuffer *buffer;
2012 gboolean linkify_email, linkify_urls;
2013 GdkColor *style_link_color;
2014 GdkColor *style_visited_link_color;
2016 GdkColor link_color;
2017 GdkColor visited_link_color;
2018 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2020 linkify_email = (!activate_email_hook_set || activate_email_hook != NULL);
2021 linkify_urls = (!activate_url_hook_set || activate_url_hook != NULL);
2023 gtk_widget_ensure_style (GTK_WIDGET (about));
2024 gtk_widget_style_get (GTK_WIDGET (about),
2025 "link-color", &style_link_color,
2026 "visited-link-color", &style_visited_link_color,
2028 if (style_link_color)
2030 link_color = *style_link_color;
2031 gdk_color_free (style_link_color);
2034 link_color = default_link_color;
2036 if (style_visited_link_color)
2038 visited_link_color = *style_visited_link_color;
2039 gdk_color_free (style_visited_link_color);
2042 visited_link_color = default_visited_link_color;
2044 view = gtk_text_view_new ();
2045 text_view = GTK_TEXT_VIEW (view);
2046 buffer = gtk_text_view_get_buffer (text_view);
2047 gtk_text_view_set_cursor_visible (text_view, FALSE);
2048 gtk_text_view_set_editable (text_view, FALSE);
2049 gtk_text_view_set_wrap_mode (text_view, wrap_mode);
2051 gtk_text_view_set_left_margin (text_view, 8);
2052 gtk_text_view_set_right_margin (text_view, 8);
2054 g_signal_connect (view, "key-press-event",
2055 G_CALLBACK (text_view_key_press_event), about);
2056 g_signal_connect (view, "event-after",
2057 G_CALLBACK (text_view_event_after), about);
2058 g_signal_connect (view, "motion-notify-event",
2059 G_CALLBACK (text_view_motion_notify_event), about);
2060 g_signal_connect (view, "visibility-notify-event",
2061 G_CALLBACK (text_view_visibility_notify_event), about);
2063 if (strings == NULL)
2065 gtk_widget_hide (view);
2069 for (p = strings; *p; p++)
2074 q1 = linkify_email ? strchr (q0, '<') : NULL;
2075 q2 = q1 ? strchr (q1, '>') : NULL;
2076 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
2079 r2 = strpbrk (r1, " \n\t");
2081 r2 = strchr (r1, '\0');
2086 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2096 const gchar *link_type;
2101 gtk_text_buffer_insert_at_cursor (buffer, q0, (q1 - q0) + 1);
2102 gtk_text_buffer_get_end_iter (buffer, &end);
2104 link_type = I_("email");
2108 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
2109 gtk_text_buffer_get_end_iter (buffer, &end);
2110 link_type = I_("url");
2115 link = g_strndup (q1, q2 - q1);
2117 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
2118 color = visited_link_color;
2122 tag = gtk_text_buffer_create_tag (buffer, NULL,
2123 "foreground-gdk", &color,
2124 "underline", PANGO_UNDERLINE_SINGLE,
2126 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
2127 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
2133 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
2139 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
2142 gtk_widget_show (view);
2147 add_credits_page (GtkAboutDialog *about,
2148 GtkWidget *credits_dialog,
2149 GtkWidget *notebook,
2153 GtkWidget *sw, *view;
2155 view = text_view_new (about, credits_dialog, people, GTK_WRAP_NONE);
2157 sw = gtk_scrolled_window_new (NULL, NULL);
2158 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2160 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2161 GTK_POLICY_AUTOMATIC,
2162 GTK_POLICY_AUTOMATIC);
2163 gtk_container_add (GTK_CONTAINER (sw), view);
2165 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
2166 sw, gtk_label_new (title));
2170 display_credits_dialog (GtkWidget *button,
2173 GtkAboutDialog *about = (GtkAboutDialog *)data;
2174 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2175 GtkWidget *dialog, *notebook;
2176 GtkDialog *credits_dialog;
2178 if (priv->credits_dialog != NULL)
2180 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
2184 dialog = gtk_dialog_new_with_buttons (_("Credits"),
2186 GTK_DIALOG_DESTROY_WITH_PARENT,
2187 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2189 credits_dialog = GTK_DIALOG (dialog);
2190 gtk_dialog_set_has_separator (credits_dialog, FALSE);
2191 gtk_container_set_border_width (GTK_CONTAINER (credits_dialog), 5);
2192 gtk_box_set_spacing (GTK_BOX (credits_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
2193 gtk_container_set_border_width (GTK_CONTAINER (credits_dialog->action_area), 5);
2195 priv->credits_dialog = dialog;
2196 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
2197 gtk_dialog_set_default_response (credits_dialog, GTK_RESPONSE_CANCEL);
2199 gtk_window_set_modal (GTK_WINDOW (dialog),
2200 gtk_window_get_modal (GTK_WINDOW (about)));
2202 g_signal_connect (dialog, "response",
2203 G_CALLBACK (gtk_widget_destroy), dialog);
2204 g_signal_connect (dialog, "destroy",
2205 G_CALLBACK (gtk_widget_destroyed),
2206 &(priv->credits_dialog));
2208 notebook = gtk_notebook_new ();
2209 gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
2210 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
2212 if (priv->authors != NULL)
2213 add_credits_page (about, dialog, notebook, _("Written by"), priv->authors);
2215 if (priv->documenters != NULL)
2216 add_credits_page (about, dialog, notebook, _("Documented by"), priv->documenters);
2218 /* Don't show an untranslated gettext msgid */
2219 if (priv->translator_credits != NULL &&
2220 strcmp (priv->translator_credits, "translator_credits") &&
2221 strcmp (priv->translator_credits, "translator-credits"))
2223 gchar *translators[2];
2225 translators[0] = priv->translator_credits;
2226 translators[1] = NULL;
2228 add_credits_page (about, dialog, notebook, _("Translated by"), translators);
2231 if (priv->artists != NULL)
2232 add_credits_page (about, dialog, notebook, _("Artwork by"), priv->artists);
2234 gtk_widget_show_all (dialog);
2238 set_policy (GtkWidget *sw)
2240 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2241 GTK_POLICY_AUTOMATIC,
2242 GTK_POLICY_AUTOMATIC);
2246 display_license_dialog (GtkWidget *button,
2249 GtkAboutDialog *about = (GtkAboutDialog *)data;
2250 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2251 GtkWidget *dialog, *view, *sw;
2252 GtkDialog *licence_dialog;
2255 if (priv->license_dialog != NULL)
2257 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2261 dialog = gtk_dialog_new_with_buttons (_("License"),
2263 GTK_DIALOG_DESTROY_WITH_PARENT,
2264 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2266 licence_dialog = GTK_DIALOG (dialog);
2267 gtk_dialog_set_has_separator (licence_dialog, FALSE);
2268 gtk_container_set_border_width (GTK_CONTAINER (licence_dialog), 5);
2269 gtk_box_set_spacing (GTK_BOX (licence_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
2270 gtk_container_set_border_width (GTK_CONTAINER (licence_dialog->action_area), 5);
2272 priv->license_dialog = dialog;
2273 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2274 gtk_dialog_set_default_response (licence_dialog, GTK_RESPONSE_CANCEL);
2276 gtk_window_set_modal (GTK_WINDOW (dialog),
2277 gtk_window_get_modal (GTK_WINDOW (about)));
2279 g_signal_connect (dialog, "response",
2280 G_CALLBACK (gtk_widget_destroy), dialog);
2281 g_signal_connect (dialog, "destroy",
2282 G_CALLBACK (gtk_widget_destroyed),
2283 &(priv->license_dialog));
2285 sw = gtk_scrolled_window_new (NULL, NULL);
2286 gtk_container_set_border_width (GTK_CONTAINER (sw), 5);
2287 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2289 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2291 GTK_POLICY_AUTOMATIC);
2292 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2293 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2295 strings[0] = priv->license;
2297 view = text_view_new (about, dialog, strings,
2298 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2300 gtk_container_add (GTK_CONTAINER (sw), view);
2302 gtk_widget_show_all (dialog);
2306 * gtk_about_dialog_new:
2308 * Creates a new #GtkAboutDialog.
2310 * Returns: a newly created #GtkAboutDialog
2315 gtk_about_dialog_new (void)
2317 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2319 return GTK_WIDGET (dialog);
2323 * gtk_about_dialog_set_email_hook:
2324 * @func: a function to call when an email link is activated.
2325 * @data: data to pass to @func
2326 * @destroy: #GDestroyNotify for @data
2328 * Installs a global function to be called whenever the user activates an
2329 * email link in an about dialog.
2331 * Since 2.18 there exists a default function which uses gtk_show_uri(). To
2332 * deactivate it, you can pass %NULL for @func.
2334 * Return value: the previous email hook.
2338 GtkAboutDialogActivateLinkFunc
2339 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2341 GDestroyNotify destroy)
2343 GtkAboutDialogActivateLinkFunc old;
2345 if (activate_email_hook_destroy != NULL)
2346 (* activate_email_hook_destroy) (activate_email_hook_data);
2348 old = activate_email_hook;
2350 activate_email_hook_set = TRUE;
2351 activate_email_hook = func;
2352 activate_email_hook_data = data;
2353 activate_email_hook_destroy = destroy;
2359 * gtk_about_dialog_set_url_hook:
2360 * @func: a function to call when a URL link is activated.
2361 * @data: data to pass to @func
2362 * @destroy: #GDestroyNotify for @data
2364 * Installs a global function to be called whenever the user activates a
2365 * URL link in an about dialog.
2367 * Since 2.18 there exists a default function which uses gtk_show_uri(). To
2368 * deactivate it, you can pass %NULL for @func.
2370 * Return value: the previous URL hook.
2374 GtkAboutDialogActivateLinkFunc
2375 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2377 GDestroyNotify destroy)
2379 GtkAboutDialogActivateLinkFunc old;
2381 if (activate_url_hook_destroy != NULL)
2382 (* activate_url_hook_destroy) (activate_url_hook_data);
2384 old = activate_url_hook;
2386 activate_url_hook_set = TRUE;
2387 activate_url_hook = func;
2388 activate_url_hook_data = data;
2389 activate_url_hook_destroy = destroy;
2395 close_cb (GtkAboutDialog *about)
2397 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2399 if (priv->license_dialog != NULL)
2401 gtk_widget_destroy (priv->license_dialog);
2402 priv->license_dialog = NULL;
2405 if (priv->credits_dialog != NULL)
2407 gtk_widget_destroy (priv->credits_dialog);
2408 priv->credits_dialog = NULL;
2411 gtk_widget_hide (GTK_WIDGET (about));
2416 * gtk_show_about_dialog:
2417 * @parent: transient parent, or %NULL for none
2418 * @first_property_name: the name of the first property
2419 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2421 * This is a convenience function for showing an application's about box.
2422 * The constructed dialog is associated with the parent window and
2423 * reused for future invocations of this function.
2428 gtk_show_about_dialog (GtkWindow *parent,
2429 const gchar *first_property_name,
2432 static GtkWidget *global_about_dialog = NULL;
2433 GtkWidget *dialog = NULL;
2437 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2439 dialog = global_about_dialog;
2443 dialog = gtk_about_dialog_new ();
2445 g_object_ref_sink (dialog);
2447 g_signal_connect (dialog, "delete-event",
2448 G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2450 /* Close dialog on user response */
2451 g_signal_connect (dialog, "response",
2452 G_CALLBACK (close_cb), NULL);
2454 va_start (var_args, first_property_name);
2455 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2460 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2461 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2462 g_object_set_data_full (G_OBJECT (parent),
2463 I_("gtk-about-dialog"),
2464 dialog, g_object_unref);
2467 global_about_dialog = dialog;
2471 gtk_window_present (GTK_WINDOW (dialog));
2474 #define __GTK_ABOUT_DIALOG_C__
2475 #include "gtkaliasdef.c"