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:program-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",
509 G_CALLBACK (display_credits_dialog), about);
510 priv->credits_button = button;
511 priv->credits_dialog = NULL;
513 /* Add the license button */
514 button = gtk_button_new_from_stock (_("_License"));
515 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
516 gtk_widget_set_no_show_all (button, TRUE);
517 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
518 button, FALSE, TRUE, 0);
519 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
520 g_signal_connect (button, "clicked",
521 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 ();
529 gtk_widget_grab_default (close_button);
530 gtk_widget_grab_focus (close_button);
533 gtk_about_dialog_set_program_name (about, NULL);
534 gtk_about_dialog_set_logo (about, NULL);
538 gtk_about_dialog_finalize (GObject *object)
540 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
541 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
544 g_free (priv->version);
545 g_free (priv->copyright);
546 g_free (priv->comments);
547 g_free (priv->license);
548 g_free (priv->website);
549 g_free (priv->website_label);
550 g_free (priv->translator_credits);
552 g_strfreev (priv->authors);
553 g_strfreev (priv->documenters);
554 g_strfreev (priv->artists);
556 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
557 g_slist_free (priv->visited_links);
559 gdk_cursor_unref (priv->hand_cursor);
560 gdk_cursor_unref (priv->regular_cursor);
562 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
566 gtk_about_dialog_set_property (GObject *object,
571 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
572 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
577 gtk_about_dialog_set_program_name (about, g_value_get_string (value));
580 gtk_about_dialog_set_version (about, g_value_get_string (value));
583 gtk_about_dialog_set_comments (about, g_value_get_string (value));
586 gtk_about_dialog_set_website (about, g_value_get_string (value));
588 case PROP_WEBSITE_LABEL:
589 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
592 gtk_about_dialog_set_license (about, g_value_get_string (value));
595 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
598 gtk_about_dialog_set_logo (about, g_value_get_object (value));
601 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
603 case PROP_DOCUMENTERS:
604 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
607 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
609 case PROP_TRANSLATOR_CREDITS:
610 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
612 case PROP_LOGO_ICON_NAME:
613 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
615 case PROP_WRAP_LICENSE:
616 priv->wrap_license = g_value_get_boolean (value);
619 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
625 gtk_about_dialog_get_property (GObject *object,
630 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
631 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
636 g_value_set_string (value, priv->name);
639 g_value_set_string (value, priv->version);
642 g_value_set_string (value, priv->copyright);
645 g_value_set_string (value, priv->comments);
648 g_value_set_string (value, priv->website);
650 case PROP_WEBSITE_LABEL:
651 g_value_set_string (value, priv->website_label);
654 g_value_set_string (value, priv->license);
656 case PROP_TRANSLATOR_CREDITS:
657 g_value_set_string (value, priv->translator_credits);
660 g_value_set_boxed (value, priv->authors);
662 case PROP_DOCUMENTERS:
663 g_value_set_boxed (value, priv->documenters);
666 g_value_set_boxed (value, priv->artists);
669 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
670 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
672 g_value_set_object (value, NULL);
674 case PROP_LOGO_ICON_NAME:
675 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
677 const gchar *icon_name;
679 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
680 g_value_set_string (value, icon_name);
683 g_value_set_string (value, NULL);
685 case PROP_WRAP_LICENSE:
686 g_value_set_boolean (value, priv->wrap_license);
689 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
695 * gtk_about_dialog_get_name:
696 * @about: a #GtkAboutDialog
698 * Returns the program name displayed in the about dialog.
700 * Return value: The program name. The string is owned by the about
701 * dialog and must not be modified.
705 * Deprecated: 2.12: Use gtk_about_dialog_get_program_name() instead.
707 G_CONST_RETURN gchar *
708 gtk_about_dialog_get_name (GtkAboutDialog *about)
710 return gtk_about_dialog_get_program_name (about);
714 * gtk_about_dialog_get_program_name:
715 * @about: a #GtkAboutDialog
717 * Returns the program name displayed in the about dialog.
719 * Return value: The program name. The string is owned by the about
720 * dialog and must not be modified.
724 G_CONST_RETURN gchar *
725 gtk_about_dialog_get_program_name (GtkAboutDialog *about)
727 GtkAboutDialogPrivate *priv;
729 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
731 priv = (GtkAboutDialogPrivate *)about->private_data;
737 update_name_version (GtkAboutDialog *about)
739 GtkAboutDialogPrivate *priv;
740 gchar *title_string, *name_string;
742 priv = (GtkAboutDialogPrivate *)about->private_data;
744 title_string = g_strdup_printf (_("About %s"), priv->name);
745 gtk_window_set_title (GTK_WINDOW (about), title_string);
746 g_free (title_string);
748 if (priv->version != NULL)
749 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
750 priv->name, priv->version);
752 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
755 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
757 g_free (name_string);
761 * gtk_about_dialog_set_name:
762 * @about: a #GtkAboutDialog
763 * @name: the program name
765 * Sets the name to display in the about dialog.
766 * If this is not set, it defaults to g_get_application_name().
770 * Deprecated: 2.12: Use gtk_about_dialog_set_program_name() instead.
773 gtk_about_dialog_set_name (GtkAboutDialog *about,
776 gtk_about_dialog_set_program_name (about, name);
780 * gtk_about_dialog_set_program_name:
781 * @about: a #GtkAboutDialog
782 * @name: the program name
784 * Sets the name to display in the about dialog.
785 * If this is not set, it defaults to g_get_application_name().
790 gtk_about_dialog_set_program_name (GtkAboutDialog *about,
793 GtkAboutDialogPrivate *priv;
796 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
798 priv = (GtkAboutDialogPrivate *)about->private_data;
800 priv->name = g_strdup (name ? name : g_get_application_name ());
803 update_name_version (about);
805 g_object_notify (G_OBJECT (about), "program-name");
810 * gtk_about_dialog_get_version:
811 * @about: a #GtkAboutDialog
813 * Returns the version string.
815 * Return value: The version string. The string is owned by the about
816 * dialog and must not be modified.
820 G_CONST_RETURN gchar *
821 gtk_about_dialog_get_version (GtkAboutDialog *about)
823 GtkAboutDialogPrivate *priv;
825 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
827 priv = (GtkAboutDialogPrivate *)about->private_data;
829 return priv->version;
833 * gtk_about_dialog_set_version:
834 * @about: a #GtkAboutDialog
835 * @version: the version string
837 * Sets the version string to display in the about dialog.
842 gtk_about_dialog_set_version (GtkAboutDialog *about,
843 const gchar *version)
845 GtkAboutDialogPrivate *priv;
848 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
850 priv = (GtkAboutDialogPrivate *)about->private_data;
853 priv->version = g_strdup (version);
856 update_name_version (about);
858 g_object_notify (G_OBJECT (about), "version");
862 * gtk_about_dialog_get_copyright:
863 * @about: a #GtkAboutDialog
865 * Returns the copyright string.
867 * Return value: The copyright string. The string is owned by the about
868 * dialog and must not be modified.
872 G_CONST_RETURN gchar *
873 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
875 GtkAboutDialogPrivate *priv;
877 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
879 priv = (GtkAboutDialogPrivate *)about->private_data;
881 return priv->copyright;
885 * gtk_about_dialog_set_copyright:
886 * @about: a #GtkAboutDialog
887 * @copyright: the copyright string
889 * Sets the copyright string to display in the about dialog.
890 * This should be a short string of one or two lines.
895 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
896 const gchar *copyright)
898 GtkAboutDialogPrivate *priv;
899 gchar *copyright_string, *tmp;
901 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
903 priv = (GtkAboutDialogPrivate *)about->private_data;
905 tmp = priv->copyright;
906 priv->copyright = g_strdup (copyright);
909 if (priv->copyright != NULL)
911 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
913 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
914 g_free (copyright_string);
916 gtk_widget_show (priv->copyright_label);
919 gtk_widget_hide (priv->copyright_label);
921 g_object_notify (G_OBJECT (about), "copyright");
925 * gtk_about_dialog_get_comments:
926 * @about: a #GtkAboutDialog
928 * Returns the comments string.
930 * Return value: The comments. The string is owned by the about
931 * dialog and must not be modified.
935 G_CONST_RETURN gchar *
936 gtk_about_dialog_get_comments (GtkAboutDialog *about)
938 GtkAboutDialogPrivate *priv;
940 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
942 priv = (GtkAboutDialogPrivate *)about->private_data;
944 return priv->comments;
948 * gtk_about_dialog_set_comments:
949 * @about: a #GtkAboutDialog
950 * @comments: a comments string
952 * Sets the comments string to display in the about
953 * dialog. This should be a short string of one or
959 gtk_about_dialog_set_comments (GtkAboutDialog *about,
960 const gchar *comments)
962 GtkAboutDialogPrivate *priv;
965 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
967 priv = (GtkAboutDialogPrivate *)about->private_data;
969 tmp = priv->comments;
972 priv->comments = g_strdup (comments);
973 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
974 gtk_widget_show (priv->comments_label);
978 priv->comments = NULL;
979 gtk_widget_hide (priv->comments_label);
983 g_object_notify (G_OBJECT (about), "comments");
987 * gtk_about_dialog_get_license:
988 * @about: a #GtkAboutDialog
990 * Returns the license information.
992 * Return value: The license information. The string is owned by the about
993 * dialog and must not be modified.
997 G_CONST_RETURN gchar *
998 gtk_about_dialog_get_license (GtkAboutDialog *about)
1000 GtkAboutDialogPrivate *priv;
1002 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1004 priv = (GtkAboutDialogPrivate *)about->private_data;
1006 return priv->license;
1010 * gtk_about_dialog_set_license:
1011 * @about: a #GtkAboutDialog
1012 * @license: the license information or %NULL
1014 * Sets the license information to be displayed in the secondary
1015 * license dialog. If @license is %NULL, the license button is
1021 gtk_about_dialog_set_license (GtkAboutDialog *about,
1022 const gchar *license)
1024 GtkAboutDialogPrivate *priv;
1027 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1029 priv = (GtkAboutDialogPrivate *)about->private_data;
1031 tmp = priv->license;
1034 priv->license = g_strdup (license);
1035 gtk_widget_show (priv->license_button);
1039 priv->license = NULL;
1040 gtk_widget_hide (priv->license_button);
1044 g_object_notify (G_OBJECT (about), "license");
1048 * gtk_about_dialog_get_wrap_license:
1049 * @about: a #GtkAboutDialog
1051 * Returns whether the license text in @about is
1052 * automatically wrapped.
1054 * Returns: %TRUE if the license text is wrapped
1059 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1061 GtkAboutDialogPrivate *priv;
1063 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1065 priv = (GtkAboutDialogPrivate *)about->private_data;
1067 return priv->wrap_license;
1071 * gtk_about_dialog_set_wrap_license:
1072 * @about: a #GtkAboutDialog
1073 * @wrap_license: whether to wrap the license
1075 * Sets whether the license text in @about is
1076 * automatically wrapped.
1081 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1082 gboolean wrap_license)
1084 GtkAboutDialogPrivate *priv;
1086 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1088 priv = (GtkAboutDialogPrivate *)about->private_data;
1090 wrap_license = wrap_license != FALSE;
1092 if (priv->wrap_license != wrap_license)
1094 priv->wrap_license = wrap_license;
1096 g_object_notify (G_OBJECT (about), "wrap-license");
1101 * gtk_about_dialog_get_website:
1102 * @about: a #GtkAboutDialog
1104 * Returns the website URL.
1106 * Return value: The website URL. The string is owned by the about
1107 * dialog and must not be modified.
1111 G_CONST_RETURN gchar *
1112 gtk_about_dialog_get_website (GtkAboutDialog *about)
1114 GtkAboutDialogPrivate *priv;
1116 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1118 priv = (GtkAboutDialogPrivate *)about->private_data;
1120 return priv->website;
1124 * gtk_about_dialog_set_website:
1125 * @about: a #GtkAboutDialog
1126 * @website: a URL string starting with "http://"
1128 * Sets the URL to use for the website link.
1130 * Note that that the hook functions need to be set up
1131 * before calling this function.
1136 gtk_about_dialog_set_website (GtkAboutDialog *about,
1137 const gchar *website)
1139 GtkAboutDialogPrivate *priv;
1142 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1144 priv = (GtkAboutDialogPrivate *)about->private_data;
1146 tmp = priv->website;
1147 if (website != NULL)
1149 priv->website = g_strdup (website);
1150 if (activate_url_hook != NULL)
1152 gtk_link_button_set_uri (GTK_LINK_BUTTON (priv->website_button), website);
1153 if (priv->website_label == NULL)
1154 gtk_about_dialog_set_website_label (about, website);
1158 GtkWidget *hbox = priv->website_button->parent;
1159 gtk_widget_destroy (priv->website_button);
1160 priv->website_button = gtk_label_new (website);
1161 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1162 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1163 gtk_widget_show (priv->website_button);
1168 priv->website = NULL;
1169 gtk_widget_hide (priv->website_button);
1173 g_object_notify (G_OBJECT (about), "website");
1177 * gtk_about_dialog_get_website_label:
1178 * @about: a #GtkAboutDialog
1180 * Returns the label used for the website link.
1182 * Return value: The label used for the website link. The string is owned by the about
1183 * dialog and must not be modified.
1187 G_CONST_RETURN gchar *
1188 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1190 GtkAboutDialogPrivate *priv;
1192 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1194 priv = (GtkAboutDialogPrivate *)about->private_data;
1196 return priv->website_label;
1200 * gtk_about_dialog_set_website_label:
1201 * @about: a #GtkAboutDialog
1202 * @website_label: the label used for the website link
1204 * Sets the label to be used for the website link.
1205 * It defaults to the website URL.
1210 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1211 const gchar *website_label)
1213 GtkAboutDialogPrivate *priv;
1216 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1218 priv = (GtkAboutDialogPrivate *)about->private_data;
1220 tmp = priv->website_label;
1221 if (activate_url_hook != NULL)
1223 if (website_label != NULL)
1225 priv->website_label = g_strdup (website_label);
1226 gtk_button_set_label (GTK_BUTTON (priv->website_button),
1227 priv->website_label);
1228 gtk_widget_show (priv->website_button);
1232 priv->website_label = NULL;
1233 gtk_widget_hide (priv->website_button);
1238 g_object_notify (G_OBJECT (about), "website-label");
1242 * gtk_about_dialog_get_authors:
1243 * @about: a #GtkAboutDialog
1245 * Returns the string which are displayed in the authors tab
1246 * of the secondary credits dialog.
1248 * Return value: A %NULL-terminated string array containing
1249 * the authors. The array is owned by the about dialog
1250 * and must not be modified.
1254 G_CONST_RETURN gchar * G_CONST_RETURN *
1255 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1257 GtkAboutDialogPrivate *priv;
1259 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1261 priv = (GtkAboutDialogPrivate *)about->private_data;
1263 return (const gchar * const *) priv->authors;
1267 update_credits_button_visibility (GtkAboutDialog *about)
1269 GtkAboutDialogPrivate *priv = about->private_data;
1272 show = priv->authors != NULL ||
1273 priv->documenters != NULL ||
1274 priv->artists != NULL ||
1275 (priv->translator_credits != NULL &&
1276 strcmp (priv->translator_credits, "translator_credits") &&
1277 strcmp (priv->translator_credits, "translator-credits"));
1279 gtk_widget_show (priv->credits_button);
1281 gtk_widget_hide (priv->credits_button);
1285 * gtk_about_dialog_set_authors:
1286 * @about: a #GtkAboutDialog
1287 * @authors: a %NULL-terminated array of strings
1289 * Sets the strings which are displayed in the authors tab
1290 * of the secondary credits dialog.
1295 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1296 const gchar **authors)
1298 GtkAboutDialogPrivate *priv;
1301 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1303 priv = (GtkAboutDialogPrivate *)about->private_data;
1305 tmp = priv->authors;
1306 priv->authors = g_strdupv ((gchar **)authors);
1309 update_credits_button_visibility (about);
1311 g_object_notify (G_OBJECT (about), "authors");
1315 * gtk_about_dialog_get_documenters:
1316 * @about: a #GtkAboutDialog
1318 * Returns the string which are displayed in the documenters
1319 * tab of the secondary credits dialog.
1321 * Return value: A %NULL-terminated string array containing
1322 * the documenters. The array is owned by the about dialog
1323 * and must not be modified.
1327 G_CONST_RETURN gchar * G_CONST_RETURN *
1328 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1330 GtkAboutDialogPrivate *priv;
1332 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1334 priv = (GtkAboutDialogPrivate *)about->private_data;
1336 return (const gchar * const *)priv->documenters;
1340 * gtk_about_dialog_set_documenters:
1341 * @about: a #GtkAboutDialog
1342 * @documenters: a %NULL-terminated array of strings
1344 * Sets the strings which are displayed in the documenters tab
1345 * of the secondary credits dialog.
1350 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1351 const gchar **documenters)
1353 GtkAboutDialogPrivate *priv;
1356 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1358 priv = (GtkAboutDialogPrivate *)about->private_data;
1360 tmp = priv->documenters;
1361 priv->documenters = g_strdupv ((gchar **)documenters);
1364 update_credits_button_visibility (about);
1366 g_object_notify (G_OBJECT (about), "documenters");
1370 * gtk_about_dialog_get_artists:
1371 * @about: a #GtkAboutDialog
1373 * Returns the string which are displayed in the artists tab
1374 * of the secondary credits dialog.
1376 * Return value: A %NULL-terminated string array containing
1377 * the artists. The array is owned by the about dialog
1378 * and must not be modified.
1382 G_CONST_RETURN gchar * G_CONST_RETURN *
1383 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1385 GtkAboutDialogPrivate *priv;
1387 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1389 priv = (GtkAboutDialogPrivate *)about->private_data;
1391 return (const gchar * const *)priv->artists;
1395 * gtk_about_dialog_set_artists:
1396 * @about: a #GtkAboutDialog
1397 * @artists: a %NULL-terminated array of strings
1399 * Sets the strings which are displayed in the artists tab
1400 * of the secondary credits dialog.
1405 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1406 const gchar **artists)
1408 GtkAboutDialogPrivate *priv;
1411 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1413 priv = (GtkAboutDialogPrivate *)about->private_data;
1415 tmp = priv->artists;
1416 priv->artists = g_strdupv ((gchar **)artists);
1419 update_credits_button_visibility (about);
1421 g_object_notify (G_OBJECT (about), "artists");
1425 * gtk_about_dialog_get_translator_credits:
1426 * @about: a #GtkAboutDialog
1428 * Returns the translator credits string which is displayed
1429 * in the translators tab of the secondary credits dialog.
1431 * Return value: The translator credits string. The string is
1432 * owned by the about dialog and must not be modified.
1436 G_CONST_RETURN gchar *
1437 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1439 GtkAboutDialogPrivate *priv;
1441 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1443 priv = (GtkAboutDialogPrivate *)about->private_data;
1445 return priv->translator_credits;
1449 * gtk_about_dialog_set_translator_credits:
1450 * @about: a #GtkAboutDialog
1451 * @translator_credits: the translator credits
1453 * Sets the translator credits string which is displayed in
1454 * the translators tab of the secondary credits dialog.
1456 * The intended use for this string is to display the translator
1457 * of the language which is currently used in the user interface.
1458 * Using gettext(), a simple way to achieve that is to mark the
1459 * string for translation:
1461 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1463 * It is a good idea to use the customary msgid "translator-credits" for this
1464 * purpose, since translators will already know the purpose of that msgid, and
1465 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1471 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1472 const gchar *translator_credits)
1474 GtkAboutDialogPrivate *priv;
1477 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1479 priv = (GtkAboutDialogPrivate *)about->private_data;
1481 tmp = priv->translator_credits;
1482 priv->translator_credits = g_strdup (translator_credits);
1485 update_credits_button_visibility (about);
1487 g_object_notify (G_OBJECT (about), "translator-credits");
1491 * gtk_about_dialog_get_logo:
1492 * @about: a #GtkAboutDialog
1494 * Returns the pixbuf displayed as logo in the about dialog.
1496 * Return value: the pixbuf displayed as logo. The pixbuf is
1497 * owned by the about dialog. If you want to keep a reference
1498 * to it, you have to call g_object_ref() on it.
1503 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1505 GtkAboutDialogPrivate *priv;
1507 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1509 priv = (GtkAboutDialogPrivate *)about->private_data;
1511 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1512 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1518 icon_set_new_from_pixbufs (GList *pixbufs)
1520 GtkIconSet *icon_set = gtk_icon_set_new ();
1522 for (; pixbufs; pixbufs = pixbufs->next)
1524 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1526 GtkIconSource *icon_source = gtk_icon_source_new ();
1527 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1528 gtk_icon_set_add_source (icon_set, icon_source);
1529 gtk_icon_source_free (icon_source);
1536 * gtk_about_dialog_set_logo:
1537 * @about: a #GtkAboutDialog
1538 * @logo: a #GdkPixbuf, or %NULL
1540 * Sets the pixbuf to be displayed as logo in
1541 * the about dialog. If it is %NULL, the default
1542 * window icon set with gtk_window_set_default_icon ()
1548 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1551 GtkAboutDialogPrivate *priv;
1553 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1555 priv = (GtkAboutDialogPrivate *)about->private_data;
1557 g_object_freeze_notify (G_OBJECT (about));
1559 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1560 g_object_notify (G_OBJECT (about), "logo-icon-name");
1563 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1566 GList *pixbufs = gtk_window_get_default_icon_list ();
1568 if (pixbufs != NULL)
1570 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1572 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1573 icon_set, GTK_ICON_SIZE_DIALOG);
1575 gtk_icon_set_unref (icon_set);
1576 g_list_free (pixbufs);
1580 g_object_notify (G_OBJECT (about), "logo");
1582 g_object_thaw_notify (G_OBJECT (about));
1586 * gtk_about_dialog_get_logo_icon_name:
1587 * @about: a #GtkAboutDialog
1589 * Returns the icon name displayed as logo in the about dialog.
1591 * Return value: the icon name displayed as logo. The string is
1592 * owned by the dialog. If you want to keep a reference
1593 * to it, you have to call g_strdup() on it.
1597 G_CONST_RETURN gchar *
1598 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1600 GtkAboutDialogPrivate *priv;
1601 const gchar *icon_name = NULL;
1603 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1605 priv = (GtkAboutDialogPrivate *)about->private_data;
1607 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1608 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1614 * gtk_about_dialog_set_logo_icon_name:
1615 * @about: a #GtkAboutDialog
1616 * @icon_name: an icon name, or %NULL
1618 * Sets the pixbuf to be displayed as logo in
1619 * the about dialog. If it is %NULL, the default
1620 * window icon set with gtk_window_set_default_icon()
1626 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1627 const gchar *icon_name)
1629 GtkAboutDialogPrivate *priv;
1631 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1633 priv = (GtkAboutDialogPrivate *)about->private_data;
1635 g_object_freeze_notify (G_OBJECT (about));
1637 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1638 g_object_notify (G_OBJECT (about), "logo");
1640 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1641 GTK_ICON_SIZE_DIALOG);
1642 g_object_notify (G_OBJECT (about), "logo-icon-name");
1644 g_object_thaw_notify (G_OBJECT (about));
1648 activate_url (GtkWidget *widget,
1651 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1652 const gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
1654 if (activate_url_hook != NULL)
1655 (* activate_url_hook) (about, url, activate_url_hook_data);
1659 follow_if_link (GtkAboutDialog *about,
1660 GtkTextView *text_view,
1663 GSList *tags = NULL, *tagp = NULL;
1664 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1667 tags = gtk_text_iter_get_tags (iter);
1668 for (tagp = tags; tagp != NULL && !url; tagp = tagp->next)
1670 GtkTextTag *tag = tagp->data;
1672 if (activate_email_hook != NULL)
1674 url = g_object_get_data (G_OBJECT (tag), "email");
1676 (* activate_email_hook) (about, url, activate_email_hook_data);
1679 if (!url && activate_url_hook != NULL)
1681 url = g_object_get_data (G_OBJECT (tag), "url");
1683 (* activate_url_hook) (about, url, activate_url_hook_data);
1686 if (url && !g_slist_find_custom (priv->visited_links, url, (GCompareFunc)strcmp))
1688 GdkColor *style_visited_link_color;
1691 gtk_widget_ensure_style (GTK_WIDGET (about));
1692 gtk_widget_style_get (GTK_WIDGET (about),
1693 "visited-link-color", &style_visited_link_color,
1695 if (style_visited_link_color)
1697 color = *style_visited_link_color;
1698 gdk_color_free (style_visited_link_color);
1701 color = default_visited_link_color;
1703 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1705 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (url));
1710 g_slist_free (tags);
1714 credits_key_press_event (GtkWidget *text_view,
1716 GtkAboutDialog *about)
1719 GtkTextBuffer *buffer;
1721 switch (event->keyval)
1726 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1727 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1728 gtk_text_buffer_get_insert (buffer));
1729 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1740 credits_event_after (GtkWidget *text_view,
1742 GtkAboutDialog *about)
1744 GtkTextIter start, end, iter;
1745 GtkTextBuffer *buffer;
1746 GdkEventButton *button_event;
1749 if (event->type != GDK_BUTTON_RELEASE)
1752 button_event = (GdkEventButton *)event;
1754 if (button_event->button != 1)
1757 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1759 /* we shouldn't follow a link if the user has selected something */
1760 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1761 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1764 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1765 GTK_TEXT_WINDOW_WIDGET,
1766 button_event->x, button_event->y, &x, &y);
1768 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1770 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1776 set_cursor_if_appropriate (GtkAboutDialog *about,
1777 GtkTextView *text_view,
1781 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1782 GSList *tags = NULL, *tagp = NULL;
1784 gboolean hovering_over_link = FALSE;
1786 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1788 tags = gtk_text_iter_get_tags (&iter);
1789 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1791 GtkTextTag *tag = tagp->data;
1792 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1793 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1795 if (email != NULL || url != NULL)
1797 hovering_over_link = TRUE;
1802 if (hovering_over_link != priv->hovering_over_link)
1804 priv->hovering_over_link = hovering_over_link;
1806 if (hovering_over_link)
1807 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1809 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1813 g_slist_free (tags);
1817 credits_motion_notify_event (GtkWidget *text_view,
1818 GdkEventMotion *event,
1819 GtkAboutDialog *about)
1823 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1824 GTK_TEXT_WINDOW_WIDGET,
1825 event->x, event->y, &x, &y);
1827 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1829 gdk_event_request_motions (event);
1836 credits_visibility_notify_event (GtkWidget *text_view,
1837 GdkEventVisibility *event,
1838 GtkAboutDialog *about)
1840 gint wx, wy, bx, by;
1842 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1844 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1845 GTK_TEXT_WINDOW_WIDGET,
1848 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1854 text_view_style_set (GtkWidget *widget,
1855 GtkStyle *prev_style,
1856 GtkWidget *text_view)
1858 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1859 &widget->style->bg[GTK_STATE_NORMAL]);
1863 add_credits_page (GtkAboutDialog *about,
1864 GtkWidget *notebook,
1869 gchar *q0, *q1, *q2, *r1, *r2;
1870 GtkWidget *sw, *view;
1871 GtkTextBuffer *buffer;
1872 gboolean linkify_email, linkify_urls;
1873 GdkColor *style_link_color;
1874 GdkColor *style_visited_link_color;
1876 GdkColor link_color;
1877 GdkColor visited_link_color;
1878 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1880 linkify_email = (activate_email_hook != NULL);
1881 linkify_urls = (activate_url_hook != NULL);
1883 gtk_widget_ensure_style (GTK_WIDGET (about));
1884 gtk_widget_style_get (GTK_WIDGET (about),
1885 "link-color", &style_link_color,
1886 "visited-link-color", &style_visited_link_color,
1888 if (style_link_color)
1890 link_color = *style_link_color;
1891 gdk_color_free (style_link_color);
1894 link_color = default_link_color;
1896 if (style_visited_link_color)
1898 visited_link_color = *style_visited_link_color;
1899 gdk_color_free (style_visited_link_color);
1902 visited_link_color = default_visited_link_color;
1904 view = gtk_text_view_new ();
1905 g_signal_connect_object (about, "style-set",
1906 G_CALLBACK (text_view_style_set), view, 0);
1908 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1909 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1910 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1912 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1913 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1915 g_signal_connect (view, "key-press-event",
1916 G_CALLBACK (credits_key_press_event), about);
1917 g_signal_connect (view, "event-after",
1918 G_CALLBACK (credits_event_after), about);
1919 g_signal_connect (view, "motion-notify-event",
1920 G_CALLBACK (credits_motion_notify_event), about);
1921 g_signal_connect (view, "visibility-notify-event",
1922 G_CALLBACK (credits_visibility_notify_event), about);
1924 sw = gtk_scrolled_window_new (NULL, NULL);
1925 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1927 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1928 GTK_POLICY_AUTOMATIC,
1929 GTK_POLICY_AUTOMATIC);
1930 gtk_container_add (GTK_CONTAINER (sw), view);
1932 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1933 sw, gtk_label_new (title));
1937 gtk_widget_hide (view);
1941 gtk_widget_show (view);
1943 for (p = people; *p; p++)
1948 q1 = linkify_email ? strchr (q0, '<') : NULL;
1949 q2 = q1 ? strchr (q1, '>') : NULL;
1950 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1953 r2 = strpbrk (r1, " \n\t");
1955 r2 = strchr (r1, '\0');
1960 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1970 const gchar *link_type;
1975 gtk_text_buffer_insert_at_cursor (buffer, q0, (q1 - q0) + 1);
1976 gtk_text_buffer_get_end_iter (buffer, &end);
1978 link_type = I_("email");
1982 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1983 gtk_text_buffer_get_end_iter (buffer, &end);
1984 link_type = I_("url");
1989 link = g_strndup (q1, q2 - q1);
1991 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
1992 color = visited_link_color;
1996 tag = gtk_text_buffer_create_tag (buffer, NULL,
1997 "foreground-gdk", &color,
1998 "underline", PANGO_UNDERLINE_SINGLE,
2000 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
2001 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
2007 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
2013 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
2018 display_credits_dialog (GtkWidget *button,
2021 GtkAboutDialog *about = (GtkAboutDialog *)data;
2022 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2023 GtkWidget *dialog, *notebook;
2024 GtkDialog *credits_dialog;
2026 if (priv->credits_dialog != NULL)
2028 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
2032 dialog = gtk_dialog_new_with_buttons (_("Credits"),
2034 GTK_DIALOG_DESTROY_WITH_PARENT,
2035 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2037 credits_dialog = GTK_DIALOG (dialog);
2038 gtk_dialog_set_has_separator (credits_dialog, FALSE);
2039 gtk_container_set_border_width (GTK_CONTAINER (credits_dialog), 5);
2040 gtk_box_set_spacing (GTK_BOX (credits_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
2041 gtk_container_set_border_width (GTK_CONTAINER (credits_dialog->action_area), 5);
2043 priv->credits_dialog = dialog;
2044 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
2045 gtk_dialog_set_default_response (credits_dialog, GTK_RESPONSE_CANCEL);
2047 gtk_window_set_modal (GTK_WINDOW (dialog),
2048 gtk_window_get_modal (GTK_WINDOW (about)));
2050 g_signal_connect (dialog, "response",
2051 G_CALLBACK (gtk_widget_destroy), dialog);
2052 g_signal_connect (dialog, "destroy",
2053 G_CALLBACK (gtk_widget_destroyed),
2054 &(priv->credits_dialog));
2056 notebook = gtk_notebook_new ();
2057 gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
2058 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
2060 if (priv->authors != NULL)
2061 add_credits_page (about, notebook, _("Written by"), priv->authors);
2063 if (priv->documenters != NULL)
2064 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
2066 /* Don't show an untranslated gettext msgid */
2067 if (priv->translator_credits != NULL &&
2068 strcmp (priv->translator_credits, "translator_credits") &&
2069 strcmp (priv->translator_credits, "translator-credits"))
2071 gchar *translators[2];
2073 translators[0] = priv->translator_credits;
2074 translators[1] = NULL;
2076 add_credits_page (about, notebook, _("Translated by"), translators);
2079 if (priv->artists != NULL)
2080 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
2082 gtk_widget_show_all (dialog);
2086 set_policy (GtkWidget *sw)
2088 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2089 GTK_POLICY_AUTOMATIC,
2090 GTK_POLICY_AUTOMATIC);
2094 display_license_dialog (GtkWidget *button,
2097 GtkAboutDialog *about = (GtkAboutDialog *)data;
2098 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2099 GtkWidget *dialog, *view, *sw;
2100 GtkDialog *licence_dialog;
2102 if (priv->license_dialog != NULL)
2104 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2108 dialog = gtk_dialog_new_with_buttons (_("License"),
2110 GTK_DIALOG_DESTROY_WITH_PARENT,
2111 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2113 licence_dialog = GTK_DIALOG (dialog);
2114 gtk_dialog_set_has_separator (licence_dialog, FALSE);
2115 gtk_container_set_border_width (GTK_CONTAINER (licence_dialog), 5);
2116 gtk_box_set_spacing (GTK_BOX (licence_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
2117 gtk_container_set_border_width (GTK_CONTAINER (licence_dialog->action_area), 5);
2119 priv->license_dialog = dialog;
2120 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2121 gtk_dialog_set_default_response (licence_dialog, GTK_RESPONSE_CANCEL);
2123 gtk_window_set_modal (GTK_WINDOW (dialog),
2124 gtk_window_get_modal (GTK_WINDOW (about)));
2126 g_signal_connect (dialog, "response",
2127 G_CALLBACK (gtk_widget_destroy), dialog);
2128 g_signal_connect (dialog, "destroy",
2129 G_CALLBACK (gtk_widget_destroyed),
2130 &(priv->license_dialog));
2132 sw = gtk_scrolled_window_new (NULL, NULL);
2133 gtk_container_set_border_width (GTK_CONTAINER (sw), 5);
2134 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2136 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2138 GTK_POLICY_AUTOMATIC);
2139 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2140 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2142 view = gtk_text_view_new ();
2143 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
2144 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2145 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2148 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2149 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2151 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2152 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2154 gtk_container_add (GTK_CONTAINER (sw), view);
2156 gtk_widget_show_all (dialog);
2160 * gtk_about_dialog_new:
2162 * Creates a new #GtkAboutDialog.
2164 * Returns: a newly created #GtkAboutDialog
2169 gtk_about_dialog_new (void)
2171 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2173 return GTK_WIDGET (dialog);
2177 * gtk_about_dialog_set_email_hook:
2178 * @func: a function to call when an email link is activated.
2179 * @data: data to pass to @func
2180 * @destroy: #GDestroyNotify for @data
2182 * Installs a global function to be called whenever the user activates an
2183 * email link in an about dialog.
2185 * Return value: the previous email hook.
2189 GtkAboutDialogActivateLinkFunc
2190 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2192 GDestroyNotify destroy)
2194 GtkAboutDialogActivateLinkFunc old;
2196 if (activate_email_hook_destroy != NULL)
2197 (* activate_email_hook_destroy) (activate_email_hook_data);
2199 old = activate_email_hook;
2201 activate_email_hook = func;
2202 activate_email_hook_data = data;
2203 activate_email_hook_destroy = destroy;
2209 * gtk_about_dialog_set_url_hook:
2210 * @func: a function to call when a URL link is activated.
2211 * @data: data to pass to @func
2212 * @destroy: #GDestroyNotify for @data
2214 * Installs a global function to be called whenever the user activates a
2215 * URL link in an about dialog.
2217 * Return value: the previous URL hook.
2221 GtkAboutDialogActivateLinkFunc
2222 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2224 GDestroyNotify destroy)
2226 GtkAboutDialogActivateLinkFunc old;
2228 if (activate_url_hook_destroy != NULL)
2229 (* activate_url_hook_destroy) (activate_url_hook_data);
2231 old = activate_url_hook;
2233 activate_url_hook = func;
2234 activate_url_hook_data = data;
2235 activate_url_hook_destroy = destroy;
2241 close_cb (GtkAboutDialog *about)
2243 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2245 if (priv->license_dialog != NULL)
2247 gtk_widget_destroy (priv->license_dialog);
2248 priv->license_dialog = NULL;
2251 if (priv->credits_dialog != NULL)
2253 gtk_widget_destroy (priv->credits_dialog);
2254 priv->credits_dialog = NULL;
2257 gtk_widget_hide (GTK_WIDGET (about));
2262 * gtk_show_about_dialog:
2263 * @parent: transient parent, or %NULL for none
2264 * @first_property_name: the name of the first property
2265 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2267 * This is a convenience function for showing an application's about box.
2268 * The constructed dialog is associated with the parent window and
2269 * reused for future invocations of this function.
2274 gtk_show_about_dialog (GtkWindow *parent,
2275 const gchar *first_property_name,
2278 static GtkWidget *global_about_dialog = NULL;
2279 GtkWidget *dialog = NULL;
2283 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2285 dialog = global_about_dialog;
2289 dialog = gtk_about_dialog_new ();
2291 g_object_ref_sink (dialog);
2293 g_signal_connect (dialog, "delete-event",
2294 G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2296 /* Close dialog on user response */
2297 g_signal_connect (dialog, "response",
2298 G_CALLBACK (close_cb), NULL);
2300 va_start (var_args, first_property_name);
2301 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2306 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2307 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2308 g_object_set_data_full (G_OBJECT (parent),
2309 I_("gtk-about-dialog"),
2310 dialog, g_object_unref);
2313 global_about_dialog = dialog;
2317 gtk_window_present (GTK_WINDOW (dialog));
2320 #define __GTK_ABOUT_DIALOG_C__
2321 #include "gtkaliasdef.c"