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>
35 #include "gtkaboutdialog.h"
36 #include "gtkbutton.h"
38 #include "gtkdialog.h"
42 #include "gtklinkbutton.h"
43 #include "gtkmarshalers.h"
44 #include "gtknotebook.h"
45 #include "gtkscrolledwindow.h"
47 #include "gtktextview.h"
49 #include "gtkviewport.h"
50 #include "gtkiconfactory.h"
51 #include "gtkprivate.h"
58 static GdkColor default_link_color = { 0, 0, 0, 0xeeee };
59 static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
61 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
62 struct _GtkAboutDialogPrivate
70 gchar *translator_credits;
77 GtkWidget *logo_image;
78 GtkWidget *name_label;
79 GtkWidget *comments_label;
80 GtkWidget *copyright_label;
81 GtkWidget *website_button;
83 GtkWidget *credits_button;
84 GtkWidget *credits_dialog;
85 GtkWidget *license_button;
86 GtkWidget *license_dialog;
88 GdkCursor *hand_cursor;
89 GdkCursor *regular_cursor;
91 GSList *visited_links;
93 guint hovering_over_link : 1;
94 guint wrap_license : 1;
97 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
112 PROP_TRANSLATOR_CREDITS,
119 static void gtk_about_dialog_finalize (GObject *object);
120 static void gtk_about_dialog_get_property (GObject *object,
124 static void gtk_about_dialog_set_property (GObject *object,
128 static void gtk_about_dialog_style_set (GtkWidget *widget,
129 GtkStyle *previous_style);
130 static void dialog_style_set (GtkWidget *widget,
131 GtkStyle *previous_style,
133 static void update_name_version (GtkAboutDialog *about);
134 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
135 static void activate_url (GtkWidget *widget,
137 static void follow_if_link (GtkAboutDialog *about,
138 GtkTextView *text_view,
140 static void set_cursor_if_appropriate (GtkAboutDialog *about,
141 GtkTextView *text_view,
144 static void add_credits_page (GtkAboutDialog *about,
148 static gboolean credits_key_press_event (GtkWidget *text_view,
150 GtkAboutDialog *about);
151 static gboolean credits_event_after (GtkWidget *text_view,
153 GtkAboutDialog *about);
154 static gboolean credits_motion_notify_event (GtkWidget *text_view,
155 GdkEventMotion *event,
156 GtkAboutDialog *about);
157 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
158 GdkEventVisibility *event,
159 GtkAboutDialog *about);
160 static void display_credits_dialog (GtkWidget *button,
162 static void display_license_dialog (GtkWidget *button,
164 static void close_cb (GtkAboutDialog *about);
167 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
168 static gpointer activate_email_hook_data = NULL;
169 static GDestroyNotify activate_email_hook_destroy = NULL;
171 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
172 static gpointer activate_url_hook_data = NULL;
173 static GDestroyNotify activate_url_hook_destroy = NULL;
175 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
178 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
180 GObjectClass *object_class;
181 GtkWidgetClass *widget_class;
182 GtkDialogClass *dialog_class;
184 object_class = (GObjectClass *)klass;
185 widget_class = (GtkWidgetClass *)klass;
186 dialog_class = (GtkDialogClass *)klass;
188 object_class->set_property = gtk_about_dialog_set_property;
189 object_class->get_property = gtk_about_dialog_get_property;
191 object_class->finalize = gtk_about_dialog_finalize;
193 widget_class->style_set = gtk_about_dialog_style_set;
197 * GtkAboutDialog:name:
199 * The name of the program.
200 * If this is not set, it defaults to g_get_application_name().
204 g_object_class_install_property (object_class,
206 g_param_spec_string ("name",
208 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
210 GTK_PARAM_READWRITE));
213 * GtkAboutDialog:version:
215 * The version of the program.
219 g_object_class_install_property (object_class,
221 g_param_spec_string ("version",
222 P_("Program version"),
223 P_("The version of the program"),
225 GTK_PARAM_READWRITE));
228 * GtkAboutDialog:copyright:
230 * Copyright information for the program.
234 g_object_class_install_property (object_class,
236 g_param_spec_string ("copyright",
237 P_("Copyright string"),
238 P_("Copyright information for the program"),
240 GTK_PARAM_READWRITE));
244 * GtkAboutDialog:comments:
246 * Comments about the program. This string is displayed in a label
247 * in the main dialog, thus it should be a short explanation of
248 * the main purpose of the program, not a detailed list of features.
252 g_object_class_install_property (object_class,
254 g_param_spec_string ("comments",
255 P_("Comments string"),
256 P_("Comments about the program"),
258 GTK_PARAM_READWRITE));
261 * GtkAboutDialog:license:
263 * The license of the program. This string is displayed in a
264 * text view in a secondary dialog, therefore it is fine to use
265 * a long multi-paragraph text. Note that the text is only wrapped
266 * in the text view if the "wrap-license" property is set to %TRUE;
267 * otherwise the text itself must contain the intended linebreaks.
271 g_object_class_install_property (object_class,
273 g_param_spec_string ("license",
275 _("The license of the program"),
277 GTK_PARAM_READWRITE));
280 * GtkAboutDialog:website:
282 * The URL for the link to the website of the program.
283 * This should be a string starting with "http://.
287 g_object_class_install_property (object_class,
289 g_param_spec_string ("website",
291 P_("The URL for the link to the website of the program"),
293 GTK_PARAM_READWRITE));
296 * GtkAboutDialog:website-label:
298 * The label for the link to the website of the program. If this is not set,
299 * it defaults to the URL specified in the
300 * <link linkend="GtkAboutDialog--website">website</link> property.
304 g_object_class_install_property (object_class,
306 g_param_spec_string ("website-label",
308 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
310 GTK_PARAM_READWRITE));
313 * GtkAboutDialog:authors:
315 * The authors of the program, as a %NULL-terminated array of strings.
316 * Each string may contain email addresses and URLs, which will be displayed
317 * as links, see the introduction for more details.
321 g_object_class_install_property (object_class,
323 g_param_spec_boxed ("authors",
325 P_("List of authors of the program"),
327 GTK_PARAM_READWRITE));
330 * GtkAboutDialog:documenters:
332 * The people documenting the program, as a %NULL-terminated array of strings.
333 * Each string may contain email addresses and URLs, which will be displayed
334 * as links, see the introduction for more details.
338 g_object_class_install_property (object_class,
340 g_param_spec_boxed ("documenters",
342 P_("List of people documenting the program"),
344 GTK_PARAM_READWRITE));
347 * GtkAboutDialog:artists:
349 * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
350 * Each string may contain email addresses and URLs, which will be displayed
351 * as links, see the introduction for more details.
355 g_object_class_install_property (object_class,
357 g_param_spec_boxed ("artists",
359 P_("List of people who have contributed artwork to the program"),
361 GTK_PARAM_READWRITE));
365 * GtkAboutDialog:translator-credits:
367 * Credits to the translators. This string should be marked as translatable.
368 * The string may contain email addresses and URLs, which will be displayed
369 * as links, see the introduction for more details.
373 g_object_class_install_property (object_class,
374 PROP_TRANSLATOR_CREDITS,
375 g_param_spec_string ("translator-credits",
376 P_("Translator credits"),
377 P_("Credits to the translators. This string should be marked as translatable"),
379 GTK_PARAM_READWRITE));
382 * GtkAboutDialog:logo:
384 * A logo for the about box. If this is not set, it defaults to
385 * gtk_window_get_default_icon_list().
389 g_object_class_install_property (object_class,
391 g_param_spec_object ("logo",
393 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
395 GTK_PARAM_READWRITE));
398 * GtkAboutDialog:logo-icon-name:
400 * A named icon to use as the logo for the about box. This property
401 * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
405 g_object_class_install_property (object_class,
407 g_param_spec_string ("logo-icon-name",
408 P_("Logo Icon Name"),
409 P_("A named icon to use as the logo for the about box."),
411 GTK_PARAM_READWRITE));
413 * GtkAboutDialog:wrap-license:
415 * Whether to wrap the text in the license dialog.
419 g_object_class_install_property (object_class,
421 g_param_spec_boolean ("wrap-license",
423 P_("Whether to wrap the license text."),
425 GTK_PARAM_READWRITE));
428 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
432 gtk_about_dialog_init (GtkAboutDialog *about)
434 GtkAboutDialogPrivate *priv;
435 GtkWidget *vbox, *hbox, *button, *image;
438 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
439 about->private_data = priv;
442 priv->version = NULL;
443 priv->copyright = NULL;
444 priv->comments = NULL;
445 priv->website = NULL;
446 priv->website_label = NULL;
447 priv->translator_credits = NULL;
448 priv->license = NULL;
449 priv->authors = NULL;
450 priv->documenters = NULL;
451 priv->artists = NULL;
453 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
454 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
455 priv->hovering_over_link = FALSE;
456 priv->wrap_license = FALSE;
458 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
461 gtk_widget_push_composite_child ();
462 vbox = gtk_vbox_new (FALSE, 8);
464 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
466 priv->logo_image = gtk_image_new ();
467 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
469 priv->name_label = gtk_label_new (NULL);
470 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
471 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
472 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
474 priv->comments_label = gtk_label_new (NULL);
475 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
476 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
477 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
478 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
480 priv->copyright_label = gtk_label_new (NULL);
481 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
482 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
483 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
485 button = gtk_link_button_new ("");
486 g_signal_connect (G_OBJECT (button), "clicked",
487 G_CALLBACK (activate_url), about);
489 hbox = gtk_hbox_new (TRUE, 0);
490 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
491 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
492 priv->website_button = button;
494 gtk_widget_show (vbox);
495 gtk_widget_show (priv->logo_image);
496 gtk_widget_show (priv->name_label);
497 gtk_widget_show (hbox);
499 /* Add the OK button */
500 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
501 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
503 /* Add the credits button */
504 button = gtk_button_new_with_mnemonic (_("C_redits"));
505 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
506 gtk_button_set_image (GTK_BUTTON (button), image);
507 gtk_widget_set_no_show_all (button, TRUE);
508 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
509 button, FALSE, TRUE, 0);
510 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
511 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
512 priv->credits_button = button;
513 priv->credits_dialog = NULL;
515 /* Add the license button */
516 button = gtk_button_new_from_stock (_("_License"));
517 gtk_widget_set_no_show_all (button, TRUE);
518 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
519 button, FALSE, TRUE, 0);
520 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
521 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
522 priv->license_button = button;
523 priv->license_dialog = NULL;
525 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
527 gtk_widget_pop_composite_child ();
530 gtk_about_dialog_set_name (about, NULL);
531 gtk_about_dialog_set_logo (about, NULL);
535 gtk_about_dialog_finalize (GObject *object)
537 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
538 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
541 g_free (priv->version);
542 g_free (priv->copyright);
543 g_free (priv->comments);
544 g_free (priv->license);
545 g_free (priv->website);
546 g_free (priv->website_label);
547 g_free (priv->translator_credits);
549 g_strfreev (priv->authors);
550 g_strfreev (priv->documenters);
551 g_strfreev (priv->artists);
553 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
554 g_slist_free (priv->visited_links);
556 gdk_cursor_unref (priv->hand_cursor);
557 gdk_cursor_unref (priv->regular_cursor);
559 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
563 gtk_about_dialog_set_property (GObject *object,
568 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
569 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
574 gtk_about_dialog_set_name (about, g_value_get_string (value));
577 gtk_about_dialog_set_version (about, g_value_get_string (value));
580 gtk_about_dialog_set_comments (about, g_value_get_string (value));
583 gtk_about_dialog_set_website (about, g_value_get_string (value));
585 case PROP_WEBSITE_LABEL:
586 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
589 gtk_about_dialog_set_license (about, g_value_get_string (value));
592 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
595 gtk_about_dialog_set_logo (about, g_value_get_object (value));
598 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
600 case PROP_DOCUMENTERS:
601 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
604 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
606 case PROP_TRANSLATOR_CREDITS:
607 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
609 case PROP_LOGO_ICON_NAME:
610 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
612 case PROP_WRAP_LICENSE:
613 priv->wrap_license = g_value_get_boolean (value);
616 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
622 gtk_about_dialog_get_property (GObject *object,
627 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
628 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
633 g_value_set_string (value, priv->name);
636 g_value_set_string (value, priv->version);
639 g_value_set_string (value, priv->copyright);
642 g_value_set_string (value, priv->comments);
645 g_value_set_string (value, priv->website);
647 case PROP_WEBSITE_LABEL:
648 g_value_set_string (value, priv->website_label);
651 g_value_set_string (value, priv->license);
653 case PROP_TRANSLATOR_CREDITS:
654 g_value_set_string (value, priv->translator_credits);
657 g_value_set_boxed (value, priv->authors);
659 case PROP_DOCUMENTERS:
660 g_value_set_boxed (value, priv->documenters);
663 g_value_set_boxed (value, priv->artists);
666 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
667 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
669 g_value_set_object (value, NULL);
671 case PROP_LOGO_ICON_NAME:
672 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
674 const gchar *icon_name;
676 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
677 g_value_set_string (value, icon_name);
680 g_value_set_string (value, NULL);
682 case PROP_WRAP_LICENSE:
683 g_value_set_boolean (value, priv->wrap_license);
686 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
692 dialog_style_set (GtkWidget *widget,
693 GtkStyle *previous_style,
698 dialog = GTK_DIALOG (widget);
700 /* Override the style properties with HIG-compliant spacings. Ugh.
701 * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
702 * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
705 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
706 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 12);
708 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
709 gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
713 gtk_about_dialog_style_set (GtkWidget *widget,
714 GtkStyle *previous_style)
716 if (GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set)
717 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set (widget, previous_style);
719 dialog_style_set (widget, previous_style, NULL);
723 * gtk_about_dialog_get_name:
724 * @about: a #GtkAboutDialog
726 * Returns the program name displayed in the about dialog.
728 * Return value: The program name. The string is owned by the about
729 * dialog and must not be modified.
733 G_CONST_RETURN gchar *
734 gtk_about_dialog_get_name (GtkAboutDialog *about)
736 GtkAboutDialogPrivate *priv;
738 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
740 priv = (GtkAboutDialogPrivate *)about->private_data;
746 update_name_version (GtkAboutDialog *about)
748 GtkAboutDialogPrivate *priv;
749 gchar *title_string, *name_string;
751 priv = (GtkAboutDialogPrivate *)about->private_data;
753 title_string = g_strdup_printf (_("About %s"), priv->name);
754 gtk_window_set_title (GTK_WINDOW (about), title_string);
755 g_free (title_string);
757 if (priv->version != NULL)
758 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
759 priv->name, priv->version);
761 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
764 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
766 g_free (name_string);
770 * gtk_about_dialog_set_name:
771 * @about: a #GtkAboutDialog
772 * @name: the program name
774 * Sets the name to display in the about dialog.
775 * If this is not set, it defaults to g_get_application_name().
780 gtk_about_dialog_set_name (GtkAboutDialog *about,
783 GtkAboutDialogPrivate *priv;
786 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
788 priv = (GtkAboutDialogPrivate *)about->private_data;
790 priv->name = g_strdup (name ? name : g_get_application_name ());
793 update_name_version (about);
795 g_object_notify (G_OBJECT (about), "name");
799 * gtk_about_dialog_get_version:
800 * @about: a #GtkAboutDialog
802 * Returns the version string.
804 * Return value: The version string. The string is owned by the about
805 * dialog and must not be modified.
809 G_CONST_RETURN gchar *
810 gtk_about_dialog_get_version (GtkAboutDialog *about)
812 GtkAboutDialogPrivate *priv;
814 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
816 priv = (GtkAboutDialogPrivate *)about->private_data;
818 return priv->version;
822 * gtk_about_dialog_set_version:
823 * @about: a #GtkAboutDialog
824 * @version: the version string
826 * Sets the version string to display in the about dialog.
831 gtk_about_dialog_set_version (GtkAboutDialog *about,
832 const gchar *version)
834 GtkAboutDialogPrivate *priv;
837 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
839 priv = (GtkAboutDialogPrivate *)about->private_data;
842 priv->version = version ? g_strdup (version) : NULL;
845 update_name_version (about);
847 g_object_notify (G_OBJECT (about), "version");
851 * gtk_about_dialog_get_copyright:
852 * @about: a #GtkAboutDialog
854 * Returns the copyright string.
856 * Return value: The copyright string. The string is owned by the about
857 * dialog and must not be modified.
861 G_CONST_RETURN gchar *
862 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
864 GtkAboutDialogPrivate *priv;
866 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
868 priv = (GtkAboutDialogPrivate *)about->private_data;
870 return priv->copyright;
874 * gtk_about_dialog_set_copyright:
875 * @about: a #GtkAboutDialog
876 * @copyright: the copyright string
878 * Sets the copyright string to display in the about dialog.
879 * This should be a short string of one or two lines.
884 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
885 const gchar *copyright)
887 GtkAboutDialogPrivate *priv;
888 gchar *copyright_string, *tmp;
890 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
892 priv = (GtkAboutDialogPrivate *)about->private_data;
894 tmp = priv->copyright;
895 priv->copyright = copyright ? g_strdup (copyright) : NULL;
898 if (priv->copyright != NULL)
900 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
902 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
903 g_free (copyright_string);
905 gtk_widget_show (priv->copyright_label);
908 gtk_widget_hide (priv->copyright_label);
910 g_object_notify (G_OBJECT (about), "copyright");
914 * gtk_about_dialog_get_comments:
915 * @about: a #GtkAboutDialog
917 * Returns the comments string.
919 * Return value: The comments. The string is owned by the about
920 * dialog and must not be modified.
924 G_CONST_RETURN gchar *
925 gtk_about_dialog_get_comments (GtkAboutDialog *about)
927 GtkAboutDialogPrivate *priv;
929 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
931 priv = (GtkAboutDialogPrivate *)about->private_data;
933 return priv->comments;
937 * gtk_about_dialog_set_comments:
938 * @about: a #GtkAboutDialog
939 * @comments: a comments string
941 * Sets the comments string to display in the about
942 * dialog. This should be a short string of one or
948 gtk_about_dialog_set_comments (GtkAboutDialog *about,
949 const gchar *comments)
951 GtkAboutDialogPrivate *priv;
954 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
956 priv = (GtkAboutDialogPrivate *)about->private_data;
958 tmp = priv->comments;
961 priv->comments = g_strdup (comments);
962 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
963 gtk_widget_show (priv->comments_label);
967 priv->comments = NULL;
968 gtk_widget_hide (priv->comments_label);
972 g_object_notify (G_OBJECT (about), "comments");
976 * gtk_about_dialog_get_license:
977 * @about: a #GtkAboutDialog
979 * Returns the license information.
981 * Return value: The license information. The string is owned by the about
982 * dialog and must not be modified.
986 G_CONST_RETURN gchar *
987 gtk_about_dialog_get_license (GtkAboutDialog *about)
989 GtkAboutDialogPrivate *priv;
991 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
993 priv = (GtkAboutDialogPrivate *)about->private_data;
995 return priv->license;
999 * gtk_about_dialog_set_license:
1000 * @about: a #GtkAboutDialog
1001 * @license: the license information or %NULL
1003 * Sets the license information to be displayed in the secondary
1004 * license dialog. If @license is %NULL, the license button is
1010 gtk_about_dialog_set_license (GtkAboutDialog *about,
1011 const gchar *license)
1013 GtkAboutDialogPrivate *priv;
1016 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1018 priv = (GtkAboutDialogPrivate *)about->private_data;
1020 tmp = priv->license;
1023 priv->license = g_strdup (license);
1024 gtk_widget_show (priv->license_button);
1028 priv->license = NULL;
1029 gtk_widget_hide (priv->license_button);
1033 g_object_notify (G_OBJECT (about), "license");
1037 * gtk_about_dialog_get_wrap_license:
1038 * @about: a #GtkAboutDialog
1040 * Returns whether the license text in @about is
1041 * automatically wrapped.
1043 * Returns: %TRUE if the license text is wrapped
1048 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1050 GtkAboutDialogPrivate *priv;
1052 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1054 priv = (GtkAboutDialogPrivate *)about->private_data;
1056 return priv->wrap_license;
1060 * gtk_about_dialog_set_wrap_license:
1061 * @about: a #GtkAboutDialog
1062 * @wrap_license: whether to wrap the license
1064 * Sets whether the license text in @about is
1065 * automatically wrapped.
1070 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1071 gboolean wrap_license)
1073 GtkAboutDialogPrivate *priv;
1075 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1077 priv = (GtkAboutDialogPrivate *)about->private_data;
1079 wrap_license = wrap_license != FALSE;
1081 if (priv->wrap_license != wrap_license)
1083 priv->wrap_license = wrap_license;
1085 g_object_notify (G_OBJECT (about), "wrap-license");
1090 * gtk_about_dialog_get_website:
1091 * @about: a #GtkAboutDialog
1093 * Returns the website URL.
1095 * Return value: The website URL. The string is owned by the about
1096 * dialog and must not be modified.
1100 G_CONST_RETURN gchar *
1101 gtk_about_dialog_get_website (GtkAboutDialog *about)
1103 GtkAboutDialogPrivate *priv;
1105 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1107 priv = (GtkAboutDialogPrivate *)about->private_data;
1109 return priv->website;
1113 * gtk_about_dialog_set_website:
1114 * @about: a #GtkAboutDialog
1115 * @website: a URL string starting with "http://"
1117 * Sets the URL to use for the website link.
1122 gtk_about_dialog_set_website (GtkAboutDialog *about,
1123 const gchar *website)
1125 GtkAboutDialogPrivate *priv;
1128 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1130 priv = (GtkAboutDialogPrivate *)about->private_data;
1132 tmp = priv->website;
1133 if (website != NULL)
1135 priv->website = g_strdup (website);
1136 if (activate_url_hook != NULL)
1138 gtk_link_button_set_uri (GTK_LINK_BUTTON (priv->website_button), website);
1139 if (priv->website_label == NULL)
1140 gtk_about_dialog_set_website_label (about, website);
1144 GtkWidget *hbox = priv->website_button->parent;
1145 gtk_widget_destroy (priv->website_button);
1146 priv->website_button = gtk_label_new (website);
1147 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1148 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1149 gtk_widget_show (priv->website_button);
1154 priv->website = NULL;
1155 gtk_widget_hide (priv->website_button);
1159 g_object_notify (G_OBJECT (about), "website");
1163 * gtk_about_dialog_get_website_label:
1164 * @about: a #GtkAboutDialog
1166 * Returns the label used for the website link.
1168 * Return value: The label used for the website link. The string is owned by the about
1169 * dialog and must not be modified.
1173 G_CONST_RETURN gchar *
1174 gtk_about_dialog_get_website_label (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->website_label;
1186 * gtk_about_dialog_set_website_label:
1187 * @about: a #GtkAboutDialog
1188 * @website_label: the label used for the website link
1190 * Sets the label to be used for the website link.
1191 * It defaults to the website URL.
1196 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1197 const gchar *website_label)
1199 GtkAboutDialogPrivate *priv;
1202 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1204 priv = (GtkAboutDialogPrivate *)about->private_data;
1206 tmp = priv->website_label;
1207 if (activate_url_hook != NULL)
1209 if (website_label != NULL)
1211 priv->website_label = g_strdup (website_label);
1212 gtk_button_set_label (GTK_BUTTON (priv->website_button),
1213 priv->website_label);
1214 gtk_widget_show (priv->website_button);
1218 priv->website_label = NULL;
1219 gtk_widget_hide (priv->website_button);
1224 g_object_notify (G_OBJECT (about), "website-label");
1228 * gtk_about_dialog_get_authors:
1229 * @about: a #GtkAboutDialog
1231 * Returns the string which are displayed in the authors tab
1232 * of the secondary credits dialog.
1234 * Return value: A %NULL-terminated string array containing
1235 * the authors. The array is owned by the about dialog
1236 * and must not be modified.
1240 G_CONST_RETURN gchar * G_CONST_RETURN *
1241 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1243 GtkAboutDialogPrivate *priv;
1245 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1247 priv = (GtkAboutDialogPrivate *)about->private_data;
1249 return (const gchar * const *) priv->authors;
1253 * gtk_about_dialog_set_authors:
1254 * @about: a #GtkAboutDialog
1255 * @authors: a %NULL-terminated array of strings
1257 * Sets the strings which are displayed in the authors tab
1258 * of the secondary credits dialog.
1263 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1264 const gchar **authors)
1266 GtkAboutDialogPrivate *priv;
1269 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1271 priv = (GtkAboutDialogPrivate *)about->private_data;
1273 tmp = priv->authors;
1274 priv->authors = g_strdupv ((gchar **)authors);
1277 if (priv->authors != NULL)
1278 gtk_widget_show (priv->credits_button);
1280 g_object_notify (G_OBJECT (about), "authors");
1284 * gtk_about_dialog_get_documenters:
1285 * @about: a #GtkAboutDialog
1287 * Returns the string which are displayed in the documenters
1288 * tab of the secondary credits dialog.
1290 * Return value: A %NULL-terminated string array containing
1291 * the documenters. The array is owned by the about dialog
1292 * and must not be modified.
1296 G_CONST_RETURN gchar * G_CONST_RETURN *
1297 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1299 GtkAboutDialogPrivate *priv;
1301 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1303 priv = (GtkAboutDialogPrivate *)about->private_data;
1305 return (const gchar * const *)priv->documenters;
1309 * gtk_about_dialog_set_documenters:
1310 * @about: a #GtkAboutDialog
1311 * @documenters: a %NULL-terminated array of strings
1313 * Sets the strings which are displayed in the documenters tab
1314 * of the secondary credits dialog.
1319 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1320 const gchar **documenters)
1322 GtkAboutDialogPrivate *priv;
1325 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1327 priv = (GtkAboutDialogPrivate *)about->private_data;
1329 tmp = priv->documenters;
1330 priv->documenters = g_strdupv ((gchar **)documenters);
1333 if (priv->documenters != NULL)
1334 gtk_widget_show (priv->credits_button);
1336 g_object_notify (G_OBJECT (about), "documenters");
1340 * gtk_about_dialog_get_artists:
1341 * @about: a #GtkAboutDialog
1343 * Returns the string which are displayed in the artists tab
1344 * of the secondary credits dialog.
1346 * Return value: A %NULL-terminated string array containing
1347 * the artists. The array is owned by the about dialog
1348 * and must not be modified.
1352 G_CONST_RETURN gchar * G_CONST_RETURN *
1353 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1355 GtkAboutDialogPrivate *priv;
1357 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1359 priv = (GtkAboutDialogPrivate *)about->private_data;
1361 return (const gchar * const *)priv->artists;
1365 * gtk_about_dialog_set_artists:
1366 * @about: a #GtkAboutDialog
1367 * @artists: a %NULL-terminated array of strings
1369 * Sets the strings which are displayed in the artists tab
1370 * of the secondary credits dialog.
1375 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1376 const gchar **artists)
1378 GtkAboutDialogPrivate *priv;
1381 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1383 priv = (GtkAboutDialogPrivate *)about->private_data;
1385 tmp = priv->artists;
1386 priv->artists = g_strdupv ((gchar **)artists);
1389 if (priv->artists != NULL)
1390 gtk_widget_show (priv->credits_button);
1392 g_object_notify (G_OBJECT (about), "artists");
1396 * gtk_about_dialog_get_translator_credits:
1397 * @about: a #GtkAboutDialog
1399 * Returns the translator credits string which is displayed
1400 * in the translators tab of the secondary credits dialog.
1402 * Return value: The translator credits string. The string is
1403 * owned by the about dialog and must not be modified.
1407 G_CONST_RETURN gchar *
1408 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1410 GtkAboutDialogPrivate *priv;
1412 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1414 priv = (GtkAboutDialogPrivate *)about->private_data;
1416 return priv->translator_credits;
1420 * gtk_about_dialog_set_translator_credits:
1421 * @about: a #GtkAboutDialog
1422 * @translator_credits: the translator credits
1424 * Sets the translator credits string which is displayed in
1425 * the translators tab of the secondary credits dialog.
1427 * The intended use for this string is to display the translator
1428 * of the language which is currently used in the user interface.
1429 * Using gettext(), a simple way to achieve that is to mark the
1430 * string for translation:
1431 * <informalexample><programlisting>
1432 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1433 * </programlisting></informalexample>
1434 * It is a good idea to use the customary msgid "translator-credits" for this
1435 * purpose, since translators will already know the purpose of that msgid, and
1436 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1442 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1443 const gchar *translator_credits)
1445 GtkAboutDialogPrivate *priv;
1448 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1450 priv = (GtkAboutDialogPrivate *)about->private_data;
1452 tmp = priv->translator_credits;
1453 priv->translator_credits = g_strdup (translator_credits);
1456 if (priv->translator_credits != NULL)
1457 gtk_widget_show (priv->credits_button);
1459 g_object_notify (G_OBJECT (about), "translator-credits");
1463 * gtk_about_dialog_get_logo:
1464 * @about: a #GtkAboutDialog
1466 * Returns the pixbuf displayed as logo in the about dialog.
1468 * Return value: the pixbuf displayed as logo. The pixbuf is
1469 * owned by the about dialog. If you want to keep a reference
1470 * to it, you have to call g_object_ref() on it.
1475 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1477 GtkAboutDialogPrivate *priv;
1479 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1481 priv = (GtkAboutDialogPrivate *)about->private_data;
1483 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1484 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1490 icon_set_new_from_pixbufs (GList *pixbufs)
1492 GtkIconSet *icon_set = gtk_icon_set_new ();
1494 for (; pixbufs; pixbufs = pixbufs->next)
1496 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1498 GtkIconSource *icon_source = gtk_icon_source_new ();
1499 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1500 gtk_icon_set_add_source (icon_set, icon_source);
1501 gtk_icon_source_free (icon_source);
1508 * gtk_about_dialog_set_logo:
1509 * @about: a #GtkAboutDialog
1510 * @logo: a #GdkPixbuf, or %NULL
1512 * Sets the pixbuf to be displayed as logo in
1513 * the about dialog. If it is %NULL, the default
1514 * window icon set with gtk_window_set_default_icon ()
1520 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1523 GtkAboutDialogPrivate *priv;
1525 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1527 priv = (GtkAboutDialogPrivate *)about->private_data;
1529 g_object_freeze_notify (G_OBJECT (about));
1531 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1532 g_object_notify (G_OBJECT (about), "logo-icon-name");
1535 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1538 GList *pixbufs = gtk_window_get_default_icon_list ();
1540 if (pixbufs != NULL)
1542 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1544 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1545 icon_set, GTK_ICON_SIZE_DIALOG);
1547 gtk_icon_set_unref (icon_set);
1548 g_list_free (pixbufs);
1552 g_object_notify (G_OBJECT (about), "logo");
1554 g_object_thaw_notify (G_OBJECT (about));
1558 * gtk_about_dialog_get_logo_icon_name:
1559 * @about: a #GtkAboutDialog
1561 * Returns the icon name displayed as logo in the about dialog.
1563 * Return value: the icon name displayed as logo. The string is
1564 * owned by the dialog. If you want to keep a reference
1565 * to it, you have to call g_strdup() on it.
1569 G_CONST_RETURN gchar *
1570 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1572 GtkAboutDialogPrivate *priv;
1573 const gchar *icon_name = NULL;
1575 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1577 priv = (GtkAboutDialogPrivate *)about->private_data;
1579 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1580 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1586 * gtk_about_dialog_set_logo_icon_name:
1587 * @about: a #GtkAboutDialog
1588 * @icon_name: an icon name, or %NULL
1590 * Sets the pixbuf to be displayed as logo in
1591 * the about dialog. If it is %NULL, the default
1592 * window icon set with gtk_window_set_default_icon()
1598 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1599 const gchar *icon_name)
1601 GtkAboutDialogPrivate *priv;
1603 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1605 priv = (GtkAboutDialogPrivate *)about->private_data;
1607 g_object_freeze_notify (G_OBJECT (about));
1609 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1610 g_object_notify (G_OBJECT (about), "logo");
1612 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1613 GTK_ICON_SIZE_DIALOG);
1614 g_object_notify (G_OBJECT (about), "logo-icon-name");
1616 g_object_thaw_notify (G_OBJECT (about));
1620 activate_url (GtkWidget *widget,
1623 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1624 const gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
1626 if (activate_url_hook != NULL)
1627 (* activate_url_hook) (about, url, activate_url_hook_data);
1631 follow_if_link (GtkAboutDialog *about,
1632 GtkTextView *text_view,
1635 GSList *tags = NULL, *tagp = NULL;
1636 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1639 tags = gtk_text_iter_get_tags (iter);
1640 for (tagp = tags; tagp != NULL && !url; tagp = tagp->next)
1642 GtkTextTag *tag = tagp->data;
1644 if (activate_email_hook != NULL)
1646 url = g_object_get_data (G_OBJECT (tag), "email");
1648 (* activate_email_hook) (about, url, activate_email_hook_data);
1651 if (!url && activate_url_hook != NULL)
1653 url = g_object_get_data (G_OBJECT (tag), "url");
1655 (* activate_url_hook) (about, url, activate_url_hook_data);
1658 if (url && !g_slist_find_custom (priv->visited_links, url, (GCompareFunc)strcmp))
1660 GdkColor *style_visited_link_color;
1663 gtk_widget_ensure_style (GTK_WIDGET (about));
1664 gtk_widget_style_get (GTK_WIDGET (about),
1665 "visited-link-color", &style_visited_link_color,
1667 if (style_visited_link_color)
1669 color = *style_visited_link_color;
1670 gdk_color_free (style_visited_link_color);
1673 color = default_visited_link_color;
1675 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1677 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (url));
1682 g_slist_free (tags);
1686 credits_key_press_event (GtkWidget *text_view,
1688 GtkAboutDialog *about)
1691 GtkTextBuffer *buffer;
1693 switch (event->keyval)
1697 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1698 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1699 gtk_text_buffer_get_insert (buffer));
1700 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1711 credits_event_after (GtkWidget *text_view,
1713 GtkAboutDialog *about)
1715 GtkTextIter start, end, iter;
1716 GtkTextBuffer *buffer;
1717 GdkEventButton *button_event;
1720 if (event->type != GDK_BUTTON_RELEASE)
1723 button_event = (GdkEventButton *)event;
1725 if (button_event->button != 1)
1728 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1730 /* we shouldn't follow a link if the user has selected something */
1731 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1732 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1735 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1736 GTK_TEXT_WINDOW_WIDGET,
1737 button_event->x, button_event->y, &x, &y);
1739 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1741 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1747 set_cursor_if_appropriate (GtkAboutDialog *about,
1748 GtkTextView *text_view,
1752 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1753 GSList *tags = NULL, *tagp = NULL;
1754 GtkTextBuffer *buffer;
1756 gboolean hovering_over_link = FALSE;
1758 buffer = gtk_text_view_get_buffer (text_view);
1760 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1762 tags = gtk_text_iter_get_tags (&iter);
1763 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1765 GtkTextTag *tag = tagp->data;
1766 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1767 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1769 if (email != NULL || url != NULL)
1771 hovering_over_link = TRUE;
1776 if (hovering_over_link != priv->hovering_over_link)
1778 priv->hovering_over_link = hovering_over_link;
1780 if (hovering_over_link)
1781 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1783 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1787 g_slist_free (tags);
1791 credits_motion_notify_event (GtkWidget *text_view,
1792 GdkEventMotion *event,
1793 GtkAboutDialog *about)
1797 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1798 GTK_TEXT_WINDOW_WIDGET,
1799 event->x, event->y, &x, &y);
1801 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1803 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1810 credits_visibility_notify_event (GtkWidget *text_view,
1811 GdkEventVisibility *event,
1812 GtkAboutDialog *about)
1814 gint wx, wy, bx, by;
1816 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1818 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1819 GTK_TEXT_WINDOW_WIDGET,
1822 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1828 text_view_style_set (GtkWidget *widget,
1829 GtkStyle *prev_style,
1830 GtkWidget *text_view)
1832 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1833 &widget->style->bg[GTK_STATE_NORMAL]);
1837 add_credits_page (GtkAboutDialog *about,
1838 GtkWidget *notebook,
1843 gchar *q0, *q1, *q2, *r1, *r2;
1844 GtkWidget *sw, *view;
1845 GtkTextBuffer *buffer;
1846 gboolean linkify_email, linkify_urls;
1847 GdkColor *style_link_color;
1848 GdkColor *style_visited_link_color;
1850 GdkColor link_color;
1851 GdkColor visited_link_color;
1852 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1854 linkify_email = (activate_email_hook != NULL);
1855 linkify_urls = (activate_url_hook != NULL);
1857 gtk_widget_ensure_style (GTK_WIDGET (about));
1858 gtk_widget_style_get (GTK_WIDGET (about),
1859 "link-color", &style_link_color,
1860 "visited-link-color", &style_visited_link_color,
1862 if (style_link_color)
1864 link_color = *style_link_color;
1865 gdk_color_free (style_link_color);
1868 link_color = default_link_color;
1870 if (style_visited_link_color)
1872 visited_link_color = *style_visited_link_color;
1873 gdk_color_free (style_visited_link_color);
1876 visited_link_color = default_visited_link_color;
1878 view = gtk_text_view_new ();
1879 g_signal_connect_object (about, "style_set",
1880 G_CALLBACK (text_view_style_set), view, 0);
1882 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1883 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1884 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1886 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1887 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1889 g_signal_connect (view, "key-press-event",
1890 G_CALLBACK (credits_key_press_event), about);
1891 g_signal_connect (view, "event-after",
1892 G_CALLBACK (credits_event_after), about);
1893 g_signal_connect (view, "motion-notify-event",
1894 G_CALLBACK (credits_motion_notify_event), about);
1895 g_signal_connect (view, "visibility-notify-event",
1896 G_CALLBACK (credits_visibility_notify_event), about);
1898 sw = gtk_scrolled_window_new (NULL, NULL);
1899 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1901 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1902 GTK_POLICY_AUTOMATIC,
1903 GTK_POLICY_AUTOMATIC);
1904 gtk_container_add (GTK_CONTAINER (sw), view);
1906 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1907 sw, gtk_label_new (title));
1911 gtk_widget_hide (view);
1915 gtk_widget_show (view);
1917 for (p = people; *p; p++)
1922 q1 = linkify_email ? strchr (q0, '<') : NULL;
1923 q2 = q1 ? strchr (q1, '>') : NULL;
1924 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1927 r2 = strpbrk (r1, " \n\t");
1929 r2 = strchr (r1, '\0');
1934 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1944 const gchar *link_type;
1947 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1948 gtk_text_buffer_get_end_iter (buffer, &end);
1956 link_type = I_("email");
1959 link_type = I_("url");
1961 link = g_strndup (q1, q2 - q1);
1963 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
1964 color = visited_link_color;
1968 tag = gtk_text_buffer_create_tag (buffer, NULL,
1969 "foreground-gdk", &color,
1970 "underline", PANGO_UNDERLINE_SINGLE,
1972 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1973 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1979 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1985 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1990 display_credits_dialog (GtkWidget *button,
1993 GtkAboutDialog *about = (GtkAboutDialog *)data;
1994 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1995 GtkWidget *dialog, *notebook;
1997 if (priv->credits_dialog != NULL)
1999 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
2003 dialog = gtk_dialog_new_with_buttons (_("Credits"),
2005 GTK_DIALOG_DESTROY_WITH_PARENT,
2006 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2008 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2010 priv->credits_dialog = dialog;
2011 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
2012 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
2014 gtk_window_set_modal (GTK_WINDOW (dialog),
2015 gtk_window_get_modal (GTK_WINDOW (about)));
2017 g_signal_connect (dialog, "response",
2018 G_CALLBACK (gtk_widget_destroy), dialog);
2019 g_signal_connect (dialog, "destroy",
2020 G_CALLBACK (gtk_widget_destroyed),
2021 &(priv->credits_dialog));
2022 g_signal_connect (dialog, "style_set",
2023 G_CALLBACK (dialog_style_set), NULL);
2025 notebook = gtk_notebook_new ();
2026 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
2028 if (priv->authors != NULL)
2029 add_credits_page (about, notebook, _("Written by"), priv->authors);
2031 if (priv->documenters != NULL)
2032 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
2034 /* Don't show an untranslated gettext msgid */
2035 if (priv->translator_credits != NULL &&
2036 strcmp (priv->translator_credits, "translator_credits") &&
2037 strcmp (priv->translator_credits, "translator-credits"))
2039 gchar *translators[2];
2041 translators[0] = priv->translator_credits;
2042 translators[1] = NULL;
2044 add_credits_page (about, notebook, _("Translated by"), translators);
2047 if (priv->artists != NULL)
2048 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
2050 gtk_widget_show_all (dialog);
2054 set_policy (GtkWidget *sw)
2056 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2057 GTK_POLICY_AUTOMATIC,
2058 GTK_POLICY_AUTOMATIC);
2062 display_license_dialog (GtkWidget *button,
2065 GtkAboutDialog *about = (GtkAboutDialog *)data;
2066 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2067 GtkWidget *dialog, *view, *sw;
2069 if (priv->license_dialog != NULL)
2071 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2075 dialog = gtk_dialog_new_with_buttons (_("License"),
2077 GTK_DIALOG_DESTROY_WITH_PARENT,
2078 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2080 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2081 priv->license_dialog = dialog;
2082 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2083 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
2085 gtk_window_set_modal (GTK_WINDOW (dialog),
2086 gtk_window_get_modal (GTK_WINDOW (about)));
2088 g_signal_connect (dialog, "response",
2089 G_CALLBACK (gtk_widget_destroy), dialog);
2090 g_signal_connect (dialog, "destroy",
2091 G_CALLBACK (gtk_widget_destroyed),
2092 &(priv->license_dialog));
2093 g_signal_connect (dialog, "style_set",
2094 G_CALLBACK (dialog_style_set), NULL);
2096 sw = gtk_scrolled_window_new (NULL, NULL);
2097 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2099 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2101 GTK_POLICY_AUTOMATIC);
2102 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2103 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2105 view = gtk_text_view_new ();
2106 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
2107 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2108 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2111 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2112 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2114 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2115 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2117 gtk_container_add (GTK_CONTAINER (sw), view);
2119 gtk_widget_show_all (dialog);
2123 * gtk_about_dialog_new:
2125 * Creates a new #GtkAboutDialog.
2127 * Returns: a newly created #GtkAboutDialog
2132 gtk_about_dialog_new (void)
2134 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2136 return GTK_WIDGET (dialog);
2140 * gtk_about_dialog_set_email_hook:
2141 * @func: a function to call when an email link is activated.
2142 * @data: data to pass to @func
2143 * @destroy: #GDestroyNotify for @data
2145 * Installs a global function to be called whenever the user activates an
2146 * email link in an about dialog.
2148 * Return value: the previous email hook.
2152 GtkAboutDialogActivateLinkFunc
2153 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2155 GDestroyNotify destroy)
2157 GtkAboutDialogActivateLinkFunc old;
2159 if (activate_email_hook_destroy != NULL)
2160 (* activate_email_hook_destroy) (activate_email_hook_data);
2162 old = activate_email_hook;
2164 activate_email_hook = func;
2165 activate_email_hook_data = data;
2166 activate_email_hook_destroy = destroy;
2172 * gtk_about_dialog_set_url_hook:
2173 * @func: a function to call when a URL link is activated.
2174 * @data: data to pass to @func
2175 * @destroy: #GDestroyNotify for @data
2177 * Installs a global function to be called whenever the user activates a
2178 * URL link in an about dialog.
2180 * Return value: the previous URL hook.
2184 GtkAboutDialogActivateLinkFunc
2185 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2187 GDestroyNotify destroy)
2189 GtkAboutDialogActivateLinkFunc old;
2191 if (activate_url_hook_destroy != NULL)
2192 (* activate_url_hook_destroy) (activate_url_hook_data);
2194 old = activate_url_hook;
2196 activate_url_hook = func;
2197 activate_url_hook_data = data;
2198 activate_url_hook_destroy = destroy;
2204 close_cb (GtkAboutDialog *about)
2206 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2208 if (priv->license_dialog != NULL)
2210 gtk_widget_destroy (priv->license_dialog);
2211 priv->license_dialog = NULL;
2214 if (priv->credits_dialog != NULL)
2216 gtk_widget_destroy (priv->credits_dialog);
2217 priv->credits_dialog = NULL;
2220 gtk_widget_hide (GTK_WIDGET (about));
2225 * gtk_show_about_dialog:
2226 * @parent: transient parent, or %NULL for none
2227 * @first_property_name: the name of the first property
2228 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2230 * This is a convenience function for showing an application's about box.
2231 * The constructed dialog is associated with the parent window and
2232 * reused for future invocations of this function.
2237 gtk_show_about_dialog (GtkWindow *parent,
2238 const gchar *first_property_name,
2241 static GtkWidget *global_about_dialog = NULL;
2242 GtkWidget *dialog = NULL;
2246 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2248 dialog = global_about_dialog;
2252 dialog = gtk_about_dialog_new ();
2254 g_object_ref_sink (dialog);
2256 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2258 /* Close dialog on user response */
2259 g_signal_connect (dialog, "response", G_CALLBACK (close_cb), NULL);
2261 va_start (var_args, first_property_name);
2262 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2267 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2268 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2269 g_object_set_data_full (G_OBJECT (parent),
2270 I_("gtk-about-dialog"),
2271 dialog, g_object_unref);
2274 global_about_dialog = dialog;
2278 gtk_window_present (GTK_WINDOW (dialog));
2281 #define __GTK_ABOUT_DIALOG_C__
2282 #include "gtkaliasdef.c"