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, see <http://www.gnu.org/licenses/>.
21 * Author: Anders Carlsson <andersca@gnome.org>
23 * Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
24 * file for a list of people on the GTK+ Team. See the ChangeLog
25 * files for a list of changes. These files are distributed with
26 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
33 #include "gtkaboutdialog.h"
34 #include "gtkbutton.h"
36 #include "gtkdialog.h"
41 #include "gtklinkbutton.h"
42 #include "gtkmarshalers.h"
43 #include "gtknotebook.h"
44 #include "gtkorientable.h"
45 #include "gtkscrolledwindow.h"
47 #include "gtktextview.h"
48 #include "gtkiconfactory.h"
51 #include "gtkmessagedialog.h"
52 #include "gtktogglebutton.h"
53 #include "gtktypebuiltins.h"
54 #include "gtkprivate.h"
59 * SECTION:gtkaboutdialog
60 * @Short_description: Display information about an application
61 * @Title: GtkAboutDialog
62 * @See_also: #GTK_STOCK_ABOUT
64 * The GtkAboutDialog offers a simple way to display information about
65 * a program like its logo, name, copyright, website and license. It is
66 * also possible to give credits to the authors, documenters, translators
67 * and artists who have worked on the program. An about dialog is typically
68 * opened when the user selects the <literal>About</literal> option from
69 * the <literal>Help</literal> menu. All parts of the dialog are optional.
71 * About dialog often contain links and email addresses. GtkAboutDialog
72 * displays these as clickable links. By default, it calls gtk_show_uri()
73 * when a user clicks one. The behaviour can be overridden with the
74 * #GtkAboutDialog::activate-link signal.
76 * To make constructing a GtkAboutDialog as convenient as possible, you can
77 * use the function gtk_show_about_dialog() which constructs and shows a dialog
78 * and keeps it around so that it can be shown again.
80 * Note that GTK+ sets a default title of <literal>_("About %s")</literal>
81 * on the dialog window (where %s is replaced by the name of the
82 * application, but in order to ensure proper translation of the title,
83 * applications should set the title property explicitly when constructing
84 * a GtkAboutDialog, as shown in the following example:
85 * <informalexample><programlisting>
86 * gtk_show_about_dialog (NULL,
87 * "program-name", "ExampleCode",
88 * "logo", example_logo,
89 * "title" _("About ExampleCode"),
91 * </programlisting></informalexample>
93 * It is also possible to show a #GtkAboutDialog like any other #GtkDialog,
94 * e.g. using gtk_dialog_run(). In this case, you might need to know that
95 * the 'Close' button returns the #GTK_RESPONSE_CANCEL response id.
98 static GdkColor default_link_color = { 0, 0, 0, 0xeeee };
99 static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
101 /* Translators: this is the license preamble; the string at the end
102 * contains the URL of the license.
104 static const gchar *gtk_license_preamble = N_("This program comes with ABSOLUTELY NO WARRANTY;\nfor details, visit <a href=\"%s\">%s</a>");
106 /* URLs for each GtkLicense type; keep in the same order as the enumeration */
107 static const gchar *gtk_license_urls[] = {
111 "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
112 "http://www.gnu.org/licenses/gpl.html",
114 "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html",
115 "http://www.gnu.org/licenses/lgpl.html",
117 "http://opensource.org/licenses/bsd-license.php",
118 "http://opensource.org/licenses/mit-license.php",
120 "http://opensource.org/licenses/artistic-license-2.0.php"
129 struct _GtkAboutDialogPrivate
137 gchar *translator_credits;
145 GSList *credit_sections;
151 GtkWidget *logo_image;
152 GtkWidget *name_label;
153 GtkWidget *version_label;
154 GtkWidget *comments_label;
155 GtkWidget *copyright_label;
156 GtkWidget *license_label;
157 GtkWidget *website_label;
159 GtkWidget *credits_button;
160 GtkWidget *license_button;
162 GdkCursor *hand_cursor;
163 GdkCursor *regular_cursor;
165 GSList *visited_links;
167 GtkLicense license_type;
169 guint hovering_over_link : 1;
170 guint wrap_license : 1;
175 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
190 PROP_TRANSLATOR_CREDITS,
198 static void gtk_about_dialog_finalize (GObject *object);
199 static void gtk_about_dialog_get_property (GObject *object,
203 static void gtk_about_dialog_set_property (GObject *object,
207 static void gtk_about_dialog_show (GtkWidget *widge);
208 static void update_name_version (GtkAboutDialog *about);
209 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
210 static void follow_if_link (GtkAboutDialog *about,
211 GtkTextView *text_view,
213 static void set_cursor_if_appropriate (GtkAboutDialog *about,
214 GtkTextView *text_view,
218 static void display_credits_page (GtkWidget *button,
220 static void display_license_page (GtkWidget *button,
222 static void close_cb (GtkAboutDialog *about);
223 static gboolean gtk_about_dialog_activate_link (GtkAboutDialog *about,
231 static guint signals[LAST_SIGNAL] = { 0 };
233 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
237 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
239 GObjectClass *object_class;
240 GtkWidgetClass *widget_class;
242 object_class = (GObjectClass *)klass;
243 widget_class = (GtkWidgetClass *)klass;
245 object_class->set_property = gtk_about_dialog_set_property;
246 object_class->get_property = gtk_about_dialog_get_property;
248 object_class->finalize = gtk_about_dialog_finalize;
250 widget_class->show = gtk_about_dialog_show;
252 klass->activate_link = gtk_about_dialog_activate_link;
255 * GtkAboutDialog::activate-link:
256 * @label: The object on which the signal was emitted
257 * @uri: the URI that is activated
259 * The signal which gets emitted to activate a URI.
260 * Applications may connect to it to override the default behaviour,
261 * which is to call gtk_show_uri().
263 * Returns: %TRUE if the link has been activated
267 signals[ACTIVATE_LINK] =
268 g_signal_new ("activate-link",
269 G_TYPE_FROM_CLASS (object_class),
271 G_STRUCT_OFFSET (GtkAboutDialogClass, activate_link),
272 _gtk_boolean_handled_accumulator, NULL,
273 _gtk_marshal_BOOLEAN__STRING,
274 G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
277 * GtkAboutDialog:program-name:
279 * The name of the program.
280 * If this is not set, it defaults to g_get_application_name().
284 g_object_class_install_property (object_class,
286 g_param_spec_string ("program-name",
288 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
290 GTK_PARAM_READWRITE));
293 * GtkAboutDialog:version:
295 * The version of the program.
299 g_object_class_install_property (object_class,
301 g_param_spec_string ("version",
302 P_("Program version"),
303 P_("The version of the program"),
305 GTK_PARAM_READWRITE));
308 * GtkAboutDialog:copyright:
310 * Copyright information for the program.
314 g_object_class_install_property (object_class,
316 g_param_spec_string ("copyright",
317 P_("Copyright string"),
318 P_("Copyright information for the program"),
320 GTK_PARAM_READWRITE));
324 * GtkAboutDialog:comments:
326 * Comments about the program. This string is displayed in a label
327 * in the main dialog, thus it should be a short explanation of
328 * the main purpose of the program, not a detailed list of features.
332 g_object_class_install_property (object_class,
334 g_param_spec_string ("comments",
335 P_("Comments string"),
336 P_("Comments about the program"),
338 GTK_PARAM_READWRITE));
341 * GtkAboutDialog:license:
343 * The license of the program. This string is displayed in a
344 * text view in a secondary dialog, therefore it is fine to use
345 * a long multi-paragraph text. Note that the text is only wrapped
346 * in the text view if the "wrap-license" property is set to %TRUE;
347 * otherwise the text itself must contain the intended linebreaks.
348 * When setting this property to a non-%NULL value, the
349 * #GtkAboutDialog:license-type property is set to %GTK_LICENSE_CUSTOM
354 g_object_class_install_property (object_class,
356 g_param_spec_string ("license",
358 _("The license of the program"),
360 GTK_PARAM_READWRITE));
363 * GtkAboutDialog:license-type:
365 * The license of the program, as a value of the %GtkLicense enumeration.
367 * The #GtkAboutDialog will automatically fill out a standard disclaimer
368 * and link the user to the appropriate online resource for the license
371 * If %GTK_LICENSE_UNKNOWN is used, the link used will be the same
372 * specified in the #GtkAboutDialog:website property.
374 * If %GTK_LICENSE_CUSTOM is used, the current contents of the
375 * #GtkAboutDialog:license property are used.
377 * For any other #GtkLicense value, the contents of the
378 * #GtkAboutDialog:license property are also set by this property as
383 g_object_class_install_property (object_class,
385 g_param_spec_enum ("license-type",
387 P_("The license type of the program"),
390 GTK_PARAM_READWRITE));
393 * GtkAboutDialog:website:
395 * The URL for the link to the website of the program.
396 * This should be a string starting with "http://.
400 g_object_class_install_property (object_class,
402 g_param_spec_string ("website",
404 P_("The URL for the link to the website of the program"),
406 GTK_PARAM_READWRITE));
409 * GtkAboutDialog:website-label:
411 * The label for the link to the website of the program.
415 g_object_class_install_property (object_class,
417 g_param_spec_string ("website-label",
419 P_("The label for the link to the website of the program"),
421 GTK_PARAM_READWRITE));
424 * GtkAboutDialog:authors:
426 * The authors of the program, as a %NULL-terminated array of strings.
427 * Each string may contain email addresses and URLs, which will be displayed
428 * as links, see the introduction for more details.
432 g_object_class_install_property (object_class,
434 g_param_spec_boxed ("authors",
436 P_("List of authors of the program"),
438 GTK_PARAM_READWRITE));
441 * GtkAboutDialog:documenters:
443 * The people documenting the program, as a %NULL-terminated array of strings.
444 * Each string may contain email addresses and URLs, which will be displayed
445 * as links, see the introduction for more details.
449 g_object_class_install_property (object_class,
451 g_param_spec_boxed ("documenters",
453 P_("List of people documenting the program"),
455 GTK_PARAM_READWRITE));
458 * GtkAboutDialog:artists:
460 * The people who contributed artwork to the program, as a %NULL-terminated
461 * array of strings. Each string may contain email addresses and URLs, which
462 * will be displayed as links, see the introduction for more details.
466 g_object_class_install_property (object_class,
468 g_param_spec_boxed ("artists",
470 P_("List of people who have contributed artwork to the program"),
472 GTK_PARAM_READWRITE));
476 * GtkAboutDialog:translator-credits:
478 * Credits to the translators. This string should be marked as translatable.
479 * The string may contain email addresses and URLs, which will be displayed
480 * as links, see the introduction for more details.
484 g_object_class_install_property (object_class,
485 PROP_TRANSLATOR_CREDITS,
486 g_param_spec_string ("translator-credits",
487 P_("Translator credits"),
488 P_("Credits to the translators. This string should be marked as translatable"),
490 GTK_PARAM_READWRITE));
493 * GtkAboutDialog:logo:
495 * A logo for the about box. If this is not set, it defaults to
496 * gtk_window_get_default_icon_list().
500 g_object_class_install_property (object_class,
502 g_param_spec_object ("logo",
504 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
506 GTK_PARAM_READWRITE));
509 * GtkAboutDialog:logo-icon-name:
511 * A named icon to use as the logo for the about box. This property
512 * overrides the #GtkAboutDialog:logo property.
516 g_object_class_install_property (object_class,
518 g_param_spec_string ("logo-icon-name",
519 P_("Logo Icon Name"),
520 P_("A named icon to use as the logo for the about box."),
522 GTK_PARAM_READWRITE));
524 * GtkAboutDialog:wrap-license:
526 * Whether to wrap the text in the license dialog.
530 g_object_class_install_property (object_class,
532 g_param_spec_boolean ("wrap-license",
534 P_("Whether to wrap the license text."),
536 GTK_PARAM_READWRITE));
539 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
543 emit_activate_link (GtkAboutDialog *about,
546 gboolean handled = FALSE;
548 g_signal_emit (about, signals[ACTIVATE_LINK], 0, uri, &handled);
554 update_license_button_visibility (GtkAboutDialog *about)
556 GtkAboutDialogPrivate *priv = about->priv;
558 if (priv->license_type == GTK_LICENSE_CUSTOM && priv->license != NULL)
559 gtk_widget_show (priv->license_button);
561 gtk_widget_hide (priv->license_button);
565 update_credits_button_visibility (GtkAboutDialog *about)
567 GtkAboutDialogPrivate *priv = about->priv;
570 show = (priv->authors != NULL ||
571 priv->documenters != NULL ||
572 priv->artists != NULL ||
573 priv->credit_sections != NULL ||
574 (priv->translator_credits != NULL &&
575 strcmp (priv->translator_credits, "translator_credits") &&
576 strcmp (priv->translator_credits, "translator-credits")));
578 gtk_widget_show (priv->credits_button);
580 gtk_widget_hide (priv->credits_button);
584 switch_page (GtkAboutDialog *about,
587 GtkAboutDialogPrivate *priv = about->priv;
589 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);
593 display_main_page (GtkButton *button,
596 GtkAboutDialog *about = (GtkAboutDialog *)data;
598 switch_page (about, 0);
602 credits_button_clicked (GtkButton *button,
605 GtkAboutDialog *about = (GtkAboutDialog *)data;
606 GtkAboutDialogPrivate *priv = about->priv;
609 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
613 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->license_button), FALSE);
614 display_credits_page (NULL, data);
618 display_main_page (NULL, data);
623 license_button_clicked (GtkButton *button,
626 GtkAboutDialog *about = (GtkAboutDialog *)data;
627 GtkAboutDialogPrivate *priv = about->priv;
630 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
634 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->credits_button), FALSE);
635 display_license_page (NULL, data);
639 display_main_page (NULL, data);
643 gtk_about_dialog_init (GtkAboutDialog *about)
645 GtkDialog *dialog = GTK_DIALOG (about);
646 GtkAboutDialogPrivate *priv;
647 GtkWidget *vbox, *page_vbox, *hbox, *button, *close_button, *image;
648 GtkWidget *content_area, *action_area;
651 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
655 priv->version = NULL;
656 priv->copyright = NULL;
657 priv->comments = NULL;
658 priv->website_url = NULL;
659 priv->website_text = NULL;
660 priv->translator_credits = NULL;
661 priv->license = NULL;
662 priv->authors = NULL;
663 priv->documenters = NULL;
664 priv->artists = NULL;
666 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
667 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
668 priv->hovering_over_link = FALSE;
669 priv->wrap_license = FALSE;
671 priv->license_type = GTK_LICENSE_UNKNOWN;
673 content_area = gtk_dialog_get_content_area (dialog);
674 action_area = gtk_dialog_get_action_area (dialog);
676 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
677 gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
678 gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
681 gtk_widget_push_composite_child ();
683 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
684 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
685 gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
687 priv->logo_image = gtk_image_new ();
688 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
690 priv->name_label = gtk_label_new (NULL);
691 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
692 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
693 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
695 priv->notebook = gtk_notebook_new ();
696 gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
697 gtk_widget_set_size_request (priv->notebook, 400, 100);
699 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
700 gtk_widget_show (page_vbox);
701 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
702 gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
703 gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
705 priv->version_label = gtk_label_new (NULL);
706 gtk_label_set_selectable (GTK_LABEL (priv->version_label), TRUE);
707 gtk_label_set_justify (GTK_LABEL (priv->version_label), GTK_JUSTIFY_CENTER);
708 gtk_box_pack_start (GTK_BOX (page_vbox), priv->version_label, FALSE, FALSE, 0);
710 priv->comments_label = gtk_label_new (NULL);
711 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
712 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
713 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
714 gtk_box_pack_start (GTK_BOX (page_vbox), priv->comments_label, FALSE, FALSE, 0);
716 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
717 gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
718 gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, FALSE, 0);
720 priv->website_label = button = gtk_label_new ("");
721 gtk_widget_set_no_show_all (button, TRUE);
722 gtk_label_set_selectable (GTK_LABEL (button), TRUE);
723 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
724 g_signal_connect_swapped (button, "activate-link",
725 G_CALLBACK (emit_activate_link), about);
727 priv->license_label = gtk_label_new (NULL);
728 gtk_label_set_use_markup (GTK_LABEL (priv->license_label), TRUE);
729 gtk_label_set_selectable (GTK_LABEL (priv->license_label), TRUE);
730 gtk_label_set_justify (GTK_LABEL (priv->license_label), GTK_JUSTIFY_CENTER);
731 gtk_box_pack_end (GTK_BOX (page_vbox), priv->license_label, FALSE, FALSE, 0);
732 gtk_label_set_line_wrap (GTK_LABEL (priv->license_label), TRUE);
734 priv->copyright_label = gtk_label_new (NULL);
735 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
736 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
737 gtk_box_pack_end (GTK_BOX (page_vbox), priv->copyright_label, FALSE, FALSE, 0);
739 gtk_widget_show (vbox);
740 gtk_widget_show (priv->notebook);
741 gtk_widget_show (priv->logo_image);
742 gtk_widget_show (priv->name_label);
743 gtk_widget_show (hbox);
745 /* Add the close button */
746 close_button = gtk_dialog_add_button (GTK_DIALOG (about),
747 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
748 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
750 /* Add the credits button */
751 button = gtk_toggle_button_new_with_mnemonic (_("C_redits"));
752 gtk_widget_set_can_default (button, TRUE);
753 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
754 gtk_button_set_image (GTK_BUTTON (button), image);
755 gtk_widget_set_no_show_all (button, TRUE);
756 gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
757 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
758 g_signal_connect (button, "clicked",
759 G_CALLBACK (credits_button_clicked), about);
760 priv->credits_button = button;
761 priv->credits_page = 0;
763 /* Add the license button */
764 button = gtk_toggle_button_new_with_mnemonic (_("_License"));
765 gtk_widget_set_can_default (button, TRUE);
766 gtk_widget_set_no_show_all (button, TRUE);
767 gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
768 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
769 g_signal_connect (button, "clicked",
770 G_CALLBACK (license_button_clicked), about);
771 priv->license_button = button;
772 priv->license_page = 0;
774 switch_page (about, 0);
776 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
778 gtk_widget_pop_composite_child ();
780 gtk_widget_grab_default (close_button);
781 gtk_widget_grab_focus (close_button);
784 gtk_about_dialog_set_program_name (about, NULL);
785 gtk_about_dialog_set_logo (about, NULL);
789 destroy_credit_section (gpointer data)
791 CreditSection *cs = data;
792 g_free (cs->heading);
793 g_strfreev (cs->people);
794 g_slice_free (CreditSection, data);
798 gtk_about_dialog_finalize (GObject *object)
800 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
801 GtkAboutDialogPrivate *priv = about->priv;
804 g_free (priv->version);
805 g_free (priv->copyright);
806 g_free (priv->comments);
807 g_free (priv->license);
808 g_free (priv->website_url);
809 g_free (priv->website_text);
810 g_free (priv->translator_credits);
812 g_strfreev (priv->authors);
813 g_strfreev (priv->documenters);
814 g_strfreev (priv->artists);
816 g_slist_free_full (priv->credit_sections, destroy_credit_section);
818 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
819 g_slist_free (priv->visited_links);
821 g_object_unref (priv->hand_cursor);
822 g_object_unref (priv->regular_cursor);
824 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
828 gtk_about_dialog_set_property (GObject *object,
833 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
834 GtkAboutDialogPrivate *priv = about->priv;
839 gtk_about_dialog_set_program_name (about, g_value_get_string (value));
842 gtk_about_dialog_set_version (about, g_value_get_string (value));
845 gtk_about_dialog_set_comments (about, g_value_get_string (value));
848 gtk_about_dialog_set_website (about, g_value_get_string (value));
850 case PROP_WEBSITE_LABEL:
851 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
854 gtk_about_dialog_set_license (about, g_value_get_string (value));
856 case PROP_LICENSE_TYPE:
857 gtk_about_dialog_set_license_type (about, g_value_get_enum (value));
860 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
863 gtk_about_dialog_set_logo (about, g_value_get_object (value));
866 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
868 case PROP_DOCUMENTERS:
869 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
872 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
874 case PROP_TRANSLATOR_CREDITS:
875 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
877 case PROP_LOGO_ICON_NAME:
878 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
880 case PROP_WRAP_LICENSE:
881 priv->wrap_license = g_value_get_boolean (value);
884 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
890 gtk_about_dialog_get_property (GObject *object,
895 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
896 GtkAboutDialogPrivate *priv = about->priv;
901 g_value_set_string (value, priv->name);
904 g_value_set_string (value, priv->version);
907 g_value_set_string (value, priv->copyright);
910 g_value_set_string (value, priv->comments);
913 g_value_set_string (value, priv->website_url);
915 case PROP_WEBSITE_LABEL:
916 g_value_set_string (value, priv->website_text);
919 g_value_set_string (value, priv->license);
921 case PROP_LICENSE_TYPE:
922 g_value_set_enum (value, priv->license_type);
924 case PROP_TRANSLATOR_CREDITS:
925 g_value_set_string (value, priv->translator_credits);
928 g_value_set_boxed (value, priv->authors);
930 case PROP_DOCUMENTERS:
931 g_value_set_boxed (value, priv->documenters);
934 g_value_set_boxed (value, priv->artists);
937 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
938 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
940 g_value_set_object (value, NULL);
942 case PROP_LOGO_ICON_NAME:
943 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
945 const gchar *icon_name;
947 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
948 g_value_set_string (value, icon_name);
951 g_value_set_string (value, NULL);
953 case PROP_WRAP_LICENSE:
954 g_value_set_boolean (value, priv->wrap_license);
957 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
963 gtk_about_dialog_activate_link (GtkAboutDialog *about,
967 GError *error = NULL;
969 screen = gtk_widget_get_screen (GTK_WIDGET (about));
971 if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error))
975 dialog = gtk_message_dialog_new (GTK_WINDOW (about),
976 GTK_DIALOG_DESTROY_WITH_PARENT |
980 "%s", _("Could not show link"));
981 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
982 "%s", error->message);
983 g_error_free (error);
985 g_signal_connect (dialog, "response",
986 G_CALLBACK (gtk_widget_destroy), NULL);
988 gtk_window_present (GTK_WINDOW (dialog));
995 update_website (GtkAboutDialog *about)
997 GtkAboutDialogPrivate *priv = about->priv;
999 gtk_widget_show (priv->website_label);
1001 if (priv->website_url)
1005 if (priv->website_text)
1009 escaped = g_markup_escape_text (priv->website_text, -1);
1010 markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
1011 priv->website_url, escaped);
1016 markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
1017 priv->website_url, _("Homepage"));
1020 gtk_label_set_markup (GTK_LABEL (priv->website_label), markup);
1025 if (priv->website_text)
1026 gtk_label_set_text (GTK_LABEL (priv->website_label), priv->website_text);
1028 gtk_widget_hide (priv->website_label);
1033 gtk_about_dialog_show (GtkWidget *widget)
1035 update_website (GTK_ABOUT_DIALOG (widget));
1037 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->show (widget);
1041 * gtk_about_dialog_get_program_name:
1042 * @about: a #GtkAboutDialog
1044 * Returns the program name displayed in the about dialog.
1046 * Return value: The program name. The string is owned by the about
1047 * dialog and must not be modified.
1052 gtk_about_dialog_get_program_name (GtkAboutDialog *about)
1054 GtkAboutDialogPrivate *priv;
1056 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1064 update_name_version (GtkAboutDialog *about)
1066 GtkAboutDialogPrivate *priv;
1067 gchar *title_string, *name_string;
1071 title_string = g_strdup_printf (_("About %s"), priv->name);
1072 gtk_window_set_title (GTK_WINDOW (about), title_string);
1073 g_free (title_string);
1075 if (priv->version != NULL)
1077 gtk_label_set_markup (GTK_LABEL (priv->version_label), priv->version);
1078 gtk_widget_show (priv->version_label);
1081 gtk_widget_hide (priv->version_label);
1083 name_string = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
1085 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
1086 g_free (name_string);
1090 * gtk_about_dialog_set_program_name:
1091 * @about: a #GtkAboutDialog
1092 * @name: the program name
1094 * Sets the name to display in the about dialog.
1095 * If this is not set, it defaults to g_get_application_name().
1100 gtk_about_dialog_set_program_name (GtkAboutDialog *about,
1103 GtkAboutDialogPrivate *priv;
1106 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1111 priv->name = g_strdup (name ? name : g_get_application_name ());
1114 update_name_version (about);
1116 g_object_notify (G_OBJECT (about), "program-name");
1121 * gtk_about_dialog_get_version:
1122 * @about: a #GtkAboutDialog
1124 * Returns the version string.
1126 * Return value: The version string. The string is owned by the about
1127 * dialog and must not be modified.
1132 gtk_about_dialog_get_version (GtkAboutDialog *about)
1134 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1136 return about->priv->version;
1140 * gtk_about_dialog_set_version:
1141 * @about: a #GtkAboutDialog
1142 * @version: (allow-none): the version string
1144 * Sets the version string to display in the about dialog.
1149 gtk_about_dialog_set_version (GtkAboutDialog *about,
1150 const gchar *version)
1152 GtkAboutDialogPrivate *priv;
1155 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1159 tmp = priv->version;
1160 priv->version = g_strdup (version);
1163 update_name_version (about);
1165 g_object_notify (G_OBJECT (about), "version");
1169 * gtk_about_dialog_get_copyright:
1170 * @about: a #GtkAboutDialog
1172 * Returns the copyright string.
1174 * Return value: The copyright string. The string is owned by the about
1175 * dialog and must not be modified.
1180 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
1182 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1184 return about->priv->copyright;
1188 * gtk_about_dialog_set_copyright:
1189 * @about: a #GtkAboutDialog
1190 * @copyright: (allow-none) the copyright string
1192 * Sets the copyright string to display in the about dialog.
1193 * This should be a short string of one or two lines.
1198 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
1199 const gchar *copyright)
1201 GtkAboutDialogPrivate *priv;
1202 gchar *copyright_string, *tmp;
1204 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1208 tmp = priv->copyright;
1209 priv->copyright = g_strdup (copyright);
1212 if (priv->copyright != NULL)
1214 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
1216 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
1217 g_free (copyright_string);
1219 gtk_widget_show (priv->copyright_label);
1222 gtk_widget_hide (priv->copyright_label);
1224 g_object_notify (G_OBJECT (about), "copyright");
1228 * gtk_about_dialog_get_comments:
1229 * @about: a #GtkAboutDialog
1231 * Returns the comments string.
1233 * Return value: The comments. The string is owned by the about
1234 * dialog and must not be modified.
1239 gtk_about_dialog_get_comments (GtkAboutDialog *about)
1241 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1243 return about->priv->comments;
1247 * gtk_about_dialog_set_comments:
1248 * @about: a #GtkAboutDialog
1249 * @comments: (allow-none): a comments string
1251 * Sets the comments string to display in the about dialog.
1252 * This should be a short string of one or two lines.
1257 gtk_about_dialog_set_comments (GtkAboutDialog *about,
1258 const gchar *comments)
1260 GtkAboutDialogPrivate *priv;
1263 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1267 tmp = priv->comments;
1270 priv->comments = g_strdup (comments);
1271 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
1272 gtk_widget_show (priv->comments_label);
1276 priv->comments = NULL;
1277 gtk_widget_hide (priv->comments_label);
1281 g_object_notify (G_OBJECT (about), "comments");
1285 * gtk_about_dialog_get_license:
1286 * @about: a #GtkAboutDialog
1288 * Returns the license information.
1290 * Return value: The license information. The string is owned by the about
1291 * dialog and must not be modified.
1296 gtk_about_dialog_get_license (GtkAboutDialog *about)
1298 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1300 return about->priv->license;
1304 * gtk_about_dialog_set_license:
1305 * @about: a #GtkAboutDialog
1306 * @license: (allow-none): the license information or %NULL
1308 * Sets the license information to be displayed in the secondary
1309 * license dialog. If @license is %NULL, the license button is
1315 gtk_about_dialog_set_license (GtkAboutDialog *about,
1316 const gchar *license)
1318 GtkAboutDialogPrivate *priv;
1321 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1325 tmp = priv->license;
1328 priv->license = g_strdup (license);
1329 priv->license_type = GTK_LICENSE_CUSTOM;
1333 priv->license = NULL;
1334 priv->license_type = GTK_LICENSE_UNKNOWN;
1338 gtk_widget_hide (priv->license_label);
1340 update_license_button_visibility (about);
1342 g_object_notify (G_OBJECT (about), "license");
1343 g_object_notify (G_OBJECT (about), "license-type");
1347 * gtk_about_dialog_get_wrap_license:
1348 * @about: a #GtkAboutDialog
1350 * Returns whether the license text in @about is
1351 * automatically wrapped.
1353 * Returns: %TRUE if the license text is wrapped
1358 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1360 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1362 return about->priv->wrap_license;
1366 * gtk_about_dialog_set_wrap_license:
1367 * @about: a #GtkAboutDialog
1368 * @wrap_license: whether to wrap the license
1370 * Sets whether the license text in @about is
1371 * automatically wrapped.
1376 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1377 gboolean wrap_license)
1379 GtkAboutDialogPrivate *priv;
1381 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1385 wrap_license = wrap_license != FALSE;
1387 if (priv->wrap_license != wrap_license)
1389 priv->wrap_license = wrap_license;
1391 g_object_notify (G_OBJECT (about), "wrap-license");
1396 * gtk_about_dialog_get_website:
1397 * @about: a #GtkAboutDialog
1399 * Returns the website URL.
1401 * Return value: The website URL. The string is owned by the about
1402 * dialog and must not be modified.
1407 gtk_about_dialog_get_website (GtkAboutDialog *about)
1409 GtkAboutDialogPrivate *priv;
1411 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1415 return priv->website_url;
1419 * gtk_about_dialog_set_website:
1420 * @about: a #GtkAboutDialog
1421 * @website: (allow-none): a URL string starting with "http://"
1423 * Sets the URL to use for the website link.
1428 gtk_about_dialog_set_website (GtkAboutDialog *about,
1429 const gchar *website)
1431 GtkAboutDialogPrivate *priv;
1434 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1438 tmp = priv->website_url;
1439 priv->website_url = g_strdup (website);
1442 update_website (about);
1444 g_object_notify (G_OBJECT (about), "website");
1448 * gtk_about_dialog_get_website_label:
1449 * @about: a #GtkAboutDialog
1451 * Returns the label used for the website link.
1453 * Return value: The label used for the website link. The string is
1454 * owned by the about dialog and must not be modified.
1459 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1461 GtkAboutDialogPrivate *priv;
1463 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1467 return priv->website_text;
1471 * gtk_about_dialog_set_website_label:
1472 * @about: a #GtkAboutDialog
1473 * @website_label: the label used for the website link
1475 * Sets the label to be used for the website link.
1480 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1481 const gchar *website_label)
1483 GtkAboutDialogPrivate *priv;
1486 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1490 tmp = priv->website_text;
1491 priv->website_text = g_strdup (website_label);
1494 update_website (about);
1496 g_object_notify (G_OBJECT (about), "website-label");
1500 * gtk_about_dialog_get_authors:
1501 * @about: a #GtkAboutDialog
1503 * Returns the string which are displayed in the authors tab
1504 * of the secondary credits dialog.
1506 * Return value: (array zero-terminated=1) (transfer none): A
1507 * %NULL-terminated string array containing the authors. The array is
1508 * owned by the about dialog and must not be modified.
1512 const gchar * const *
1513 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1515 GtkAboutDialogPrivate *priv;
1517 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1521 return (const gchar * const *) priv->authors;
1525 * gtk_about_dialog_set_authors:
1526 * @about: a #GtkAboutDialog
1527 * @authors: (array zero-terminated=1): a %NULL-terminated array of strings
1529 * Sets the strings which are displayed in the authors tab
1530 * of the secondary credits dialog.
1535 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1536 const gchar **authors)
1538 GtkAboutDialogPrivate *priv;
1541 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1545 tmp = priv->authors;
1546 priv->authors = g_strdupv ((gchar **)authors);
1549 update_credits_button_visibility (about);
1551 g_object_notify (G_OBJECT (about), "authors");
1555 * gtk_about_dialog_get_documenters:
1556 * @about: a #GtkAboutDialog
1558 * Returns the string which are displayed in the documenters
1559 * tab of the secondary credits dialog.
1561 * Return value: (array zero-terminated=1) (transfer none): A
1562 * %NULL-terminated string array containing the documenters. The
1563 * array is owned by the about dialog and must not be modified.
1567 const gchar * const *
1568 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1570 GtkAboutDialogPrivate *priv;
1572 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1576 return (const gchar * const *)priv->documenters;
1580 * gtk_about_dialog_set_documenters:
1581 * @about: a #GtkAboutDialog
1582 * @documenters: (array zero-terminated=1): a %NULL-terminated array of strings
1584 * Sets the strings which are displayed in the documenters tab
1585 * of the secondary credits dialog.
1590 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1591 const gchar **documenters)
1593 GtkAboutDialogPrivate *priv;
1596 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1600 tmp = priv->documenters;
1601 priv->documenters = g_strdupv ((gchar **)documenters);
1604 update_credits_button_visibility (about);
1606 g_object_notify (G_OBJECT (about), "documenters");
1610 * gtk_about_dialog_get_artists:
1611 * @about: a #GtkAboutDialog
1613 * Returns the string which are displayed in the artists tab
1614 * of the secondary credits dialog.
1616 * Return value: (array zero-terminated=1) (transfer none): A
1617 * %NULL-terminated string array containing the artists. The array is
1618 * owned by the about dialog and must not be modified.
1622 const gchar * const *
1623 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1625 GtkAboutDialogPrivate *priv;
1627 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1631 return (const gchar * const *)priv->artists;
1635 * gtk_about_dialog_set_artists:
1636 * @about: a #GtkAboutDialog
1637 * @artists: (array zero-terminated=1): a %NULL-terminated array of strings
1639 * Sets the strings which are displayed in the artists tab
1640 * of the secondary credits dialog.
1645 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1646 const gchar **artists)
1648 GtkAboutDialogPrivate *priv;
1651 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1655 tmp = priv->artists;
1656 priv->artists = g_strdupv ((gchar **)artists);
1659 update_credits_button_visibility (about);
1661 g_object_notify (G_OBJECT (about), "artists");
1665 * gtk_about_dialog_get_translator_credits:
1666 * @about: a #GtkAboutDialog
1668 * Returns the translator credits string which is displayed
1669 * in the translators tab of the secondary credits dialog.
1671 * Return value: The translator credits string. The string is
1672 * owned by the about dialog and must not be modified.
1677 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1679 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1681 return about->priv->translator_credits;
1685 * gtk_about_dialog_set_translator_credits:
1686 * @about: a #GtkAboutDialog
1687 * @translator_credits: (allow-none): the translator credits
1689 * Sets the translator credits string which is displayed in
1690 * the translators tab of the secondary credits dialog.
1692 * The intended use for this string is to display the translator
1693 * of the language which is currently used in the user interface.
1694 * Using gettext(), a simple way to achieve that is to mark the
1695 * string for translation:
1697 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1699 * It is a good idea to use the customary msgid "translator-credits" for this
1700 * purpose, since translators will already know the purpose of that msgid, and
1701 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1707 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1708 const gchar *translator_credits)
1710 GtkAboutDialogPrivate *priv;
1713 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1717 tmp = priv->translator_credits;
1718 priv->translator_credits = g_strdup (translator_credits);
1721 update_credits_button_visibility (about);
1723 g_object_notify (G_OBJECT (about), "translator-credits");
1727 * gtk_about_dialog_get_logo:
1728 * @about: a #GtkAboutDialog
1730 * Returns the pixbuf displayed as logo in the about dialog.
1732 * Return value: (transfer none): the pixbuf displayed as logo. The
1733 * pixbuf is owned by the about dialog. If you want to keep a
1734 * reference to it, you have to call g_object_ref() on it.
1739 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1741 GtkAboutDialogPrivate *priv;
1743 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1747 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1748 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1754 icon_set_new_from_pixbufs (GList *pixbufs)
1756 GtkIconSet *icon_set = gtk_icon_set_new ();
1758 for (; pixbufs; pixbufs = pixbufs->next)
1760 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1762 GtkIconSource *icon_source = gtk_icon_source_new ();
1763 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1764 gtk_icon_set_add_source (icon_set, icon_source);
1765 gtk_icon_source_free (icon_source);
1772 * gtk_about_dialog_set_logo:
1773 * @about: a #GtkAboutDialog
1774 * @logo: (allow-none): a #GdkPixbuf, or %NULL
1776 * Sets the pixbuf to be displayed as logo in the about dialog.
1777 * If it is %NULL, the default window icon set with
1778 * gtk_window_set_default_icon() will be used.
1783 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1786 GtkAboutDialogPrivate *priv;
1788 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1792 g_object_freeze_notify (G_OBJECT (about));
1794 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1795 g_object_notify (G_OBJECT (about), "logo-icon-name");
1798 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1801 GList *pixbufs = gtk_window_get_default_icon_list ();
1803 if (pixbufs != NULL)
1805 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1807 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1808 icon_set, GTK_ICON_SIZE_DIALOG);
1810 gtk_icon_set_unref (icon_set);
1811 g_list_free (pixbufs);
1815 g_object_notify (G_OBJECT (about), "logo");
1817 g_object_thaw_notify (G_OBJECT (about));
1821 * gtk_about_dialog_get_logo_icon_name:
1822 * @about: a #GtkAboutDialog
1824 * Returns the icon name displayed as logo in the about dialog.
1826 * Return value: the icon name displayed as logo. The string is
1827 * owned by the dialog. If you want to keep a reference
1828 * to it, you have to call g_strdup() on it.
1833 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1835 GtkAboutDialogPrivate *priv;
1836 const gchar *icon_name = NULL;
1838 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1842 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1843 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1849 * gtk_about_dialog_set_logo_icon_name:
1850 * @about: a #GtkAboutDialog
1851 * @icon_name: (allow-none): an icon name, or %NULL
1853 * Sets the pixbuf to be displayed as logo in the about dialog.
1854 * If it is %NULL, the default window icon set with
1855 * gtk_window_set_default_icon() will be used.
1860 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1861 const gchar *icon_name)
1863 GtkAboutDialogPrivate *priv;
1865 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1869 g_object_freeze_notify (G_OBJECT (about));
1871 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1872 g_object_notify (G_OBJECT (about), "logo");
1874 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1875 GTK_ICON_SIZE_DIALOG);
1876 g_object_notify (G_OBJECT (about), "logo-icon-name");
1878 g_object_thaw_notify (G_OBJECT (about));
1882 follow_if_link (GtkAboutDialog *about,
1883 GtkTextView *text_view,
1886 GSList *tags = NULL, *tagp = NULL;
1887 GtkAboutDialogPrivate *priv = about->priv;
1890 tags = gtk_text_iter_get_tags (iter);
1891 for (tagp = tags; tagp != NULL && !uri; tagp = tagp->next)
1893 GtkTextTag *tag = tagp->data;
1895 uri = g_object_get_data (G_OBJECT (tag), "uri");
1897 emit_activate_link (about, uri);
1899 if (uri && !g_slist_find_custom (priv->visited_links, uri, (GCompareFunc)strcmp))
1901 GdkColor *style_visited_link_color;
1904 gtk_widget_style_get (GTK_WIDGET (about),
1905 "visited-link-color", &style_visited_link_color,
1907 if (style_visited_link_color)
1909 color = *style_visited_link_color;
1910 gdk_color_free (style_visited_link_color);
1913 color = default_visited_link_color;
1915 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1917 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (uri));
1922 g_slist_free (tags);
1926 text_view_key_press_event (GtkWidget *text_view,
1928 GtkAboutDialog *about)
1931 GtkTextBuffer *buffer;
1933 switch (event->keyval)
1935 case GDK_KEY_Return:
1936 case GDK_KEY_ISO_Enter:
1937 case GDK_KEY_KP_Enter:
1938 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1939 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1940 gtk_text_buffer_get_insert (buffer));
1941 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1952 text_view_event_after (GtkWidget *text_view,
1954 GtkAboutDialog *about)
1956 GtkTextIter start, end, iter;
1957 GtkTextBuffer *buffer;
1958 GdkEventButton *button_event;
1961 if (event->type != GDK_BUTTON_RELEASE)
1964 button_event = (GdkEventButton *)event;
1966 if (button_event->button != GDK_BUTTON_PRIMARY)
1969 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1971 /* we shouldn't follow a link if the user has selected something */
1972 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1973 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1976 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1977 GTK_TEXT_WINDOW_WIDGET,
1978 button_event->x, button_event->y, &x, &y);
1980 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1982 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1988 set_cursor_if_appropriate (GtkAboutDialog *about,
1989 GtkTextView *text_view,
1994 GtkAboutDialogPrivate *priv = about->priv;
1995 GSList *tags = NULL, *tagp = NULL;
1997 gboolean hovering_over_link = FALSE;
1999 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
2001 tags = gtk_text_iter_get_tags (&iter);
2002 for (tagp = tags; tagp != NULL; tagp = tagp->next)
2004 GtkTextTag *tag = tagp->data;
2005 gchar *uri = g_object_get_data (G_OBJECT (tag), "uri");
2009 hovering_over_link = TRUE;
2014 if (hovering_over_link != priv->hovering_over_link)
2016 priv->hovering_over_link = hovering_over_link;
2018 if (hovering_over_link)
2019 gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->hand_cursor);
2021 gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->regular_cursor);
2025 g_slist_free (tags);
2029 text_view_motion_notify_event (GtkWidget *text_view,
2030 GdkEventMotion *event,
2031 GtkAboutDialog *about)
2035 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
2036 GTK_TEXT_WINDOW_WIDGET,
2037 event->x, event->y, &x, &y);
2039 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), event->device, x, y);
2041 gdk_event_request_motions (event);
2048 text_view_visibility_notify_event (GtkWidget *text_view,
2049 GdkEventVisibility *event,
2050 GtkAboutDialog *about)
2052 GdkDeviceManager *device_manager;
2053 GdkDisplay *display;
2055 gint wx, wy, bx, by;
2057 display = gdk_window_get_display (event->window);
2058 device_manager = gdk_display_get_device_manager (display);
2059 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
2061 for (d = devices; d; d = d->next)
2063 GdkDevice *dev = d->data;
2065 if (gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD)
2068 gdk_window_get_device_position (gtk_widget_get_window (text_view), dev,
2071 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
2072 GTK_TEXT_WINDOW_WIDGET,
2075 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), dev, bx, by);
2078 g_list_free (devices);
2084 text_view_new (GtkAboutDialog *about,
2086 GtkWrapMode wrap_mode)
2089 gchar *q0, *q1, *q2, *r1, *r2;
2091 GtkTextView *text_view;
2092 GtkTextBuffer *buffer;
2093 GdkColor *style_link_color;
2094 GdkColor *style_visited_link_color;
2096 GdkColor link_color;
2097 GdkColor visited_link_color;
2098 GtkAboutDialogPrivate *priv = about->priv;
2099 GtkTextIter start_iter, end_iter;
2102 gtk_widget_style_get (GTK_WIDGET (about),
2103 "link-color", &style_link_color,
2104 "visited-link-color", &style_visited_link_color,
2106 if (style_link_color)
2108 link_color = *style_link_color;
2109 gdk_color_free (style_link_color);
2112 link_color = default_link_color;
2114 if (style_visited_link_color)
2116 visited_link_color = *style_visited_link_color;
2117 gdk_color_free (style_visited_link_color);
2120 visited_link_color = default_visited_link_color;
2122 view = gtk_text_view_new ();
2123 text_view = GTK_TEXT_VIEW (view);
2124 buffer = gtk_text_view_get_buffer (text_view);
2125 gtk_text_view_set_cursor_visible (text_view, FALSE);
2126 gtk_text_view_set_editable (text_view, FALSE);
2127 gtk_text_view_set_wrap_mode (text_view, wrap_mode);
2129 gtk_text_buffer_get_start_iter (buffer, &start_iter);
2130 gtk_text_buffer_get_start_iter (buffer, &end_iter);
2131 tag = gtk_text_tag_new (NULL);
2132 g_object_set (tag, "font-scale", PANGO_SCALE_SMALL, NULL);
2133 gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
2135 gtk_text_view_set_left_margin (text_view, 8);
2136 gtk_text_view_set_right_margin (text_view, 8);
2138 g_signal_connect (view, "key-press-event",
2139 G_CALLBACK (text_view_key_press_event), about);
2140 g_signal_connect (view, "event-after",
2141 G_CALLBACK (text_view_event_after), about);
2142 g_signal_connect (view, "motion-notify-event",
2143 G_CALLBACK (text_view_motion_notify_event), about);
2144 g_signal_connect (view, "visibility-notify-event",
2145 G_CALLBACK (text_view_visibility_notify_event), about);
2147 if (strings == NULL)
2149 gtk_widget_hide (view);
2153 for (p = strings; *p; p++)
2158 q1 = strchr (q0, '<');
2159 q2 = q1 ? strchr (q1, '>') : NULL;
2160 r1 = strstr (q0, "http://");
2163 r2 = strpbrk (r1, " \n\t");
2165 r2 = strchr (r1, '\0');
2170 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2181 const gchar *link_type;
2186 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0 + 1);
2187 gtk_text_buffer_get_end_iter (buffer, &end);
2189 link_type = "email";
2193 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
2194 gtk_text_buffer_get_end_iter (buffer, &end);
2200 link = g_strndup (q1, q2 - q1);
2202 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
2203 color = visited_link_color;
2207 tag = gtk_text_buffer_create_tag (buffer, NULL,
2208 "foreground-gdk", &color,
2209 "underline", PANGO_UNDERLINE_SINGLE,
2211 if (strcmp (link_type, "email") == 0)
2215 escaped = g_uri_escape_string (link, NULL, FALSE);
2216 uri = g_strconcat ("mailto:", escaped, NULL);
2221 uri = g_strdup (link);
2223 g_object_set_data_full (G_OBJECT (tag), I_("uri"), uri, g_free);
2224 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
2230 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
2236 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
2239 gtk_widget_show (view);
2244 add_credits_section (GtkAboutDialog *about,
2253 gchar *q0, *q1, *q2, *r1, *r2;
2258 markup = g_strdup_printf ("<span size=\"small\">%s</span>", title);
2259 label = gtk_label_new (markup);
2260 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
2262 gtk_widget_set_halign (label, GTK_ALIGN_END);
2263 gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
2264 gtk_grid_attach (grid, label, 0, *row, 1, 1);
2266 for (p = people; *p; p++)
2270 str = g_string_new ("<span size=\"small\">");
2275 q1 = strchr (q0, '<');
2276 q2 = q1 ? strchr (q1, '>') : NULL;
2277 r1 = strstr (q0, "http://");
2280 r2 = strpbrk (r1, " \n\t");
2282 r2 = strchr (r1, '\0');
2287 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2292 else if (q1 && (q1[1] == 'a' || q1[1] == 'A') && q1[2] == ' ')
2294 /* if it is a <a> link leave it for the label to parse */
2309 text = g_strstrip (g_strndup (q0, q1 - q0));
2310 name = g_markup_escape_text (text, -1);
2312 link = g_strndup (q1, q2 - q1);
2314 escaped = g_uri_escape_string (link, NULL, FALSE);
2315 g_string_append_printf (str,
2316 "<a href=\"mailto:%s\">%s</a>",
2318 name[0] ? name : link);
2327 text = g_strstrip (g_strndup (q0, q1 - q0));
2328 name = g_markup_escape_text (text, -1);
2329 link = g_strndup (q1, q2 - q1);
2330 g_string_append_printf (str,
2331 "<a href=\"%s\">%s</a>",
2333 name[0] ? name : link);
2343 g_string_append (str, q0);
2347 g_string_append (str, "</span>");
2349 label = gtk_label_new (str->str);
2350 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
2351 g_string_free (str, TRUE);
2352 gtk_widget_set_halign (label, GTK_ALIGN_START);
2353 gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
2354 gtk_grid_attach (grid, label, 1, *row, 1, 1);
2358 /* skip one at the end */
2359 label = gtk_label_new ("");
2360 gtk_grid_attach (grid, label, 1, *row, 1, 1);
2365 create_credits_page (GtkAboutDialog *about)
2367 GtkAboutDialogPrivate *priv = about->priv;
2368 GtkWidget *page_vbox;
2373 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
2374 gtk_widget_show (page_vbox);
2375 priv->credits_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
2377 sw = gtk_scrolled_window_new (NULL, NULL);
2378 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
2379 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2381 GTK_POLICY_AUTOMATIC);
2382 gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
2384 grid = gtk_grid_new ();
2385 gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
2386 gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
2387 gtk_grid_set_column_spacing (GTK_GRID (grid), 8);
2388 gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
2389 gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
2390 gtk_widget_set_valign (grid, GTK_ALIGN_START);
2391 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), grid);
2392 gtk_style_context_add_class (gtk_widget_get_style_context (gtk_bin_get_child (GTK_BIN (sw))),
2393 GTK_STYLE_CLASS_VIEW);
2397 if (priv->authors != NULL)
2398 add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
2400 if (priv->documenters != NULL)
2401 add_credits_section (about, GTK_GRID (grid), &row, _("Documented by"), priv->documenters);
2403 /* Don't show an untranslated gettext msgid */
2404 if (priv->translator_credits != NULL &&
2405 strcmp (priv->translator_credits, "translator_credits") != 0 &&
2406 strcmp (priv->translator_credits, "translator-credits") != 0)
2408 gchar **translators;
2410 translators = g_strsplit (priv->translator_credits, "\n", 0);
2411 add_credits_section (about, GTK_GRID (grid), &row, _("Translated by"), translators);
2412 g_strfreev (translators);
2415 if (priv->artists != NULL)
2416 add_credits_section (about, GTK_GRID (grid), &row, _("Artwork by"), priv->artists);
2418 if (priv->credit_sections != NULL)
2421 for (cs = priv->credit_sections; cs != NULL; cs = cs->next)
2423 CreditSection *section = cs->data;
2424 add_credits_section (about, GTK_GRID (grid), &row, section->heading, section->people);
2428 gtk_widget_show_all (sw);
2432 display_credits_page (GtkWidget *button,
2435 GtkAboutDialog *about = (GtkAboutDialog *)data;
2436 GtkAboutDialogPrivate *priv = about->priv;
2438 if (priv->credits_page == 0)
2439 create_credits_page (about);
2441 switch_page (about, priv->credits_page);
2445 create_license_page (GtkAboutDialog *about)
2447 GtkAboutDialogPrivate *priv = about->priv;
2448 GtkWidget *page_vbox;
2453 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
2454 priv->license_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
2456 sw = gtk_scrolled_window_new (NULL, NULL);
2457 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
2458 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2459 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2460 gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
2462 strings[0] = priv->license;
2464 view = text_view_new (about, strings,
2465 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2467 gtk_container_add (GTK_CONTAINER (sw), view);
2469 gtk_widget_show_all (page_vbox);
2473 display_license_page (GtkWidget *button,
2476 GtkAboutDialog *about = (GtkAboutDialog *)data;
2477 GtkAboutDialogPrivate *priv = about->priv;
2479 if (priv->license_page == 0)
2480 create_license_page (about);
2482 switch_page (about, priv->license_page);
2486 * gtk_about_dialog_new:
2488 * Creates a new #GtkAboutDialog.
2490 * Returns: a newly created #GtkAboutDialog
2495 gtk_about_dialog_new (void)
2497 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2499 return GTK_WIDGET (dialog);
2503 close_cb (GtkAboutDialog *about)
2505 GtkAboutDialogPrivate *priv = about->priv;
2507 switch_page (about, 0);
2508 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->credits_button), FALSE);
2509 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->license_button), FALSE);
2510 gtk_widget_hide (GTK_WIDGET (about));
2514 * gtk_show_about_dialog:
2515 * @parent: (allow-none): transient parent, or %NULL for none
2516 * @first_property_name: the name of the first property
2517 * @...: value of first property, followed by more properties, %NULL-terminated
2519 * This is a convenience function for showing an application's about box.
2520 * The constructed dialog is associated with the parent window and
2521 * reused for future invocations of this function.
2526 gtk_show_about_dialog (GtkWindow *parent,
2527 const gchar *first_property_name,
2530 static GtkWidget *global_about_dialog = NULL;
2531 GtkWidget *dialog = NULL;
2535 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2537 dialog = global_about_dialog;
2541 dialog = gtk_about_dialog_new ();
2543 g_object_ref_sink (dialog);
2545 g_signal_connect (dialog, "delete-event",
2546 G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2548 /* Close dialog on user response */
2549 g_signal_connect (dialog, "response",
2550 G_CALLBACK (close_cb), NULL);
2552 va_start (var_args, first_property_name);
2553 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2558 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
2559 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2560 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2561 g_object_set_data_full (G_OBJECT (parent),
2562 I_("gtk-about-dialog"),
2563 dialog, g_object_unref);
2566 global_about_dialog = dialog;
2570 gtk_window_present (GTK_WINDOW (dialog));
2574 * gtk_about_dialog_set_license_type:
2575 * @about: a #GtkAboutDialog
2576 * @license_type: the type of license
2578 * Sets the license of the application showing the @about dialog from a
2579 * list of known licenses.
2581 * This function overrides the license set using
2582 * gtk_about_dialog_set_license().
2587 gtk_about_dialog_set_license_type (GtkAboutDialog *about,
2588 GtkLicense license_type)
2590 GtkAboutDialogPrivate *priv;
2592 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
2593 g_return_if_fail (license_type >= GTK_LICENSE_UNKNOWN &&
2594 license_type <= GTK_LICENSE_ARTISTIC);
2598 if (priv->license_type != license_type)
2600 g_object_freeze_notify (G_OBJECT (about));
2602 priv->license_type = license_type;
2604 /* custom licenses use the contents of the :license property */
2605 if (priv->license_type != GTK_LICENSE_CUSTOM)
2608 gchar *license_string;
2611 url = gtk_license_urls[priv->license_type];
2613 url = priv->website_url;
2615 str = g_string_sized_new (256);
2616 g_string_append_printf (str, _(gtk_license_preamble), url, url);
2618 g_free (priv->license);
2619 priv->license = g_string_free (str, FALSE);
2620 priv->wrap_license = TRUE;
2622 license_string = g_strdup_printf ("<span size=\"small\">%s</span>",
2624 gtk_label_set_markup (GTK_LABEL (priv->license_label), license_string);
2625 g_free (license_string);
2626 gtk_widget_show (priv->license_label);
2628 update_license_button_visibility (about);
2630 g_object_notify (G_OBJECT (about), "wrap-license");
2631 g_object_notify (G_OBJECT (about), "license");
2635 gtk_widget_show (priv->license_label);
2638 g_object_notify (G_OBJECT (about), "license-type");
2640 g_object_thaw_notify (G_OBJECT (about));
2645 * gtk_about_dialog_get_license_type:
2646 * @about: a #GtkAboutDialog
2648 * Retrieves the license set using gtk_about_dialog_set_license_type()
2650 * Return value: a #GtkLicense value
2655 gtk_about_dialog_get_license_type (GtkAboutDialog *about)
2657 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), GTK_LICENSE_UNKNOWN);
2659 return about->priv->license_type;
2663 * gtk_about_dialog_add_credit_section:
2664 * @about: A #GtkAboutDialog
2665 * @section_name: The name of the section
2666 * @people: (array zero-terminated=1): The people who belong to that section
2668 * Creates a new section in the Credits page.
2673 gtk_about_dialog_add_credit_section (GtkAboutDialog *about,
2674 const gchar *section_name,
2675 const gchar **people)
2677 GtkAboutDialogPrivate *priv;
2678 CreditSection *new_entry;
2680 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
2681 g_return_if_fail (section_name != NULL);
2682 g_return_if_fail (people != NULL);
2686 new_entry = g_slice_new (CreditSection);
2687 new_entry->heading = g_strdup ((gchar *)section_name);
2688 new_entry->people = g_strdupv ((gchar **)people);
2690 priv->credit_sections = g_slist_append (priv->credit_sections, new_entry);
2691 update_credits_button_visibility (about);