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, (const gchar**)g_value_get_boxed (value));
565 case PROP_DOCUMENTERS:
566 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
569 gtk_about_dialog_set_artists (about, (const 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);
1032 gtk_widget_hide (priv->website_button);
1036 g_object_notify (G_OBJECT (about), "website");
1040 * gtk_about_dialog_get_website_label:
1041 * @about: a #GtkAboutDialog
1043 * Returns the label used for the website link.
1045 * Return value: The label used for the website link. The string is owned by the about
1046 * dialog and must not be modified.
1050 G_CONST_RETURN gchar *
1051 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1053 GtkAboutDialogPrivate *priv;
1055 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1057 priv = (GtkAboutDialogPrivate *)about->private_data;
1059 return priv->website_label;
1063 * gtk_about_dialog_set_website_label:
1064 * @about: a #GtkAboutDialog
1065 * @website_label: the label used for the website link
1067 * Sets the label to be used for the website link.
1068 * It defaults to the website URL.
1073 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1074 const gchar *website_label)
1076 GtkAboutDialogPrivate *priv;
1079 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1081 priv = (GtkAboutDialogPrivate *)about->private_data;
1083 tmp = priv->website_label;
1084 if (activate_url_hook != NULL)
1086 if (website_label != NULL)
1088 priv->website_label = g_strdup (website_label);
1089 set_link_button_text (GTK_WIDGET (about),
1090 priv->website_button,
1091 priv->website_label);
1092 gtk_widget_show (priv->website_button);
1096 priv->website_label = NULL;
1097 gtk_widget_hide (priv->website_button);
1102 g_object_notify (G_OBJECT (about), "website_label");
1106 * gtk_about_dialog_get_authors:
1107 * @about: a #GtkAboutDialog
1109 * Returns the string which are displayed in the authors tab
1110 * of the secondary credits dialog.
1112 * Return value: A %NULL-terminated string array containing
1113 * the authors. The array is owned by the about dialog
1114 * and must not be modified.
1118 G_CONST_RETURN gchar * G_CONST_RETURN *
1119 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1121 GtkAboutDialogPrivate *priv;
1123 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1125 priv = (GtkAboutDialogPrivate *)about->private_data;
1127 return (const gchar * const *) priv->authors;
1131 * gtk_about_dialog_set_authors:
1132 * @about: a #GtkAboutDialog
1133 * @authors: a %NULL-terminated array of strings
1135 * Sets the strings which are displayed in the authors tab
1136 * of the secondary credits dialog.
1141 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1142 const gchar **authors)
1144 GtkAboutDialogPrivate *priv;
1147 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1149 priv = (GtkAboutDialogPrivate *)about->private_data;
1151 tmp = priv->authors;
1152 priv->authors = g_strdupv ((gchar **)authors);
1155 if (priv->authors != NULL)
1156 gtk_widget_show (priv->credits_button);
1158 g_object_notify (G_OBJECT (about), "authors");
1162 * gtk_about_dialog_get_documenters:
1163 * @about: a #GtkAboutDialog
1165 * Returns the string which are displayed in the documenters
1166 * tab of the secondary credits dialog.
1168 * Return value: A %NULL-terminated string array containing
1169 * the documenters. The array is owned by the about dialog
1170 * and must not be modified.
1174 G_CONST_RETURN gchar * G_CONST_RETURN *
1175 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1177 GtkAboutDialogPrivate *priv;
1179 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1181 priv = (GtkAboutDialogPrivate *)about->private_data;
1183 return (const gchar * const *)priv->documenters;
1187 * gtk_about_dialog_set_documenters:
1188 * @about: a #GtkAboutDialog
1189 * @documenters: a %NULL-terminated array of strings
1191 * Sets the strings which are displayed in the documenters tab
1192 * of the secondary credits dialog.
1197 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1198 const gchar **documenters)
1200 GtkAboutDialogPrivate *priv;
1203 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1205 priv = (GtkAboutDialogPrivate *)about->private_data;
1207 tmp = priv->documenters;
1208 priv->documenters = g_strdupv ((gchar **)documenters);
1211 if (priv->documenters != NULL)
1212 gtk_widget_show (priv->credits_button);
1214 g_object_notify (G_OBJECT (about), "documenters");
1218 * gtk_about_dialog_get_artists:
1219 * @about: a #GtkAboutDialog
1221 * Returns the string which are displayed in the artists tab
1222 * of the secondary credits dialog.
1224 * Return value: A %NULL-terminated string array containing
1225 * the artists. The array is owned by the about dialog
1226 * and must not be modified.
1230 G_CONST_RETURN gchar * G_CONST_RETURN *
1231 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1233 GtkAboutDialogPrivate *priv;
1235 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1237 priv = (GtkAboutDialogPrivate *)about->private_data;
1239 return (const gchar * const *)priv->artists;
1243 * gtk_about_dialog_set_artists:
1244 * @about: a #GtkAboutDialog
1245 * @artists: a %NULL-terminated array of strings
1247 * Sets the strings which are displayed in the artists tab
1248 * of the secondary credits dialog.
1253 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1254 const gchar **artists)
1256 GtkAboutDialogPrivate *priv;
1259 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1261 priv = (GtkAboutDialogPrivate *)about->private_data;
1263 tmp = priv->artists;
1264 priv->artists = g_strdupv ((gchar **)artists);
1267 if (priv->artists != NULL)
1268 gtk_widget_show (priv->credits_button);
1270 g_object_notify (G_OBJECT (about), "artists");
1274 * gtk_about_dialog_get_translator_credits:
1275 * @about: a #GtkAboutDialog
1277 * Returns the translator credits string which is displayed
1278 * in the translators tab of the secondary credits dialog.
1280 * Return value: The translator credits string. The string is
1281 * owned by the about dialog and must not be modified.
1285 G_CONST_RETURN gchar *
1286 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1288 GtkAboutDialogPrivate *priv;
1290 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1292 priv = (GtkAboutDialogPrivate *)about->private_data;
1294 return priv->translator_credits;
1298 * gtk_about_dialog_set_translator_credits:
1299 * @about: a #GtkAboutDialog
1300 * @translator_credits: the translator credits
1302 * Sets the translator credits string which is displayed in
1303 * the translators tab of the secondary credits dialog.
1305 * The intended use for this string is to display the translator
1306 * of the language which is currently used in the user interface.
1307 * Using gettext(), a simple way to achieve that is to mark the
1308 * string for translation:
1309 * <informalexample><programlisting>
1310 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1311 * </programlisting></informalexample>
1312 * It is a good idea to use the customary msgid "translator-credits" for this
1313 * purpose, since translators will already know the purpose of that msgid, and
1314 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1320 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1321 const gchar *translator_credits)
1323 GtkAboutDialogPrivate *priv;
1326 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1328 priv = (GtkAboutDialogPrivate *)about->private_data;
1330 tmp = priv->translator_credits;
1331 priv->translator_credits = g_strdup (translator_credits);
1334 if (priv->translator_credits != NULL)
1335 gtk_widget_show (priv->credits_button);
1337 g_object_notify (G_OBJECT (about), "translator-credits");
1341 * gtk_about_dialog_get_logo:
1342 * @about: a #GtkAboutDialog
1344 * Returns the pixbuf displayed as logo in the about dialog.
1346 * Return value: the pixbuf displayed as logo. The pixbuf is
1347 * owned by the about dialog. If you want to keep a reference
1348 * to it, you have to call g_object_ref() on it.
1353 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1355 GtkAboutDialogPrivate *priv;
1357 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1359 priv = (GtkAboutDialogPrivate *)about->private_data;
1361 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1362 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1368 icon_set_new_from_pixbufs (GList *pixbufs)
1370 GtkIconSet *icon_set = gtk_icon_set_new ();
1372 for (; pixbufs; pixbufs = pixbufs->next)
1374 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1376 GtkIconSource *icon_source = gtk_icon_source_new ();
1377 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1378 gtk_icon_set_add_source (icon_set, icon_source);
1379 gtk_icon_source_free (icon_source);
1386 * gtk_about_dialog_set_logo:
1387 * @about: a #GtkAboutDialog
1388 * @logo: a #GdkPixbuf, or %NULL
1390 * Sets the pixbuf to be displayed as logo in
1391 * the about dialog. If it is %NULL, the default
1392 * window icon set with gtk_window_set_default_icon ()
1398 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1401 GtkAboutDialogPrivate *priv;
1403 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1405 priv = (GtkAboutDialogPrivate *)about->private_data;
1407 g_object_freeze_notify (G_OBJECT (about));
1409 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1410 g_object_notify (G_OBJECT (about), "logo_icon_name");
1413 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1416 GList *pixbufs = gtk_window_get_default_icon_list ();
1418 if (pixbufs != NULL)
1420 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1422 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1423 icon_set, GTK_ICON_SIZE_DIALOG);
1425 gtk_icon_set_unref (icon_set);
1426 g_list_free (pixbufs);
1430 g_object_notify (G_OBJECT (about), "logo");
1432 g_object_thaw_notify (G_OBJECT (about));
1436 * gtk_about_dialog_get_logo_icon_name:
1437 * @about: a #GtkAboutDialog
1439 * Returns the icon name displayed as logo in the about dialog.
1441 * Return value: the icon name displayed as logo. The string is
1442 * owned by the about dialog. If you want to keep a reference
1443 * to it, you have to call g_strdup() on it.
1447 G_CONST_RETURN gchar *
1448 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1450 GtkAboutDialogPrivate *priv;
1451 const gchar *icon_name;
1453 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1455 priv = (GtkAboutDialogPrivate *)about->private_data;
1457 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1458 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1464 * gtk_about_dialog_set_logo_icon_name:
1465 * @about: a #GtkAboutDialog
1466 * @icon_name: an icon name, or %NULL
1468 * Sets the pixbuf to be displayed as logo in
1469 * the about dialog. If it is %NULL, the default
1470 * window icon set with gtk_window_set_default_icon()
1476 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1477 const gchar *icon_name)
1479 GtkAboutDialogPrivate *priv;
1481 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1483 priv = (GtkAboutDialogPrivate *)about->private_data;
1485 g_object_freeze_notify (G_OBJECT (about));
1487 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1488 g_object_notify (G_OBJECT (about), "logo");
1490 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1491 GTK_ICON_SIZE_DIALOG);
1492 g_object_notify (G_OBJECT (about), "logo_icon_name");
1494 g_object_thaw_notify (G_OBJECT (about));
1498 activate_url (GtkWidget *widget,
1501 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1502 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1504 if (activate_url_hook != NULL)
1505 (* activate_url_hook) (about, url, activate_url_hook_data);
1509 set_link_button_text (GtkWidget *about,
1515 GdkColor *style_link_color;
1516 GdkColor link_color = { 0, 0, 0, 0xffff };
1518 gtk_widget_ensure_style (about);
1519 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1520 if (style_link_color)
1522 link_color = *style_link_color;
1523 gdk_color_free (style_link_color);
1526 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1527 link_color.red, link_color.green, link_color.blue, text);
1529 label = gtk_bin_get_child (GTK_BIN (button));
1530 gtk_label_set_markup (GTK_LABEL (label), link);
1535 create_link_button (GtkWidget *about,
1543 button = gtk_button_new_with_label ("");
1544 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1545 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1547 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1548 set_link_button_text (about, button, text);
1550 g_signal_connect (G_OBJECT (button), "clicked", callback, data);
1556 follow_if_link (GtkAboutDialog *about,
1559 GSList *tags = NULL, *tagp = NULL;
1561 tags = gtk_text_iter_get_tags (iter);
1562 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1564 GtkTextTag *tag = tagp->data;
1565 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1566 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1568 if (email != NULL && activate_email_hook != NULL)
1570 (* activate_email_hook) (about, email, activate_email_hook_data);
1574 if (url != NULL && activate_url_hook != NULL)
1576 (* activate_url_hook) (about, url, activate_url_hook_data);
1582 g_slist_free (tags);
1586 credits_key_press_event (GtkWidget *text_view,
1588 GtkAboutDialog *about)
1591 GtkTextBuffer *buffer;
1593 switch (event->keyval)
1597 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1598 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1599 gtk_text_buffer_get_insert (buffer));
1600 follow_if_link (about, &iter);
1611 credits_event_after (GtkWidget *text_view,
1613 GtkAboutDialog *about)
1615 GtkTextIter start, end, iter;
1616 GtkTextBuffer *buffer;
1617 GdkEventButton *button_event;
1620 if (event->type != GDK_BUTTON_RELEASE)
1623 button_event = (GdkEventButton *)event;
1625 if (button_event->button != 1)
1628 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1630 /* we shouldn't follow a link if the user has selected something */
1631 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1632 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1635 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1636 GTK_TEXT_WINDOW_WIDGET,
1637 button_event->x, button_event->y, &x, &y);
1639 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1641 follow_if_link (about, &iter);
1647 set_cursor_if_appropriate (GtkAboutDialog *about,
1648 GtkTextView *text_view,
1652 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1653 GSList *tags = NULL, *tagp = NULL;
1654 GtkTextBuffer *buffer;
1656 gboolean hovering_over_link = FALSE;
1658 buffer = gtk_text_view_get_buffer (text_view);
1660 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1662 tags = gtk_text_iter_get_tags (&iter);
1663 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1665 GtkTextTag *tag = tagp->data;
1666 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1667 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1669 if (email != NULL || url != NULL)
1671 hovering_over_link = TRUE;
1676 if (hovering_over_link != priv->hovering_over_link)
1678 priv->hovering_over_link = hovering_over_link;
1680 if (hovering_over_link)
1681 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1683 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1687 g_slist_free (tags);
1691 credits_motion_notify_event (GtkWidget *text_view,
1692 GdkEventMotion *event,
1693 GtkAboutDialog *about)
1697 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1698 GTK_TEXT_WINDOW_WIDGET,
1699 event->x, event->y, &x, &y);
1701 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1703 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1710 credits_visibility_notify_event (GtkWidget *text_view,
1711 GdkEventVisibility *event,
1712 GtkAboutDialog *about)
1714 gint wx, wy, bx, by;
1716 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1718 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1719 GTK_TEXT_WINDOW_WIDGET,
1722 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1728 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1730 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1731 &widget->style->bg[GTK_STATE_NORMAL]);
1735 add_credits_page (GtkAboutDialog *about,
1736 GtkWidget *notebook,
1741 gchar *q0, *q1, *q2, *r1, *r2;
1742 GtkWidget *sw, *view;
1743 GtkTextBuffer *buffer;
1744 gboolean linkify_email, linkify_urls;
1745 GdkColor *style_link_color;
1746 GdkColor link_color = { 0, 0, 0, 0xffff };
1748 linkify_email = (activate_email_hook != NULL);
1749 linkify_urls = (activate_url_hook != NULL);
1751 gtk_widget_ensure_style (GTK_WIDGET (about));
1752 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1753 if (style_link_color)
1755 link_color = *style_link_color;
1756 gdk_color_free (style_link_color);
1759 view = gtk_text_view_new ();
1760 g_signal_connect (about, "style_set",
1761 G_CALLBACK (text_view_style_set), view);
1763 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1764 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1765 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1766 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1767 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1769 g_signal_connect (G_OBJECT (view), "key-press-event",
1770 G_CALLBACK (credits_key_press_event), about);
1771 g_signal_connect (G_OBJECT (view), "event-after",
1772 G_CALLBACK (credits_event_after), about);
1773 g_signal_connect (G_OBJECT (view), "motion-notify-event",
1774 G_CALLBACK (credits_motion_notify_event), about);
1775 g_signal_connect (G_OBJECT (view), "visibility-notify-event",
1776 G_CALLBACK (credits_visibility_notify_event), about);
1778 sw = gtk_scrolled_window_new (NULL, NULL);
1779 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1780 GTK_POLICY_AUTOMATIC,
1781 GTK_POLICY_AUTOMATIC);
1782 gtk_container_add (GTK_CONTAINER (sw), view);
1784 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1785 sw, gtk_label_new (title));
1789 gtk_widget_hide (view);
1793 gtk_widget_show (view);
1795 for (p = people; *p; p++)
1800 q1 = linkify_email ? strchr (q0, '<') : NULL;
1801 q2 = q1 ? strchr (q1, '>') : NULL;
1802 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1805 r2 = strpbrk (r1, " \n\t");
1807 r2 = strchr (r1, '\0');
1812 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1825 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1826 gtk_text_buffer_get_end_iter (buffer, &end);
1834 link_type = "email";
1839 link = g_strndup (q1, q2 - q1);
1840 tag = gtk_text_buffer_create_tag (buffer, NULL,
1841 "foreground_gdk", &link_color,
1842 "underline", PANGO_UNDERLINE_SINGLE,
1844 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1845 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1851 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1857 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1862 display_credits_dialog (GtkWidget *button,
1865 GtkAboutDialog *about = (GtkAboutDialog *)data;
1866 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1867 GtkWidget *dialog, *notebook;
1869 if (priv->credits_dialog != NULL)
1871 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1875 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1877 GTK_DIALOG_DESTROY_WITH_PARENT,
1878 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1880 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1882 priv->credits_dialog = dialog;
1883 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1884 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1886 gtk_window_set_modal (GTK_WINDOW (dialog),
1887 gtk_window_get_modal (GTK_WINDOW (about)));
1889 g_signal_connect (dialog, "response",
1890 G_CALLBACK (gtk_widget_destroy), dialog);
1891 g_signal_connect (dialog, "destroy",
1892 G_CALLBACK (gtk_widget_destroyed),
1893 &(priv->credits_dialog));
1895 notebook = gtk_notebook_new ();
1896 gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
1897 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1899 if (priv->authors != NULL)
1900 add_credits_page (about, notebook, _("Written by"), priv->authors);
1902 if (priv->documenters != NULL)
1903 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1905 /* Don't show an untranslated gettext msgid */
1906 if (priv->translator_credits != NULL &&
1907 strcmp (priv->translator_credits, "translator_credits") &&
1908 strcmp (priv->translator_credits, "translator-credits"))
1910 gchar *translators[2];
1912 translators[0] = priv->translator_credits;
1913 translators[1] = NULL;
1915 add_credits_page (about, notebook, _("Translated by"), translators);
1918 if (priv->artists != NULL)
1919 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1921 gtk_widget_show_all (dialog);
1925 display_license_dialog (GtkWidget *button,
1928 GtkAboutDialog *about = (GtkAboutDialog *)data;
1929 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1930 GtkWidget *dialog, *view, *sw;
1932 if (priv->license_dialog != NULL)
1934 gtk_window_present (GTK_WINDOW (priv->license_dialog));
1938 dialog = gtk_dialog_new_with_buttons (_("License"),
1940 GTK_DIALOG_DESTROY_WITH_PARENT,
1941 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1943 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1944 priv->license_dialog = dialog;
1945 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
1946 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1948 gtk_window_set_modal (GTK_WINDOW (dialog),
1949 gtk_window_get_modal (GTK_WINDOW (about)));
1951 g_signal_connect (dialog, "response",
1952 G_CALLBACK (gtk_widget_destroy), dialog);
1953 g_signal_connect (dialog, "destroy",
1954 G_CALLBACK (gtk_widget_destroyed),
1955 &(priv->license_dialog));
1957 sw = gtk_scrolled_window_new (NULL, NULL);
1958 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1960 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1961 GTK_POLICY_AUTOMATIC,
1962 GTK_POLICY_AUTOMATIC);
1963 gtk_container_set_border_width (GTK_CONTAINER (sw), 8);
1964 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
1966 view = gtk_text_view_new ();
1967 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
1970 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1971 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1972 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1973 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1975 gtk_container_add (GTK_CONTAINER (sw), view);
1977 gtk_widget_show_all (dialog);
1981 close_cb (GtkAboutDialog *about)
1983 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1985 if (priv->license_dialog != NULL)
1987 gtk_widget_destroy (priv->license_dialog);
1988 priv->license_dialog = NULL;
1991 if (priv->credits_dialog != NULL)
1993 gtk_widget_destroy (priv->credits_dialog);
1994 priv->credits_dialog = NULL;
1997 gtk_widget_hide (GTK_WIDGET (about));
2002 * gtk_about_dialog_new:
2004 * Creates a new #GtkAboutDialog.
2006 * Returns: a newly created #GtkAboutDialog
2011 gtk_about_dialog_new (void)
2013 GtkAboutDialog *dialog = GTK_ABOUT_DIALOG (g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL));
2015 /* force defaults */
2016 gtk_about_dialog_set_name (dialog, NULL);
2017 gtk_about_dialog_set_logo (dialog, NULL);
2019 /* Close dialog on user response */
2020 g_signal_connect (G_OBJECT (dialog),
2022 G_CALLBACK (close_cb),
2025 return GTK_WIDGET (dialog);
2029 * gtk_about_dialog_set_email_hook:
2030 * @func: a function to call when an email link is activated.
2031 * @data: data to pass to @func
2032 * @destroy: #GDestroyNotify for @data
2034 * Installs a global function to be called whenever the user activates an
2035 * email link in an about dialog.
2037 * Return value: the previous email hook.
2041 GtkAboutDialogActivateLinkFunc
2042 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2044 GDestroyNotify destroy)
2046 GtkAboutDialogActivateLinkFunc old;
2048 if (activate_email_hook_destroy != NULL)
2049 (* activate_email_hook_destroy) (activate_url_hook_data);
2051 old = activate_email_hook;
2053 activate_email_hook = func;
2054 activate_email_hook_data = data;
2055 activate_email_hook_destroy = destroy;
2061 * gtk_about_dialog_set_url_hook:
2062 * @func: a function to call when a URL link is activated.
2063 * @data: data to pass to @func
2064 * @destroy: #GDestroyNotify for @data
2066 * Installs a global function to be called whenever the user activates a
2067 * URL link in an about dialog.
2069 * Return value: the previous URL hook.
2073 GtkAboutDialogActivateLinkFunc
2074 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2076 GDestroyNotify destroy)
2078 GtkAboutDialogActivateLinkFunc old;
2080 if (activate_url_hook_destroy != NULL)
2081 (* activate_url_hook_destroy) (activate_email_hook_data);
2083 old = activate_url_hook;
2085 activate_url_hook = func;
2086 activate_url_hook_data = data;
2087 activate_url_hook_destroy = destroy;
2093 * gtk_show_about_dialog:
2094 * @parent: transient parent, or %NULL for none
2095 * @first_property_name: the name of the first property
2096 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2098 * This is a convenience function for showing an application's about box.
2099 * The constructed dialog is associated with the parent window and
2100 * reused for future invocations of this function.
2105 gtk_show_about_dialog (GtkWindow *parent,
2106 const gchar *first_property_name,
2109 static GtkWidget *global_about_dialog = NULL;
2110 GtkWidget *dialog = NULL;
2114 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2116 dialog = global_about_dialog;
2120 dialog = gtk_about_dialog_new ();
2122 g_object_ref (G_OBJECT (dialog));
2123 gtk_object_sink (GTK_OBJECT (dialog));
2125 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2127 va_start (var_args, first_property_name);
2128 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2133 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2134 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2135 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
2136 dialog, g_object_unref);
2139 global_about_dialog = dialog;
2143 gtk_window_present (GTK_WINDOW (dialog));