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/.
33 #include <gdk/gdkkeysyms.h>
37 #include "gtkaboutdialog.h"
38 #include "gtkbutton.h"
40 #include "gtkdialog.h"
44 #include "gtkmarshalers.h"
45 #include "gtknotebook.h"
46 #include "gtkscrolledwindow.h"
48 #include "gtktextview.h"
50 #include "gtkviewport.h"
51 #include "gtkiconfactory.h"
56 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
57 struct _GtkAboutDialogPrivate
65 gchar *translator_credits;
72 GtkWidget *logo_image;
73 GtkWidget *name_label;
74 GtkWidget *comments_label;
75 GtkWidget *copyright_label;
76 GtkWidget *website_button;
78 GtkWidget *credits_button;
79 GtkWidget *credits_dialog;
80 GtkWidget *license_button;
81 GtkWidget *license_dialog;
83 GdkCursor *hand_cursor;
84 GdkCursor *regular_cursor;
85 gboolean hovering_over_link;
88 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
103 PROP_TRANSLATOR_CREDITS,
109 static void gtk_about_dialog_finalize (GObject *object);
110 static void gtk_about_dialog_get_property (GObject *object,
114 static void gtk_about_dialog_set_property (GObject *object,
118 static void update_name_version (GtkAboutDialog *about);
119 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
120 static void activate_url (GtkWidget *widget,
122 static void set_link_button_text (GtkWidget *about,
125 static GtkWidget * create_link_button (GtkWidget *about,
130 static void follow_if_link (GtkAboutDialog *about,
132 static void set_cursor_if_appropriate (GtkAboutDialog *about,
133 GtkTextView *text_view,
136 static void add_credits_page (GtkAboutDialog *about,
140 static gboolean credits_key_press_event (GtkWidget *text_view,
142 GtkAboutDialog *about);
143 static gboolean credits_event_after (GtkWidget *text_view,
145 GtkAboutDialog *about);
146 static gboolean credits_motion_notify_event (GtkWidget *text_view,
147 GdkEventMotion *event,
148 GtkAboutDialog *about);
149 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
150 GdkEventVisibility *event,
151 GtkAboutDialog *about);
152 static void display_credits_dialog (GtkWidget *button,
154 static void display_license_dialog (GtkWidget *button,
158 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
159 static gpointer activate_email_hook_data = NULL;
160 static GDestroyNotify activate_email_hook_destroy = NULL;
162 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
163 static gpointer activate_url_hook_data = NULL;
164 static GDestroyNotify activate_url_hook_destroy = NULL;
166 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
169 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
171 GObjectClass *object_class;
172 GtkWidgetClass *widget_class;
173 GtkDialogClass *dialog_class;
175 object_class = (GObjectClass *)klass;
176 widget_class = (GtkWidgetClass *)klass;
177 dialog_class = (GtkDialogClass *)klass;
179 object_class->set_property = gtk_about_dialog_set_property;
180 object_class->get_property = gtk_about_dialog_get_property;
182 object_class->finalize = gtk_about_dialog_finalize;
185 * GtkAboutDialog:name:
187 * The name of the program.
188 * If this is not set, it defaults to g_get_application_name().
192 g_object_class_install_property (object_class,
194 g_param_spec_string ("name",
196 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
201 * GtkAboutDialog:version:
203 * The version of the program.
207 g_object_class_install_property (object_class,
209 g_param_spec_string ("version",
210 P_("Program version"),
211 P_("The version of the program"),
216 * GtkAboutDialog:copyright:
218 * Copyright information for the program.
222 g_object_class_install_property (object_class,
224 g_param_spec_string ("copyright",
225 P_("Copyright string"),
226 P_("Copyright information for the program"),
232 * GtkAboutDialog:comments:
234 * Comments about the program. This string is displayed in a label
235 * in the main dialog, thus it should be a short explanation of
236 * the main purpose of the program, not a detailed list of features.
240 g_object_class_install_property (object_class,
242 g_param_spec_string ("comments",
243 P_("Comments string"),
244 P_("Comments about the program"),
249 * GtkAboutDialog:license:
251 * The license of the program. This string is displayed in a
252 * text view in a secondary dialog, therefore it is fine to use
253 * a long multi-paragraph text.
257 g_object_class_install_property (object_class,
259 g_param_spec_string ("license",
261 _("The license of the program"),
266 * GtkAboutDialog:website:
268 * The URL for the link to the website of the program.
269 * This should be a string starting with "http://.
273 g_object_class_install_property (object_class,
275 g_param_spec_string ("website",
277 P_("The URL for the link to the website of the program"),
282 * GtkAboutDialog:website-label:
284 * The label for the link to the website of the program. If this is not set,
285 * it defaults to the URL specified in the
286 * <link linkend="GtkAboutDialog--website">website</link> property.
290 g_object_class_install_property (object_class,
292 g_param_spec_string ("website_label",
294 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
299 * GtkAboutDialog:authors:
301 * The authors of the program, as a %NULL-terminated array of strings.
302 * Each string may contain email addresses and URLs, which will be displayed
303 * as links, see the introduction for more details.
307 g_object_class_install_property (object_class,
309 g_param_spec_boxed ("authors",
311 P_("List of authors of the program"),
316 * GtkAboutDialog:documenters:
318 * The people documenting the program, as a %NULL-terminated array of strings.
319 * Each string may contain email addresses and URLs, which will be displayed
320 * as links, see the introduction for more details.
324 g_object_class_install_property (object_class,
326 g_param_spec_boxed ("documenters",
328 P_("List of people documenting the program"),
333 * GtkAboutDialog:artists:
335 * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
336 * Each string may contain email addresses and URLs, which will be displayed
337 * as links, see the introduction for more details.
341 g_object_class_install_property (object_class,
343 g_param_spec_boxed ("artists",
345 P_("List of people who have contributed artwork to the program"),
351 * GtkAboutDialog:translator-credits:
353 * Credits to the translators. This string should be marked as translatable.
354 * The string may contain email addresses and URLs, which will be displayed
355 * as links, see the introduction for more details.
359 g_object_class_install_property (object_class,
360 PROP_TRANSLATOR_CREDITS,
361 g_param_spec_string ("translator_credits",
362 P_("Translator credits"),
363 P_("Credits to the translators. This string should be marked as translatable"),
368 * GtkAboutDialog:logo:
370 * A logo for the about box. If this is not set, it defaults to
371 * gtk_window_get_default_icon_list().
375 g_object_class_install_property (object_class,
377 g_param_spec_object ("logo",
379 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
384 * GtkAboutDialog:logo-icon-name:
386 * A named icon to use as the logo for the about box. This property
387 * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
391 g_object_class_install_property (object_class,
393 g_param_spec_string ("logo_icon_name",
394 P_("Logo Icon Name"),
395 P_("A named icon to use as the logo for the about box."),
399 /* Style properties */
400 gtk_widget_class_install_style_property (widget_class,
401 g_param_spec_boxed ("link_color",
403 P_("Color of hyperlinks"),
407 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
411 gtk_about_dialog_init (GtkAboutDialog *about)
413 GtkAboutDialogPrivate *priv;
414 GtkWidget *vbox, *hbox, *button;
417 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
418 about->private_data = priv;
421 priv->version = NULL;
422 priv->copyright = NULL;
423 priv->comments = NULL;
424 priv->website = NULL;
425 priv->website_label = NULL;
426 priv->translator_credits = NULL;
427 priv->authors = NULL;
428 priv->documenters = NULL;
429 priv->artists = NULL;
431 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
432 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
433 priv->hovering_over_link = FALSE;
435 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
438 gtk_widget_push_composite_child ();
439 vbox = gtk_vbox_new (FALSE, 8);
440 gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
442 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
444 priv->logo_image = gtk_image_new ();
445 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
447 priv->name_label = gtk_label_new (NULL);
448 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
449 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
450 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
452 priv->comments_label = gtk_label_new (NULL);
453 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
454 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
455 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
456 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
458 priv->copyright_label = gtk_label_new (NULL);
459 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
460 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
461 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
463 button = create_link_button (GTK_WIDGET (about), "", "",
464 G_CALLBACK (activate_url), about);
466 hbox = gtk_hbox_new (TRUE, 0);
467 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
468 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
469 priv->website_button = button;
471 gtk_widget_show (vbox);
472 gtk_widget_show (priv->logo_image);
473 gtk_widget_show (priv->name_label);
474 gtk_widget_show (hbox);
476 /* Add the OK button */
477 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
478 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CLOSE);
480 /* Add the credits button */
481 button = gtk_button_new_from_stock (_("_Credits"));
482 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
483 button, FALSE, TRUE, 0);
484 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
485 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
486 priv->credits_button = button;
487 priv->credits_dialog = NULL;
489 /* Add the license button */
490 button = gtk_button_new_from_stock (_("_License"));
491 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
492 button, FALSE, TRUE, 0);
493 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
494 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
495 priv->license_button = button;
496 priv->license_dialog = NULL;
498 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
500 gtk_widget_pop_composite_child ();
504 gtk_about_dialog_finalize (GObject *object)
506 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
507 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
510 g_free (priv->version);
511 g_free (priv->copyright);
512 g_free (priv->comments);
513 g_free (priv->license);
514 g_free (priv->website);
515 g_free (priv->website_label);
516 g_free (priv->translator_credits);
518 g_strfreev (priv->authors);
519 g_strfreev (priv->documenters);
520 g_strfreev (priv->artists);
522 gdk_cursor_unref (priv->hand_cursor);
523 gdk_cursor_unref (priv->regular_cursor);
525 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
529 gtk_about_dialog_set_property (GObject *object,
534 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
539 gtk_about_dialog_set_name (about, g_value_get_string (value));
542 gtk_about_dialog_set_version (about, g_value_get_string (value));
545 gtk_about_dialog_set_comments (about, g_value_get_string (value));
548 gtk_about_dialog_set_website (about, g_value_get_string (value));
550 case PROP_WEBSITE_LABEL:
551 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
554 gtk_about_dialog_set_license (about, g_value_get_string (value));
557 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
560 gtk_about_dialog_set_logo (about, g_value_get_object (value));
563 gtk_about_dialog_set_authors (about, (gchar**)g_value_get_boxed (value));
565 case PROP_DOCUMENTERS:
566 gtk_about_dialog_set_documenters (about, (gchar**)g_value_get_boxed (value));
569 gtk_about_dialog_set_artists (about, (gchar**)g_value_get_boxed (value));
571 case PROP_TRANSLATOR_CREDITS:
572 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
574 case PROP_LOGO_ICON_NAME:
575 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
578 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
584 gtk_about_dialog_get_property (GObject *object,
589 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
590 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
595 g_value_set_string (value, priv->name);
598 g_value_set_string (value, priv->version);
601 g_value_set_string (value, priv->copyright);
604 g_value_set_string (value, priv->comments);
607 g_value_set_string (value, priv->website);
609 case PROP_WEBSITE_LABEL:
610 g_value_set_string (value, priv->website_label);
613 g_value_set_string (value, priv->license);
615 case PROP_TRANSLATOR_CREDITS:
616 g_value_set_string (value, priv->translator_credits);
619 g_value_set_boxed (value, priv->authors);
621 case PROP_DOCUMENTERS:
622 g_value_set_boxed (value, priv->documenters);
625 g_value_set_boxed (value, priv->artists);
628 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
629 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
631 g_value_set_object (value, NULL);
633 case PROP_LOGO_ICON_NAME:
634 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
636 const gchar *icon_name;
638 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
639 g_value_set_string (value, icon_name);
642 g_value_set_string (value, NULL);
645 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
651 * gtk_about_dialog_get_name:
652 * @about: a #GtkAboutDialog
654 * Returns the program name displayed in the about dialog.
656 * Return value: The program name. The string is owned by the about
657 * dialog and must not be modified.
661 G_CONST_RETURN gchar *
662 gtk_about_dialog_get_name (GtkAboutDialog *about)
664 GtkAboutDialogPrivate *priv;
666 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
668 priv = (GtkAboutDialogPrivate *)about->private_data;
674 update_name_version (GtkAboutDialog *about)
676 GtkAboutDialogPrivate *priv;
677 gchar *title_string, *name_string;
679 priv = (GtkAboutDialogPrivate *)about->private_data;
681 title_string = g_strdup_printf (_("About %s"), priv->name);
682 gtk_window_set_title (GTK_WINDOW (about), title_string);
683 g_free (title_string);
685 if (priv->version != NULL)
686 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
687 priv->name, priv->version);
689 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
692 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
694 g_free (name_string);
698 * gtk_about_dialog_set_name:
699 * @about: a #GtkAboutDialog
700 * @name: the program name
702 * Sets the name to display in the about dialog.
703 * If this is not set, it defaults to g_get_application_name().
708 gtk_about_dialog_set_name (GtkAboutDialog *about,
711 GtkAboutDialogPrivate *priv;
714 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
716 priv = (GtkAboutDialogPrivate *)about->private_data;
718 priv->name = g_strdup (name ? name : g_get_application_name ());
721 update_name_version (about);
723 g_object_notify (G_OBJECT (about), "name");
727 * gtk_about_dialog_get_version:
728 * @about: a #GtkAboutDialog
730 * Returns the version string.
732 * Return value: The version string. The string is owned by the about
733 * dialog and must not be modified.
737 G_CONST_RETURN gchar *
738 gtk_about_dialog_get_version (GtkAboutDialog *about)
740 GtkAboutDialogPrivate *priv;
742 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
744 priv = (GtkAboutDialogPrivate *)about->private_data;
746 return priv->version;
750 * gtk_about_dialog_set_version:
751 * @about: a #GtkAboutDialog
752 * @version: the version string
754 * Sets the version string to display in the about dialog.
759 gtk_about_dialog_set_version (GtkAboutDialog *about,
760 const gchar *version)
762 GtkAboutDialogPrivate *priv;
765 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
767 priv = (GtkAboutDialogPrivate *)about->private_data;
770 priv->version = version ? g_strdup (version) : NULL;
773 update_name_version (about);
775 g_object_notify (G_OBJECT (about), "version");
779 * gtk_about_dialog_get_copyright:
780 * @about: a #GtkAboutDialog
782 * Returns the copyright string.
784 * Return value: The copyright string. The string is owned by the about
785 * dialog and must not be modified.
789 G_CONST_RETURN gchar *
790 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
792 GtkAboutDialogPrivate *priv;
794 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
796 priv = (GtkAboutDialogPrivate *)about->private_data;
798 return priv->copyright;
802 * gtk_about_dialog_set_copyright:
803 * @about: a #GtkAboutDialog
804 * @copyright: the copyright string
806 * Sets the copyright string to display in the about dialog.
807 * This should be a short string of one or two lines.
812 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
813 const gchar *copyright)
815 GtkAboutDialogPrivate *priv;
816 gchar *copyright_string, *tmp;
818 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
820 priv = (GtkAboutDialogPrivate *)about->private_data;
822 tmp = priv->copyright;
823 priv->copyright = copyright ? g_strdup (copyright) : NULL;
826 if (priv->copyright != NULL)
828 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
830 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
831 g_free (copyright_string);
833 gtk_widget_show (priv->copyright_label);
836 gtk_widget_hide (priv->copyright_label);
838 g_object_notify (G_OBJECT (about), "copyright");
842 * gtk_about_dialog_get_comments:
843 * @about: a #GtkAboutDialog
845 * Returns the comments string.
847 * Return value: The comments. The string is owned by the about
848 * dialog and must not be modified.
852 G_CONST_RETURN gchar *
853 gtk_about_dialog_get_comments (GtkAboutDialog *about)
855 GtkAboutDialogPrivate *priv;
857 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
859 priv = (GtkAboutDialogPrivate *)about->private_data;
861 return priv->comments;
865 * gtk_about_dialog_set_comments:
866 * @about: a #GtkAboutDialog
867 * @comments: a comments string
869 * Sets the comments string to display in the about
870 * dialog. This should be a short string of one or
876 gtk_about_dialog_set_comments (GtkAboutDialog *about,
877 const gchar *comments)
879 GtkAboutDialogPrivate *priv;
882 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
884 priv = (GtkAboutDialogPrivate *)about->private_data;
886 tmp = priv->comments;
889 priv->comments = g_strdup (comments);
890 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
891 gtk_widget_show (priv->comments_label);
895 priv->comments = NULL;
896 gtk_widget_hide (priv->comments_label);
900 g_object_notify (G_OBJECT (about), "comments");
904 * gtk_about_dialog_get_license:
905 * @about: a #GtkAboutDialog
907 * Returns the license information.
909 * Return value: The license information. The string is owned by the about
910 * dialog and must not be modified.
914 G_CONST_RETURN gchar *
915 gtk_about_dialog_get_license (GtkAboutDialog *about)
917 GtkAboutDialogPrivate *priv;
919 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
921 priv = (GtkAboutDialogPrivate *)about->private_data;
923 return priv->license;
927 * gtk_about_dialog_set_license:
928 * @about: a #GtkAboutDialog
929 * @license: the license information or %NULL
931 * Sets the license information to be displayed in the secondary
932 * license dialog. If @license is %NULL, the license button is
938 gtk_about_dialog_set_license (GtkAboutDialog *about,
939 const gchar *license)
941 GtkAboutDialogPrivate *priv;
944 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
946 priv = (GtkAboutDialogPrivate *)about->private_data;
951 priv->license = g_strdup (license);
952 gtk_widget_show (priv->license_button);
956 priv->license = NULL;
957 gtk_widget_hide (priv->license_button);
961 g_object_notify (G_OBJECT (about), "license");
965 * gtk_about_dialog_get_website:
966 * @about: a #GtkAboutDialog
968 * Returns the website URL.
970 * Return value: The website URL. The string is owned by the about
971 * dialog and must not be modified.
975 G_CONST_RETURN gchar *
976 gtk_about_dialog_get_website (GtkAboutDialog *about)
978 GtkAboutDialogPrivate *priv;
980 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
982 priv = (GtkAboutDialogPrivate *)about->private_data;
984 return priv->website;
988 * gtk_about_dialog_set_website:
989 * @about: a #GtkAboutDialog
990 * @website: a URL string starting with "http://"
992 * Sets the URL to use for the website link.
997 gtk_about_dialog_set_website (GtkAboutDialog *about,
998 const gchar *website)
1000 GtkAboutDialogPrivate *priv;
1003 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1005 priv = (GtkAboutDialogPrivate *)about->private_data;
1007 tmp = priv->website;
1008 if (website != NULL)
1010 priv->website = g_strdup (website);
1011 if (activate_url_hook != NULL)
1013 g_object_set_data_full (G_OBJECT (priv->website_button),
1014 "url", g_strdup (website), g_free);
1015 if (priv->website_label == NULL)
1016 gtk_about_dialog_set_website_label (about, website);
1020 GtkWidget *hbox = priv->website_button->parent;
1021 gtk_widget_destroy (priv->website_button);
1022 priv->website_button = gtk_label_new (website);
1023 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1024 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1025 gtk_widget_show (priv->website_button);
1030 priv->website = NULL;
1031 g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
1035 g_object_notify (G_OBJECT (about), "website");
1039 * gtk_about_dialog_get_website_label:
1040 * @about: a #GtkAboutDialog
1042 * Returns the label used for the website link.
1044 * Return value: The label used for the website link. The string is owned by the about
1045 * dialog and must not be modified.
1049 G_CONST_RETURN gchar *
1050 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1052 GtkAboutDialogPrivate *priv;
1054 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1056 priv = (GtkAboutDialogPrivate *)about->private_data;
1058 return priv->website_label;
1062 * gtk_about_dialog_set_website_label:
1063 * @about: a #GtkAboutDialog
1064 * @website_label: the label used for the website link
1066 * Sets the label to be used for the website link.
1067 * It defaults to the website URL.
1072 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1073 const gchar *website_label)
1075 GtkAboutDialogPrivate *priv;
1078 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1080 priv = (GtkAboutDialogPrivate *)about->private_data;
1082 tmp = priv->website_label;
1083 if (activate_url_hook != NULL)
1085 if (website_label != NULL)
1087 priv->website_label = g_strdup (website_label);
1088 set_link_button_text (GTK_WIDGET (about),
1089 priv->website_button,
1090 priv->website_label);
1091 gtk_widget_show (priv->website_button);
1095 priv->website_label = NULL;
1096 gtk_widget_hide (priv->website_button);
1101 g_object_notify (G_OBJECT (about), "website_label");
1105 * gtk_about_dialog_get_authors:
1106 * @about: a #GtkAboutDialog
1108 * Returns the string which are displayed in the authors tab
1109 * of the secondary credits dialog.
1111 * Return value: A %NULL-terminated string array containing
1112 * the authors. The array is owned by the about dialog
1113 * and must not be modified.
1118 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1120 GtkAboutDialogPrivate *priv;
1122 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1124 priv = (GtkAboutDialogPrivate *)about->private_data;
1126 return priv->authors;
1130 * gtk_about_dialog_set_authors:
1131 * @about: a #GtkAboutDialog
1132 * @authors: a %NULL-terminated array of strings
1134 * Sets the strings which are displayed in the authors tab
1135 * of the secondary credits dialog.
1140 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1143 GtkAboutDialogPrivate *priv;
1146 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1148 priv = (GtkAboutDialogPrivate *)about->private_data;
1150 tmp = priv->authors;
1151 priv->authors = g_strdupv (authors);
1154 if (priv->authors != NULL)
1155 gtk_widget_show (priv->credits_button);
1157 g_object_notify (G_OBJECT (about), "authors");
1161 * gtk_about_dialog_get_documenters:
1162 * @about: a #GtkAboutDialog
1164 * Returns the string which are displayed in the documenters
1165 * tab of the secondary credits dialog.
1167 * Return value: A %NULL-terminated string array containing
1168 * the documenters. The array is owned by the about dialog
1169 * and must not be modified.
1174 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1176 GtkAboutDialogPrivate *priv;
1178 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1180 priv = (GtkAboutDialogPrivate *)about->private_data;
1182 return priv->documenters;
1186 * gtk_about_dialog_set_documenters:
1187 * @about: a #GtkAboutDialog
1188 * @documenters: a %NULL-terminated array of strings
1190 * Sets the strings which are displayed in the documenters tab
1191 * of the secondary credits dialog.
1196 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1197 gchar **documenters)
1199 GtkAboutDialogPrivate *priv;
1202 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1204 priv = (GtkAboutDialogPrivate *)about->private_data;
1206 tmp = priv->documenters;
1207 priv->documenters = g_strdupv (documenters);
1210 if (priv->documenters != NULL)
1211 gtk_widget_show (priv->credits_button);
1213 g_object_notify (G_OBJECT (about), "documenters");
1217 * gtk_about_dialog_get_artists:
1218 * @about: a #GtkAboutDialog
1220 * Returns the string which are displayed in the artists tab
1221 * of the secondary credits dialog.
1223 * Return value: A %NULL-terminated string array containing
1224 * the artists. The array is owned by the about dialog
1225 * and must not be modified.
1230 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1232 GtkAboutDialogPrivate *priv;
1234 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1236 priv = (GtkAboutDialogPrivate *)about->private_data;
1238 return priv->artists;
1242 * gtk_about_dialog_set_artists:
1243 * @about: a #GtkAboutDialog
1244 * @artists: a %NULL-terminated array of strings
1246 * Sets the strings which are displayed in the artists tab
1247 * of the secondary credits dialog.
1252 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1255 GtkAboutDialogPrivate *priv;
1258 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1260 priv = (GtkAboutDialogPrivate *)about->private_data;
1262 tmp = priv->artists;
1263 priv->artists = g_strdupv (artists);
1266 if (priv->artists != NULL)
1267 gtk_widget_show (priv->credits_button);
1269 g_object_notify (G_OBJECT (about), "artists");
1273 * gtk_about_dialog_get_translator_credits:
1274 * @about: a #GtkAboutDialog
1276 * Returns the translator credits string which is displayed
1277 * in the translators tab of the secondary credits dialog.
1279 * Return value: The translator credits string. The string is
1280 * owned by the about dialog and must not be modified.
1284 G_CONST_RETURN gchar *
1285 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1287 GtkAboutDialogPrivate *priv;
1289 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1291 priv = (GtkAboutDialogPrivate *)about->private_data;
1293 return priv->translator_credits;
1297 * gtk_about_dialog_set_translator_credits:
1298 * @about: a #GtkAboutDialog
1299 * @translator_credits: the translator credits
1301 * Sets the translator credits string which is displayed in
1302 * the translators tab of the secondary credits dialog.
1304 * The intended use for this string is to display the translator
1305 * of the language which is currently used in the user interface.
1306 * Using gettext(), a simple way to achieve that is to mark the
1307 * string for translation:
1308 * <informalexample><programlisting>
1309 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1310 * </programlisting></informalexample>
1311 * It is a good idea to use the customary msgid "translator-credits" for this
1312 * purpose, since translators will already know the purpose of that msgid, and
1313 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1319 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1320 const gchar *translator_credits)
1322 GtkAboutDialogPrivate *priv;
1325 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1327 priv = (GtkAboutDialogPrivate *)about->private_data;
1329 tmp = priv->translator_credits;
1330 priv->translator_credits = g_strdup (translator_credits);
1333 if (priv->translator_credits != NULL)
1334 gtk_widget_show (priv->credits_button);
1336 g_object_notify (G_OBJECT (about), "translator-credits");
1340 * gtk_about_dialog_get_logo:
1341 * @about: a #GtkAboutDialog
1343 * Returns the pixbuf displayed as logo in the about dialog.
1345 * Return value: the pixbuf displayed as logo. The pixbuf is
1346 * owned by the about dialog. If you want to keep a reference
1347 * to it, you have to call g_object_ref() on it.
1352 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1354 GtkAboutDialogPrivate *priv;
1356 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1358 priv = (GtkAboutDialogPrivate *)about->private_data;
1360 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1361 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1367 icon_set_new_from_pixbufs (GList *pixbufs)
1369 GtkIconSet *icon_set = gtk_icon_set_new ();
1371 for (; pixbufs; pixbufs = pixbufs->next)
1373 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1375 GtkIconSource *icon_source = gtk_icon_source_new ();
1376 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1377 gtk_icon_set_add_source (icon_set, icon_source);
1378 gtk_icon_source_free (icon_source);
1385 * gtk_about_dialog_set_logo:
1386 * @about: a #GtkAboutDialog
1387 * @logo: a #GdkPixbuf, or %NULL
1389 * Sets the pixbuf to be displayed as logo in
1390 * the about dialog. If it is %NULL, the default
1391 * window icon set with gtk_window_set_default_icon ()
1397 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1400 GtkAboutDialogPrivate *priv;
1402 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1404 priv = (GtkAboutDialogPrivate *)about->private_data;
1406 g_object_freeze_notify (G_OBJECT (about));
1408 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1409 g_object_notify (G_OBJECT (about), "logo_icon_name");
1412 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1415 GList *pixbufs = gtk_window_get_default_icon_list ();
1417 if (pixbufs != NULL)
1419 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1421 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1422 icon_set, GTK_ICON_SIZE_DIALOG);
1424 gtk_icon_set_unref (icon_set);
1425 g_list_free (pixbufs);
1429 g_object_notify (G_OBJECT (about), "logo");
1431 g_object_thaw_notify (G_OBJECT (about));
1435 * gtk_about_dialog_get_logo_icon_name:
1436 * @about: a #GtkAboutDialog
1438 * Returns the icon name displayed as logo in the about dialog.
1440 * Return value: the icon name displayed as logo. The string is
1441 * owned by the about dialog. If you want to keep a reference
1442 * to it, you have to call g_strdup() on it.
1446 G_CONST_RETURN gchar *
1447 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1449 GtkAboutDialogPrivate *priv;
1450 const gchar *icon_name;
1452 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1454 priv = (GtkAboutDialogPrivate *)about->private_data;
1456 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1457 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1463 * gtk_about_dialog_set_logo_icon_name:
1464 * @about: a #GtkAboutDialog
1465 * @icon_name: an icon name, or %NULL
1467 * Sets the pixbuf to be displayed as logo in
1468 * the about dialog. If it is %NULL, the default
1469 * window icon set with gtk_window_set_default_icon()
1475 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1476 const gchar *icon_name)
1478 GtkAboutDialogPrivate *priv;
1480 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1482 priv = (GtkAboutDialogPrivate *)about->private_data;
1484 g_object_freeze_notify (G_OBJECT (about));
1486 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1487 g_object_notify (G_OBJECT (about), "logo");
1489 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1490 GTK_ICON_SIZE_DIALOG);
1491 g_object_notify (G_OBJECT (about), "logo_icon_name");
1493 g_object_thaw_notify (G_OBJECT (about));
1497 activate_url (GtkWidget *widget,
1500 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1501 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1503 if (activate_url_hook != NULL)
1504 (* activate_url_hook) (about, url, activate_url_hook_data);
1508 set_link_button_text (GtkWidget *about,
1514 GdkColor *style_link_color;
1515 GdkColor link_color = { 0, 0, 0, 0xffff };
1517 gtk_widget_ensure_style (about);
1518 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1519 if (style_link_color)
1521 link_color = *style_link_color;
1522 gdk_color_free (style_link_color);
1525 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1526 link_color.red, link_color.green, link_color.blue, text);
1528 label = gtk_bin_get_child (GTK_BIN (button));
1529 gtk_label_set_markup (GTK_LABEL (label), link);
1534 create_link_button (GtkWidget *about,
1542 button = gtk_button_new_with_label ("");
1543 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1544 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1546 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1547 set_link_button_text (about, button, text);
1549 g_signal_connect (G_OBJECT (button), "clicked", callback, data);
1555 follow_if_link (GtkAboutDialog *about,
1558 GSList *tags = NULL, *tagp = NULL;
1560 tags = gtk_text_iter_get_tags (iter);
1561 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1563 GtkTextTag *tag = tagp->data;
1564 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1565 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1567 if (email != NULL && activate_email_hook != NULL)
1569 (* activate_email_hook) (about, email, activate_email_hook_data);
1573 if (url != NULL && activate_url_hook != NULL)
1575 (* activate_url_hook) (about, url, activate_url_hook_data);
1581 g_slist_free (tags);
1585 credits_key_press_event (GtkWidget *text_view,
1587 GtkAboutDialog *about)
1590 GtkTextBuffer *buffer;
1592 switch (event->keyval)
1596 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1597 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1598 gtk_text_buffer_get_insert (buffer));
1599 follow_if_link (about, &iter);
1610 credits_event_after (GtkWidget *text_view,
1612 GtkAboutDialog *about)
1614 GtkTextIter start, end, iter;
1615 GtkTextBuffer *buffer;
1616 GdkEventButton *button_event;
1619 if (event->type != GDK_BUTTON_RELEASE)
1622 button_event = (GdkEventButton *)event;
1624 if (button_event->button != 1)
1627 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1629 /* we shouldn't follow a link if the user has selected something */
1630 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1631 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1634 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1635 GTK_TEXT_WINDOW_WIDGET,
1636 button_event->x, button_event->y, &x, &y);
1638 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1640 follow_if_link (about, &iter);
1646 set_cursor_if_appropriate (GtkAboutDialog *about,
1647 GtkTextView *text_view,
1651 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1652 GSList *tags = NULL, *tagp = NULL;
1653 GtkTextBuffer *buffer;
1655 gboolean hovering_over_link = FALSE;
1657 buffer = gtk_text_view_get_buffer (text_view);
1659 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1661 tags = gtk_text_iter_get_tags (&iter);
1662 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1664 GtkTextTag *tag = tagp->data;
1665 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1666 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1668 if (email != NULL || url != NULL)
1670 hovering_over_link = TRUE;
1675 if (hovering_over_link != priv->hovering_over_link)
1677 priv->hovering_over_link = hovering_over_link;
1679 if (hovering_over_link)
1680 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1682 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1686 g_slist_free (tags);
1690 credits_motion_notify_event (GtkWidget *text_view,
1691 GdkEventMotion *event,
1692 GtkAboutDialog *about)
1696 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1697 GTK_TEXT_WINDOW_WIDGET,
1698 event->x, event->y, &x, &y);
1700 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1702 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1709 credits_visibility_notify_event (GtkWidget *text_view,
1710 GdkEventVisibility *event,
1711 GtkAboutDialog *about)
1713 gint wx, wy, bx, by;
1715 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1717 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1718 GTK_TEXT_WINDOW_WIDGET,
1721 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1727 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1729 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1730 &widget->style->bg[GTK_STATE_NORMAL]);
1734 add_credits_page (GtkAboutDialog *about,
1735 GtkWidget *notebook,
1740 gchar *q0, *q1, *q2, *r1, *r2;
1741 GtkWidget *sw, *view;
1742 GtkTextBuffer *buffer;
1743 gboolean linkify_email, linkify_urls;
1744 GdkColor *style_link_color;
1745 GdkColor link_color = { 0, 0, 0, 0xffff };
1747 linkify_email = (activate_email_hook != NULL);
1748 linkify_urls = (activate_url_hook != NULL);
1750 gtk_widget_ensure_style (GTK_WIDGET (about));
1751 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1752 if (style_link_color)
1754 link_color = *style_link_color;
1755 gdk_color_free (style_link_color);
1758 view = gtk_text_view_new ();
1759 g_signal_connect (about, "style_set",
1760 G_CALLBACK (text_view_style_set), view);
1762 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1763 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1764 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1765 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1766 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1768 g_signal_connect (G_OBJECT (view), "key-press-event",
1769 G_CALLBACK (credits_key_press_event), about);
1770 g_signal_connect (G_OBJECT (view), "event-after",
1771 G_CALLBACK (credits_event_after), about);
1772 g_signal_connect (G_OBJECT (view), "motion-notify-event",
1773 G_CALLBACK (credits_motion_notify_event), about);
1774 g_signal_connect (G_OBJECT (view), "visibility-notify-event",
1775 G_CALLBACK (credits_visibility_notify_event), about);
1777 sw = gtk_scrolled_window_new (NULL, NULL);
1778 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1779 GTK_POLICY_AUTOMATIC,
1780 GTK_POLICY_AUTOMATIC);
1781 gtk_container_add (GTK_CONTAINER (sw), view);
1783 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1784 sw, gtk_label_new (title));
1788 gtk_widget_hide (view);
1792 gtk_widget_show (view);
1794 for (p = people; *p; p++)
1799 q1 = linkify_email ? strchr (q0, '<') : NULL;
1800 q2 = q1 ? strchr (q1, '>') : NULL;
1801 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1804 r2 = strpbrk (r1, " \n\t");
1806 r2 = strchr (r1, '\0');
1811 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1824 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1825 gtk_text_buffer_get_end_iter (buffer, &end);
1833 link_type = "email";
1838 link = g_strndup (q1, q2 - q1);
1839 tag = gtk_text_buffer_create_tag (buffer, NULL,
1840 "foreground_gdk", &link_color,
1841 "underline", PANGO_UNDERLINE_SINGLE,
1843 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1844 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1850 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1856 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1861 display_credits_dialog (GtkWidget *button,
1864 GtkAboutDialog *about = (GtkAboutDialog *)data;
1865 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1866 GtkWidget *dialog, *notebook;
1868 if (priv->credits_dialog != NULL)
1870 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1874 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1876 GTK_DIALOG_DESTROY_WITH_PARENT,
1877 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1879 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1881 priv->credits_dialog = dialog;
1882 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1883 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1885 gtk_window_set_modal (GTK_WINDOW (dialog),
1886 gtk_window_get_modal (GTK_WINDOW (about)));
1888 g_signal_connect (dialog, "response",
1889 G_CALLBACK (gtk_widget_destroy), dialog);
1890 g_signal_connect (dialog, "destroy",
1891 G_CALLBACK (gtk_widget_destroyed),
1892 &(priv->credits_dialog));
1894 notebook = gtk_notebook_new ();
1895 gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
1896 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1898 if (priv->authors != NULL)
1899 add_credits_page (about, notebook, _("Written by"), priv->authors);
1901 if (priv->documenters != NULL)
1902 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1904 /* Don't show an untranslated gettext msgid */
1905 if (priv->translator_credits != NULL &&
1906 strcmp (priv->translator_credits, "translator_credits") &&
1907 strcmp (priv->translator_credits, "translator-credits"))
1909 gchar *translators[2];
1911 translators[0] = priv->translator_credits;
1912 translators[1] = NULL;
1914 add_credits_page (about, notebook, _("Translated by"), translators);
1917 if (priv->artists != NULL)
1918 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1920 gtk_widget_show_all (dialog);
1924 display_license_dialog (GtkWidget *button,
1927 GtkAboutDialog *about = (GtkAboutDialog *)data;
1928 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1929 GtkWidget *dialog, *view, *sw;
1931 if (priv->license_dialog != NULL)
1933 gtk_window_present (GTK_WINDOW (priv->license_dialog));
1937 dialog = gtk_dialog_new_with_buttons (_("License"),
1939 GTK_DIALOG_DESTROY_WITH_PARENT,
1940 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1942 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1943 priv->license_dialog = dialog;
1944 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
1945 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1947 gtk_window_set_modal (GTK_WINDOW (dialog),
1948 gtk_window_get_modal (GTK_WINDOW (about)));
1950 g_signal_connect (dialog, "response",
1951 G_CALLBACK (gtk_widget_destroy), dialog);
1952 g_signal_connect (dialog, "destroy",
1953 G_CALLBACK (gtk_widget_destroyed),
1954 &(priv->license_dialog));
1956 sw = gtk_scrolled_window_new (NULL, NULL);
1957 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1959 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1960 GTK_POLICY_AUTOMATIC,
1961 GTK_POLICY_AUTOMATIC);
1962 gtk_container_set_border_width (GTK_CONTAINER (sw), 8);
1963 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
1965 view = gtk_text_view_new ();
1966 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
1969 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1970 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1971 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1972 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1974 gtk_container_add (GTK_CONTAINER (sw), view);
1976 gtk_widget_show_all (dialog);
1980 close_cb (GtkAboutDialog *about)
1982 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1984 if (priv->license_dialog != NULL)
1986 gtk_widget_destroy (priv->license_dialog);
1987 priv->license_dialog = NULL;
1990 if (priv->credits_dialog != NULL)
1992 gtk_widget_destroy (priv->credits_dialog);
1993 priv->credits_dialog = NULL;
1996 gtk_widget_hide (GTK_WIDGET (about));
2001 * gtk_about_dialog_new:
2003 * Creates a new #GtkAboutDialog.
2005 * Returns: a newly created #GtkAboutDialog
2010 gtk_about_dialog_new (void)
2012 GtkAboutDialog *dialog = GTK_ABOUT_DIALOG (g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL));
2014 /* force defaults */
2015 gtk_about_dialog_set_name (dialog, NULL);
2016 gtk_about_dialog_set_logo (dialog, NULL);
2018 /* Close dialog on user response */
2019 g_signal_connect (G_OBJECT (dialog),
2021 G_CALLBACK (close_cb),
2024 return GTK_WIDGET (dialog);
2028 * gtk_about_dialog_set_email_hook:
2029 * @func: a function to call when an email link is activated.
2030 * @data: data to pass to @func
2031 * @destroy: #GDestroyNotify for @data
2033 * Installs a global function to be called whenever the user activates an
2034 * email link in an about dialog.
2036 * Return value: the previous email hook.
2040 GtkAboutDialogActivateLinkFunc
2041 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2043 GDestroyNotify destroy)
2045 GtkAboutDialogActivateLinkFunc old;
2047 if (activate_email_hook_destroy != NULL)
2048 (* activate_email_hook_destroy) (activate_url_hook_data);
2050 old = activate_email_hook;
2052 activate_email_hook = func;
2053 activate_email_hook_data = data;
2054 activate_email_hook_destroy = destroy;
2060 * gtk_about_dialog_set_url_hook:
2061 * @func: a function to call when a URL link is activated.
2062 * @data: data to pass to @func
2063 * @destroy: #GDestroyNotify for @data
2065 * Installs a global function to be called whenever the user activates a
2066 * URL link in an about dialog.
2068 * Return value: the previous URL hook.
2072 GtkAboutDialogActivateLinkFunc
2073 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2075 GDestroyNotify destroy)
2077 GtkAboutDialogActivateLinkFunc old;
2079 if (activate_url_hook_destroy != NULL)
2080 (* activate_url_hook_destroy) (activate_email_hook_data);
2082 old = activate_url_hook;
2084 activate_url_hook = func;
2085 activate_url_hook_data = data;
2086 activate_url_hook_destroy = destroy;
2092 * gtk_show_about_dialog:
2093 * @parent: transient parent, or %NULL for none
2094 * @first_property_name: the name of the first property
2095 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2097 * This is a convenience function for showing an application's about box.
2098 * The constructed dialog is associated with the parent window and
2099 * reused for future invocations of this function.
2104 gtk_show_about_dialog (GtkWindow *parent,
2105 const gchar *first_property_name,
2108 static GtkWidget *global_about_dialog = NULL;
2109 GtkWidget *dialog = NULL;
2113 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2115 dialog = global_about_dialog;
2119 dialog = gtk_about_dialog_new ();
2121 g_object_ref (G_OBJECT (dialog));
2122 gtk_object_sink (GTK_OBJECT (dialog));
2124 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2126 va_start (var_args, first_property_name);
2127 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2132 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2133 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2134 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
2135 dialog, g_object_unref);
2138 global_about_dialog = dialog;
2142 gtk_window_present (GTK_WINDOW (dialog));