1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2001 CodeFactory AB
3 * Copyright (C) 2001, 2002 Anders Carlsson
4 * Copyright (C) 2003, 2004 Matthias Clasen <mclasen@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * Author: Anders Carlsson <andersca@gnome.org>
25 * Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
35 #include <gdk/gdkkeysyms.h>
37 #include "gtkaboutdialog.h"
38 #include "gtkbutton.h"
40 #include "gtkdialog.h"
44 #include "gtklinkbutton.h"
45 #include "gtkmarshalers.h"
46 #include "gtknotebook.h"
47 #include "gtkscrolledwindow.h"
49 #include "gtktextview.h"
51 #include "gtkiconfactory.h"
52 #include "gtkprivate.h"
57 static GdkColor default_link_color = { 0, 0, 0, 0xeeee };
58 static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
60 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
61 struct _GtkAboutDialogPrivate
69 gchar *translator_credits;
76 GtkWidget *logo_image;
77 GtkWidget *name_label;
78 GtkWidget *comments_label;
79 GtkWidget *copyright_label;
80 GtkWidget *website_button;
82 GtkWidget *credits_button;
83 GtkWidget *credits_dialog;
84 GtkWidget *license_button;
85 GtkWidget *license_dialog;
87 GdkCursor *hand_cursor;
88 GdkCursor *regular_cursor;
90 GSList *visited_links;
92 guint hovering_over_link : 1;
93 guint wrap_license : 1;
96 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
111 PROP_TRANSLATOR_CREDITS,
118 static void gtk_about_dialog_finalize (GObject *object);
119 static void gtk_about_dialog_get_property (GObject *object,
123 static void gtk_about_dialog_set_property (GObject *object,
127 static void update_name_version (GtkAboutDialog *about);
128 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
129 static void activate_url (GtkWidget *widget,
131 static void follow_if_link (GtkAboutDialog *about,
132 GtkTextView *text_view,
134 static void set_cursor_if_appropriate (GtkAboutDialog *about,
135 GtkTextView *text_view,
138 static void add_credits_page (GtkAboutDialog *about,
142 static gboolean credits_key_press_event (GtkWidget *text_view,
144 GtkAboutDialog *about);
145 static gboolean credits_event_after (GtkWidget *text_view,
147 GtkAboutDialog *about);
148 static gboolean credits_motion_notify_event (GtkWidget *text_view,
149 GdkEventMotion *event,
150 GtkAboutDialog *about);
151 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
152 GdkEventVisibility *event,
153 GtkAboutDialog *about);
154 static void display_credits_dialog (GtkWidget *button,
156 static void display_license_dialog (GtkWidget *button,
158 static void close_cb (GtkAboutDialog *about);
161 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
162 static gpointer activate_email_hook_data = NULL;
163 static GDestroyNotify activate_email_hook_destroy = NULL;
165 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
166 static gpointer activate_url_hook_data = NULL;
167 static GDestroyNotify activate_url_hook_destroy = NULL;
169 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
172 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
174 GObjectClass *object_class;
175 GtkWidgetClass *widget_class;
177 object_class = (GObjectClass *)klass;
178 widget_class = (GtkWidgetClass *)klass;
180 object_class->set_property = gtk_about_dialog_set_property;
181 object_class->get_property = gtk_about_dialog_get_property;
183 object_class->finalize = gtk_about_dialog_finalize;
187 * GtkAboutDialog:name:
189 * The name of the program.
190 * If this is not set, it defaults to g_get_application_name().
194 g_object_class_install_property (object_class,
196 g_param_spec_string ("program-name",
198 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
200 GTK_PARAM_READWRITE));
203 * GtkAboutDialog:version:
205 * The version of the program.
209 g_object_class_install_property (object_class,
211 g_param_spec_string ("version",
212 P_("Program version"),
213 P_("The version of the program"),
215 GTK_PARAM_READWRITE));
218 * GtkAboutDialog:copyright:
220 * Copyright information for the program.
224 g_object_class_install_property (object_class,
226 g_param_spec_string ("copyright",
227 P_("Copyright string"),
228 P_("Copyright information for the program"),
230 GTK_PARAM_READWRITE));
234 * GtkAboutDialog:comments:
236 * Comments about the program. This string is displayed in a label
237 * in the main dialog, thus it should be a short explanation of
238 * the main purpose of the program, not a detailed list of features.
242 g_object_class_install_property (object_class,
244 g_param_spec_string ("comments",
245 P_("Comments string"),
246 P_("Comments about the program"),
248 GTK_PARAM_READWRITE));
251 * GtkAboutDialog:license:
253 * The license of the program. This string is displayed in a
254 * text view in a secondary dialog, therefore it is fine to use
255 * a long multi-paragraph text. Note that the text is only wrapped
256 * in the text view if the "wrap-license" property is set to %TRUE;
257 * otherwise the text itself must contain the intended linebreaks.
261 g_object_class_install_property (object_class,
263 g_param_spec_string ("license",
265 _("The license of the program"),
267 GTK_PARAM_READWRITE));
270 * GtkAboutDialog:website:
272 * The URL for the link to the website of the program.
273 * This should be a string starting with "http://.
277 g_object_class_install_property (object_class,
279 g_param_spec_string ("website",
281 P_("The URL for the link to the website of the program"),
283 GTK_PARAM_READWRITE));
286 * GtkAboutDialog:website-label:
288 * The label for the link to the website of the program. If this is not set,
289 * it defaults to the URL specified in the
290 * <link linkend="GtkAboutDialog--website">website</link> property.
294 g_object_class_install_property (object_class,
296 g_param_spec_string ("website-label",
298 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
300 GTK_PARAM_READWRITE));
303 * GtkAboutDialog:authors:
305 * The authors of the program, as a %NULL-terminated array of strings.
306 * Each string may contain email addresses and URLs, which will be displayed
307 * as links, see the introduction for more details.
311 g_object_class_install_property (object_class,
313 g_param_spec_boxed ("authors",
315 P_("List of authors of the program"),
317 GTK_PARAM_READWRITE));
320 * GtkAboutDialog:documenters:
322 * The people documenting the program, as a %NULL-terminated array of strings.
323 * Each string may contain email addresses and URLs, which will be displayed
324 * as links, see the introduction for more details.
328 g_object_class_install_property (object_class,
330 g_param_spec_boxed ("documenters",
332 P_("List of people documenting the program"),
334 GTK_PARAM_READWRITE));
337 * GtkAboutDialog:artists:
339 * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
340 * Each string may contain email addresses and URLs, which will be displayed
341 * as links, see the introduction for more details.
345 g_object_class_install_property (object_class,
347 g_param_spec_boxed ("artists",
349 P_("List of people who have contributed artwork to the program"),
351 GTK_PARAM_READWRITE));
355 * GtkAboutDialog:translator-credits:
357 * Credits to the translators. This string should be marked as translatable.
358 * The string may contain email addresses and URLs, which will be displayed
359 * as links, see the introduction for more details.
363 g_object_class_install_property (object_class,
364 PROP_TRANSLATOR_CREDITS,
365 g_param_spec_string ("translator-credits",
366 P_("Translator credits"),
367 P_("Credits to the translators. This string should be marked as translatable"),
369 GTK_PARAM_READWRITE));
372 * GtkAboutDialog:logo:
374 * A logo for the about box. If this is not set, it defaults to
375 * gtk_window_get_default_icon_list().
379 g_object_class_install_property (object_class,
381 g_param_spec_object ("logo",
383 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
385 GTK_PARAM_READWRITE));
388 * GtkAboutDialog:logo-icon-name:
390 * A named icon to use as the logo for the about box. This property
391 * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
395 g_object_class_install_property (object_class,
397 g_param_spec_string ("logo-icon-name",
398 P_("Logo Icon Name"),
399 P_("A named icon to use as the logo for the about box."),
401 GTK_PARAM_READWRITE));
403 * GtkAboutDialog:wrap-license:
405 * Whether to wrap the text in the license dialog.
409 g_object_class_install_property (object_class,
411 g_param_spec_boolean ("wrap-license",
413 P_("Whether to wrap the license text."),
415 GTK_PARAM_READWRITE));
418 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
422 gtk_about_dialog_init (GtkAboutDialog *about)
424 GtkDialog *dialog = GTK_DIALOG (about);
425 GtkAboutDialogPrivate *priv;
426 GtkWidget *vbox, *hbox, *button, *close_button, *image;
429 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
430 about->private_data = priv;
433 priv->version = NULL;
434 priv->copyright = NULL;
435 priv->comments = NULL;
436 priv->website = NULL;
437 priv->website_label = NULL;
438 priv->translator_credits = NULL;
439 priv->license = NULL;
440 priv->authors = NULL;
441 priv->documenters = NULL;
442 priv->artists = NULL;
444 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
445 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
446 priv->hovering_over_link = FALSE;
447 priv->wrap_license = FALSE;
449 gtk_dialog_set_has_separator (dialog, FALSE);
450 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
451 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
452 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
455 gtk_widget_push_composite_child ();
457 vbox = gtk_vbox_new (FALSE, 8);
458 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
459 gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, TRUE, TRUE, 0);
461 priv->logo_image = gtk_image_new ();
462 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
464 priv->name_label = gtk_label_new (NULL);
465 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
466 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
467 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
469 priv->comments_label = gtk_label_new (NULL);
470 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
471 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
472 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
473 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
475 priv->copyright_label = gtk_label_new (NULL);
476 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
477 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
478 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
480 button = gtk_link_button_new ("");
481 g_signal_connect (G_OBJECT (button), "clicked",
482 G_CALLBACK (activate_url), about);
484 hbox = gtk_hbox_new (TRUE, 0);
485 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
486 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
487 priv->website_button = button;
489 gtk_widget_show (vbox);
490 gtk_widget_show (priv->logo_image);
491 gtk_widget_show (priv->name_label);
492 gtk_widget_show (hbox);
494 /* Add the OK button */
495 close_button = gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE,
496 GTK_RESPONSE_CANCEL);
497 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
499 /* Add the credits button */
500 button = gtk_button_new_with_mnemonic (_("C_redits"));
501 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
502 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
503 gtk_button_set_image (GTK_BUTTON (button), image);
504 gtk_widget_set_no_show_all (button, TRUE);
505 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
506 button, FALSE, TRUE, 0);
507 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
508 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
509 priv->credits_button = button;
510 priv->credits_dialog = NULL;
512 /* Add the license button */
513 button = gtk_button_new_from_stock (_("_License"));
514 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
515 gtk_widget_set_no_show_all (button, TRUE);
516 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
517 button, FALSE, TRUE, 0);
518 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
519 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
520 priv->license_button = button;
521 priv->license_dialog = NULL;
523 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
525 gtk_widget_pop_composite_child ();
527 gtk_widget_grab_default (close_button);
528 gtk_widget_grab_focus (close_button);
531 gtk_about_dialog_set_program_name (about, NULL);
532 gtk_about_dialog_set_logo (about, NULL);
536 gtk_about_dialog_finalize (GObject *object)
538 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
539 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
542 g_free (priv->version);
543 g_free (priv->copyright);
544 g_free (priv->comments);
545 g_free (priv->license);
546 g_free (priv->website);
547 g_free (priv->website_label);
548 g_free (priv->translator_credits);
550 g_strfreev (priv->authors);
551 g_strfreev (priv->documenters);
552 g_strfreev (priv->artists);
554 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
555 g_slist_free (priv->visited_links);
557 gdk_cursor_unref (priv->hand_cursor);
558 gdk_cursor_unref (priv->regular_cursor);
560 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
564 gtk_about_dialog_set_property (GObject *object,
569 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
570 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
575 gtk_about_dialog_set_program_name (about, g_value_get_string (value));
578 gtk_about_dialog_set_version (about, g_value_get_string (value));
581 gtk_about_dialog_set_comments (about, g_value_get_string (value));
584 gtk_about_dialog_set_website (about, g_value_get_string (value));
586 case PROP_WEBSITE_LABEL:
587 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
590 gtk_about_dialog_set_license (about, g_value_get_string (value));
593 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
596 gtk_about_dialog_set_logo (about, g_value_get_object (value));
599 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
601 case PROP_DOCUMENTERS:
602 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
605 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
607 case PROP_TRANSLATOR_CREDITS:
608 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
610 case PROP_LOGO_ICON_NAME:
611 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
613 case PROP_WRAP_LICENSE:
614 priv->wrap_license = g_value_get_boolean (value);
617 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
623 gtk_about_dialog_get_property (GObject *object,
628 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
629 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
634 g_value_set_string (value, priv->name);
637 g_value_set_string (value, priv->version);
640 g_value_set_string (value, priv->copyright);
643 g_value_set_string (value, priv->comments);
646 g_value_set_string (value, priv->website);
648 case PROP_WEBSITE_LABEL:
649 g_value_set_string (value, priv->website_label);
652 g_value_set_string (value, priv->license);
654 case PROP_TRANSLATOR_CREDITS:
655 g_value_set_string (value, priv->translator_credits);
658 g_value_set_boxed (value, priv->authors);
660 case PROP_DOCUMENTERS:
661 g_value_set_boxed (value, priv->documenters);
664 g_value_set_boxed (value, priv->artists);
667 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
668 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
670 g_value_set_object (value, NULL);
672 case PROP_LOGO_ICON_NAME:
673 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
675 const gchar *icon_name;
677 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
678 g_value_set_string (value, icon_name);
681 g_value_set_string (value, NULL);
683 case PROP_WRAP_LICENSE:
684 g_value_set_boolean (value, priv->wrap_license);
687 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
693 * gtk_about_dialog_get_name:
694 * @about: a #GtkAboutDialog
696 * Returns the program name displayed in the about dialog.
698 * Return value: The program name. The string is owned by the about
699 * dialog and must not be modified.
703 * @Deprecated: 2.12: Use gtk_about_dialog_get_program_name() instead.
705 G_CONST_RETURN gchar *
706 gtk_about_dialog_get_name (GtkAboutDialog *about)
708 return gtk_about_dialog_get_program_name (about);
712 * gtk_about_dialog_get_program_name:
713 * @about: a #GtkAboutDialog
715 * Returns the program name displayed in the about dialog.
717 * Return value: The program name. The string is owned by the about
718 * dialog and must not be modified.
722 G_CONST_RETURN gchar *
723 gtk_about_dialog_get_program_name (GtkAboutDialog *about)
725 GtkAboutDialogPrivate *priv;
727 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
729 priv = (GtkAboutDialogPrivate *)about->private_data;
735 update_name_version (GtkAboutDialog *about)
737 GtkAboutDialogPrivate *priv;
738 gchar *title_string, *name_string;
740 priv = (GtkAboutDialogPrivate *)about->private_data;
742 title_string = g_strdup_printf (_("About %s"), priv->name);
743 gtk_window_set_title (GTK_WINDOW (about), title_string);
744 g_free (title_string);
746 if (priv->version != NULL)
747 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
748 priv->name, priv->version);
750 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
753 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
755 g_free (name_string);
759 * gtk_about_dialog_set_name:
760 * @about: a #GtkAboutDialog
761 * @name: the program name
763 * Sets the name to display in the about dialog.
764 * If this is not set, it defaults to g_get_application_name().
768 * @Deprecated: 2.12: Use gtk_about_dialog_set_program_name() instead.
771 gtk_about_dialog_set_name (GtkAboutDialog *about,
774 gtk_about_dialog_set_program_name (about, name);
778 * gtk_about_dialog_set_program_name:
779 * @about: a #GtkAboutDialog
780 * @name: the program name
782 * Sets the name to display in the about dialog.
783 * If this is not set, it defaults to g_get_application_name().
788 gtk_about_dialog_set_program_name (GtkAboutDialog *about,
791 GtkAboutDialogPrivate *priv;
794 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
796 priv = (GtkAboutDialogPrivate *)about->private_data;
798 priv->name = g_strdup (name ? name : g_get_application_name ());
801 update_name_version (about);
803 g_object_notify (G_OBJECT (about), "program-name");
808 * gtk_about_dialog_get_version:
809 * @about: a #GtkAboutDialog
811 * Returns the version string.
813 * Return value: The version string. The string is owned by the about
814 * dialog and must not be modified.
818 G_CONST_RETURN gchar *
819 gtk_about_dialog_get_version (GtkAboutDialog *about)
821 GtkAboutDialogPrivate *priv;
823 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
825 priv = (GtkAboutDialogPrivate *)about->private_data;
827 return priv->version;
831 * gtk_about_dialog_set_version:
832 * @about: a #GtkAboutDialog
833 * @version: the version string
835 * Sets the version string to display in the about dialog.
840 gtk_about_dialog_set_version (GtkAboutDialog *about,
841 const gchar *version)
843 GtkAboutDialogPrivate *priv;
846 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
848 priv = (GtkAboutDialogPrivate *)about->private_data;
851 priv->version = g_strdup (version);
854 update_name_version (about);
856 g_object_notify (G_OBJECT (about), "version");
860 * gtk_about_dialog_get_copyright:
861 * @about: a #GtkAboutDialog
863 * Returns the copyright string.
865 * Return value: The copyright string. The string is owned by the about
866 * dialog and must not be modified.
870 G_CONST_RETURN gchar *
871 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
873 GtkAboutDialogPrivate *priv;
875 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
877 priv = (GtkAboutDialogPrivate *)about->private_data;
879 return priv->copyright;
883 * gtk_about_dialog_set_copyright:
884 * @about: a #GtkAboutDialog
885 * @copyright: the copyright string
887 * Sets the copyright string to display in the about dialog.
888 * This should be a short string of one or two lines.
893 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
894 const gchar *copyright)
896 GtkAboutDialogPrivate *priv;
897 gchar *copyright_string, *tmp;
899 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
901 priv = (GtkAboutDialogPrivate *)about->private_data;
903 tmp = priv->copyright;
904 priv->copyright = g_strdup (copyright);
907 if (priv->copyright != NULL)
909 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
911 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
912 g_free (copyright_string);
914 gtk_widget_show (priv->copyright_label);
917 gtk_widget_hide (priv->copyright_label);
919 g_object_notify (G_OBJECT (about), "copyright");
923 * gtk_about_dialog_get_comments:
924 * @about: a #GtkAboutDialog
926 * Returns the comments string.
928 * Return value: The comments. The string is owned by the about
929 * dialog and must not be modified.
933 G_CONST_RETURN gchar *
934 gtk_about_dialog_get_comments (GtkAboutDialog *about)
936 GtkAboutDialogPrivate *priv;
938 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
940 priv = (GtkAboutDialogPrivate *)about->private_data;
942 return priv->comments;
946 * gtk_about_dialog_set_comments:
947 * @about: a #GtkAboutDialog
948 * @comments: a comments string
950 * Sets the comments string to display in the about
951 * dialog. This should be a short string of one or
957 gtk_about_dialog_set_comments (GtkAboutDialog *about,
958 const gchar *comments)
960 GtkAboutDialogPrivate *priv;
963 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
965 priv = (GtkAboutDialogPrivate *)about->private_data;
967 tmp = priv->comments;
970 priv->comments = g_strdup (comments);
971 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
972 gtk_widget_show (priv->comments_label);
976 priv->comments = NULL;
977 gtk_widget_hide (priv->comments_label);
981 g_object_notify (G_OBJECT (about), "comments");
985 * gtk_about_dialog_get_license:
986 * @about: a #GtkAboutDialog
988 * Returns the license information.
990 * Return value: The license information. The string is owned by the about
991 * dialog and must not be modified.
995 G_CONST_RETURN gchar *
996 gtk_about_dialog_get_license (GtkAboutDialog *about)
998 GtkAboutDialogPrivate *priv;
1000 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1002 priv = (GtkAboutDialogPrivate *)about->private_data;
1004 return priv->license;
1008 * gtk_about_dialog_set_license:
1009 * @about: a #GtkAboutDialog
1010 * @license: the license information or %NULL
1012 * Sets the license information to be displayed in the secondary
1013 * license dialog. If @license is %NULL, the license button is
1019 gtk_about_dialog_set_license (GtkAboutDialog *about,
1020 const gchar *license)
1022 GtkAboutDialogPrivate *priv;
1025 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1027 priv = (GtkAboutDialogPrivate *)about->private_data;
1029 tmp = priv->license;
1032 priv->license = g_strdup (license);
1033 gtk_widget_show (priv->license_button);
1037 priv->license = NULL;
1038 gtk_widget_hide (priv->license_button);
1042 g_object_notify (G_OBJECT (about), "license");
1046 * gtk_about_dialog_get_wrap_license:
1047 * @about: a #GtkAboutDialog
1049 * Returns whether the license text in @about is
1050 * automatically wrapped.
1052 * Returns: %TRUE if the license text is wrapped
1057 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1059 GtkAboutDialogPrivate *priv;
1061 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1063 priv = (GtkAboutDialogPrivate *)about->private_data;
1065 return priv->wrap_license;
1069 * gtk_about_dialog_set_wrap_license:
1070 * @about: a #GtkAboutDialog
1071 * @wrap_license: whether to wrap the license
1073 * Sets whether the license text in @about is
1074 * automatically wrapped.
1079 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1080 gboolean wrap_license)
1082 GtkAboutDialogPrivate *priv;
1084 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1086 priv = (GtkAboutDialogPrivate *)about->private_data;
1088 wrap_license = wrap_license != FALSE;
1090 if (priv->wrap_license != wrap_license)
1092 priv->wrap_license = wrap_license;
1094 g_object_notify (G_OBJECT (about), "wrap-license");
1099 * gtk_about_dialog_get_website:
1100 * @about: a #GtkAboutDialog
1102 * Returns the website URL.
1104 * Return value: The website URL. The string is owned by the about
1105 * dialog and must not be modified.
1109 G_CONST_RETURN gchar *
1110 gtk_about_dialog_get_website (GtkAboutDialog *about)
1112 GtkAboutDialogPrivate *priv;
1114 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1116 priv = (GtkAboutDialogPrivate *)about->private_data;
1118 return priv->website;
1122 * gtk_about_dialog_set_website:
1123 * @about: a #GtkAboutDialog
1124 * @website: a URL string starting with "http://"
1126 * Sets the URL to use for the website link.
1131 gtk_about_dialog_set_website (GtkAboutDialog *about,
1132 const gchar *website)
1134 GtkAboutDialogPrivate *priv;
1137 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1139 priv = (GtkAboutDialogPrivate *)about->private_data;
1141 tmp = priv->website;
1142 if (website != NULL)
1144 priv->website = g_strdup (website);
1145 if (activate_url_hook != NULL)
1147 gtk_link_button_set_uri (GTK_LINK_BUTTON (priv->website_button), website);
1148 if (priv->website_label == NULL)
1149 gtk_about_dialog_set_website_label (about, website);
1153 GtkWidget *hbox = priv->website_button->parent;
1154 gtk_widget_destroy (priv->website_button);
1155 priv->website_button = gtk_label_new (website);
1156 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1157 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1158 gtk_widget_show (priv->website_button);
1163 priv->website = NULL;
1164 gtk_widget_hide (priv->website_button);
1168 g_object_notify (G_OBJECT (about), "website");
1172 * gtk_about_dialog_get_website_label:
1173 * @about: a #GtkAboutDialog
1175 * Returns the label used for the website link.
1177 * Return value: The label used for the website link. The string is owned by the about
1178 * dialog and must not be modified.
1182 G_CONST_RETURN gchar *
1183 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1185 GtkAboutDialogPrivate *priv;
1187 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1189 priv = (GtkAboutDialogPrivate *)about->private_data;
1191 return priv->website_label;
1195 * gtk_about_dialog_set_website_label:
1196 * @about: a #GtkAboutDialog
1197 * @website_label: the label used for the website link
1199 * Sets the label to be used for the website link.
1200 * It defaults to the website URL.
1205 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1206 const gchar *website_label)
1208 GtkAboutDialogPrivate *priv;
1211 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1213 priv = (GtkAboutDialogPrivate *)about->private_data;
1215 tmp = priv->website_label;
1216 if (activate_url_hook != NULL)
1218 if (website_label != NULL)
1220 priv->website_label = g_strdup (website_label);
1221 gtk_button_set_label (GTK_BUTTON (priv->website_button),
1222 priv->website_label);
1223 gtk_widget_show (priv->website_button);
1227 priv->website_label = NULL;
1228 gtk_widget_hide (priv->website_button);
1233 g_object_notify (G_OBJECT (about), "website-label");
1237 * gtk_about_dialog_get_authors:
1238 * @about: a #GtkAboutDialog
1240 * Returns the string which are displayed in the authors tab
1241 * of the secondary credits dialog.
1243 * Return value: A %NULL-terminated string array containing
1244 * the authors. The array is owned by the about dialog
1245 * and must not be modified.
1249 G_CONST_RETURN gchar * G_CONST_RETURN *
1250 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1252 GtkAboutDialogPrivate *priv;
1254 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1256 priv = (GtkAboutDialogPrivate *)about->private_data;
1258 return (const gchar * const *) priv->authors;
1262 update_credits_button_visibility (GtkAboutDialog *about)
1264 GtkAboutDialogPrivate *priv = about->private_data;
1267 show = priv->authors != NULL ||
1268 priv->documenters != NULL ||
1269 priv->artists != NULL ||
1270 (priv->translator_credits != NULL &&
1271 strcmp (priv->translator_credits, "translator_credits") &&
1272 strcmp (priv->translator_credits, "translator-credits"));
1274 gtk_widget_show (priv->credits_button);
1276 gtk_widget_hide (priv->credits_button);
1280 * gtk_about_dialog_set_authors:
1281 * @about: a #GtkAboutDialog
1282 * @authors: a %NULL-terminated array of strings
1284 * Sets the strings which are displayed in the authors tab
1285 * of the secondary credits dialog.
1290 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1291 const gchar **authors)
1293 GtkAboutDialogPrivate *priv;
1296 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1298 priv = (GtkAboutDialogPrivate *)about->private_data;
1300 tmp = priv->authors;
1301 priv->authors = g_strdupv ((gchar **)authors);
1304 update_credits_button_visibility (about);
1306 g_object_notify (G_OBJECT (about), "authors");
1310 * gtk_about_dialog_get_documenters:
1311 * @about: a #GtkAboutDialog
1313 * Returns the string which are displayed in the documenters
1314 * tab of the secondary credits dialog.
1316 * Return value: A %NULL-terminated string array containing
1317 * the documenters. The array is owned by the about dialog
1318 * and must not be modified.
1322 G_CONST_RETURN gchar * G_CONST_RETURN *
1323 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1325 GtkAboutDialogPrivate *priv;
1327 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1329 priv = (GtkAboutDialogPrivate *)about->private_data;
1331 return (const gchar * const *)priv->documenters;
1335 * gtk_about_dialog_set_documenters:
1336 * @about: a #GtkAboutDialog
1337 * @documenters: a %NULL-terminated array of strings
1339 * Sets the strings which are displayed in the documenters tab
1340 * of the secondary credits dialog.
1345 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1346 const gchar **documenters)
1348 GtkAboutDialogPrivate *priv;
1351 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1353 priv = (GtkAboutDialogPrivate *)about->private_data;
1355 tmp = priv->documenters;
1356 priv->documenters = g_strdupv ((gchar **)documenters);
1359 update_credits_button_visibility (about);
1361 g_object_notify (G_OBJECT (about), "documenters");
1365 * gtk_about_dialog_get_artists:
1366 * @about: a #GtkAboutDialog
1368 * Returns the string which are displayed in the artists tab
1369 * of the secondary credits dialog.
1371 * Return value: A %NULL-terminated string array containing
1372 * the artists. The array is owned by the about dialog
1373 * and must not be modified.
1377 G_CONST_RETURN gchar * G_CONST_RETURN *
1378 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1380 GtkAboutDialogPrivate *priv;
1382 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1384 priv = (GtkAboutDialogPrivate *)about->private_data;
1386 return (const gchar * const *)priv->artists;
1390 * gtk_about_dialog_set_artists:
1391 * @about: a #GtkAboutDialog
1392 * @artists: a %NULL-terminated array of strings
1394 * Sets the strings which are displayed in the artists tab
1395 * of the secondary credits dialog.
1400 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1401 const gchar **artists)
1403 GtkAboutDialogPrivate *priv;
1406 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1408 priv = (GtkAboutDialogPrivate *)about->private_data;
1410 tmp = priv->artists;
1411 priv->artists = g_strdupv ((gchar **)artists);
1414 update_credits_button_visibility (about);
1416 g_object_notify (G_OBJECT (about), "artists");
1420 * gtk_about_dialog_get_translator_credits:
1421 * @about: a #GtkAboutDialog
1423 * Returns the translator credits string which is displayed
1424 * in the translators tab of the secondary credits dialog.
1426 * Return value: The translator credits string. The string is
1427 * owned by the about dialog and must not be modified.
1431 G_CONST_RETURN gchar *
1432 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1434 GtkAboutDialogPrivate *priv;
1436 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1438 priv = (GtkAboutDialogPrivate *)about->private_data;
1440 return priv->translator_credits;
1444 * gtk_about_dialog_set_translator_credits:
1445 * @about: a #GtkAboutDialog
1446 * @translator_credits: the translator credits
1448 * Sets the translator credits string which is displayed in
1449 * the translators tab of the secondary credits dialog.
1451 * The intended use for this string is to display the translator
1452 * of the language which is currently used in the user interface.
1453 * Using gettext(), a simple way to achieve that is to mark the
1454 * string for translation:
1455 * <informalexample><programlisting>
1456 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1457 * </programlisting></informalexample>
1458 * It is a good idea to use the customary msgid "translator-credits" for this
1459 * purpose, since translators will already know the purpose of that msgid, and
1460 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1466 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1467 const gchar *translator_credits)
1469 GtkAboutDialogPrivate *priv;
1472 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1474 priv = (GtkAboutDialogPrivate *)about->private_data;
1476 tmp = priv->translator_credits;
1477 priv->translator_credits = g_strdup (translator_credits);
1480 update_credits_button_visibility (about);
1482 g_object_notify (G_OBJECT (about), "translator-credits");
1486 * gtk_about_dialog_get_logo:
1487 * @about: a #GtkAboutDialog
1489 * Returns the pixbuf displayed as logo in the about dialog.
1491 * Return value: the pixbuf displayed as logo. The pixbuf is
1492 * owned by the about dialog. If you want to keep a reference
1493 * to it, you have to call g_object_ref() on it.
1498 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1500 GtkAboutDialogPrivate *priv;
1502 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1504 priv = (GtkAboutDialogPrivate *)about->private_data;
1506 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1507 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1513 icon_set_new_from_pixbufs (GList *pixbufs)
1515 GtkIconSet *icon_set = gtk_icon_set_new ();
1517 for (; pixbufs; pixbufs = pixbufs->next)
1519 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1521 GtkIconSource *icon_source = gtk_icon_source_new ();
1522 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1523 gtk_icon_set_add_source (icon_set, icon_source);
1524 gtk_icon_source_free (icon_source);
1531 * gtk_about_dialog_set_logo:
1532 * @about: a #GtkAboutDialog
1533 * @logo: a #GdkPixbuf, or %NULL
1535 * Sets the pixbuf to be displayed as logo in
1536 * the about dialog. If it is %NULL, the default
1537 * window icon set with gtk_window_set_default_icon ()
1543 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1546 GtkAboutDialogPrivate *priv;
1548 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1550 priv = (GtkAboutDialogPrivate *)about->private_data;
1552 g_object_freeze_notify (G_OBJECT (about));
1554 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1555 g_object_notify (G_OBJECT (about), "logo-icon-name");
1558 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1561 GList *pixbufs = gtk_window_get_default_icon_list ();
1563 if (pixbufs != NULL)
1565 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1567 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1568 icon_set, GTK_ICON_SIZE_DIALOG);
1570 gtk_icon_set_unref (icon_set);
1571 g_list_free (pixbufs);
1575 g_object_notify (G_OBJECT (about), "logo");
1577 g_object_thaw_notify (G_OBJECT (about));
1581 * gtk_about_dialog_get_logo_icon_name:
1582 * @about: a #GtkAboutDialog
1584 * Returns the icon name displayed as logo in the about dialog.
1586 * Return value: the icon name displayed as logo. The string is
1587 * owned by the dialog. If you want to keep a reference
1588 * to it, you have to call g_strdup() on it.
1592 G_CONST_RETURN gchar *
1593 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1595 GtkAboutDialogPrivate *priv;
1596 const gchar *icon_name = NULL;
1598 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1600 priv = (GtkAboutDialogPrivate *)about->private_data;
1602 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1603 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1609 * gtk_about_dialog_set_logo_icon_name:
1610 * @about: a #GtkAboutDialog
1611 * @icon_name: an icon name, or %NULL
1613 * Sets the pixbuf to be displayed as logo in
1614 * the about dialog. If it is %NULL, the default
1615 * window icon set with gtk_window_set_default_icon()
1621 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1622 const gchar *icon_name)
1624 GtkAboutDialogPrivate *priv;
1626 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1628 priv = (GtkAboutDialogPrivate *)about->private_data;
1630 g_object_freeze_notify (G_OBJECT (about));
1632 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1633 g_object_notify (G_OBJECT (about), "logo");
1635 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1636 GTK_ICON_SIZE_DIALOG);
1637 g_object_notify (G_OBJECT (about), "logo-icon-name");
1639 g_object_thaw_notify (G_OBJECT (about));
1643 activate_url (GtkWidget *widget,
1646 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1647 const gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
1649 if (activate_url_hook != NULL)
1650 (* activate_url_hook) (about, url, activate_url_hook_data);
1654 follow_if_link (GtkAboutDialog *about,
1655 GtkTextView *text_view,
1658 GSList *tags = NULL, *tagp = NULL;
1659 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1662 tags = gtk_text_iter_get_tags (iter);
1663 for (tagp = tags; tagp != NULL && !url; tagp = tagp->next)
1665 GtkTextTag *tag = tagp->data;
1667 if (activate_email_hook != NULL)
1669 url = g_object_get_data (G_OBJECT (tag), "email");
1671 (* activate_email_hook) (about, url, activate_email_hook_data);
1674 if (!url && activate_url_hook != NULL)
1676 url = g_object_get_data (G_OBJECT (tag), "url");
1678 (* activate_url_hook) (about, url, activate_url_hook_data);
1681 if (url && !g_slist_find_custom (priv->visited_links, url, (GCompareFunc)strcmp))
1683 GdkColor *style_visited_link_color;
1686 gtk_widget_ensure_style (GTK_WIDGET (about));
1687 gtk_widget_style_get (GTK_WIDGET (about),
1688 "visited-link-color", &style_visited_link_color,
1690 if (style_visited_link_color)
1692 color = *style_visited_link_color;
1693 gdk_color_free (style_visited_link_color);
1696 color = default_visited_link_color;
1698 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1700 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (url));
1705 g_slist_free (tags);
1709 credits_key_press_event (GtkWidget *text_view,
1711 GtkAboutDialog *about)
1714 GtkTextBuffer *buffer;
1716 switch (event->keyval)
1720 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1721 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1722 gtk_text_buffer_get_insert (buffer));
1723 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1734 credits_event_after (GtkWidget *text_view,
1736 GtkAboutDialog *about)
1738 GtkTextIter start, end, iter;
1739 GtkTextBuffer *buffer;
1740 GdkEventButton *button_event;
1743 if (event->type != GDK_BUTTON_RELEASE)
1746 button_event = (GdkEventButton *)event;
1748 if (button_event->button != 1)
1751 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1753 /* we shouldn't follow a link if the user has selected something */
1754 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1755 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1758 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1759 GTK_TEXT_WINDOW_WIDGET,
1760 button_event->x, button_event->y, &x, &y);
1762 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1764 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1770 set_cursor_if_appropriate (GtkAboutDialog *about,
1771 GtkTextView *text_view,
1775 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1776 GSList *tags = NULL, *tagp = NULL;
1778 gboolean hovering_over_link = FALSE;
1780 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1782 tags = gtk_text_iter_get_tags (&iter);
1783 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1785 GtkTextTag *tag = tagp->data;
1786 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1787 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1789 if (email != NULL || url != NULL)
1791 hovering_over_link = TRUE;
1796 if (hovering_over_link != priv->hovering_over_link)
1798 priv->hovering_over_link = hovering_over_link;
1800 if (hovering_over_link)
1801 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1803 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1807 g_slist_free (tags);
1811 credits_motion_notify_event (GtkWidget *text_view,
1812 GdkEventMotion *event,
1813 GtkAboutDialog *about)
1817 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1818 GTK_TEXT_WINDOW_WIDGET,
1819 event->x, event->y, &x, &y);
1821 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1823 gdk_event_request_motions (event);
1830 credits_visibility_notify_event (GtkWidget *text_view,
1831 GdkEventVisibility *event,
1832 GtkAboutDialog *about)
1834 gint wx, wy, bx, by;
1836 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1838 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1839 GTK_TEXT_WINDOW_WIDGET,
1842 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1848 text_view_style_set (GtkWidget *widget,
1849 GtkStyle *prev_style,
1850 GtkWidget *text_view)
1852 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1853 &widget->style->bg[GTK_STATE_NORMAL]);
1857 add_credits_page (GtkAboutDialog *about,
1858 GtkWidget *notebook,
1863 gchar *q0, *q1, *q2, *r1, *r2;
1864 GtkWidget *sw, *view;
1865 GtkTextBuffer *buffer;
1866 gboolean linkify_email, linkify_urls;
1867 GdkColor *style_link_color;
1868 GdkColor *style_visited_link_color;
1870 GdkColor link_color;
1871 GdkColor visited_link_color;
1872 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1874 linkify_email = (activate_email_hook != NULL);
1875 linkify_urls = (activate_url_hook != NULL);
1877 gtk_widget_ensure_style (GTK_WIDGET (about));
1878 gtk_widget_style_get (GTK_WIDGET (about),
1879 "link-color", &style_link_color,
1880 "visited-link-color", &style_visited_link_color,
1882 if (style_link_color)
1884 link_color = *style_link_color;
1885 gdk_color_free (style_link_color);
1888 link_color = default_link_color;
1890 if (style_visited_link_color)
1892 visited_link_color = *style_visited_link_color;
1893 gdk_color_free (style_visited_link_color);
1896 visited_link_color = default_visited_link_color;
1898 view = gtk_text_view_new ();
1899 g_signal_connect_object (about, "style_set",
1900 G_CALLBACK (text_view_style_set), view, 0);
1902 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1903 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1904 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1906 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1907 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1909 g_signal_connect (view, "key_press_event",
1910 G_CALLBACK (credits_key_press_event), about);
1911 g_signal_connect (view, "event_after",
1912 G_CALLBACK (credits_event_after), about);
1913 g_signal_connect (view, "motion_notify_event",
1914 G_CALLBACK (credits_motion_notify_event), about);
1915 g_signal_connect (view, "visibility_notify_event",
1916 G_CALLBACK (credits_visibility_notify_event), about);
1918 sw = gtk_scrolled_window_new (NULL, NULL);
1919 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1921 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1922 GTK_POLICY_AUTOMATIC,
1923 GTK_POLICY_AUTOMATIC);
1924 gtk_container_add (GTK_CONTAINER (sw), view);
1926 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1927 sw, gtk_label_new (title));
1931 gtk_widget_hide (view);
1935 gtk_widget_show (view);
1937 for (p = people; *p; p++)
1942 q1 = linkify_email ? strchr (q0, '<') : NULL;
1943 q2 = q1 ? strchr (q1, '>') : NULL;
1944 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1947 r2 = strpbrk (r1, " \n\t");
1949 r2 = strchr (r1, '\0');
1954 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1964 const gchar *link_type;
1967 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1968 gtk_text_buffer_get_end_iter (buffer, &end);
1976 link_type = I_("email");
1979 link_type = I_("url");
1981 link = g_strndup (q1, q2 - q1);
1983 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
1984 color = visited_link_color;
1988 tag = gtk_text_buffer_create_tag (buffer, NULL,
1989 "foreground-gdk", &color,
1990 "underline", PANGO_UNDERLINE_SINGLE,
1992 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1993 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1999 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
2005 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
2010 display_credits_dialog (GtkWidget *button,
2013 GtkAboutDialog *about = (GtkAboutDialog *)data;
2014 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2015 GtkWidget *dialog, *notebook;
2016 GtkDialog *credits_dialog;
2018 if (priv->credits_dialog != NULL)
2020 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
2024 dialog = gtk_dialog_new_with_buttons (_("Credits"),
2026 GTK_DIALOG_DESTROY_WITH_PARENT,
2027 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2029 credits_dialog = GTK_DIALOG (dialog);
2030 gtk_dialog_set_has_separator (credits_dialog, FALSE);
2031 gtk_container_set_border_width (GTK_CONTAINER (credits_dialog), 5);
2032 gtk_box_set_spacing (GTK_BOX (credits_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
2033 gtk_container_set_border_width (GTK_CONTAINER (credits_dialog->action_area), 5);
2035 priv->credits_dialog = dialog;
2036 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
2037 gtk_dialog_set_default_response (credits_dialog, GTK_RESPONSE_CANCEL);
2039 gtk_window_set_modal (GTK_WINDOW (dialog),
2040 gtk_window_get_modal (GTK_WINDOW (about)));
2042 g_signal_connect (dialog, "response",
2043 G_CALLBACK (gtk_widget_destroy), dialog);
2044 g_signal_connect (dialog, "destroy",
2045 G_CALLBACK (gtk_widget_destroyed),
2046 &(priv->credits_dialog));
2048 notebook = gtk_notebook_new ();
2049 gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
2050 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
2052 if (priv->authors != NULL)
2053 add_credits_page (about, notebook, _("Written by"), priv->authors);
2055 if (priv->documenters != NULL)
2056 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
2058 /* Don't show an untranslated gettext msgid */
2059 if (priv->translator_credits != NULL &&
2060 strcmp (priv->translator_credits, "translator_credits") &&
2061 strcmp (priv->translator_credits, "translator-credits"))
2063 gchar *translators[2];
2065 translators[0] = priv->translator_credits;
2066 translators[1] = NULL;
2068 add_credits_page (about, notebook, _("Translated by"), translators);
2071 if (priv->artists != NULL)
2072 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
2074 gtk_widget_show_all (dialog);
2078 set_policy (GtkWidget *sw)
2080 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2081 GTK_POLICY_AUTOMATIC,
2082 GTK_POLICY_AUTOMATIC);
2086 display_license_dialog (GtkWidget *button,
2089 GtkAboutDialog *about = (GtkAboutDialog *)data;
2090 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2091 GtkWidget *dialog, *view, *sw;
2092 GtkDialog *licence_dialog;
2094 if (priv->license_dialog != NULL)
2096 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2100 dialog = gtk_dialog_new_with_buttons (_("License"),
2102 GTK_DIALOG_DESTROY_WITH_PARENT,
2103 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2105 licence_dialog = GTK_DIALOG (dialog);
2106 gtk_dialog_set_has_separator (licence_dialog, FALSE);
2107 gtk_container_set_border_width (GTK_CONTAINER (licence_dialog), 5);
2108 gtk_box_set_spacing (GTK_BOX (licence_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
2109 gtk_container_set_border_width (GTK_CONTAINER (licence_dialog->action_area), 5);
2111 priv->license_dialog = dialog;
2112 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2113 gtk_dialog_set_default_response (licence_dialog, GTK_RESPONSE_CANCEL);
2115 gtk_window_set_modal (GTK_WINDOW (dialog),
2116 gtk_window_get_modal (GTK_WINDOW (about)));
2118 g_signal_connect (dialog, "response",
2119 G_CALLBACK (gtk_widget_destroy), dialog);
2120 g_signal_connect (dialog, "destroy",
2121 G_CALLBACK (gtk_widget_destroyed),
2122 &(priv->license_dialog));
2124 sw = gtk_scrolled_window_new (NULL, NULL);
2125 gtk_container_set_border_width (GTK_CONTAINER (sw), 5);
2126 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2128 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2130 GTK_POLICY_AUTOMATIC);
2131 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2132 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2134 view = gtk_text_view_new ();
2135 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
2136 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2137 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2140 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2141 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2143 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2144 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2146 gtk_container_add (GTK_CONTAINER (sw), view);
2148 gtk_widget_show_all (dialog);
2152 * gtk_about_dialog_new:
2154 * Creates a new #GtkAboutDialog.
2156 * Returns: a newly created #GtkAboutDialog
2161 gtk_about_dialog_new (void)
2163 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2165 return GTK_WIDGET (dialog);
2169 * gtk_about_dialog_set_email_hook:
2170 * @func: a function to call when an email link is activated.
2171 * @data: data to pass to @func
2172 * @destroy: #GDestroyNotify for @data
2174 * Installs a global function to be called whenever the user activates an
2175 * email link in an about dialog.
2177 * Return value: the previous email hook.
2181 GtkAboutDialogActivateLinkFunc
2182 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2184 GDestroyNotify destroy)
2186 GtkAboutDialogActivateLinkFunc old;
2188 if (activate_email_hook_destroy != NULL)
2189 (* activate_email_hook_destroy) (activate_email_hook_data);
2191 old = activate_email_hook;
2193 activate_email_hook = func;
2194 activate_email_hook_data = data;
2195 activate_email_hook_destroy = destroy;
2201 * gtk_about_dialog_set_url_hook:
2202 * @func: a function to call when a URL link is activated.
2203 * @data: data to pass to @func
2204 * @destroy: #GDestroyNotify for @data
2206 * Installs a global function to be called whenever the user activates a
2207 * URL link in an about dialog.
2209 * Return value: the previous URL hook.
2213 GtkAboutDialogActivateLinkFunc
2214 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2216 GDestroyNotify destroy)
2218 GtkAboutDialogActivateLinkFunc old;
2220 if (activate_url_hook_destroy != NULL)
2221 (* activate_url_hook_destroy) (activate_url_hook_data);
2223 old = activate_url_hook;
2225 activate_url_hook = func;
2226 activate_url_hook_data = data;
2227 activate_url_hook_destroy = destroy;
2233 close_cb (GtkAboutDialog *about)
2235 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2237 if (priv->license_dialog != NULL)
2239 gtk_widget_destroy (priv->license_dialog);
2240 priv->license_dialog = NULL;
2243 if (priv->credits_dialog != NULL)
2245 gtk_widget_destroy (priv->credits_dialog);
2246 priv->credits_dialog = NULL;
2249 gtk_widget_hide (GTK_WIDGET (about));
2254 * gtk_show_about_dialog:
2255 * @parent: transient parent, or %NULL for none
2256 * @first_property_name: the name of the first property
2257 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2259 * This is a convenience function for showing an application's about box.
2260 * The constructed dialog is associated with the parent window and
2261 * reused for future invocations of this function.
2266 gtk_show_about_dialog (GtkWindow *parent,
2267 const gchar *first_property_name,
2270 static GtkWidget *global_about_dialog = NULL;
2271 GtkWidget *dialog = NULL;
2275 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2277 dialog = global_about_dialog;
2281 dialog = gtk_about_dialog_new ();
2283 g_object_ref_sink (dialog);
2285 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2287 /* Close dialog on user response */
2288 g_signal_connect (dialog, "response", G_CALLBACK (close_cb), NULL);
2290 va_start (var_args, first_property_name);
2291 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2296 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2297 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2298 g_object_set_data_full (G_OBJECT (parent),
2299 I_("gtk-about-dialog"),
2300 dialog, g_object_unref);
2303 global_about_dialog = dialog;
2307 gtk_window_present (GTK_WINDOW (dialog));
2310 #define __GTK_ABOUT_DIALOG_C__
2311 #include "gtkaliasdef.c"