1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2001 CodeFactory AB
3 * Copyright (C) 2001, 2002 Anders Carlsson
4 * Copyright (C) 2003, 2004 Matthias Clasen <mclasen@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * Author: Anders Carlsson <andersca@gnome.org>
25 * Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
35 #include <gdk/gdkkeysyms.h>
37 #include "gtkaboutdialog.h"
38 #include "gtkalignment.h"
39 #include "gtkbutton.h"
41 #include "gtkdialog.h"
46 #include "gtklinkbutton.h"
47 #include "gtkmarshalers.h"
48 #include "gtknotebook.h"
49 #include "gtkorientable.h"
50 #include "gtkscrolledwindow.h"
52 #include "gtktextview.h"
54 #include "gtkiconfactory.h"
57 #include "gtkmessagedialog.h"
58 #include "gtktogglebutton.h"
59 #include "gtkprivate.h"
64 * SECTION:gtkaboutdialog
65 * @Short_description: Display information about an application
66 * @Title: GtkAboutDialog
67 * @See_also: #GTK_STOCK_ABOUT
69 * The GtkAboutDialog offers a simple way to display information about
70 * a program like its logo, name, copyright, website and license. It is
71 * also possible to give credits to the authors, documenters, translators
72 * and artists who have worked on the program. An about dialog is typically
73 * opened when the user selects the <literal>About</literal> option from
74 * the <literal>Help</literal> menu. All parts of the dialog are optional.
76 * About dialog often contain links and email addresses. GtkAboutDialog
77 * displays these as clickable links. By default, it calls gtk_show_uri()
78 * when a user clicks one. The behaviour can be overridden with the
79 * #GtkAboutDialog::activate-link signal.
81 * To make constructing a GtkAboutDialog as convenient as possible, you can
82 * use the function gtk_show_about_dialog() which constructs and shows a dialog
83 * and keeps it around so that it can be shown again.
85 * Note that GTK+ sets a default title of <literal>_("About %s")</literal>
86 * on the dialog window (where %s is replaced by the name of the
87 * application, but in order to ensure proper translation of the title,
88 * applications should set the title property explicitly when constructing
89 * a GtkAboutDialog, as shown in the following example:
90 * <informalexample><programlisting>
91 * gtk_show_about_dialog (NULL,
92 * "program-name", "ExampleCode",
93 * "logo", example_logo,
94 * "title" _("About ExampleCode"),
96 * </programlisting></informalexample>
99 static GdkColor default_link_color = { 0, 0, 0, 0xeeee };
100 static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
102 /* Translators: this is the license preamble; the string at the end
103 * contains the URL of the license.
105 static const gchar *gtk_license_preamble = N_("This program comes with ABSOLUTELY NO WARRANTY; for details, visit <a href=\"%s\">%s</a>");
107 /* URLs for each GtkLicense type; keep in the same order as the enumeration */
108 static const gchar *gtk_license_urls[] = {
112 "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
113 "http://www.gnu.org/licenses/gpl.html",
115 "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html",
116 "http://www.gnu.org/licenses/lgpl.html",
118 "http://opensource.org/licenses/bsd-license.php",
119 "http://opensource.org/licenses/mit-license.php",
121 "http://opensource.org/licenses/artistic-license-2.0.php"
124 struct _GtkAboutDialogPrivate
132 gchar *translator_credits;
143 GtkWidget *logo_image;
144 GtkWidget *name_label;
145 GtkWidget *version_label;
146 GtkWidget *comments_label;
147 GtkWidget *copyright_label;
148 GtkWidget *license_label;
149 GtkWidget *website_label;
151 GtkWidget *credits_button;
152 GtkWidget *license_button;
154 GdkCursor *hand_cursor;
155 GdkCursor *regular_cursor;
157 GSList *visited_links;
159 GtkLicense license_type;
161 guint hovering_over_link : 1;
162 guint wrap_license : 1;
165 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
180 PROP_TRANSLATOR_CREDITS,
188 static void gtk_about_dialog_finalize (GObject *object);
189 static void gtk_about_dialog_get_property (GObject *object,
193 static void gtk_about_dialog_set_property (GObject *object,
197 static void gtk_about_dialog_show (GtkWidget *widge);
198 static void update_name_version (GtkAboutDialog *about);
199 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
200 static void follow_if_link (GtkAboutDialog *about,
201 GtkTextView *text_view,
203 static void set_cursor_if_appropriate (GtkAboutDialog *about,
204 GtkTextView *text_view,
208 static void display_credits_page (GtkWidget *button,
210 static void display_license_page (GtkWidget *button,
212 static void close_cb (GtkAboutDialog *about);
213 static gboolean gtk_about_dialog_activate_link (GtkAboutDialog *about,
221 static guint signals[LAST_SIGNAL] = { 0 };
223 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
227 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
229 GObjectClass *object_class;
230 GtkWidgetClass *widget_class;
232 object_class = (GObjectClass *)klass;
233 widget_class = (GtkWidgetClass *)klass;
235 object_class->set_property = gtk_about_dialog_set_property;
236 object_class->get_property = gtk_about_dialog_get_property;
238 object_class->finalize = gtk_about_dialog_finalize;
240 widget_class->show = gtk_about_dialog_show;
242 klass->activate_link = gtk_about_dialog_activate_link;
245 * GtkAboutDialog::activate-link:
246 * @label: The object on which the signal was emitted
247 * @uri: the URI that is activated
249 * The signal which gets emitted to activate a URI.
250 * Applications may connect to it to override the default behaviour,
251 * which is to call gtk_show_uri().
253 * Returns: %TRUE if the link has been activated
257 signals[ACTIVATE_LINK] =
258 g_signal_new ("activate-link",
259 G_TYPE_FROM_CLASS (object_class),
261 G_STRUCT_OFFSET (GtkAboutDialogClass, activate_link),
262 _gtk_boolean_handled_accumulator, NULL,
263 _gtk_marshal_BOOLEAN__STRING,
264 G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
267 * GtkAboutDialog:program-name:
269 * The name of the program.
270 * If this is not set, it defaults to g_get_application_name().
274 g_object_class_install_property (object_class,
276 g_param_spec_string ("program-name",
278 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
280 GTK_PARAM_READWRITE));
283 * GtkAboutDialog:version:
285 * The version of the program.
289 g_object_class_install_property (object_class,
291 g_param_spec_string ("version",
292 P_("Program version"),
293 P_("The version of the program"),
295 GTK_PARAM_READWRITE));
298 * GtkAboutDialog:copyright:
300 * Copyright information for the program.
304 g_object_class_install_property (object_class,
306 g_param_spec_string ("copyright",
307 P_("Copyright string"),
308 P_("Copyright information for the program"),
310 GTK_PARAM_READWRITE));
314 * GtkAboutDialog:comments:
316 * Comments about the program. This string is displayed in a label
317 * in the main dialog, thus it should be a short explanation of
318 * the main purpose of the program, not a detailed list of features.
322 g_object_class_install_property (object_class,
324 g_param_spec_string ("comments",
325 P_("Comments string"),
326 P_("Comments about the program"),
328 GTK_PARAM_READWRITE));
331 * GtkAboutDialog:license:
333 * The license of the program. This string is displayed in a
334 * text view in a secondary dialog, therefore it is fine to use
335 * a long multi-paragraph text. Note that the text is only wrapped
336 * in the text view if the "wrap-license" property is set to %TRUE;
337 * otherwise the text itself must contain the intended linebreaks.
338 * When setting this property to a non-%NULL value, the
339 * #GtkAboutDialog:license-type property is set to %GTK_LICENSE_CUSTOM
344 g_object_class_install_property (object_class,
346 g_param_spec_string ("license",
348 _("The license of the program"),
350 GTK_PARAM_READWRITE));
353 * GtkAboutDialog:license-type:
355 * The license of the program, as a value of the %GtkLicense enumeration.
357 * The #GtkAboutDialog will automatically fill out a standard disclaimer
358 * and link the user to the appropriate online resource for the license
361 * If %GTK_LICENSE_UNKNOWN is used, the link used will be the same
362 * specified in the #GtkAboutDialog:website property.
364 * If %GTK_LICENSE_CUSTOM is used, the current contents of the
365 * #GtkAboutDialog:license property are used.
367 * For any other #GtkLicense value, the contents of the
368 * #GtkAboutDialog:license property are also set by this property as
373 g_object_class_install_property (object_class,
375 g_param_spec_enum ("license-type",
377 P_("The license type of the program"),
380 GTK_PARAM_READWRITE));
383 * GtkAboutDialog:website:
385 * The URL for the link to the website of the program.
386 * This should be a string starting with "http://.
390 g_object_class_install_property (object_class,
392 g_param_spec_string ("website",
394 P_("The URL for the link to the website of the program"),
396 GTK_PARAM_READWRITE));
399 * GtkAboutDialog:website-label:
401 * The label for the link to the website of the program.
405 g_object_class_install_property (object_class,
407 g_param_spec_string ("website-label",
409 P_("The label for the link to the website of the program"),
411 GTK_PARAM_READWRITE));
414 * GtkAboutDialog:authors:
416 * The authors of the program, as a %NULL-terminated array of strings.
417 * Each string may contain email addresses and URLs, which will be displayed
418 * as links, see the introduction for more details.
422 g_object_class_install_property (object_class,
424 g_param_spec_boxed ("authors",
426 P_("List of authors of the program"),
428 GTK_PARAM_READWRITE));
431 * GtkAboutDialog:documenters:
433 * The people documenting the program, as a %NULL-terminated array of strings.
434 * Each string may contain email addresses and URLs, which will be displayed
435 * as links, see the introduction for more details.
439 g_object_class_install_property (object_class,
441 g_param_spec_boxed ("documenters",
443 P_("List of people documenting the program"),
445 GTK_PARAM_READWRITE));
448 * GtkAboutDialog:artists:
450 * The people who contributed artwork to the program, as a %NULL-terminated
451 * array of strings. Each string may contain email addresses and URLs, which
452 * will be displayed as links, see the introduction for more details.
456 g_object_class_install_property (object_class,
458 g_param_spec_boxed ("artists",
460 P_("List of people who have contributed artwork to the program"),
462 GTK_PARAM_READWRITE));
466 * GtkAboutDialog:translator-credits:
468 * Credits to the translators. This string should be marked as translatable.
469 * The string may contain email addresses and URLs, which will be displayed
470 * as links, see the introduction for more details.
474 g_object_class_install_property (object_class,
475 PROP_TRANSLATOR_CREDITS,
476 g_param_spec_string ("translator-credits",
477 P_("Translator credits"),
478 P_("Credits to the translators. This string should be marked as translatable"),
480 GTK_PARAM_READWRITE));
483 * GtkAboutDialog:logo:
485 * A logo for the about box. If this is not set, it defaults to
486 * gtk_window_get_default_icon_list().
490 g_object_class_install_property (object_class,
492 g_param_spec_object ("logo",
494 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
496 GTK_PARAM_READWRITE));
499 * GtkAboutDialog:logo-icon-name:
501 * A named icon to use as the logo for the about box. This property
502 * overrides the #GtkAboutDialog:logo property.
506 g_object_class_install_property (object_class,
508 g_param_spec_string ("logo-icon-name",
509 P_("Logo Icon Name"),
510 P_("A named icon to use as the logo for the about box."),
512 GTK_PARAM_READWRITE));
514 * GtkAboutDialog:wrap-license:
516 * Whether to wrap the text in the license dialog.
520 g_object_class_install_property (object_class,
522 g_param_spec_boolean ("wrap-license",
524 P_("Whether to wrap the license text."),
526 GTK_PARAM_READWRITE));
529 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
533 emit_activate_link (GtkAboutDialog *about,
536 gboolean handled = FALSE;
538 g_signal_emit (about, signals[ACTIVATE_LINK], 0, uri, &handled);
544 update_license_button_visibility (GtkAboutDialog *about)
546 GtkAboutDialogPrivate *priv = about->priv;
548 if (priv->license_type == GTK_LICENSE_CUSTOM && priv->license != NULL)
549 gtk_widget_show (priv->license_button);
551 gtk_widget_hide (priv->license_button);
555 update_credits_button_visibility (GtkAboutDialog *about)
557 GtkAboutDialogPrivate *priv = about->priv;
560 show = (priv->authors != NULL ||
561 priv->documenters != NULL ||
562 priv->artists != NULL ||
563 (priv->translator_credits != NULL &&
564 strcmp (priv->translator_credits, "translator_credits") &&
565 strcmp (priv->translator_credits, "translator-credits")));
567 gtk_widget_show (priv->credits_button);
569 gtk_widget_hide (priv->credits_button);
573 switch_page (GtkAboutDialog *about,
576 GtkAboutDialogPrivate *priv = about->priv;
578 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page);
582 display_main_page (GtkButton *button,
585 GtkAboutDialog *about = (GtkAboutDialog *)data;
587 switch_page (about, 0);
591 credits_button_clicked (GtkButton *button,
594 GtkAboutDialog *about = (GtkAboutDialog *)data;
595 GtkAboutDialogPrivate *priv = about->priv;
598 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
602 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->license_button), FALSE);
603 display_credits_page (NULL, data);
607 display_main_page (NULL, data);
612 license_button_clicked (GtkButton *button,
615 GtkAboutDialog *about = (GtkAboutDialog *)data;
616 GtkAboutDialogPrivate *priv = about->priv;
619 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
623 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->credits_button), FALSE);
624 display_license_page (NULL, data);
628 display_main_page (NULL, data);
632 gtk_about_dialog_init (GtkAboutDialog *about)
634 GtkDialog *dialog = GTK_DIALOG (about);
635 GtkAboutDialogPrivate *priv;
636 GtkWidget *vbox, *page_vbox, *hbox, *button, *close_button, *image;
637 GtkWidget *content_area, *action_area;
640 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
644 priv->version = NULL;
645 priv->copyright = NULL;
646 priv->comments = NULL;
647 priv->website_url = NULL;
648 priv->website_text = NULL;
649 priv->translator_credits = NULL;
650 priv->license = NULL;
651 priv->authors = NULL;
652 priv->documenters = NULL;
653 priv->artists = NULL;
655 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
656 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
657 priv->hovering_over_link = FALSE;
658 priv->wrap_license = FALSE;
660 priv->license_type = GTK_LICENSE_UNKNOWN;
662 content_area = gtk_dialog_get_content_area (dialog);
663 action_area = gtk_dialog_get_action_area (dialog);
665 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
666 gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
667 gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
670 gtk_widget_push_composite_child ();
672 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
673 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
674 gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
676 priv->logo_image = gtk_image_new ();
677 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
679 priv->name_label = gtk_label_new (NULL);
680 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
681 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
682 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
684 priv->notebook = gtk_notebook_new ();
685 gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
686 gtk_widget_set_size_request (priv->notebook, 400, 100);
688 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
689 gtk_widget_show (page_vbox);
690 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
691 gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
692 gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
694 priv->version_label = gtk_label_new (NULL);
695 gtk_label_set_selectable (GTK_LABEL (priv->version_label), TRUE);
696 gtk_label_set_justify (GTK_LABEL (priv->version_label), GTK_JUSTIFY_CENTER);
697 gtk_box_pack_start (GTK_BOX (page_vbox), priv->version_label, FALSE, FALSE, 0);
699 priv->comments_label = gtk_label_new (NULL);
700 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
701 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
702 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
703 gtk_box_pack_start (GTK_BOX (page_vbox), priv->comments_label, FALSE, FALSE, 0);
705 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
706 gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
707 gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, FALSE, 0);
709 priv->website_label = button = gtk_label_new ("");
710 gtk_widget_set_no_show_all (button, TRUE);
711 gtk_label_set_selectable (GTK_LABEL (button), TRUE);
712 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
713 g_signal_connect_swapped (button, "activate-link",
714 G_CALLBACK (emit_activate_link), about);
716 priv->license_label = gtk_label_new (NULL);
717 gtk_label_set_use_markup (GTK_LABEL (priv->license_label), TRUE);
718 gtk_label_set_selectable (GTK_LABEL (priv->license_label), TRUE);
719 gtk_label_set_justify (GTK_LABEL (priv->license_label), GTK_JUSTIFY_CENTER);
720 gtk_box_pack_end (GTK_BOX (page_vbox), priv->license_label, FALSE, FALSE, 0);
721 gtk_label_set_line_wrap (GTK_LABEL (priv->license_label), TRUE);
723 priv->copyright_label = gtk_label_new (NULL);
724 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
725 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
726 gtk_box_pack_end (GTK_BOX (page_vbox), priv->copyright_label, FALSE, FALSE, 0);
728 gtk_widget_show (vbox);
729 gtk_widget_show (priv->notebook);
730 gtk_widget_show (priv->logo_image);
731 gtk_widget_show (priv->name_label);
732 gtk_widget_show (hbox);
734 /* Add the close button */
735 close_button = gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE,
736 GTK_RESPONSE_CANCEL);
737 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
739 /* Add the credits button */
740 button = gtk_toggle_button_new_with_mnemonic (_("C_redits"));
741 gtk_widget_set_can_default (button, TRUE);
742 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
743 gtk_button_set_image (GTK_BUTTON (button), image);
744 gtk_widget_set_no_show_all (button, TRUE);
745 gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
746 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
747 g_signal_connect (button, "clicked",
748 G_CALLBACK (credits_button_clicked), about);
749 priv->credits_button = button;
750 priv->credits_page = 0;
752 /* Add the license button */
753 button = gtk_toggle_button_new_with_mnemonic (_("_License"));
754 gtk_widget_set_can_default (button, TRUE);
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 (license_button_clicked), about);
760 priv->license_button = button;
761 priv->license_page = 0;
763 switch_page (about, 0);
765 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
767 gtk_widget_pop_composite_child ();
769 gtk_widget_grab_default (close_button);
770 gtk_widget_grab_focus (close_button);
773 gtk_about_dialog_set_program_name (about, NULL);
774 gtk_about_dialog_set_logo (about, NULL);
778 gtk_about_dialog_finalize (GObject *object)
780 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
781 GtkAboutDialogPrivate *priv = about->priv;
784 g_free (priv->version);
785 g_free (priv->copyright);
786 g_free (priv->comments);
787 g_free (priv->license);
788 g_free (priv->website_url);
789 g_free (priv->website_text);
790 g_free (priv->translator_credits);
792 g_strfreev (priv->authors);
793 g_strfreev (priv->documenters);
794 g_strfreev (priv->artists);
796 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
797 g_slist_free (priv->visited_links);
799 g_object_unref (priv->hand_cursor);
800 g_object_unref (priv->regular_cursor);
802 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
806 gtk_about_dialog_set_property (GObject *object,
811 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
812 GtkAboutDialogPrivate *priv = about->priv;
817 gtk_about_dialog_set_program_name (about, g_value_get_string (value));
820 gtk_about_dialog_set_version (about, g_value_get_string (value));
823 gtk_about_dialog_set_comments (about, g_value_get_string (value));
826 gtk_about_dialog_set_website (about, g_value_get_string (value));
828 case PROP_WEBSITE_LABEL:
829 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
832 gtk_about_dialog_set_license (about, g_value_get_string (value));
834 case PROP_LICENSE_TYPE:
835 gtk_about_dialog_set_license_type (about, g_value_get_enum (value));
838 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
841 gtk_about_dialog_set_logo (about, g_value_get_object (value));
844 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
846 case PROP_DOCUMENTERS:
847 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
850 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
852 case PROP_TRANSLATOR_CREDITS:
853 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
855 case PROP_LOGO_ICON_NAME:
856 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
858 case PROP_WRAP_LICENSE:
859 priv->wrap_license = g_value_get_boolean (value);
862 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
868 gtk_about_dialog_get_property (GObject *object,
873 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
874 GtkAboutDialogPrivate *priv = about->priv;
879 g_value_set_string (value, priv->name);
882 g_value_set_string (value, priv->version);
885 g_value_set_string (value, priv->copyright);
888 g_value_set_string (value, priv->comments);
891 g_value_set_string (value, priv->website_url);
893 case PROP_WEBSITE_LABEL:
894 g_value_set_string (value, priv->website_text);
897 g_value_set_string (value, priv->license);
899 case PROP_LICENSE_TYPE:
900 g_value_set_enum (value, priv->license_type);
902 case PROP_TRANSLATOR_CREDITS:
903 g_value_set_string (value, priv->translator_credits);
906 g_value_set_boxed (value, priv->authors);
908 case PROP_DOCUMENTERS:
909 g_value_set_boxed (value, priv->documenters);
912 g_value_set_boxed (value, priv->artists);
915 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
916 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
918 g_value_set_object (value, NULL);
920 case PROP_LOGO_ICON_NAME:
921 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
923 const gchar *icon_name;
925 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
926 g_value_set_string (value, icon_name);
929 g_value_set_string (value, NULL);
931 case PROP_WRAP_LICENSE:
932 g_value_set_boolean (value, priv->wrap_license);
935 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
941 gtk_about_dialog_activate_link (GtkAboutDialog *about,
945 GError *error = NULL;
947 screen = gtk_widget_get_screen (GTK_WIDGET (about));
949 if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error))
953 dialog = gtk_message_dialog_new (GTK_WINDOW (about),
954 GTK_DIALOG_DESTROY_WITH_PARENT |
958 "%s", _("Could not show link"));
959 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
960 "%s", error->message);
961 g_error_free (error);
963 g_signal_connect (dialog, "response",
964 G_CALLBACK (gtk_widget_destroy), NULL);
966 gtk_window_present (GTK_WINDOW (dialog));
973 update_website (GtkAboutDialog *about)
975 GtkAboutDialogPrivate *priv = about->priv;
977 gtk_widget_show (priv->website_label);
979 if (priv->website_url)
983 if (priv->website_text)
987 escaped = g_markup_escape_text (priv->website_text, -1);
988 markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
989 priv->website_url, escaped);
994 markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
995 priv->website_url, _("Homepage"));
998 gtk_label_set_markup (GTK_LABEL (priv->website_label), markup);
1003 if (priv->website_text)
1004 gtk_label_set_text (GTK_LABEL (priv->website_label), priv->website_text);
1006 gtk_widget_hide (priv->website_label);
1011 gtk_about_dialog_show (GtkWidget *widget)
1013 update_website (GTK_ABOUT_DIALOG (widget));
1015 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->show (widget);
1019 * gtk_about_dialog_get_program_name:
1020 * @about: a #GtkAboutDialog
1022 * Returns the program name displayed in the about dialog.
1024 * Return value: The program name. The string is owned by the about
1025 * dialog and must not be modified.
1029 G_CONST_RETURN gchar *
1030 gtk_about_dialog_get_program_name (GtkAboutDialog *about)
1032 GtkAboutDialogPrivate *priv;
1034 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1042 update_name_version (GtkAboutDialog *about)
1044 GtkAboutDialogPrivate *priv;
1045 gchar *title_string, *name_string;
1049 title_string = g_strdup_printf (_("About %s"), priv->name);
1050 gtk_window_set_title (GTK_WINDOW (about), title_string);
1051 g_free (title_string);
1053 if (priv->version != NULL)
1055 gtk_label_set_markup (GTK_LABEL (priv->version_label), priv->version);
1056 gtk_widget_show (priv->version_label);
1059 gtk_widget_hide (priv->version_label);
1061 name_string = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
1063 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
1064 g_free (name_string);
1068 * gtk_about_dialog_set_program_name:
1069 * @about: a #GtkAboutDialog
1070 * @name: the program name
1072 * Sets the name to display in the about dialog.
1073 * If this is not set, it defaults to g_get_application_name().
1078 gtk_about_dialog_set_program_name (GtkAboutDialog *about,
1081 GtkAboutDialogPrivate *priv;
1084 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1089 priv->name = g_strdup (name ? name : g_get_application_name ());
1092 update_name_version (about);
1094 g_object_notify (G_OBJECT (about), "program-name");
1099 * gtk_about_dialog_get_version:
1100 * @about: a #GtkAboutDialog
1102 * Returns the version string.
1104 * Return value: The version string. The string is owned by the about
1105 * dialog and must not be modified.
1109 G_CONST_RETURN gchar *
1110 gtk_about_dialog_get_version (GtkAboutDialog *about)
1112 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1114 return about->priv->version;
1118 * gtk_about_dialog_set_version:
1119 * @about: a #GtkAboutDialog
1120 * @version: (allow-none): the version string
1122 * Sets the version string to display in the about dialog.
1127 gtk_about_dialog_set_version (GtkAboutDialog *about,
1128 const gchar *version)
1130 GtkAboutDialogPrivate *priv;
1133 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1137 tmp = priv->version;
1138 priv->version = g_strdup (version);
1141 update_name_version (about);
1143 g_object_notify (G_OBJECT (about), "version");
1147 * gtk_about_dialog_get_copyright:
1148 * @about: a #GtkAboutDialog
1150 * Returns the copyright string.
1152 * Return value: The copyright string. The string is owned by the about
1153 * dialog and must not be modified.
1157 G_CONST_RETURN gchar *
1158 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
1160 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1162 return about->priv->copyright;
1166 * gtk_about_dialog_set_copyright:
1167 * @about: a #GtkAboutDialog
1168 * @copyright: (allow-none) the copyright string
1170 * Sets the copyright string to display in the about dialog.
1171 * This should be a short string of one or two lines.
1176 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
1177 const gchar *copyright)
1179 GtkAboutDialogPrivate *priv;
1180 gchar *copyright_string, *tmp;
1182 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1186 tmp = priv->copyright;
1187 priv->copyright = g_strdup (copyright);
1190 if (priv->copyright != NULL)
1192 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
1194 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
1195 g_free (copyright_string);
1197 gtk_widget_show (priv->copyright_label);
1200 gtk_widget_hide (priv->copyright_label);
1202 g_object_notify (G_OBJECT (about), "copyright");
1206 * gtk_about_dialog_get_comments:
1207 * @about: a #GtkAboutDialog
1209 * Returns the comments string.
1211 * Return value: The comments. The string is owned by the about
1212 * dialog and must not be modified.
1216 G_CONST_RETURN gchar *
1217 gtk_about_dialog_get_comments (GtkAboutDialog *about)
1219 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1221 return about->priv->comments;
1225 * gtk_about_dialog_set_comments:
1226 * @about: a #GtkAboutDialog
1227 * @comments: (allow-none): a comments string
1229 * Sets the comments string to display in the about dialog.
1230 * This should be a short string of one or two lines.
1235 gtk_about_dialog_set_comments (GtkAboutDialog *about,
1236 const gchar *comments)
1238 GtkAboutDialogPrivate *priv;
1241 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1245 tmp = priv->comments;
1248 priv->comments = g_strdup (comments);
1249 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
1250 gtk_widget_show (priv->comments_label);
1254 priv->comments = NULL;
1255 gtk_widget_hide (priv->comments_label);
1259 g_object_notify (G_OBJECT (about), "comments");
1263 * gtk_about_dialog_get_license:
1264 * @about: a #GtkAboutDialog
1266 * Returns the license information.
1268 * Return value: The license information. The string is owned by the about
1269 * dialog and must not be modified.
1273 G_CONST_RETURN gchar *
1274 gtk_about_dialog_get_license (GtkAboutDialog *about)
1276 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1278 return about->priv->license;
1282 * gtk_about_dialog_set_license:
1283 * @about: a #GtkAboutDialog
1284 * @license: (allow-none): the license information or %NULL
1286 * Sets the license information to be displayed in the secondary
1287 * license dialog. If @license is %NULL, the license button is
1293 gtk_about_dialog_set_license (GtkAboutDialog *about,
1294 const gchar *license)
1296 GtkAboutDialogPrivate *priv;
1299 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1303 tmp = priv->license;
1306 priv->license = g_strdup (license);
1307 priv->license_type = GTK_LICENSE_CUSTOM;
1311 priv->license = NULL;
1312 priv->license_type = GTK_LICENSE_UNKNOWN;
1316 gtk_widget_hide (priv->license_label);
1318 update_license_button_visibility (about);
1320 g_object_notify (G_OBJECT (about), "license");
1321 g_object_notify (G_OBJECT (about), "license-type");
1325 * gtk_about_dialog_get_wrap_license:
1326 * @about: a #GtkAboutDialog
1328 * Returns whether the license text in @about is
1329 * automatically wrapped.
1331 * Returns: %TRUE if the license text is wrapped
1336 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1338 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1340 return about->priv->wrap_license;
1344 * gtk_about_dialog_set_wrap_license:
1345 * @about: a #GtkAboutDialog
1346 * @wrap_license: whether to wrap the license
1348 * Sets whether the license text in @about is
1349 * automatically wrapped.
1354 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1355 gboolean wrap_license)
1357 GtkAboutDialogPrivate *priv;
1359 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1363 wrap_license = wrap_license != FALSE;
1365 if (priv->wrap_license != wrap_license)
1367 priv->wrap_license = wrap_license;
1369 g_object_notify (G_OBJECT (about), "wrap-license");
1374 * gtk_about_dialog_get_website:
1375 * @about: a #GtkAboutDialog
1377 * Returns the website URL.
1379 * Return value: The website URL. The string is owned by the about
1380 * dialog and must not be modified.
1384 G_CONST_RETURN gchar *
1385 gtk_about_dialog_get_website (GtkAboutDialog *about)
1387 GtkAboutDialogPrivate *priv;
1389 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1393 return priv->website_url;
1397 * gtk_about_dialog_set_website:
1398 * @about: a #GtkAboutDialog
1399 * @website: (allow-none): a URL string starting with "http://"
1401 * Sets the URL to use for the website link.
1406 gtk_about_dialog_set_website (GtkAboutDialog *about,
1407 const gchar *website)
1409 GtkAboutDialogPrivate *priv;
1412 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1416 tmp = priv->website_url;
1417 priv->website_url = g_strdup (website);
1420 update_website (about);
1422 g_object_notify (G_OBJECT (about), "website");
1426 * gtk_about_dialog_get_website_label:
1427 * @about: a #GtkAboutDialog
1429 * Returns the label used for the website link.
1431 * Return value: The label used for the website link. The string is
1432 * owned by the about dialog and must not be modified.
1436 G_CONST_RETURN gchar *
1437 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1439 GtkAboutDialogPrivate *priv;
1441 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1445 return priv->website_text;
1449 * gtk_about_dialog_set_website_label:
1450 * @about: a #GtkAboutDialog
1451 * @website_label: the label used for the website link
1453 * Sets the label to be used for the website link.
1458 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1459 const gchar *website_label)
1461 GtkAboutDialogPrivate *priv;
1464 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1468 tmp = priv->website_text;
1469 priv->website_text = g_strdup (website_label);
1472 update_website (about);
1474 g_object_notify (G_OBJECT (about), "website-label");
1478 * gtk_about_dialog_get_authors:
1479 * @about: a #GtkAboutDialog
1481 * Returns the string which are displayed in the authors tab
1482 * of the secondary credits dialog.
1484 * Return value: A %NULL-terminated string array containing
1485 * the authors. The array is owned by the about dialog
1486 * and must not be modified.
1490 G_CONST_RETURN gchar * G_CONST_RETURN *
1491 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1493 GtkAboutDialogPrivate *priv;
1495 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1499 return (const gchar * const *) priv->authors;
1503 * gtk_about_dialog_set_authors:
1504 * @about: a #GtkAboutDialog
1505 * @authors: (array zero-terminated=1): a %NULL-terminated array of strings
1507 * Sets the strings which are displayed in the authors tab
1508 * of the secondary credits dialog.
1513 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1514 const gchar **authors)
1516 GtkAboutDialogPrivate *priv;
1519 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1523 tmp = priv->authors;
1524 priv->authors = g_strdupv ((gchar **)authors);
1527 update_credits_button_visibility (about);
1529 g_object_notify (G_OBJECT (about), "authors");
1533 * gtk_about_dialog_get_documenters:
1534 * @about: a #GtkAboutDialog
1536 * Returns the string which are displayed in the documenters
1537 * tab of the secondary credits dialog.
1539 * Return value: A %NULL-terminated string array containing
1540 * the documenters. The array is owned by the about dialog
1541 * and must not be modified.
1545 G_CONST_RETURN gchar * G_CONST_RETURN *
1546 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1548 GtkAboutDialogPrivate *priv;
1550 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1554 return (const gchar * const *)priv->documenters;
1558 * gtk_about_dialog_set_documenters:
1559 * @about: a #GtkAboutDialog
1560 * @documenters: (array zero-terminated=1): a %NULL-terminated array of strings
1562 * Sets the strings which are displayed in the documenters tab
1563 * of the secondary credits dialog.
1568 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1569 const gchar **documenters)
1571 GtkAboutDialogPrivate *priv;
1574 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1578 tmp = priv->documenters;
1579 priv->documenters = g_strdupv ((gchar **)documenters);
1582 update_credits_button_visibility (about);
1584 g_object_notify (G_OBJECT (about), "documenters");
1588 * gtk_about_dialog_get_artists:
1589 * @about: a #GtkAboutDialog
1591 * Returns the string which are displayed in the artists tab
1592 * of the secondary credits dialog.
1594 * Return value: A %NULL-terminated string array containing
1595 * the artists. The array is owned by the about dialog
1596 * and must not be modified.
1600 G_CONST_RETURN gchar * G_CONST_RETURN *
1601 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1603 GtkAboutDialogPrivate *priv;
1605 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1609 return (const gchar * const *)priv->artists;
1613 * gtk_about_dialog_set_artists:
1614 * @about: a #GtkAboutDialog
1615 * @artists: (array zero-terminated=1): a %NULL-terminated array of strings
1617 * Sets the strings which are displayed in the artists tab
1618 * of the secondary credits dialog.
1623 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1624 const gchar **artists)
1626 GtkAboutDialogPrivate *priv;
1629 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1633 tmp = priv->artists;
1634 priv->artists = g_strdupv ((gchar **)artists);
1637 update_credits_button_visibility (about);
1639 g_object_notify (G_OBJECT (about), "artists");
1643 * gtk_about_dialog_get_translator_credits:
1644 * @about: a #GtkAboutDialog
1646 * Returns the translator credits string which is displayed
1647 * in the translators tab of the secondary credits dialog.
1649 * Return value: The translator credits string. The string is
1650 * owned by the about dialog and must not be modified.
1654 G_CONST_RETURN gchar *
1655 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1657 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1659 return about->priv->translator_credits;
1663 * gtk_about_dialog_set_translator_credits:
1664 * @about: a #GtkAboutDialog
1665 * @translator_credits: (allow-none): the translator credits
1667 * Sets the translator credits string which is displayed in
1668 * the translators tab of the secondary credits dialog.
1670 * The intended use for this string is to display the translator
1671 * of the language which is currently used in the user interface.
1672 * Using gettext(), a simple way to achieve that is to mark the
1673 * string for translation:
1675 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1677 * It is a good idea to use the customary msgid "translator-credits" for this
1678 * purpose, since translators will already know the purpose of that msgid, and
1679 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1685 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1686 const gchar *translator_credits)
1688 GtkAboutDialogPrivate *priv;
1691 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1695 tmp = priv->translator_credits;
1696 priv->translator_credits = g_strdup (translator_credits);
1699 update_credits_button_visibility (about);
1701 g_object_notify (G_OBJECT (about), "translator-credits");
1705 * gtk_about_dialog_get_logo:
1706 * @about: a #GtkAboutDialog
1708 * Returns the pixbuf displayed as logo in the about dialog.
1710 * Return value: the pixbuf displayed as logo. The pixbuf is
1711 * owned by the about dialog. If you want to keep a reference
1712 * to it, you have to call g_object_ref() on it.
1717 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1719 GtkAboutDialogPrivate *priv;
1721 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1725 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1726 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1732 icon_set_new_from_pixbufs (GList *pixbufs)
1734 GtkIconSet *icon_set = gtk_icon_set_new ();
1736 for (; pixbufs; pixbufs = pixbufs->next)
1738 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1740 GtkIconSource *icon_source = gtk_icon_source_new ();
1741 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1742 gtk_icon_set_add_source (icon_set, icon_source);
1743 gtk_icon_source_free (icon_source);
1750 * gtk_about_dialog_set_logo:
1751 * @about: a #GtkAboutDialog
1752 * @logo: (allow-none): a #GdkPixbuf, or %NULL
1754 * Sets the pixbuf to be displayed as logo in the about dialog.
1755 * If it is %NULL, the default window icon set with
1756 * gtk_window_set_default_icon() will be used.
1761 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1764 GtkAboutDialogPrivate *priv;
1766 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1770 g_object_freeze_notify (G_OBJECT (about));
1772 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1773 g_object_notify (G_OBJECT (about), "logo-icon-name");
1776 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1779 GList *pixbufs = gtk_window_get_default_icon_list ();
1781 if (pixbufs != NULL)
1783 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1785 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1786 icon_set, GTK_ICON_SIZE_DIALOG);
1788 gtk_icon_set_unref (icon_set);
1789 g_list_free (pixbufs);
1793 g_object_notify (G_OBJECT (about), "logo");
1795 g_object_thaw_notify (G_OBJECT (about));
1799 * gtk_about_dialog_get_logo_icon_name:
1800 * @about: a #GtkAboutDialog
1802 * Returns the icon name displayed as logo in the about dialog.
1804 * Return value: the icon name displayed as logo. The string is
1805 * owned by the dialog. If you want to keep a reference
1806 * to it, you have to call g_strdup() on it.
1810 G_CONST_RETURN gchar *
1811 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1813 GtkAboutDialogPrivate *priv;
1814 const gchar *icon_name = NULL;
1816 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1820 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1821 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1827 * gtk_about_dialog_set_logo_icon_name:
1828 * @about: a #GtkAboutDialog
1829 * @icon_name: (allow-none): an icon name, or %NULL
1831 * Sets the pixbuf to be displayed as logo in the about dialog.
1832 * If it is %NULL, the default window icon set with
1833 * gtk_window_set_default_icon() will be used.
1838 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1839 const gchar *icon_name)
1841 GtkAboutDialogPrivate *priv;
1843 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1847 g_object_freeze_notify (G_OBJECT (about));
1849 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1850 g_object_notify (G_OBJECT (about), "logo");
1852 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1853 GTK_ICON_SIZE_DIALOG);
1854 g_object_notify (G_OBJECT (about), "logo-icon-name");
1856 g_object_thaw_notify (G_OBJECT (about));
1860 follow_if_link (GtkAboutDialog *about,
1861 GtkTextView *text_view,
1864 GSList *tags = NULL, *tagp = NULL;
1865 GtkAboutDialogPrivate *priv = about->priv;
1868 tags = gtk_text_iter_get_tags (iter);
1869 for (tagp = tags; tagp != NULL && !uri; tagp = tagp->next)
1871 GtkTextTag *tag = tagp->data;
1873 uri = g_object_get_data (G_OBJECT (tag), "uri");
1875 emit_activate_link (about, uri);
1877 if (uri && !g_slist_find_custom (priv->visited_links, uri, (GCompareFunc)strcmp))
1879 GdkColor *style_visited_link_color;
1882 gtk_widget_ensure_style (GTK_WIDGET (about));
1883 gtk_widget_style_get (GTK_WIDGET (about),
1884 "visited-link-color", &style_visited_link_color,
1886 if (style_visited_link_color)
1888 color = *style_visited_link_color;
1889 gdk_color_free (style_visited_link_color);
1892 color = default_visited_link_color;
1894 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1896 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (uri));
1901 g_slist_free (tags);
1905 text_view_key_press_event (GtkWidget *text_view,
1907 GtkAboutDialog *about)
1910 GtkTextBuffer *buffer;
1912 switch (event->keyval)
1914 case GDK_KEY_Return:
1915 case GDK_KEY_ISO_Enter:
1916 case GDK_KEY_KP_Enter:
1917 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1918 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1919 gtk_text_buffer_get_insert (buffer));
1920 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1931 text_view_event_after (GtkWidget *text_view,
1933 GtkAboutDialog *about)
1935 GtkTextIter start, end, iter;
1936 GtkTextBuffer *buffer;
1937 GdkEventButton *button_event;
1940 if (event->type != GDK_BUTTON_RELEASE)
1943 button_event = (GdkEventButton *)event;
1945 if (button_event->button != 1)
1948 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1950 /* we shouldn't follow a link if the user has selected something */
1951 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1952 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1955 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1956 GTK_TEXT_WINDOW_WIDGET,
1957 button_event->x, button_event->y, &x, &y);
1959 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1961 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1967 set_cursor_if_appropriate (GtkAboutDialog *about,
1968 GtkTextView *text_view,
1973 GtkAboutDialogPrivate *priv = about->priv;
1974 GSList *tags = NULL, *tagp = NULL;
1976 gboolean hovering_over_link = FALSE;
1978 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1980 tags = gtk_text_iter_get_tags (&iter);
1981 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1983 GtkTextTag *tag = tagp->data;
1984 gchar *uri = g_object_get_data (G_OBJECT (tag), "uri");
1988 hovering_over_link = TRUE;
1993 if (hovering_over_link != priv->hovering_over_link)
1995 priv->hovering_over_link = hovering_over_link;
1997 if (hovering_over_link)
1998 gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->hand_cursor);
2000 gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->regular_cursor);
2004 g_slist_free (tags);
2008 text_view_motion_notify_event (GtkWidget *text_view,
2009 GdkEventMotion *event,
2010 GtkAboutDialog *about)
2014 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
2015 GTK_TEXT_WINDOW_WIDGET,
2016 event->x, event->y, &x, &y);
2018 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), event->device, x, y);
2020 gdk_event_request_motions (event);
2027 text_view_visibility_notify_event (GtkWidget *text_view,
2028 GdkEventVisibility *event,
2029 GtkAboutDialog *about)
2031 GdkDeviceManager *device_manager;
2032 GdkDisplay *display;
2034 gint wx, wy, bx, by;
2036 display = gdk_window_get_display (event->window);
2037 device_manager = gdk_display_get_device_manager (display);
2038 devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
2040 for (d = devices; d; d = d->next)
2042 GdkDevice *dev = d->data;
2044 if (gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD)
2047 gdk_window_get_device_position (gtk_widget_get_window (text_view), dev,
2050 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
2051 GTK_TEXT_WINDOW_WIDGET,
2054 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), dev, bx, by);
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;
2078 GtkAboutDialogPrivate *priv = about->priv;
2080 gtk_widget_ensure_style (GTK_WIDGET (about));
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 size = pango_font_description_get_size (gtk_widget_get_style (view)->font_desc);
2109 font_desc = pango_font_description_new ();
2110 pango_font_description_set_size (font_desc, size * PANGO_SCALE_SMALL);
2111 gtk_widget_modify_font (view, font_desc);
2112 pango_font_description_free (font_desc);
2114 gtk_text_view_set_left_margin (text_view, 8);
2115 gtk_text_view_set_right_margin (text_view, 8);
2117 g_signal_connect (view, "key-press-event",
2118 G_CALLBACK (text_view_key_press_event), about);
2119 g_signal_connect (view, "event-after",
2120 G_CALLBACK (text_view_event_after), about);
2121 g_signal_connect (view, "motion-notify-event",
2122 G_CALLBACK (text_view_motion_notify_event), about);
2123 g_signal_connect (view, "visibility-notify-event",
2124 G_CALLBACK (text_view_visibility_notify_event), about);
2126 if (strings == NULL)
2128 gtk_widget_hide (view);
2132 for (p = strings; *p; p++)
2137 q1 = strchr (q0, '<');
2138 q2 = q1 ? strchr (q1, '>') : NULL;
2139 r1 = strstr (q0, "http://");
2142 r2 = strpbrk (r1, " \n\t");
2144 r2 = strchr (r1, '\0');
2149 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2160 const gchar *link_type;
2165 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0 + 1);
2166 gtk_text_buffer_get_end_iter (buffer, &end);
2168 link_type = "email";
2172 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
2173 gtk_text_buffer_get_end_iter (buffer, &end);
2179 link = g_strndup (q1, q2 - q1);
2181 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
2182 color = visited_link_color;
2186 tag = gtk_text_buffer_create_tag (buffer, NULL,
2187 "foreground-gdk", &color,
2188 "underline", PANGO_UNDERLINE_SINGLE,
2190 if (strcmp (link_type, "email") == 0)
2194 escaped = g_uri_escape_string (link, NULL, FALSE);
2195 uri = g_strconcat ("mailto:", escaped, NULL);
2200 uri = g_strdup (link);
2202 g_object_set_data_full (G_OBJECT (tag), I_("uri"), uri, g_free);
2203 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
2209 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
2215 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
2218 gtk_widget_show (view);
2223 add_credits_section (GtkAboutDialog *about,
2232 gchar *q0, *q1, *q2, *r1, *r2;
2237 markup = g_strdup_printf ("<span size=\"small\">%s</span>", title);
2238 label = gtk_label_new (markup);
2239 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
2241 gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
2242 gtk_grid_attach (grid, label, 0, *row, 1, 1);
2244 for (p = people; *p; p++)
2248 str = g_string_new ("<span size=\"small\">");
2253 q1 = strchr (q0, '<');
2254 q2 = q1 ? strchr (q1, '>') : NULL;
2255 r1 = strstr (q0, "http://");
2258 r2 = strpbrk (r1, " \n\t");
2260 r2 = strchr (r1, '\0');
2265 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
2270 else if (q1 && (q1[1] == 'a' || q1[1] == 'A') && q1[2] == ' ')
2272 /* if it is a <a> link leave it for the label to parse */
2286 text = g_strstrip (g_strndup (q0, q1 - q0));
2288 link = g_strndup (q1, q2 - q1);
2290 escaped = g_uri_escape_string (link, NULL, FALSE);
2291 g_string_append_printf (str,
2292 "<a href=\"mailto:%s\">%s</a>",
2302 text = g_strstrip (g_strndup (q0, q1 - q0));
2303 link = g_strndup (q1, q2 - q1);
2304 g_string_append_printf (str,
2305 "<a href=\"%s\">%s</a>",
2316 g_string_append (str, q0);
2320 g_string_append (str, "</span>");
2322 label = gtk_label_new (str->str);
2323 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
2324 g_string_free (str, TRUE);
2325 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2326 gtk_grid_attach (grid, label, 1, *row, 1, 1);
2330 /* skip one at the end */
2335 create_credits_page (GtkAboutDialog *about)
2337 GtkAboutDialogPrivate *priv = about->priv;
2338 GtkWidget *page_vbox;
2341 GtkWidget *alignment;
2344 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
2345 gtk_widget_show (page_vbox);
2346 priv->credits_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
2348 sw = gtk_scrolled_window_new (NULL, NULL);
2349 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
2350 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2352 GTK_POLICY_AUTOMATIC);
2353 gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
2355 alignment = gtk_alignment_new (0.5, 0, 0, 0);
2356 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), alignment);
2358 grid = gtk_grid_new ();
2359 gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
2360 gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
2361 gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
2362 gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
2363 gtk_container_add (GTK_CONTAINER (alignment), grid);
2365 if (priv->authors != NULL)
2366 add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
2368 if (priv->documenters != NULL)
2369 add_credits_section (about, GTK_GRID (grid), &row, _("Documented by"), priv->documenters);
2371 /* Don't show an untranslated gettext msgid */
2372 if (priv->translator_credits != NULL &&
2373 strcmp (priv->translator_credits, "translator_credits") != 0 &&
2374 strcmp (priv->translator_credits, "translator-credits") != 0)
2376 gchar **translators;
2378 translators = g_strsplit (priv->translator_credits, "\n", 0);
2379 add_credits_section (about, GTK_GRID (grid), &row, _("Translated by"), translators);
2380 g_strfreev (translators);
2383 if (priv->artists != NULL)
2384 add_credits_section (about, GTK_GRID (grid), &row, _("Artwork by"), priv->artists);
2386 gtk_widget_show_all (sw);
2390 display_credits_page (GtkWidget *button,
2393 GtkAboutDialog *about = (GtkAboutDialog *)data;
2394 GtkAboutDialogPrivate *priv = about->priv;
2396 if (priv->credits_page == 0)
2397 create_credits_page (about);
2399 switch_page (about, priv->credits_page);
2403 create_license_page (GtkAboutDialog *about)
2405 GtkAboutDialogPrivate *priv = about->priv;
2406 GtkWidget *page_vbox;
2411 page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
2412 priv->license_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
2414 sw = gtk_scrolled_window_new (NULL, NULL);
2415 gtk_container_set_border_width (GTK_CONTAINER (sw), 5);
2416 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
2417 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2418 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2419 gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
2421 strings[0] = priv->license;
2423 view = text_view_new (about, strings,
2424 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2426 gtk_container_add (GTK_CONTAINER (sw), view);
2428 gtk_widget_show_all (page_vbox);
2432 display_license_page (GtkWidget *button,
2435 GtkAboutDialog *about = (GtkAboutDialog *)data;
2436 GtkAboutDialogPrivate *priv = about->priv;
2438 if (priv->license_page == 0)
2439 create_license_page (about);
2441 switch_page (about, priv->license_page);
2445 * gtk_about_dialog_new:
2447 * Creates a new #GtkAboutDialog.
2449 * Returns: a newly created #GtkAboutDialog
2454 gtk_about_dialog_new (void)
2456 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2458 return GTK_WIDGET (dialog);
2462 close_cb (GtkAboutDialog *about)
2464 switch_page (about, 0);
2465 gtk_widget_hide (GTK_WIDGET (about));
2469 * gtk_show_about_dialog:
2470 * @parent: (allow-none): transient parent, or %NULL for none
2471 * @first_property_name: the name of the first property
2472 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2474 * This is a convenience function for showing an application's about box.
2475 * The constructed dialog is associated with the parent window and
2476 * reused for future invocations of this function.
2481 gtk_show_about_dialog (GtkWindow *parent,
2482 const gchar *first_property_name,
2485 static GtkWidget *global_about_dialog = NULL;
2486 GtkWidget *dialog = NULL;
2490 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2492 dialog = global_about_dialog;
2496 dialog = gtk_about_dialog_new ();
2498 g_object_ref_sink (dialog);
2500 g_signal_connect (dialog, "delete-event",
2501 G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2503 /* Close dialog on user response */
2504 g_signal_connect (dialog, "response",
2505 G_CALLBACK (close_cb), NULL);
2507 va_start (var_args, first_property_name);
2508 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2513 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
2514 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2515 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2516 g_object_set_data_full (G_OBJECT (parent),
2517 I_("gtk-about-dialog"),
2518 dialog, g_object_unref);
2521 global_about_dialog = dialog;
2525 gtk_window_present (GTK_WINDOW (dialog));
2529 * gtk_about_dialog_set_license_type:
2530 * @about: a #GtkAboutDialog
2531 * @license_type: the type of license
2533 * Sets the license of the application showing the @about dialog from a
2534 * list of known licenses.
2536 * This function overrides the license set using
2537 * gtk_about_dialog_set_license().
2542 gtk_about_dialog_set_license_type (GtkAboutDialog *about,
2543 GtkLicense license_type)
2545 GtkAboutDialogPrivate *priv;
2547 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
2548 g_return_if_fail (license_type >= GTK_LICENSE_UNKNOWN &&
2549 license_type <= GTK_LICENSE_ARTISTIC);
2553 if (priv->license_type != license_type)
2555 g_object_freeze_notify (G_OBJECT (about));
2557 priv->license_type = license_type;
2559 /* custom licenses use the contents of the :license property */
2560 if (priv->license_type != GTK_LICENSE_CUSTOM)
2563 gchar *license_string;
2566 url = gtk_license_urls[priv->license_type];
2568 url = priv->website_url;
2570 str = g_string_sized_new (256);
2571 g_string_append_printf (str, _(gtk_license_preamble), url, url);
2573 g_free (priv->license);
2574 priv->license = g_string_free (str, FALSE);
2575 priv->wrap_license = TRUE;
2577 license_string = g_strdup_printf ("<span size=\"small\">%s</span>",
2579 gtk_label_set_markup (GTK_LABEL (priv->license_label), license_string);
2580 g_free (license_string);
2581 gtk_widget_show (priv->license_label);
2583 update_license_button_visibility (about);
2585 g_object_notify (G_OBJECT (about), "wrap-license");
2586 g_object_notify (G_OBJECT (about), "license");
2590 gtk_widget_show (priv->license_label);
2593 g_object_notify (G_OBJECT (about), "license-type");
2595 g_object_thaw_notify (G_OBJECT (about));
2600 * gtk_about_dialog_get_license_type:
2601 * @about: a #GtkAboutDialog
2603 * Retrieves the license set using gtk_about_dialog_set_license_type()
2605 * Return value: a #GtkLicense value
2610 gtk_about_dialog_get_license_type (GtkAboutDialog *about)
2612 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), GTK_LICENSE_UNKNOWN);
2614 return about->priv->license_type;