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 "gtkaboutdialog.h"
36 #include "gtkalignment.h"
37 #include "gtkbutton.h"
39 #include "gtkdialog.h"
44 #include "gtklinkbutton.h"
45 #include "gtkmarshalers.h"
46 #include "gtknotebook.h"
47 #include "gtkorientable.h"
48 #include "gtkscrolledwindow.h"
50 #include "gtktextview.h"
52 #include "gtkiconfactory.h"
54 #include "gtkmainprivate.h"
55 #include "gtkmessagedialog.h"
56 #include "gtktogglebutton.h"
57 #include "gtktypebuiltins.h"
58 #include "gtkprivate.h"
63 * SECTION:gtkaboutdialog
64 * @Short_description: Display information about an application
65 * @Title: GtkAboutDialog
66 * @See_also: #GTK_STOCK_ABOUT
68 * The GtkAboutDialog offers a simple way to display information about
69 * a program like its logo, name, copyright, website and license. It is
70 * also possible to give credits to the authors, documenters, translators
71 * and artists who have worked on the program. An about dialog is typically
72 * opened when the user selects the <literal>About</literal> option from
73 * the <literal>Help</literal> menu. All parts of the dialog are optional.
75 * About dialog often contain links and email addresses. GtkAboutDialog
76 * displays these as clickable links. By default, it calls gtk_show_uri()
77 * when a user clicks one. The behaviour can be overridden with the
78 * #GtkAboutDialog::activate-link signal.
80 * To make constructing a GtkAboutDialog as convenient as possible, you can
81 * use the function gtk_show_about_dialog() which constructs and shows a dialog
82 * and keeps it around so that it can be shown again.
84 * Note that GTK+ sets a default title of <literal>_("About %s")</literal>
85 * on the dialog window (where %s is replaced by the name of the
86 * application, but in order to ensure proper translation of the title,
87 * applications should set the title property explicitly when constructing
88 * a GtkAboutDialog, as shown in the following example:
89 * <informalexample><programlisting>
90 * gtk_show_about_dialog (NULL,
91 * "program-name", "ExampleCode",
92 * "logo", example_logo,
93 * "title" _("About ExampleCode"),
95 * </programlisting></informalexample>
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; for 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"
123 struct _GtkAboutDialogPrivate
131 gchar *translator_credits;
142 GtkWidget *logo_image;
143 GtkWidget *name_label;
144 GtkWidget *version_label;
145 GtkWidget *comments_label;
146 GtkWidget *copyright_label;
147 GtkWidget *license_label;
148 GtkWidget *website_label;
150 GtkWidget *credits_button;
151 GtkWidget *license_button;
153 GdkCursor *hand_cursor;
154 GdkCursor *regular_cursor;
156 GSList *visited_links;
158 GtkLicense license_type;
160 guint hovering_over_link : 1;
161 guint wrap_license : 1;
164 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
179 PROP_TRANSLATOR_CREDITS,
187 static void gtk_about_dialog_finalize (GObject *object);
188 static void gtk_about_dialog_get_property (GObject *object,
192 static void gtk_about_dialog_set_property (GObject *object,
196 static void gtk_about_dialog_show (GtkWidget *widge);
197 static void update_name_version (GtkAboutDialog *about);
198 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
199 static void follow_if_link (GtkAboutDialog *about,
200 GtkTextView *text_view,
202 static void set_cursor_if_appropriate (GtkAboutDialog *about,
203 GtkTextView *text_view,
207 static void display_credits_page (GtkWidget *button,
209 static void display_license_page (GtkWidget *button,
211 static void close_cb (GtkAboutDialog *about);
212 static gboolean gtk_about_dialog_activate_link (GtkAboutDialog *about,
220 static guint signals[LAST_SIGNAL] = { 0 };
222 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
226 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
228 GObjectClass *object_class;
229 GtkWidgetClass *widget_class;
231 object_class = (GObjectClass *)klass;
232 widget_class = (GtkWidgetClass *)klass;
234 object_class->set_property = gtk_about_dialog_set_property;
235 object_class->get_property = gtk_about_dialog_get_property;
237 object_class->finalize = gtk_about_dialog_finalize;
239 widget_class->show = gtk_about_dialog_show;
241 klass->activate_link = gtk_about_dialog_activate_link;
244 * GtkAboutDialog::activate-link:
245 * @label: The object on which the signal was emitted
246 * @uri: the URI that is activated
248 * The signal which gets emitted to activate a URI.
249 * Applications may connect to it to override the default behaviour,
250 * which is to call gtk_show_uri().
252 * Returns: %TRUE if the link has been activated
256 signals[ACTIVATE_LINK] =
257 g_signal_new ("activate-link",
258 G_TYPE_FROM_CLASS (object_class),
260 G_STRUCT_OFFSET (GtkAboutDialogClass, activate_link),
261 _gtk_boolean_handled_accumulator, NULL,
262 _gtk_marshal_BOOLEAN__STRING,
263 G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
266 * GtkAboutDialog:program-name:
268 * The name of the program.
269 * If this is not set, it defaults to g_get_application_name().
273 g_object_class_install_property (object_class,
275 g_param_spec_string ("program-name",
277 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
279 GTK_PARAM_READWRITE));
282 * GtkAboutDialog:version:
284 * The version of the program.
288 g_object_class_install_property (object_class,
290 g_param_spec_string ("version",
291 P_("Program version"),
292 P_("The version of the program"),
294 GTK_PARAM_READWRITE));
297 * GtkAboutDialog:copyright:
299 * Copyright information for the program.
303 g_object_class_install_property (object_class,
305 g_param_spec_string ("copyright",
306 P_("Copyright string"),
307 P_("Copyright information for the program"),
309 GTK_PARAM_READWRITE));
313 * GtkAboutDialog:comments:
315 * Comments about the program. This string is displayed in a label
316 * in the main dialog, thus it should be a short explanation of
317 * the main purpose of the program, not a detailed list of features.
321 g_object_class_install_property (object_class,
323 g_param_spec_string ("comments",
324 P_("Comments string"),
325 P_("Comments about the program"),
327 GTK_PARAM_READWRITE));
330 * GtkAboutDialog:license:
332 * The license of the program. This string is displayed in a
333 * text view in a secondary dialog, therefore it is fine to use
334 * a long multi-paragraph text. Note that the text is only wrapped
335 * in the text view if the "wrap-license" property is set to %TRUE;
336 * otherwise the text itself must contain the intended linebreaks.
337 * When setting this property to a non-%NULL value, the
338 * #GtkAboutDialog:license-type property is set to %GTK_LICENSE_CUSTOM
343 g_object_class_install_property (object_class,
345 g_param_spec_string ("license",
347 _("The license of the program"),
349 GTK_PARAM_READWRITE));
352 * GtkAboutDialog:license-type:
354 * The license of the program, as a value of the %GtkLicense enumeration.
356 * The #GtkAboutDialog will automatically fill out a standard disclaimer
357 * and link the user to the appropriate online resource for the license
360 * If %GTK_LICENSE_UNKNOWN is used, the link used will be the same
361 * specified in the #GtkAboutDialog:website property.
363 * If %GTK_LICENSE_CUSTOM is used, the current contents of the
364 * #GtkAboutDialog:license property are used.
366 * For any other #GtkLicense value, the contents of the
367 * #GtkAboutDialog:license property are also set by this property as
372 g_object_class_install_property (object_class,
374 g_param_spec_enum ("license-type",
376 P_("The license type of the program"),
379 GTK_PARAM_READWRITE));
382 * GtkAboutDialog:website:
384 * The URL for the link to the website of the program.
385 * This should be a string starting with "http://.
389 g_object_class_install_property (object_class,
391 g_param_spec_string ("website",
393 P_("The URL for the link to the website of the program"),
395 GTK_PARAM_READWRITE));
398 * GtkAboutDialog:website-label:
400 * The label for the link to the website of the program.
404 g_object_class_install_property (object_class,
406 g_param_spec_string ("website-label",
408 P_("The label for the link to the website of the program"),
410 GTK_PARAM_READWRITE));
413 * GtkAboutDialog:authors:
415 * The authors of the program, as a %NULL-terminated array of strings.
416 * Each string may contain email addresses and URLs, which will be displayed
417 * as links, see the introduction for more details.
421 g_object_class_install_property (object_class,
423 g_param_spec_boxed ("authors",
425 P_("List of authors of the program"),
427 GTK_PARAM_READWRITE));
430 * GtkAboutDialog:documenters:
432 * The people documenting the program, as a %NULL-terminated array of strings.
433 * Each string may contain email addresses and URLs, which will be displayed
434 * as links, see the introduction for more details.
438 g_object_class_install_property (object_class,
440 g_param_spec_boxed ("documenters",
442 P_("List of people documenting the program"),
444 GTK_PARAM_READWRITE));
447 * GtkAboutDialog:artists:
449 * The people who contributed artwork to the program, as a %NULL-terminated
450 * array of strings. Each string may contain email addresses and URLs, which
451 * will be displayed as links, see the introduction for more details.
455 g_object_class_install_property (object_class,
457 g_param_spec_boxed ("artists",
459 P_("List of people who have contributed artwork to the program"),
461 GTK_PARAM_READWRITE));
465 * GtkAboutDialog:translator-credits:
467 * Credits to the translators. This string should be marked as translatable.
468 * The string may contain email addresses and URLs, which will be displayed
469 * as links, see the introduction for more details.
473 g_object_class_install_property (object_class,
474 PROP_TRANSLATOR_CREDITS,
475 g_param_spec_string ("translator-credits",
476 P_("Translator credits"),
477 P_("Credits to the translators. This string should be marked as translatable"),
479 GTK_PARAM_READWRITE));
482 * GtkAboutDialog:logo:
484 * A logo for the about box. If this is not set, it defaults to
485 * gtk_window_get_default_icon_list().
489 g_object_class_install_property (object_class,
491 g_param_spec_object ("logo",
493 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
495 GTK_PARAM_READWRITE));
498 * GtkAboutDialog:logo-icon-name:
500 * A named icon to use as the logo for the about box. This property
501 * overrides the #GtkAboutDialog:logo property.
505 g_object_class_install_property (object_class,
507 g_param_spec_string ("logo-icon-name",
508 P_("Logo Icon Name"),
509 P_("A named icon to use as the logo for the about box."),
511 GTK_PARAM_READWRITE));
513 * GtkAboutDialog:wrap-license:
515 * Whether to wrap the text in the license dialog.
519 g_object_class_install_property (object_class,
521 g_param_spec_boolean ("wrap-license",
523 P_("Whether to wrap the license text."),
525 GTK_PARAM_READWRITE));
528 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
532 emit_activate_link (GtkAboutDialog *about,
535 gboolean handled = FALSE;
537 g_signal_emit (about, signals[ACTIVATE_LINK], 0, uri, &handled);
543 update_license_button_visibility (GtkAboutDialog *about)
545 GtkAboutDialogPrivate *priv = about->priv;
547 if (priv->license_type == GTK_LICENSE_CUSTOM && priv->license != NULL)
548 gtk_widget_show (priv->license_button);
550 gtk_widget_hide (priv->license_button);
554 update_credits_button_visibility (GtkAboutDialog *about)
556 GtkAboutDialogPrivate *priv = about->priv;
559 show = (priv->authors != NULL ||
560 priv->documenters != NULL ||
561 priv->artists != NULL ||
562 (priv->translator_credits != NULL &&
563 strcmp (priv->translator_credits, "translator_credits") &&
564 strcmp (priv->translator_credits, "translator-credits")));
566 gtk_widget_show (priv->credits_button);
568 gtk_widget_hide (priv->credits_button);
572 switch_page (GtkAboutDialog *about,
575 GtkAboutDialogPrivate *priv = about->priv;
577 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);
581 display_main_page (GtkButton *button,
584 GtkAboutDialog *about = (GtkAboutDialog *)data;
586 switch_page (about, 0);
590 credits_button_clicked (GtkButton *button,
593 GtkAboutDialog *about = (GtkAboutDialog *)data;
594 GtkAboutDialogPrivate *priv = about->priv;
597 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
601 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->license_button), FALSE);
602 display_credits_page (NULL, data);
606 display_main_page (NULL, data);
611 license_button_clicked (GtkButton *button,
614 GtkAboutDialog *about = (GtkAboutDialog *)data;
615 GtkAboutDialogPrivate *priv = about->priv;
618 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
622 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->credits_button), FALSE);
623 display_license_page (NULL, data);
627 display_main_page (NULL, data);
631 gtk_about_dialog_init (GtkAboutDialog *about)
633 GtkDialog *dialog = GTK_DIALOG (about);
634 GtkAboutDialogPrivate *priv;
635 GtkWidget *vbox, *page_vbox, *hbox, *button, *close_button, *image;
636 GtkWidget *content_area, *action_area;
639 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
643 priv->version = NULL;
644 priv->copyright = NULL;
645 priv->comments = NULL;
646 priv->website_url = NULL;
647 priv->website_text = NULL;
648 priv->translator_credits = NULL;
649 priv->license = NULL;
650 priv->authors = NULL;
651 priv->documenters = NULL;
652 priv->artists = NULL;
654 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
655 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
656 priv->hovering_over_link = FALSE;
657 priv->wrap_license = FALSE;
659 priv->license_type = GTK_LICENSE_UNKNOWN;
661 content_area = gtk_dialog_get_content_area (dialog);
662 action_area = gtk_dialog_get_action_area (dialog);
664 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
665 gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
666 gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
669 gtk_widget_push_composite_child ();
671 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
672 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
673 gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
675 priv->logo_image = gtk_image_new ();
676 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
678 priv->name_label = gtk_label_new (NULL);
679 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
680 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
681 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
683 priv->notebook = gtk_notebook_new ();
684 gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
685 gtk_widget_set_size_request (priv->notebook, 400, 100);
687 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
688 gtk_widget_show (page_vbox);
689 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
690 gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
691 gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
693 priv->version_label = gtk_label_new (NULL);
694 gtk_label_set_selectable (GTK_LABEL (priv->version_label), TRUE);
695 gtk_label_set_justify (GTK_LABEL (priv->version_label), GTK_JUSTIFY_CENTER);
696 gtk_box_pack_start (GTK_BOX (page_vbox), priv->version_label, FALSE, FALSE, 0);
698 priv->comments_label = gtk_label_new (NULL);
699 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
700 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
701 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
702 gtk_box_pack_start (GTK_BOX (page_vbox), priv->comments_label, FALSE, FALSE, 0);
704 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
705 gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
706 gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, FALSE, 0);
708 priv->website_label = button = gtk_label_new ("");
709 gtk_widget_set_no_show_all (button, TRUE);
710 gtk_label_set_selectable (GTK_LABEL (button), TRUE);
711 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
712 g_signal_connect_swapped (button, "activate-link",
713 G_CALLBACK (emit_activate_link), about);
715 priv->license_label = gtk_label_new (NULL);
716 gtk_label_set_use_markup (GTK_LABEL (priv->license_label), TRUE);
717 gtk_label_set_selectable (GTK_LABEL (priv->license_label), TRUE);
718 gtk_label_set_justify (GTK_LABEL (priv->license_label), GTK_JUSTIFY_CENTER);
719 gtk_box_pack_end (GTK_BOX (page_vbox), priv->license_label, FALSE, FALSE, 0);
720 gtk_label_set_line_wrap (GTK_LABEL (priv->license_label), TRUE);
722 priv->copyright_label = gtk_label_new (NULL);
723 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
724 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
725 gtk_box_pack_end (GTK_BOX (page_vbox), priv->copyright_label, FALSE, FALSE, 0);
727 gtk_widget_show (vbox);
728 gtk_widget_show (priv->notebook);
729 gtk_widget_show (priv->logo_image);
730 gtk_widget_show (priv->name_label);
731 gtk_widget_show (hbox);
733 /* Add the close button */
734 close_button = gtk_dialog_add_button (GTK_DIALOG (about),
735 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
736 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
738 /* Add the credits button */
739 button = gtk_toggle_button_new_with_mnemonic (_("C_redits"));
740 gtk_widget_set_can_default (button, TRUE);
741 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
742 gtk_button_set_image (GTK_BUTTON (button), image);
743 gtk_widget_set_no_show_all (button, TRUE);
744 gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
745 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
746 g_signal_connect (button, "clicked",
747 G_CALLBACK (credits_button_clicked), about);
748 priv->credits_button = button;
749 priv->credits_page = 0;
751 /* Add the license button */
752 button = gtk_toggle_button_new_with_mnemonic (_("_License"));
753 gtk_widget_set_can_default (button, TRUE);
754 gtk_widget_set_no_show_all (button, TRUE);
755 gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
756 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
757 g_signal_connect (button, "clicked",
758 G_CALLBACK (license_button_clicked), about);
759 priv->license_button = button;
760 priv->license_page = 0;
762 switch_page (about, 0);
764 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
766 gtk_widget_pop_composite_child ();
768 gtk_widget_grab_default (close_button);
769 gtk_widget_grab_focus (close_button);
772 gtk_about_dialog_set_program_name (about, NULL);
773 gtk_about_dialog_set_logo (about, NULL);
777 gtk_about_dialog_finalize (GObject *object)
779 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
780 GtkAboutDialogPrivate *priv = about->priv;
783 g_free (priv->version);
784 g_free (priv->copyright);
785 g_free (priv->comments);
786 g_free (priv->license);
787 g_free (priv->website_url);
788 g_free (priv->website_text);
789 g_free (priv->translator_credits);
791 g_strfreev (priv->authors);
792 g_strfreev (priv->documenters);
793 g_strfreev (priv->artists);
795 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
796 g_slist_free (priv->visited_links);
798 g_object_unref (priv->hand_cursor);
799 g_object_unref (priv->regular_cursor);
801 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
805 gtk_about_dialog_set_property (GObject *object,
810 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
811 GtkAboutDialogPrivate *priv = about->priv;
816 gtk_about_dialog_set_program_name (about, g_value_get_string (value));
819 gtk_about_dialog_set_version (about, g_value_get_string (value));
822 gtk_about_dialog_set_comments (about, g_value_get_string (value));
825 gtk_about_dialog_set_website (about, g_value_get_string (value));
827 case PROP_WEBSITE_LABEL:
828 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
831 gtk_about_dialog_set_license (about, g_value_get_string (value));
833 case PROP_LICENSE_TYPE:
834 gtk_about_dialog_set_license_type (about, g_value_get_enum (value));
837 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
840 gtk_about_dialog_set_logo (about, g_value_get_object (value));
843 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
845 case PROP_DOCUMENTERS:
846 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
849 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
851 case PROP_TRANSLATOR_CREDITS:
852 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
854 case PROP_LOGO_ICON_NAME:
855 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
857 case PROP_WRAP_LICENSE:
858 priv->wrap_license = g_value_get_boolean (value);
861 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
867 gtk_about_dialog_get_property (GObject *object,
872 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
873 GtkAboutDialogPrivate *priv = about->priv;
878 g_value_set_string (value, priv->name);
881 g_value_set_string (value, priv->version);
884 g_value_set_string (value, priv->copyright);
887 g_value_set_string (value, priv->comments);
890 g_value_set_string (value, priv->website_url);
892 case PROP_WEBSITE_LABEL:
893 g_value_set_string (value, priv->website_text);
896 g_value_set_string (value, priv->license);
898 case PROP_LICENSE_TYPE:
899 g_value_set_enum (value, priv->license_type);
901 case PROP_TRANSLATOR_CREDITS:
902 g_value_set_string (value, priv->translator_credits);
905 g_value_set_boxed (value, priv->authors);
907 case PROP_DOCUMENTERS:
908 g_value_set_boxed (value, priv->documenters);
911 g_value_set_boxed (value, priv->artists);
914 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
915 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
917 g_value_set_object (value, NULL);
919 case PROP_LOGO_ICON_NAME:
920 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
922 const gchar *icon_name;
924 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
925 g_value_set_string (value, icon_name);
928 g_value_set_string (value, NULL);
930 case PROP_WRAP_LICENSE:
931 g_value_set_boolean (value, priv->wrap_license);
934 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
940 gtk_about_dialog_activate_link (GtkAboutDialog *about,
944 GError *error = NULL;
946 screen = gtk_widget_get_screen (GTK_WIDGET (about));
948 if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error))
952 dialog = gtk_message_dialog_new (GTK_WINDOW (about),
953 GTK_DIALOG_DESTROY_WITH_PARENT |
957 "%s", _("Could not show link"));
958 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
959 "%s", error->message);
960 g_error_free (error);
962 g_signal_connect (dialog, "response",
963 G_CALLBACK (gtk_widget_destroy), NULL);
965 gtk_window_present (GTK_WINDOW (dialog));
972 update_website (GtkAboutDialog *about)
974 GtkAboutDialogPrivate *priv = about->priv;
976 gtk_widget_show (priv->website_label);
978 if (priv->website_url)
982 if (priv->website_text)
986 escaped = g_markup_escape_text (priv->website_text, -1);
987 markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
988 priv->website_url, escaped);
993 markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
994 priv->website_url, _("Homepage"));
997 gtk_label_set_markup (GTK_LABEL (priv->website_label), markup);
1002 if (priv->website_text)
1003 gtk_label_set_text (GTK_LABEL (priv->website_label), priv->website_text);
1005 gtk_widget_hide (priv->website_label);
1010 gtk_about_dialog_show (GtkWidget *widget)
1012 update_website (GTK_ABOUT_DIALOG (widget));
1014 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->show (widget);
1018 * gtk_about_dialog_get_program_name:
1019 * @about: a #GtkAboutDialog
1021 * Returns the program name displayed in the about dialog.
1023 * Return value: The program name. The string is owned by the about
1024 * dialog and must not be modified.
1028 G_CONST_RETURN gchar *
1029 gtk_about_dialog_get_program_name (GtkAboutDialog *about)
1031 GtkAboutDialogPrivate *priv;
1033 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1041 update_name_version (GtkAboutDialog *about)
1043 GtkAboutDialogPrivate *priv;
1044 gchar *title_string, *name_string;
1048 title_string = g_strdup_printf (_("About %s"), priv->name);
1049 gtk_window_set_title (GTK_WINDOW (about), title_string);
1050 g_free (title_string);
1052 if (priv->version != NULL)
1054 gtk_label_set_markup (GTK_LABEL (priv->version_label), priv->version);
1055 gtk_widget_show (priv->version_label);
1058 gtk_widget_hide (priv->version_label);
1060 name_string = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
1062 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
1063 g_free (name_string);
1067 * gtk_about_dialog_set_program_name:
1068 * @about: a #GtkAboutDialog
1069 * @name: the program name
1071 * Sets the name to display in the about dialog.
1072 * If this is not set, it defaults to g_get_application_name().
1077 gtk_about_dialog_set_program_name (GtkAboutDialog *about,
1080 GtkAboutDialogPrivate *priv;
1083 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1088 priv->name = g_strdup (name ? name : g_get_application_name ());
1091 update_name_version (about);
1093 g_object_notify (G_OBJECT (about), "program-name");
1098 * gtk_about_dialog_get_version:
1099 * @about: a #GtkAboutDialog
1101 * Returns the version string.
1103 * Return value: The version string. The string is owned by the about
1104 * dialog and must not be modified.
1108 G_CONST_RETURN gchar *
1109 gtk_about_dialog_get_version (GtkAboutDialog *about)
1111 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1113 return about->priv->version;
1117 * gtk_about_dialog_set_version:
1118 * @about: a #GtkAboutDialog
1119 * @version: (allow-none): the version string
1121 * Sets the version string to display in the about dialog.
1126 gtk_about_dialog_set_version (GtkAboutDialog *about,
1127 const gchar *version)
1129 GtkAboutDialogPrivate *priv;
1132 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1136 tmp = priv->version;
1137 priv->version = g_strdup (version);
1140 update_name_version (about);
1142 g_object_notify (G_OBJECT (about), "version");
1146 * gtk_about_dialog_get_copyright:
1147 * @about: a #GtkAboutDialog
1149 * Returns the copyright string.
1151 * Return value: The copyright string. The string is owned by the about
1152 * dialog and must not be modified.
1156 G_CONST_RETURN gchar *
1157 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
1159 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1161 return about->priv->copyright;
1165 * gtk_about_dialog_set_copyright:
1166 * @about: a #GtkAboutDialog
1167 * @copyright: (allow-none) the copyright string
1169 * Sets the copyright string to display in the about dialog.
1170 * This should be a short string of one or two lines.
1175 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
1176 const gchar *copyright)
1178 GtkAboutDialogPrivate *priv;
1179 gchar *copyright_string, *tmp;
1181 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1185 tmp = priv->copyright;
1186 priv->copyright = g_strdup (copyright);
1189 if (priv->copyright != NULL)
1191 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
1193 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
1194 g_free (copyright_string);
1196 gtk_widget_show (priv->copyright_label);
1199 gtk_widget_hide (priv->copyright_label);
1201 g_object_notify (G_OBJECT (about), "copyright");
1205 * gtk_about_dialog_get_comments:
1206 * @about: a #GtkAboutDialog
1208 * Returns the comments string.
1210 * Return value: The comments. The string is owned by the about
1211 * dialog and must not be modified.
1215 G_CONST_RETURN gchar *
1216 gtk_about_dialog_get_comments (GtkAboutDialog *about)
1218 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1220 return about->priv->comments;
1224 * gtk_about_dialog_set_comments:
1225 * @about: a #GtkAboutDialog
1226 * @comments: (allow-none): a comments string
1228 * Sets the comments string to display in the about dialog.
1229 * This should be a short string of one or two lines.
1234 gtk_about_dialog_set_comments (GtkAboutDialog *about,
1235 const gchar *comments)
1237 GtkAboutDialogPrivate *priv;
1240 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1244 tmp = priv->comments;
1247 priv->comments = g_strdup (comments);
1248 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
1249 gtk_widget_show (priv->comments_label);
1253 priv->comments = NULL;
1254 gtk_widget_hide (priv->comments_label);
1258 g_object_notify (G_OBJECT (about), "comments");
1262 * gtk_about_dialog_get_license:
1263 * @about: a #GtkAboutDialog
1265 * Returns the license information.
1267 * Return value: The license information. The string is owned by the about
1268 * dialog and must not be modified.
1272 G_CONST_RETURN gchar *
1273 gtk_about_dialog_get_license (GtkAboutDialog *about)
1275 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1277 return about->priv->license;
1281 * gtk_about_dialog_set_license:
1282 * @about: a #GtkAboutDialog
1283 * @license: (allow-none): the license information or %NULL
1285 * Sets the license information to be displayed in the secondary
1286 * license dialog. If @license is %NULL, the license button is
1292 gtk_about_dialog_set_license (GtkAboutDialog *about,
1293 const gchar *license)
1295 GtkAboutDialogPrivate *priv;
1298 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1302 tmp = priv->license;
1305 priv->license = g_strdup (license);
1306 priv->license_type = GTK_LICENSE_CUSTOM;
1310 priv->license = NULL;
1311 priv->license_type = GTK_LICENSE_UNKNOWN;
1315 gtk_widget_hide (priv->license_label);
1317 update_license_button_visibility (about);
1319 g_object_notify (G_OBJECT (about), "license");
1320 g_object_notify (G_OBJECT (about), "license-type");
1324 * gtk_about_dialog_get_wrap_license:
1325 * @about: a #GtkAboutDialog
1327 * Returns whether the license text in @about is
1328 * automatically wrapped.
1330 * Returns: %TRUE if the license text is wrapped
1335 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1337 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1339 return about->priv->wrap_license;
1343 * gtk_about_dialog_set_wrap_license:
1344 * @about: a #GtkAboutDialog
1345 * @wrap_license: whether to wrap the license
1347 * Sets whether the license text in @about is
1348 * automatically wrapped.
1353 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1354 gboolean wrap_license)
1356 GtkAboutDialogPrivate *priv;
1358 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1362 wrap_license = wrap_license != FALSE;
1364 if (priv->wrap_license != wrap_license)
1366 priv->wrap_license = wrap_license;
1368 g_object_notify (G_OBJECT (about), "wrap-license");
1373 * gtk_about_dialog_get_website:
1374 * @about: a #GtkAboutDialog
1376 * Returns the website URL.
1378 * Return value: The website URL. The string is owned by the about
1379 * dialog and must not be modified.
1383 G_CONST_RETURN gchar *
1384 gtk_about_dialog_get_website (GtkAboutDialog *about)
1386 GtkAboutDialogPrivate *priv;
1388 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1392 return priv->website_url;
1396 * gtk_about_dialog_set_website:
1397 * @about: a #GtkAboutDialog
1398 * @website: (allow-none): a URL string starting with "http://"
1400 * Sets the URL to use for the website link.
1405 gtk_about_dialog_set_website (GtkAboutDialog *about,
1406 const gchar *website)
1408 GtkAboutDialogPrivate *priv;
1411 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1415 tmp = priv->website_url;
1416 priv->website_url = g_strdup (website);
1419 update_website (about);
1421 g_object_notify (G_OBJECT (about), "website");
1425 * gtk_about_dialog_get_website_label:
1426 * @about: a #GtkAboutDialog
1428 * Returns the label used for the website link.
1430 * Return value: The label used for the website link. The string is
1431 * owned by the about dialog and must not be modified.
1435 G_CONST_RETURN gchar *
1436 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1438 GtkAboutDialogPrivate *priv;
1440 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1444 return priv->website_text;
1448 * gtk_about_dialog_set_website_label:
1449 * @about: a #GtkAboutDialog
1450 * @website_label: the label used for the website link
1452 * Sets the label to be used for the website link.
1457 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1458 const gchar *website_label)
1460 GtkAboutDialogPrivate *priv;
1463 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1467 tmp = priv->website_text;
1468 priv->website_text = g_strdup (website_label);
1471 update_website (about);
1473 g_object_notify (G_OBJECT (about), "website-label");
1477 * gtk_about_dialog_get_authors:
1478 * @about: a #GtkAboutDialog
1480 * Returns the string which are displayed in the authors tab
1481 * of the secondary credits dialog.
1483 * Return value: (array zero-terminated=1) (transfer none): A
1484 * %NULL-terminated string array containing the authors. The array is
1485 * owned by the about dialog and must not be modified.
1489 G_CONST_RETURN gchar * G_CONST_RETURN *
1490 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1492 GtkAboutDialogPrivate *priv;
1494 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1498 return (const gchar * const *) priv->authors;
1502 * gtk_about_dialog_set_authors:
1503 * @about: a #GtkAboutDialog
1504 * @authors: (array zero-terminated=1): a %NULL-terminated array of strings
1506 * Sets the strings which are displayed in the authors tab
1507 * of the secondary credits dialog.
1512 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1513 const gchar **authors)
1515 GtkAboutDialogPrivate *priv;
1518 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1522 tmp = priv->authors;
1523 priv->authors = g_strdupv ((gchar **)authors);
1526 update_credits_button_visibility (about);
1528 g_object_notify (G_OBJECT (about), "authors");
1532 * gtk_about_dialog_get_documenters:
1533 * @about: a #GtkAboutDialog
1535 * Returns the string which are displayed in the documenters
1536 * tab of the secondary credits dialog.
1538 * Return value: (array zero-terminated=1) (transfer none): A
1539 * %NULL-terminated string array containing the documenters. The
1540 * array is owned by the about dialog and must not be modified.
1544 G_CONST_RETURN gchar * G_CONST_RETURN *
1545 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1547 GtkAboutDialogPrivate *priv;
1549 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1553 return (const gchar * const *)priv->documenters;
1557 * gtk_about_dialog_set_documenters:
1558 * @about: a #GtkAboutDialog
1559 * @documenters: (array zero-terminated=1): a %NULL-terminated array of strings
1561 * Sets the strings which are displayed in the documenters tab
1562 * of the secondary credits dialog.
1567 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1568 const gchar **documenters)
1570 GtkAboutDialogPrivate *priv;
1573 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1577 tmp = priv->documenters;
1578 priv->documenters = g_strdupv ((gchar **)documenters);
1581 update_credits_button_visibility (about);
1583 g_object_notify (G_OBJECT (about), "documenters");
1587 * gtk_about_dialog_get_artists:
1588 * @about: a #GtkAboutDialog
1590 * Returns the string which are displayed in the artists tab
1591 * of the secondary credits dialog.
1593 * Return value: (array zero-terminated=1) (transfer none): A
1594 * %NULL-terminated string array containing the artists. The array is
1595 * owned by the about dialog and must not be modified.
1599 G_CONST_RETURN gchar * G_CONST_RETURN *
1600 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1602 GtkAboutDialogPrivate *priv;
1604 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1608 return (const gchar * const *)priv->artists;
1612 * gtk_about_dialog_set_artists:
1613 * @about: a #GtkAboutDialog
1614 * @artists: (array zero-terminated=1): a %NULL-terminated array of strings
1616 * Sets the strings which are displayed in the artists tab
1617 * of the secondary credits dialog.
1622 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1623 const gchar **artists)
1625 GtkAboutDialogPrivate *priv;
1628 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1632 tmp = priv->artists;
1633 priv->artists = g_strdupv ((gchar **)artists);
1636 update_credits_button_visibility (about);
1638 g_object_notify (G_OBJECT (about), "artists");
1642 * gtk_about_dialog_get_translator_credits:
1643 * @about: a #GtkAboutDialog
1645 * Returns the translator credits string which is displayed
1646 * in the translators tab of the secondary credits dialog.
1648 * Return value: The translator credits string. The string is
1649 * owned by the about dialog and must not be modified.
1653 G_CONST_RETURN gchar *
1654 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1656 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1658 return about->priv->translator_credits;
1662 * gtk_about_dialog_set_translator_credits:
1663 * @about: a #GtkAboutDialog
1664 * @translator_credits: (allow-none): the translator credits
1666 * Sets the translator credits string which is displayed in
1667 * the translators tab of the secondary credits dialog.
1669 * The intended use for this string is to display the translator
1670 * of the language which is currently used in the user interface.
1671 * Using gettext(), a simple way to achieve that is to mark the
1672 * string for translation:
1674 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1676 * It is a good idea to use the customary msgid "translator-credits" for this
1677 * purpose, since translators will already know the purpose of that msgid, and
1678 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1684 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1685 const gchar *translator_credits)
1687 GtkAboutDialogPrivate *priv;
1690 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1694 tmp = priv->translator_credits;
1695 priv->translator_credits = g_strdup (translator_credits);
1698 update_credits_button_visibility (about);
1700 g_object_notify (G_OBJECT (about), "translator-credits");
1704 * gtk_about_dialog_get_logo:
1705 * @about: a #GtkAboutDialog
1707 * Returns the pixbuf displayed as logo in the about dialog.
1709 * Return value: (transfer none): the pixbuf displayed as logo. The
1710 * pixbuf is owned by the about dialog. If you want to keep a
1711 * reference to it, you have to call g_object_ref() on it.
1716 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1718 GtkAboutDialogPrivate *priv;
1720 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1724 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1725 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1731 icon_set_new_from_pixbufs (GList *pixbufs)
1733 GtkIconSet *icon_set = gtk_icon_set_new ();
1735 for (; pixbufs; pixbufs = pixbufs->next)
1737 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1739 GtkIconSource *icon_source = gtk_icon_source_new ();
1740 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1741 gtk_icon_set_add_source (icon_set, icon_source);
1742 gtk_icon_source_free (icon_source);
1749 * gtk_about_dialog_set_logo:
1750 * @about: a #GtkAboutDialog
1751 * @logo: (allow-none): a #GdkPixbuf, or %NULL
1753 * Sets the pixbuf to be displayed as logo in the about dialog.
1754 * If it is %NULL, the default window icon set with
1755 * gtk_window_set_default_icon() will be used.
1760 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1763 GtkAboutDialogPrivate *priv;
1765 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1769 g_object_freeze_notify (G_OBJECT (about));
1771 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1772 g_object_notify (G_OBJECT (about), "logo-icon-name");
1775 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1778 GList *pixbufs = gtk_window_get_default_icon_list ();
1780 if (pixbufs != NULL)
1782 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1784 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1785 icon_set, GTK_ICON_SIZE_DIALOG);
1787 gtk_icon_set_unref (icon_set);
1788 g_list_free (pixbufs);
1792 g_object_notify (G_OBJECT (about), "logo");
1794 g_object_thaw_notify (G_OBJECT (about));
1798 * gtk_about_dialog_get_logo_icon_name:
1799 * @about: a #GtkAboutDialog
1801 * Returns the icon name displayed as logo in the about dialog.
1803 * Return value: the icon name displayed as logo. The string is
1804 * owned by the dialog. If you want to keep a reference
1805 * to it, you have to call g_strdup() on it.
1809 G_CONST_RETURN gchar *
1810 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1812 GtkAboutDialogPrivate *priv;
1813 const gchar *icon_name = NULL;
1815 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1819 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1820 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1826 * gtk_about_dialog_set_logo_icon_name:
1827 * @about: a #GtkAboutDialog
1828 * @icon_name: (allow-none): an icon name, or %NULL
1830 * Sets the pixbuf to be displayed as logo in the about dialog.
1831 * If it is %NULL, the default window icon set with
1832 * gtk_window_set_default_icon() will be used.
1837 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1838 const gchar *icon_name)
1840 GtkAboutDialogPrivate *priv;
1842 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1846 g_object_freeze_notify (G_OBJECT (about));
1848 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1849 g_object_notify (G_OBJECT (about), "logo");
1851 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1852 GTK_ICON_SIZE_DIALOG);
1853 g_object_notify (G_OBJECT (about), "logo-icon-name");
1855 g_object_thaw_notify (G_OBJECT (about));
1859 follow_if_link (GtkAboutDialog *about,
1860 GtkTextView *text_view,
1863 GSList *tags = NULL, *tagp = NULL;
1864 GtkAboutDialogPrivate *priv = about->priv;
1867 tags = gtk_text_iter_get_tags (iter);
1868 for (tagp = tags; tagp != NULL && !uri; tagp = tagp->next)
1870 GtkTextTag *tag = tagp->data;
1872 uri = g_object_get_data (G_OBJECT (tag), "uri");
1874 emit_activate_link (about, uri);
1876 if (uri && !g_slist_find_custom (priv->visited_links, uri, (GCompareFunc)strcmp))
1878 GdkColor *style_visited_link_color;
1881 gtk_widget_style_get (GTK_WIDGET (about),
1882 "visited-link-color", &style_visited_link_color,
1884 if (style_visited_link_color)
1886 color = *style_visited_link_color;
1887 gdk_color_free (style_visited_link_color);
1890 color = default_visited_link_color;
1892 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1894 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (uri));
1899 g_slist_free (tags);
1903 text_view_key_press_event (GtkWidget *text_view,
1905 GtkAboutDialog *about)
1908 GtkTextBuffer *buffer;
1910 switch (event->keyval)
1912 case GDK_KEY_Return:
1913 case GDK_KEY_ISO_Enter:
1914 case GDK_KEY_KP_Enter:
1915 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1916 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1917 gtk_text_buffer_get_insert (buffer));
1918 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1929 text_view_event_after (GtkWidget *text_view,
1931 GtkAboutDialog *about)
1933 GtkTextIter start, end, iter;
1934 GtkTextBuffer *buffer;
1935 GdkEventButton *button_event;
1938 if (event->type != GDK_BUTTON_RELEASE)
1941 button_event = (GdkEventButton *)event;
1943 if (button_event->button != 1)
1946 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1948 /* we shouldn't follow a link if the user has selected something */
1949 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1950 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1953 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1954 GTK_TEXT_WINDOW_WIDGET,
1955 button_event->x, button_event->y, &x, &y);
1957 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1959 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1965 set_cursor_if_appropriate (GtkAboutDialog *about,
1966 GtkTextView *text_view,
1971 GtkAboutDialogPrivate *priv = about->priv;
1972 GSList *tags = NULL, *tagp = NULL;
1974 gboolean hovering_over_link = FALSE;
1976 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1978 tags = gtk_text_iter_get_tags (&iter);
1979 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1981 GtkTextTag *tag = tagp->data;
1982 gchar *uri = g_object_get_data (G_OBJECT (tag), "uri");
1986 hovering_over_link = TRUE;
1991 if (hovering_over_link != priv->hovering_over_link)
1993 priv->hovering_over_link = hovering_over_link;
1995 if (hovering_over_link)
1996 gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->hand_cursor);
1998 gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->regular_cursor);
2002 g_slist_free (tags);
2006 text_view_motion_notify_event (GtkWidget *text_view,
2007 GdkEventMotion *event,
2008 GtkAboutDialog *about)
2012 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
2013 GTK_TEXT_WINDOW_WIDGET,
2014 event->x, event->y, &x, &y);
2016 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), event->device, x, y);
2018 gdk_event_request_motions (event);
2025 text_view_visibility_notify_event (GtkWidget *text_view,
2026 GdkEventVisibility *event,
2027 GtkAboutDialog *about)
2029 GdkDeviceManager *device_manager;
2030 GdkDisplay *display;
2032 gint wx, wy, bx, by;
2034 display = gdk_window_get_display (event->window);
2035 device_manager = gdk_display_get_device_manager (display);
2036 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
2038 for (d = devices; d; d = d->next)
2040 GdkDevice *dev = d->data;
2042 if (gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD)
2045 gdk_window_get_device_position (gtk_widget_get_window (text_view), dev,
2048 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
2049 GTK_TEXT_WINDOW_WIDGET,
2052 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), dev, bx, by);
2055 g_list_free (devices);
2061 text_view_new (GtkAboutDialog *about,
2063 GtkWrapMode wrap_mode)
2066 gchar *q0, *q1, *q2, *r1, *r2;
2068 GtkTextView *text_view;
2069 GtkTextBuffer *buffer;
2070 GdkColor *style_link_color;
2071 GdkColor *style_visited_link_color;
2073 GdkColor link_color;
2074 GdkColor visited_link_color;
2076 PangoFontDescription *font_desc;
2077 GtkAboutDialogPrivate *priv = about->priv;
2078 GtkStyleContext *context;
2079 GtkStateFlags state;
2081 gtk_widget_style_get (GTK_WIDGET (about),
2082 "link-color", &style_link_color,
2083 "visited-link-color", &style_visited_link_color,
2085 if (style_link_color)
2087 link_color = *style_link_color;
2088 gdk_color_free (style_link_color);
2091 link_color = default_link_color;
2093 if (style_visited_link_color)
2095 visited_link_color = *style_visited_link_color;
2096 gdk_color_free (style_visited_link_color);
2099 visited_link_color = default_visited_link_color;
2101 view = gtk_text_view_new ();
2102 text_view = GTK_TEXT_VIEW (view);
2103 buffer = gtk_text_view_get_buffer (text_view);
2104 gtk_text_view_set_cursor_visible (text_view, FALSE);
2105 gtk_text_view_set_editable (text_view, FALSE);
2106 gtk_text_view_set_wrap_mode (text_view, wrap_mode);
2108 context = gtk_widget_get_style_context (view);
2109 state = gtk_widget_get_state_flags (view);
2111 size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
2112 font_desc = pango_font_description_new ();
2113 pango_font_description_set_size (font_desc, size * PANGO_SCALE_SMALL);
2114 gtk_widget_modify_font (view, font_desc);
2115 pango_font_description_free (font_desc);
2117 gtk_text_view_set_left_margin (text_view, 8);
2118 gtk_text_view_set_right_margin (text_view, 8);
2120 g_signal_connect (view, "key-press-event",
2121 G_CALLBACK (text_view_key_press_event), about);
2122 g_signal_connect (view, "event-after",
2123 G_CALLBACK (text_view_event_after), about);
2124 g_signal_connect (view, "motion-notify-event",
2125 G_CALLBACK (text_view_motion_notify_event), about);
2126 g_signal_connect (view, "visibility-notify-event",
2127 G_CALLBACK (text_view_visibility_notify_event), about);
2129 if (strings == NULL)
2131 gtk_widget_hide (view);
2135 for (p = strings; *p; p++)
2140 q1 = strchr (q0, '<');
2141 q2 = q1 ? strchr (q1, '>') : NULL;
2142 r1 = strstr (q0, "http://");
2145 r2 = strpbrk (r1, " \n\t");
2147 r2 = strchr (r1, '\0');
2152 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2163 const gchar *link_type;
2168 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0 + 1);
2169 gtk_text_buffer_get_end_iter (buffer, &end);
2171 link_type = "email";
2175 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
2176 gtk_text_buffer_get_end_iter (buffer, &end);
2182 link = g_strndup (q1, q2 - q1);
2184 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
2185 color = visited_link_color;
2189 tag = gtk_text_buffer_create_tag (buffer, NULL,
2190 "foreground-gdk", &color,
2191 "underline", PANGO_UNDERLINE_SINGLE,
2193 if (strcmp (link_type, "email") == 0)
2197 escaped = g_uri_escape_string (link, NULL, FALSE);
2198 uri = g_strconcat ("mailto:", escaped, NULL);
2203 uri = g_strdup (link);
2205 g_object_set_data_full (G_OBJECT (tag), I_("uri"), uri, g_free);
2206 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
2212 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
2218 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
2221 gtk_widget_show (view);
2226 add_credits_section (GtkAboutDialog *about,
2235 gchar *q0, *q1, *q2, *r1, *r2;
2240 markup = g_strdup_printf ("<span size=\"small\">%s</span>", title);
2241 label = gtk_label_new (markup);
2242 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
2244 gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
2245 gtk_grid_attach (grid, label, 0, *row, 1, 1);
2247 for (p = people; *p; p++)
2251 str = g_string_new ("<span size=\"small\">");
2256 q1 = strchr (q0, '<');
2257 q2 = q1 ? strchr (q1, '>') : NULL;
2258 r1 = strstr (q0, "http://");
2261 r2 = strpbrk (r1, " \n\t");
2263 r2 = strchr (r1, '\0');
2268 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2273 else if (q1 && (q1[1] == 'a' || q1[1] == 'A') && q1[2] == ' ')
2275 /* if it is a <a> link leave it for the label to parse */
2290 text = g_strstrip (g_strndup (q0, q1 - q0));
2291 name = g_markup_escape_text (text, -1);
2293 link = g_strndup (q1, q2 - q1);
2295 escaped = g_uri_escape_string (link, NULL, FALSE);
2296 g_string_append_printf (str,
2297 "<a href=\"mailto:%s\">%s</a>",
2299 name[0] ? name : link);
2308 text = g_strstrip (g_strndup (q0, q1 - q0));
2309 name = g_markup_escape_text (text, -1);
2310 link = g_strndup (q1, q2 - q1);
2311 g_string_append_printf (str,
2312 "<a href=\"%s\">%s</a>",
2314 name[0] ? name : link);
2324 g_string_append (str, q0);
2328 g_string_append (str, "</span>");
2330 label = gtk_label_new (str->str);
2331 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
2332 g_string_free (str, TRUE);
2333 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2334 gtk_grid_attach (grid, label, 1, *row, 1, 1);
2338 /* skip one at the end */
2343 create_credits_page (GtkAboutDialog *about)
2345 GtkAboutDialogPrivate *priv = about->priv;
2346 GtkWidget *page_vbox;
2349 GtkWidget *alignment;
2352 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
2353 gtk_widget_show (page_vbox);
2354 priv->credits_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
2356 sw = gtk_scrolled_window_new (NULL, NULL);
2357 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
2358 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2360 GTK_POLICY_AUTOMATIC);
2361 gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
2363 alignment = gtk_alignment_new (0.5, 0, 0, 0);
2364 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), alignment);
2366 grid = gtk_grid_new ();
2367 gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
2368 gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
2369 gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
2370 gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
2371 gtk_container_add (GTK_CONTAINER (alignment), grid);
2373 if (priv->authors != NULL)
2374 add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
2376 if (priv->documenters != NULL)
2377 add_credits_section (about, GTK_GRID (grid), &row, _("Documented by"), priv->documenters);
2379 /* Don't show an untranslated gettext msgid */
2380 if (priv->translator_credits != NULL &&
2381 strcmp (priv->translator_credits, "translator_credits") != 0 &&
2382 strcmp (priv->translator_credits, "translator-credits") != 0)
2384 gchar **translators;
2386 translators = g_strsplit (priv->translator_credits, "\n", 0);
2387 add_credits_section (about, GTK_GRID (grid), &row, _("Translated by"), translators);
2388 g_strfreev (translators);
2391 if (priv->artists != NULL)
2392 add_credits_section (about, GTK_GRID (grid), &row, _("Artwork by"), priv->artists);
2394 gtk_widget_show_all (sw);
2398 display_credits_page (GtkWidget *button,
2401 GtkAboutDialog *about = (GtkAboutDialog *)data;
2402 GtkAboutDialogPrivate *priv = about->priv;
2404 if (priv->credits_page == 0)
2405 create_credits_page (about);
2407 switch_page (about, priv->credits_page);
2411 create_license_page (GtkAboutDialog *about)
2413 GtkAboutDialogPrivate *priv = about->priv;
2414 GtkWidget *page_vbox;
2419 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
2420 priv->license_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
2422 sw = gtk_scrolled_window_new (NULL, NULL);
2423 gtk_container_set_border_width (GTK_CONTAINER (sw), 5);
2424 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
2425 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2426 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2427 gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
2429 strings[0] = priv->license;
2431 view = text_view_new (about, strings,
2432 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2434 gtk_container_add (GTK_CONTAINER (sw), view);
2436 gtk_widget_show_all (page_vbox);
2440 display_license_page (GtkWidget *button,
2443 GtkAboutDialog *about = (GtkAboutDialog *)data;
2444 GtkAboutDialogPrivate *priv = about->priv;
2446 if (priv->license_page == 0)
2447 create_license_page (about);
2449 switch_page (about, priv->license_page);
2453 * gtk_about_dialog_new:
2455 * Creates a new #GtkAboutDialog.
2457 * Returns: a newly created #GtkAboutDialog
2462 gtk_about_dialog_new (void)
2464 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2466 return GTK_WIDGET (dialog);
2470 close_cb (GtkAboutDialog *about)
2472 GtkAboutDialogPrivate *priv = about->priv;
2474 switch_page (about, 0);
2475 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->credits_button), FALSE);
2476 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->license_button), FALSE);
2477 gtk_widget_hide (GTK_WIDGET (about));
2481 * gtk_show_about_dialog:
2482 * @parent: (allow-none): transient parent, or %NULL for none
2483 * @first_property_name: the name of the first property
2484 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2486 * This is a convenience function for showing an application's about box.
2487 * The constructed dialog is associated with the parent window and
2488 * reused for future invocations of this function.
2493 gtk_show_about_dialog (GtkWindow *parent,
2494 const gchar *first_property_name,
2497 static GtkWidget *global_about_dialog = NULL;
2498 GtkWidget *dialog = NULL;
2502 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2504 dialog = global_about_dialog;
2508 dialog = gtk_about_dialog_new ();
2510 g_object_ref_sink (dialog);
2512 g_signal_connect (dialog, "delete-event",
2513 G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2515 /* Close dialog on user response */
2516 g_signal_connect (dialog, "response",
2517 G_CALLBACK (close_cb), NULL);
2519 va_start (var_args, first_property_name);
2520 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2525 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
2526 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2527 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2528 g_object_set_data_full (G_OBJECT (parent),
2529 I_("gtk-about-dialog"),
2530 dialog, g_object_unref);
2533 global_about_dialog = dialog;
2537 gtk_window_present (GTK_WINDOW (dialog));
2541 * gtk_about_dialog_set_license_type:
2542 * @about: a #GtkAboutDialog
2543 * @license_type: the type of license
2545 * Sets the license of the application showing the @about dialog from a
2546 * list of known licenses.
2548 * This function overrides the license set using
2549 * gtk_about_dialog_set_license().
2554 gtk_about_dialog_set_license_type (GtkAboutDialog *about,
2555 GtkLicense license_type)
2557 GtkAboutDialogPrivate *priv;
2559 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
2560 g_return_if_fail (license_type >= GTK_LICENSE_UNKNOWN &&
2561 license_type <= GTK_LICENSE_ARTISTIC);
2565 if (priv->license_type != license_type)
2567 g_object_freeze_notify (G_OBJECT (about));
2569 priv->license_type = license_type;
2571 /* custom licenses use the contents of the :license property */
2572 if (priv->license_type != GTK_LICENSE_CUSTOM)
2575 gchar *license_string;
2578 url = gtk_license_urls[priv->license_type];
2580 url = priv->website_url;
2582 str = g_string_sized_new (256);
2583 g_string_append_printf (str, _(gtk_license_preamble), url, url);
2585 g_free (priv->license);
2586 priv->license = g_string_free (str, FALSE);
2587 priv->wrap_license = TRUE;
2589 license_string = g_strdup_printf ("<span size=\"small\">%s</span>",
2591 gtk_label_set_markup (GTK_LABEL (priv->license_label), license_string);
2592 g_free (license_string);
2593 gtk_widget_show (priv->license_label);
2595 update_license_button_visibility (about);
2597 g_object_notify (G_OBJECT (about), "wrap-license");
2598 g_object_notify (G_OBJECT (about), "license");
2602 gtk_widget_show (priv->license_label);
2605 g_object_notify (G_OBJECT (about), "license-type");
2607 g_object_thaw_notify (G_OBJECT (about));
2612 * gtk_about_dialog_get_license_type:
2613 * @about: a #GtkAboutDialog
2615 * Retrieves the license set using gtk_about_dialog_set_license_type()
2617 * Return value: a #GtkLicense value
2622 gtk_about_dialog_get_license_type (GtkAboutDialog *about)
2624 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), GTK_LICENSE_UNKNOWN);
2626 return about->priv->license_type;