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 gtk_about_dialog_style_set (GtkWidget *widget,
128 GtkStyle *previous_style);
129 static void dialog_style_set (GtkWidget *widget,
130 GtkStyle *previous_style,
132 static void update_name_version (GtkAboutDialog *about);
133 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
134 static void activate_url (GtkWidget *widget,
136 static void follow_if_link (GtkAboutDialog *about,
137 GtkTextView *text_view,
139 static void set_cursor_if_appropriate (GtkAboutDialog *about,
140 GtkTextView *text_view,
143 static void add_credits_page (GtkAboutDialog *about,
147 static gboolean credits_key_press_event (GtkWidget *text_view,
149 GtkAboutDialog *about);
150 static gboolean credits_event_after (GtkWidget *text_view,
152 GtkAboutDialog *about);
153 static gboolean credits_motion_notify_event (GtkWidget *text_view,
154 GdkEventMotion *event,
155 GtkAboutDialog *about);
156 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
157 GdkEventVisibility *event,
158 GtkAboutDialog *about);
159 static void display_credits_dialog (GtkWidget *button,
161 static void display_license_dialog (GtkWidget *button,
163 static void close_cb (GtkAboutDialog *about);
166 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
167 static gpointer activate_email_hook_data = NULL;
168 static GDestroyNotify activate_email_hook_destroy = NULL;
170 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
171 static gpointer activate_url_hook_data = NULL;
172 static GDestroyNotify activate_url_hook_destroy = NULL;
174 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
177 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
179 GObjectClass *object_class;
180 GtkWidgetClass *widget_class;
182 object_class = (GObjectClass *)klass;
183 widget_class = (GtkWidgetClass *)klass;
185 object_class->set_property = gtk_about_dialog_set_property;
186 object_class->get_property = gtk_about_dialog_get_property;
188 object_class->finalize = gtk_about_dialog_finalize;
190 widget_class->style_set = gtk_about_dialog_style_set;
194 * GtkAboutDialog:name:
196 * The name of the program.
197 * If this is not set, it defaults to g_get_application_name().
201 g_object_class_install_property (object_class,
203 g_param_spec_string ("name",
205 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
207 GTK_PARAM_READWRITE));
210 * GtkAboutDialog:version:
212 * The version of the program.
216 g_object_class_install_property (object_class,
218 g_param_spec_string ("version",
219 P_("Program version"),
220 P_("The version of the program"),
222 GTK_PARAM_READWRITE));
225 * GtkAboutDialog:copyright:
227 * Copyright information for the program.
231 g_object_class_install_property (object_class,
233 g_param_spec_string ("copyright",
234 P_("Copyright string"),
235 P_("Copyright information for the program"),
237 GTK_PARAM_READWRITE));
241 * GtkAboutDialog:comments:
243 * Comments about the program. This string is displayed in a label
244 * in the main dialog, thus it should be a short explanation of
245 * the main purpose of the program, not a detailed list of features.
249 g_object_class_install_property (object_class,
251 g_param_spec_string ("comments",
252 P_("Comments string"),
253 P_("Comments about the program"),
255 GTK_PARAM_READWRITE));
258 * GtkAboutDialog:license:
260 * The license of the program. This string is displayed in a
261 * text view in a secondary dialog, therefore it is fine to use
262 * a long multi-paragraph text. Note that the text is only wrapped
263 * in the text view if the "wrap-license" property is set to %TRUE;
264 * otherwise the text itself must contain the intended linebreaks.
268 g_object_class_install_property (object_class,
270 g_param_spec_string ("license",
272 _("The license of the program"),
274 GTK_PARAM_READWRITE));
277 * GtkAboutDialog:website:
279 * The URL for the link to the website of the program.
280 * This should be a string starting with "http://.
284 g_object_class_install_property (object_class,
286 g_param_spec_string ("website",
288 P_("The URL for the link to the website of the program"),
290 GTK_PARAM_READWRITE));
293 * GtkAboutDialog:website-label:
295 * The label for the link to the website of the program. If this is not set,
296 * it defaults to the URL specified in the
297 * <link linkend="GtkAboutDialog--website">website</link> property.
301 g_object_class_install_property (object_class,
303 g_param_spec_string ("website-label",
305 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
307 GTK_PARAM_READWRITE));
310 * GtkAboutDialog:authors:
312 * The authors of the program, as a %NULL-terminated array of strings.
313 * Each string may contain email addresses and URLs, which will be displayed
314 * as links, see the introduction for more details.
318 g_object_class_install_property (object_class,
320 g_param_spec_boxed ("authors",
322 P_("List of authors of the program"),
324 GTK_PARAM_READWRITE));
327 * GtkAboutDialog:documenters:
329 * The people documenting the program, as a %NULL-terminated array of strings.
330 * Each string may contain email addresses and URLs, which will be displayed
331 * as links, see the introduction for more details.
335 g_object_class_install_property (object_class,
337 g_param_spec_boxed ("documenters",
339 P_("List of people documenting the program"),
341 GTK_PARAM_READWRITE));
344 * GtkAboutDialog:artists:
346 * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
347 * Each string may contain email addresses and URLs, which will be displayed
348 * as links, see the introduction for more details.
352 g_object_class_install_property (object_class,
354 g_param_spec_boxed ("artists",
356 P_("List of people who have contributed artwork to the program"),
358 GTK_PARAM_READWRITE));
362 * GtkAboutDialog:translator-credits:
364 * Credits to the translators. This string should be marked as translatable.
365 * The string may contain email addresses and URLs, which will be displayed
366 * as links, see the introduction for more details.
370 g_object_class_install_property (object_class,
371 PROP_TRANSLATOR_CREDITS,
372 g_param_spec_string ("translator-credits",
373 P_("Translator credits"),
374 P_("Credits to the translators. This string should be marked as translatable"),
376 GTK_PARAM_READWRITE));
379 * GtkAboutDialog:logo:
381 * A logo for the about box. If this is not set, it defaults to
382 * gtk_window_get_default_icon_list().
386 g_object_class_install_property (object_class,
388 g_param_spec_object ("logo",
390 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
392 GTK_PARAM_READWRITE));
395 * GtkAboutDialog:logo-icon-name:
397 * A named icon to use as the logo for the about box. This property
398 * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
402 g_object_class_install_property (object_class,
404 g_param_spec_string ("logo-icon-name",
405 P_("Logo Icon Name"),
406 P_("A named icon to use as the logo for the about box."),
408 GTK_PARAM_READWRITE));
410 * GtkAboutDialog:wrap-license:
412 * Whether to wrap the text in the license dialog.
416 g_object_class_install_property (object_class,
418 g_param_spec_boolean ("wrap-license",
420 P_("Whether to wrap the license text."),
422 GTK_PARAM_READWRITE));
425 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
429 gtk_about_dialog_init (GtkAboutDialog *about)
431 GtkAboutDialogPrivate *priv;
432 GtkWidget *vbox, *hbox, *button, *image;
435 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
436 about->private_data = priv;
439 priv->version = NULL;
440 priv->copyright = NULL;
441 priv->comments = NULL;
442 priv->website = NULL;
443 priv->website_label = NULL;
444 priv->translator_credits = NULL;
445 priv->license = NULL;
446 priv->authors = NULL;
447 priv->documenters = NULL;
448 priv->artists = NULL;
450 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
451 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
452 priv->hovering_over_link = FALSE;
453 priv->wrap_license = FALSE;
455 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
458 gtk_widget_push_composite_child ();
459 vbox = gtk_vbox_new (FALSE, 8);
461 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
463 priv->logo_image = gtk_image_new ();
464 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
466 priv->name_label = gtk_label_new (NULL);
467 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
468 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
469 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
471 priv->comments_label = gtk_label_new (NULL);
472 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
473 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
474 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
475 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
477 priv->copyright_label = gtk_label_new (NULL);
478 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
479 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
480 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
482 button = gtk_link_button_new ("");
483 g_signal_connect (G_OBJECT (button), "clicked",
484 G_CALLBACK (activate_url), about);
486 hbox = gtk_hbox_new (TRUE, 0);
487 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
488 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
489 priv->website_button = button;
491 gtk_widget_show (vbox);
492 gtk_widget_show (priv->logo_image);
493 gtk_widget_show (priv->name_label);
494 gtk_widget_show (hbox);
496 /* Add the OK button */
497 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
498 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
500 /* Add the credits button */
501 button = gtk_button_new_with_mnemonic (_("C_redits"));
502 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
503 image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
504 gtk_button_set_image (GTK_BUTTON (button), image);
505 gtk_widget_set_no_show_all (button, TRUE);
506 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
507 button, FALSE, TRUE, 0);
508 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
509 g_signal_connect (button, "clicked", 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", G_CALLBACK (display_license_dialog), about);
521 priv->license_button = button;
522 priv->license_dialog = NULL;
524 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
526 gtk_widget_pop_composite_child ();
529 gtk_about_dialog_set_name (about, NULL);
530 gtk_about_dialog_set_logo (about, NULL);
534 gtk_about_dialog_finalize (GObject *object)
536 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
537 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
540 g_free (priv->version);
541 g_free (priv->copyright);
542 g_free (priv->comments);
543 g_free (priv->license);
544 g_free (priv->website);
545 g_free (priv->website_label);
546 g_free (priv->translator_credits);
548 g_strfreev (priv->authors);
549 g_strfreev (priv->documenters);
550 g_strfreev (priv->artists);
552 g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
553 g_slist_free (priv->visited_links);
555 gdk_cursor_unref (priv->hand_cursor);
556 gdk_cursor_unref (priv->regular_cursor);
558 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
562 gtk_about_dialog_set_property (GObject *object,
567 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
568 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
573 gtk_about_dialog_set_name (about, g_value_get_string (value));
576 gtk_about_dialog_set_version (about, g_value_get_string (value));
579 gtk_about_dialog_set_comments (about, g_value_get_string (value));
582 gtk_about_dialog_set_website (about, g_value_get_string (value));
584 case PROP_WEBSITE_LABEL:
585 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
588 gtk_about_dialog_set_license (about, g_value_get_string (value));
591 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
594 gtk_about_dialog_set_logo (about, g_value_get_object (value));
597 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
599 case PROP_DOCUMENTERS:
600 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
603 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
605 case PROP_TRANSLATOR_CREDITS:
606 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
608 case PROP_LOGO_ICON_NAME:
609 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
611 case PROP_WRAP_LICENSE:
612 priv->wrap_license = g_value_get_boolean (value);
615 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
621 gtk_about_dialog_get_property (GObject *object,
626 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
627 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
632 g_value_set_string (value, priv->name);
635 g_value_set_string (value, priv->version);
638 g_value_set_string (value, priv->copyright);
641 g_value_set_string (value, priv->comments);
644 g_value_set_string (value, priv->website);
646 case PROP_WEBSITE_LABEL:
647 g_value_set_string (value, priv->website_label);
650 g_value_set_string (value, priv->license);
652 case PROP_TRANSLATOR_CREDITS:
653 g_value_set_string (value, priv->translator_credits);
656 g_value_set_boxed (value, priv->authors);
658 case PROP_DOCUMENTERS:
659 g_value_set_boxed (value, priv->documenters);
662 g_value_set_boxed (value, priv->artists);
665 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
666 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
668 g_value_set_object (value, NULL);
670 case PROP_LOGO_ICON_NAME:
671 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
673 const gchar *icon_name;
675 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
676 g_value_set_string (value, icon_name);
679 g_value_set_string (value, NULL);
681 case PROP_WRAP_LICENSE:
682 g_value_set_boolean (value, priv->wrap_license);
685 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
691 dialog_style_set (GtkWidget *widget,
692 GtkStyle *previous_style,
697 dialog = GTK_DIALOG (widget);
699 /* Override the style properties with HIG-compliant spacings. Ugh.
700 * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
701 * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
704 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
705 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 12);
707 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
708 gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
712 gtk_about_dialog_style_set (GtkWidget *widget,
713 GtkStyle *previous_style)
715 if (GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set)
716 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set (widget, previous_style);
718 dialog_style_set (widget, previous_style, NULL);
722 * gtk_about_dialog_get_name:
723 * @about: a #GtkAboutDialog
725 * Returns the program name displayed in the about dialog.
727 * Return value: The program name. The string is owned by the about
728 * dialog and must not be modified.
732 G_CONST_RETURN gchar *
733 gtk_about_dialog_get_name (GtkAboutDialog *about)
735 GtkAboutDialogPrivate *priv;
737 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
739 priv = (GtkAboutDialogPrivate *)about->private_data;
745 update_name_version (GtkAboutDialog *about)
747 GtkAboutDialogPrivate *priv;
748 gchar *title_string, *name_string;
750 priv = (GtkAboutDialogPrivate *)about->private_data;
752 title_string = g_strdup_printf (_("About %s"), priv->name);
753 gtk_window_set_title (GTK_WINDOW (about), title_string);
754 g_free (title_string);
756 if (priv->version != NULL)
757 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
758 priv->name, priv->version);
760 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
763 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
765 g_free (name_string);
769 * gtk_about_dialog_set_name:
770 * @about: a #GtkAboutDialog
771 * @name: the program name
773 * Sets the name to display in the about dialog.
774 * If this is not set, it defaults to g_get_application_name().
779 gtk_about_dialog_set_name (GtkAboutDialog *about,
782 GtkAboutDialogPrivate *priv;
785 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
787 priv = (GtkAboutDialogPrivate *)about->private_data;
789 priv->name = g_strdup (name ? name : g_get_application_name ());
792 update_name_version (about);
794 g_object_notify (G_OBJECT (about), "name");
798 * gtk_about_dialog_get_version:
799 * @about: a #GtkAboutDialog
801 * Returns the version string.
803 * Return value: The version string. The string is owned by the about
804 * dialog and must not be modified.
808 G_CONST_RETURN gchar *
809 gtk_about_dialog_get_version (GtkAboutDialog *about)
811 GtkAboutDialogPrivate *priv;
813 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
815 priv = (GtkAboutDialogPrivate *)about->private_data;
817 return priv->version;
821 * gtk_about_dialog_set_version:
822 * @about: a #GtkAboutDialog
823 * @version: the version string
825 * Sets the version string to display in the about dialog.
830 gtk_about_dialog_set_version (GtkAboutDialog *about,
831 const gchar *version)
833 GtkAboutDialogPrivate *priv;
836 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
838 priv = (GtkAboutDialogPrivate *)about->private_data;
841 priv->version = version ? g_strdup (version) : NULL;
844 update_name_version (about);
846 g_object_notify (G_OBJECT (about), "version");
850 * gtk_about_dialog_get_copyright:
851 * @about: a #GtkAboutDialog
853 * Returns the copyright string.
855 * Return value: The copyright string. The string is owned by the about
856 * dialog and must not be modified.
860 G_CONST_RETURN gchar *
861 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
863 GtkAboutDialogPrivate *priv;
865 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
867 priv = (GtkAboutDialogPrivate *)about->private_data;
869 return priv->copyright;
873 * gtk_about_dialog_set_copyright:
874 * @about: a #GtkAboutDialog
875 * @copyright: the copyright string
877 * Sets the copyright string to display in the about dialog.
878 * This should be a short string of one or two lines.
883 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
884 const gchar *copyright)
886 GtkAboutDialogPrivate *priv;
887 gchar *copyright_string, *tmp;
889 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
891 priv = (GtkAboutDialogPrivate *)about->private_data;
893 tmp = priv->copyright;
894 priv->copyright = copyright ? g_strdup (copyright) : NULL;
897 if (priv->copyright != NULL)
899 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
901 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
902 g_free (copyright_string);
904 gtk_widget_show (priv->copyright_label);
907 gtk_widget_hide (priv->copyright_label);
909 g_object_notify (G_OBJECT (about), "copyright");
913 * gtk_about_dialog_get_comments:
914 * @about: a #GtkAboutDialog
916 * Returns the comments string.
918 * Return value: The comments. The string is owned by the about
919 * dialog and must not be modified.
923 G_CONST_RETURN gchar *
924 gtk_about_dialog_get_comments (GtkAboutDialog *about)
926 GtkAboutDialogPrivate *priv;
928 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
930 priv = (GtkAboutDialogPrivate *)about->private_data;
932 return priv->comments;
936 * gtk_about_dialog_set_comments:
937 * @about: a #GtkAboutDialog
938 * @comments: a comments string
940 * Sets the comments string to display in the about
941 * dialog. This should be a short string of one or
947 gtk_about_dialog_set_comments (GtkAboutDialog *about,
948 const gchar *comments)
950 GtkAboutDialogPrivate *priv;
953 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
955 priv = (GtkAboutDialogPrivate *)about->private_data;
957 tmp = priv->comments;
960 priv->comments = g_strdup (comments);
961 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
962 gtk_widget_show (priv->comments_label);
966 priv->comments = NULL;
967 gtk_widget_hide (priv->comments_label);
971 g_object_notify (G_OBJECT (about), "comments");
975 * gtk_about_dialog_get_license:
976 * @about: a #GtkAboutDialog
978 * Returns the license information.
980 * Return value: The license information. The string is owned by the about
981 * dialog and must not be modified.
985 G_CONST_RETURN gchar *
986 gtk_about_dialog_get_license (GtkAboutDialog *about)
988 GtkAboutDialogPrivate *priv;
990 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
992 priv = (GtkAboutDialogPrivate *)about->private_data;
994 return priv->license;
998 * gtk_about_dialog_set_license:
999 * @about: a #GtkAboutDialog
1000 * @license: the license information or %NULL
1002 * Sets the license information to be displayed in the secondary
1003 * license dialog. If @license is %NULL, the license button is
1009 gtk_about_dialog_set_license (GtkAboutDialog *about,
1010 const gchar *license)
1012 GtkAboutDialogPrivate *priv;
1015 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1017 priv = (GtkAboutDialogPrivate *)about->private_data;
1019 tmp = priv->license;
1022 priv->license = g_strdup (license);
1023 gtk_widget_show (priv->license_button);
1027 priv->license = NULL;
1028 gtk_widget_hide (priv->license_button);
1032 g_object_notify (G_OBJECT (about), "license");
1036 * gtk_about_dialog_get_wrap_license:
1037 * @about: a #GtkAboutDialog
1039 * Returns whether the license text in @about is
1040 * automatically wrapped.
1042 * Returns: %TRUE if the license text is wrapped
1047 gtk_about_dialog_get_wrap_license (GtkAboutDialog *about)
1049 GtkAboutDialogPrivate *priv;
1051 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE);
1053 priv = (GtkAboutDialogPrivate *)about->private_data;
1055 return priv->wrap_license;
1059 * gtk_about_dialog_set_wrap_license:
1060 * @about: a #GtkAboutDialog
1061 * @wrap_license: whether to wrap the license
1063 * Sets whether the license text in @about is
1064 * automatically wrapped.
1069 gtk_about_dialog_set_wrap_license (GtkAboutDialog *about,
1070 gboolean wrap_license)
1072 GtkAboutDialogPrivate *priv;
1074 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1076 priv = (GtkAboutDialogPrivate *)about->private_data;
1078 wrap_license = wrap_license != FALSE;
1080 if (priv->wrap_license != wrap_license)
1082 priv->wrap_license = wrap_license;
1084 g_object_notify (G_OBJECT (about), "wrap-license");
1089 * gtk_about_dialog_get_website:
1090 * @about: a #GtkAboutDialog
1092 * Returns the website URL.
1094 * Return value: The website URL. The string is owned by the about
1095 * dialog and must not be modified.
1099 G_CONST_RETURN gchar *
1100 gtk_about_dialog_get_website (GtkAboutDialog *about)
1102 GtkAboutDialogPrivate *priv;
1104 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1106 priv = (GtkAboutDialogPrivate *)about->private_data;
1108 return priv->website;
1112 * gtk_about_dialog_set_website:
1113 * @about: a #GtkAboutDialog
1114 * @website: a URL string starting with "http://"
1116 * Sets the URL to use for the website link.
1121 gtk_about_dialog_set_website (GtkAboutDialog *about,
1122 const gchar *website)
1124 GtkAboutDialogPrivate *priv;
1127 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1129 priv = (GtkAboutDialogPrivate *)about->private_data;
1131 tmp = priv->website;
1132 if (website != NULL)
1134 priv->website = g_strdup (website);
1135 if (activate_url_hook != NULL)
1137 gtk_link_button_set_uri (GTK_LINK_BUTTON (priv->website_button), website);
1138 if (priv->website_label == NULL)
1139 gtk_about_dialog_set_website_label (about, website);
1143 GtkWidget *hbox = priv->website_button->parent;
1144 gtk_widget_destroy (priv->website_button);
1145 priv->website_button = gtk_label_new (website);
1146 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1147 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1148 gtk_widget_show (priv->website_button);
1153 priv->website = NULL;
1154 gtk_widget_hide (priv->website_button);
1158 g_object_notify (G_OBJECT (about), "website");
1162 * gtk_about_dialog_get_website_label:
1163 * @about: a #GtkAboutDialog
1165 * Returns the label used for the website link.
1167 * Return value: The label used for the website link. The string is owned by the about
1168 * dialog and must not be modified.
1172 G_CONST_RETURN gchar *
1173 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1175 GtkAboutDialogPrivate *priv;
1177 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1179 priv = (GtkAboutDialogPrivate *)about->private_data;
1181 return priv->website_label;
1185 * gtk_about_dialog_set_website_label:
1186 * @about: a #GtkAboutDialog
1187 * @website_label: the label used for the website link
1189 * Sets the label to be used for the website link.
1190 * It defaults to the website URL.
1195 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1196 const gchar *website_label)
1198 GtkAboutDialogPrivate *priv;
1201 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1203 priv = (GtkAboutDialogPrivate *)about->private_data;
1205 tmp = priv->website_label;
1206 if (activate_url_hook != NULL)
1208 if (website_label != NULL)
1210 priv->website_label = g_strdup (website_label);
1211 gtk_button_set_label (GTK_BUTTON (priv->website_button),
1212 priv->website_label);
1213 gtk_widget_show (priv->website_button);
1217 priv->website_label = NULL;
1218 gtk_widget_hide (priv->website_button);
1223 g_object_notify (G_OBJECT (about), "website-label");
1227 * gtk_about_dialog_get_authors:
1228 * @about: a #GtkAboutDialog
1230 * Returns the string which are displayed in the authors tab
1231 * of the secondary credits dialog.
1233 * Return value: A %NULL-terminated string array containing
1234 * the authors. The array is owned by the about dialog
1235 * and must not be modified.
1239 G_CONST_RETURN gchar * G_CONST_RETURN *
1240 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1242 GtkAboutDialogPrivate *priv;
1244 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1246 priv = (GtkAboutDialogPrivate *)about->private_data;
1248 return (const gchar * const *) priv->authors;
1252 * gtk_about_dialog_set_authors:
1253 * @about: a #GtkAboutDialog
1254 * @authors: a %NULL-terminated array of strings
1256 * Sets the strings which are displayed in the authors tab
1257 * of the secondary credits dialog.
1262 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1263 const gchar **authors)
1265 GtkAboutDialogPrivate *priv;
1268 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1270 priv = (GtkAboutDialogPrivate *)about->private_data;
1272 tmp = priv->authors;
1273 priv->authors = g_strdupv ((gchar **)authors);
1276 if (priv->authors != NULL)
1277 gtk_widget_show (priv->credits_button);
1279 g_object_notify (G_OBJECT (about), "authors");
1283 * gtk_about_dialog_get_documenters:
1284 * @about: a #GtkAboutDialog
1286 * Returns the string which are displayed in the documenters
1287 * tab of the secondary credits dialog.
1289 * Return value: A %NULL-terminated string array containing
1290 * the documenters. The array is owned by the about dialog
1291 * and must not be modified.
1295 G_CONST_RETURN gchar * G_CONST_RETURN *
1296 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1298 GtkAboutDialogPrivate *priv;
1300 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1302 priv = (GtkAboutDialogPrivate *)about->private_data;
1304 return (const gchar * const *)priv->documenters;
1308 * gtk_about_dialog_set_documenters:
1309 * @about: a #GtkAboutDialog
1310 * @documenters: a %NULL-terminated array of strings
1312 * Sets the strings which are displayed in the documenters tab
1313 * of the secondary credits dialog.
1318 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1319 const gchar **documenters)
1321 GtkAboutDialogPrivate *priv;
1324 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1326 priv = (GtkAboutDialogPrivate *)about->private_data;
1328 tmp = priv->documenters;
1329 priv->documenters = g_strdupv ((gchar **)documenters);
1332 if (priv->documenters != NULL)
1333 gtk_widget_show (priv->credits_button);
1335 g_object_notify (G_OBJECT (about), "documenters");
1339 * gtk_about_dialog_get_artists:
1340 * @about: a #GtkAboutDialog
1342 * Returns the string which are displayed in the artists tab
1343 * of the secondary credits dialog.
1345 * Return value: A %NULL-terminated string array containing
1346 * the artists. The array is owned by the about dialog
1347 * and must not be modified.
1351 G_CONST_RETURN gchar * G_CONST_RETURN *
1352 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1354 GtkAboutDialogPrivate *priv;
1356 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1358 priv = (GtkAboutDialogPrivate *)about->private_data;
1360 return (const gchar * const *)priv->artists;
1364 * gtk_about_dialog_set_artists:
1365 * @about: a #GtkAboutDialog
1366 * @artists: a %NULL-terminated array of strings
1368 * Sets the strings which are displayed in the artists tab
1369 * of the secondary credits dialog.
1374 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1375 const gchar **artists)
1377 GtkAboutDialogPrivate *priv;
1380 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1382 priv = (GtkAboutDialogPrivate *)about->private_data;
1384 tmp = priv->artists;
1385 priv->artists = g_strdupv ((gchar **)artists);
1388 if (priv->artists != NULL)
1389 gtk_widget_show (priv->credits_button);
1391 g_object_notify (G_OBJECT (about), "artists");
1395 * gtk_about_dialog_get_translator_credits:
1396 * @about: a #GtkAboutDialog
1398 * Returns the translator credits string which is displayed
1399 * in the translators tab of the secondary credits dialog.
1401 * Return value: The translator credits string. The string is
1402 * owned by the about dialog and must not be modified.
1406 G_CONST_RETURN gchar *
1407 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1409 GtkAboutDialogPrivate *priv;
1411 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1413 priv = (GtkAboutDialogPrivate *)about->private_data;
1415 return priv->translator_credits;
1419 * gtk_about_dialog_set_translator_credits:
1420 * @about: a #GtkAboutDialog
1421 * @translator_credits: the translator credits
1423 * Sets the translator credits string which is displayed in
1424 * the translators tab of the secondary credits dialog.
1426 * The intended use for this string is to display the translator
1427 * of the language which is currently used in the user interface.
1428 * Using gettext(), a simple way to achieve that is to mark the
1429 * string for translation:
1430 * <informalexample><programlisting>
1431 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1432 * </programlisting></informalexample>
1433 * It is a good idea to use the customary msgid "translator-credits" for this
1434 * purpose, since translators will already know the purpose of that msgid, and
1435 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1441 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1442 const gchar *translator_credits)
1444 GtkAboutDialogPrivate *priv;
1447 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1449 priv = (GtkAboutDialogPrivate *)about->private_data;
1451 tmp = priv->translator_credits;
1452 priv->translator_credits = g_strdup (translator_credits);
1455 if (priv->translator_credits != NULL)
1456 gtk_widget_show (priv->credits_button);
1458 g_object_notify (G_OBJECT (about), "translator-credits");
1462 * gtk_about_dialog_get_logo:
1463 * @about: a #GtkAboutDialog
1465 * Returns the pixbuf displayed as logo in the about dialog.
1467 * Return value: the pixbuf displayed as logo. The pixbuf is
1468 * owned by the about dialog. If you want to keep a reference
1469 * to it, you have to call g_object_ref() on it.
1474 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1476 GtkAboutDialogPrivate *priv;
1478 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1480 priv = (GtkAboutDialogPrivate *)about->private_data;
1482 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1483 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1489 icon_set_new_from_pixbufs (GList *pixbufs)
1491 GtkIconSet *icon_set = gtk_icon_set_new ();
1493 for (; pixbufs; pixbufs = pixbufs->next)
1495 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1497 GtkIconSource *icon_source = gtk_icon_source_new ();
1498 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1499 gtk_icon_set_add_source (icon_set, icon_source);
1500 gtk_icon_source_free (icon_source);
1507 * gtk_about_dialog_set_logo:
1508 * @about: a #GtkAboutDialog
1509 * @logo: a #GdkPixbuf, or %NULL
1511 * Sets the pixbuf to be displayed as logo in
1512 * the about dialog. If it is %NULL, the default
1513 * window icon set with gtk_window_set_default_icon ()
1519 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1522 GtkAboutDialogPrivate *priv;
1524 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1526 priv = (GtkAboutDialogPrivate *)about->private_data;
1528 g_object_freeze_notify (G_OBJECT (about));
1530 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1531 g_object_notify (G_OBJECT (about), "logo-icon-name");
1534 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1537 GList *pixbufs = gtk_window_get_default_icon_list ();
1539 if (pixbufs != NULL)
1541 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1543 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1544 icon_set, GTK_ICON_SIZE_DIALOG);
1546 gtk_icon_set_unref (icon_set);
1547 g_list_free (pixbufs);
1551 g_object_notify (G_OBJECT (about), "logo");
1553 g_object_thaw_notify (G_OBJECT (about));
1557 * gtk_about_dialog_get_logo_icon_name:
1558 * @about: a #GtkAboutDialog
1560 * Returns the icon name displayed as logo in the about dialog.
1562 * Return value: the icon name displayed as logo. The string is
1563 * owned by the dialog. If you want to keep a reference
1564 * to it, you have to call g_strdup() on it.
1568 G_CONST_RETURN gchar *
1569 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1571 GtkAboutDialogPrivate *priv;
1572 const gchar *icon_name = NULL;
1574 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1576 priv = (GtkAboutDialogPrivate *)about->private_data;
1578 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1579 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1585 * gtk_about_dialog_set_logo_icon_name:
1586 * @about: a #GtkAboutDialog
1587 * @icon_name: an icon name, or %NULL
1589 * Sets the pixbuf to be displayed as logo in
1590 * the about dialog. If it is %NULL, the default
1591 * window icon set with gtk_window_set_default_icon()
1597 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1598 const gchar *icon_name)
1600 GtkAboutDialogPrivate *priv;
1602 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1604 priv = (GtkAboutDialogPrivate *)about->private_data;
1606 g_object_freeze_notify (G_OBJECT (about));
1608 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1609 g_object_notify (G_OBJECT (about), "logo");
1611 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1612 GTK_ICON_SIZE_DIALOG);
1613 g_object_notify (G_OBJECT (about), "logo-icon-name");
1615 g_object_thaw_notify (G_OBJECT (about));
1619 activate_url (GtkWidget *widget,
1622 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1623 const gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
1625 if (activate_url_hook != NULL)
1626 (* activate_url_hook) (about, url, activate_url_hook_data);
1630 follow_if_link (GtkAboutDialog *about,
1631 GtkTextView *text_view,
1634 GSList *tags = NULL, *tagp = NULL;
1635 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1638 tags = gtk_text_iter_get_tags (iter);
1639 for (tagp = tags; tagp != NULL && !url; tagp = tagp->next)
1641 GtkTextTag *tag = tagp->data;
1643 if (activate_email_hook != NULL)
1645 url = g_object_get_data (G_OBJECT (tag), "email");
1647 (* activate_email_hook) (about, url, activate_email_hook_data);
1650 if (!url && activate_url_hook != NULL)
1652 url = g_object_get_data (G_OBJECT (tag), "url");
1654 (* activate_url_hook) (about, url, activate_url_hook_data);
1657 if (url && !g_slist_find_custom (priv->visited_links, url, (GCompareFunc)strcmp))
1659 GdkColor *style_visited_link_color;
1662 gtk_widget_ensure_style (GTK_WIDGET (about));
1663 gtk_widget_style_get (GTK_WIDGET (about),
1664 "visited-link-color", &style_visited_link_color,
1666 if (style_visited_link_color)
1668 color = *style_visited_link_color;
1669 gdk_color_free (style_visited_link_color);
1672 color = default_visited_link_color;
1674 g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
1676 priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (url));
1681 g_slist_free (tags);
1685 credits_key_press_event (GtkWidget *text_view,
1687 GtkAboutDialog *about)
1690 GtkTextBuffer *buffer;
1692 switch (event->keyval)
1696 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1697 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1698 gtk_text_buffer_get_insert (buffer));
1699 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1710 credits_event_after (GtkWidget *text_view,
1712 GtkAboutDialog *about)
1714 GtkTextIter start, end, iter;
1715 GtkTextBuffer *buffer;
1716 GdkEventButton *button_event;
1719 if (event->type != GDK_BUTTON_RELEASE)
1722 button_event = (GdkEventButton *)event;
1724 if (button_event->button != 1)
1727 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1729 /* we shouldn't follow a link if the user has selected something */
1730 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1731 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1734 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1735 GTK_TEXT_WINDOW_WIDGET,
1736 button_event->x, button_event->y, &x, &y);
1738 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1740 follow_if_link (about, GTK_TEXT_VIEW (text_view), &iter);
1746 set_cursor_if_appropriate (GtkAboutDialog *about,
1747 GtkTextView *text_view,
1751 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1752 GSList *tags = NULL, *tagp = NULL;
1754 gboolean hovering_over_link = FALSE;
1756 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1758 tags = gtk_text_iter_get_tags (&iter);
1759 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1761 GtkTextTag *tag = tagp->data;
1762 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1763 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1765 if (email != NULL || url != NULL)
1767 hovering_over_link = TRUE;
1772 if (hovering_over_link != priv->hovering_over_link)
1774 priv->hovering_over_link = hovering_over_link;
1776 if (hovering_over_link)
1777 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1779 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1783 g_slist_free (tags);
1787 credits_motion_notify_event (GtkWidget *text_view,
1788 GdkEventMotion *event,
1789 GtkAboutDialog *about)
1793 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1794 GTK_TEXT_WINDOW_WIDGET,
1795 event->x, event->y, &x, &y);
1797 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1799 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1806 credits_visibility_notify_event (GtkWidget *text_view,
1807 GdkEventVisibility *event,
1808 GtkAboutDialog *about)
1810 gint wx, wy, bx, by;
1812 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1814 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1815 GTK_TEXT_WINDOW_WIDGET,
1818 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1824 text_view_style_set (GtkWidget *widget,
1825 GtkStyle *prev_style,
1826 GtkWidget *text_view)
1828 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1829 &widget->style->bg[GTK_STATE_NORMAL]);
1833 add_credits_page (GtkAboutDialog *about,
1834 GtkWidget *notebook,
1839 gchar *q0, *q1, *q2, *r1, *r2;
1840 GtkWidget *sw, *view;
1841 GtkTextBuffer *buffer;
1842 gboolean linkify_email, linkify_urls;
1843 GdkColor *style_link_color;
1844 GdkColor *style_visited_link_color;
1846 GdkColor link_color;
1847 GdkColor visited_link_color;
1848 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1850 linkify_email = (activate_email_hook != NULL);
1851 linkify_urls = (activate_url_hook != NULL);
1853 gtk_widget_ensure_style (GTK_WIDGET (about));
1854 gtk_widget_style_get (GTK_WIDGET (about),
1855 "link-color", &style_link_color,
1856 "visited-link-color", &style_visited_link_color,
1858 if (style_link_color)
1860 link_color = *style_link_color;
1861 gdk_color_free (style_link_color);
1864 link_color = default_link_color;
1866 if (style_visited_link_color)
1868 visited_link_color = *style_visited_link_color;
1869 gdk_color_free (style_visited_link_color);
1872 visited_link_color = default_visited_link_color;
1874 view = gtk_text_view_new ();
1875 g_signal_connect_object (about, "style_set",
1876 G_CALLBACK (text_view_style_set), view, 0);
1878 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1879 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1880 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1882 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1883 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1885 g_signal_connect (view, "key_press_event",
1886 G_CALLBACK (credits_key_press_event), about);
1887 g_signal_connect (view, "event_after",
1888 G_CALLBACK (credits_event_after), about);
1889 g_signal_connect (view, "motion_notify_event",
1890 G_CALLBACK (credits_motion_notify_event), about);
1891 g_signal_connect (view, "visibility_notify_event",
1892 G_CALLBACK (credits_visibility_notify_event), about);
1894 sw = gtk_scrolled_window_new (NULL, NULL);
1895 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1897 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1898 GTK_POLICY_AUTOMATIC,
1899 GTK_POLICY_AUTOMATIC);
1900 gtk_container_add (GTK_CONTAINER (sw), view);
1902 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1903 sw, gtk_label_new (title));
1907 gtk_widget_hide (view);
1911 gtk_widget_show (view);
1913 for (p = people; *p; p++)
1918 q1 = linkify_email ? strchr (q0, '<') : NULL;
1919 q2 = q1 ? strchr (q1, '>') : NULL;
1920 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1923 r2 = strpbrk (r1, " \n\t");
1925 r2 = strchr (r1, '\0');
1930 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1940 const gchar *link_type;
1943 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1944 gtk_text_buffer_get_end_iter (buffer, &end);
1952 link_type = I_("email");
1955 link_type = I_("url");
1957 link = g_strndup (q1, q2 - q1);
1959 if (g_slist_find_custom (priv->visited_links, link, (GCompareFunc)strcmp))
1960 color = visited_link_color;
1964 tag = gtk_text_buffer_create_tag (buffer, NULL,
1965 "foreground-gdk", &color,
1966 "underline", PANGO_UNDERLINE_SINGLE,
1968 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1969 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1975 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1981 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1986 display_credits_dialog (GtkWidget *button,
1989 GtkAboutDialog *about = (GtkAboutDialog *)data;
1990 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1991 GtkWidget *dialog, *notebook;
1993 if (priv->credits_dialog != NULL)
1995 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1999 dialog = gtk_dialog_new_with_buttons (_("Credits"),
2001 GTK_DIALOG_DESTROY_WITH_PARENT,
2002 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2004 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2006 priv->credits_dialog = dialog;
2007 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
2008 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
2010 gtk_window_set_modal (GTK_WINDOW (dialog),
2011 gtk_window_get_modal (GTK_WINDOW (about)));
2013 g_signal_connect (dialog, "response",
2014 G_CALLBACK (gtk_widget_destroy), dialog);
2015 g_signal_connect (dialog, "destroy",
2016 G_CALLBACK (gtk_widget_destroyed),
2017 &(priv->credits_dialog));
2018 g_signal_connect (dialog, "style_set",
2019 G_CALLBACK (dialog_style_set), NULL);
2021 notebook = gtk_notebook_new ();
2022 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
2024 if (priv->authors != NULL)
2025 add_credits_page (about, notebook, _("Written by"), priv->authors);
2027 if (priv->documenters != NULL)
2028 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
2030 /* Don't show an untranslated gettext msgid */
2031 if (priv->translator_credits != NULL &&
2032 strcmp (priv->translator_credits, "translator_credits") &&
2033 strcmp (priv->translator_credits, "translator-credits"))
2035 gchar *translators[2];
2037 translators[0] = priv->translator_credits;
2038 translators[1] = NULL;
2040 add_credits_page (about, notebook, _("Translated by"), translators);
2043 if (priv->artists != NULL)
2044 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
2046 gtk_widget_show_all (dialog);
2050 set_policy (GtkWidget *sw)
2052 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2053 GTK_POLICY_AUTOMATIC,
2054 GTK_POLICY_AUTOMATIC);
2058 display_license_dialog (GtkWidget *button,
2061 GtkAboutDialog *about = (GtkAboutDialog *)data;
2062 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2063 GtkWidget *dialog, *view, *sw;
2065 if (priv->license_dialog != NULL)
2067 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2071 dialog = gtk_dialog_new_with_buttons (_("License"),
2073 GTK_DIALOG_DESTROY_WITH_PARENT,
2074 GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
2076 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2077 priv->license_dialog = dialog;
2078 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2079 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
2081 gtk_window_set_modal (GTK_WINDOW (dialog),
2082 gtk_window_get_modal (GTK_WINDOW (about)));
2084 g_signal_connect (dialog, "response",
2085 G_CALLBACK (gtk_widget_destroy), dialog);
2086 g_signal_connect (dialog, "destroy",
2087 G_CALLBACK (gtk_widget_destroyed),
2088 &(priv->license_dialog));
2089 g_signal_connect (dialog, "style_set",
2090 G_CALLBACK (dialog_style_set), NULL);
2092 sw = gtk_scrolled_window_new (NULL, NULL);
2093 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2095 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2097 GTK_POLICY_AUTOMATIC);
2098 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2099 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2101 view = gtk_text_view_new ();
2102 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
2103 priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
2104 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2107 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2108 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2110 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2111 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2113 gtk_container_add (GTK_CONTAINER (sw), view);
2115 gtk_widget_show_all (dialog);
2119 * gtk_about_dialog_new:
2121 * Creates a new #GtkAboutDialog.
2123 * Returns: a newly created #GtkAboutDialog
2128 gtk_about_dialog_new (void)
2130 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2132 return GTK_WIDGET (dialog);
2136 * gtk_about_dialog_set_email_hook:
2137 * @func: a function to call when an email link is activated.
2138 * @data: data to pass to @func
2139 * @destroy: #GDestroyNotify for @data
2141 * Installs a global function to be called whenever the user activates an
2142 * email link in an about dialog.
2144 * Return value: the previous email hook.
2148 GtkAboutDialogActivateLinkFunc
2149 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2151 GDestroyNotify destroy)
2153 GtkAboutDialogActivateLinkFunc old;
2155 if (activate_email_hook_destroy != NULL)
2156 (* activate_email_hook_destroy) (activate_email_hook_data);
2158 old = activate_email_hook;
2160 activate_email_hook = func;
2161 activate_email_hook_data = data;
2162 activate_email_hook_destroy = destroy;
2168 * gtk_about_dialog_set_url_hook:
2169 * @func: a function to call when a URL link is activated.
2170 * @data: data to pass to @func
2171 * @destroy: #GDestroyNotify for @data
2173 * Installs a global function to be called whenever the user activates a
2174 * URL link in an about dialog.
2176 * Return value: the previous URL hook.
2180 GtkAboutDialogActivateLinkFunc
2181 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2183 GDestroyNotify destroy)
2185 GtkAboutDialogActivateLinkFunc old;
2187 if (activate_url_hook_destroy != NULL)
2188 (* activate_url_hook_destroy) (activate_url_hook_data);
2190 old = activate_url_hook;
2192 activate_url_hook = func;
2193 activate_url_hook_data = data;
2194 activate_url_hook_destroy = destroy;
2200 close_cb (GtkAboutDialog *about)
2202 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2204 if (priv->license_dialog != NULL)
2206 gtk_widget_destroy (priv->license_dialog);
2207 priv->license_dialog = NULL;
2210 if (priv->credits_dialog != NULL)
2212 gtk_widget_destroy (priv->credits_dialog);
2213 priv->credits_dialog = NULL;
2216 gtk_widget_hide (GTK_WIDGET (about));
2221 * gtk_show_about_dialog:
2222 * @parent: transient parent, or %NULL for none
2223 * @first_property_name: the name of the first property
2224 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2226 * This is a convenience function for showing an application's about box.
2227 * The constructed dialog is associated with the parent window and
2228 * reused for future invocations of this function.
2233 gtk_show_about_dialog (GtkWindow *parent,
2234 const gchar *first_property_name,
2237 static GtkWidget *global_about_dialog = NULL;
2238 GtkWidget *dialog = NULL;
2242 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2244 dialog = global_about_dialog;
2248 dialog = gtk_about_dialog_new ();
2250 g_object_ref_sink (dialog);
2252 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2254 /* Close dialog on user response */
2255 g_signal_connect (dialog, "response", G_CALLBACK (close_cb), NULL);
2257 va_start (var_args, first_property_name);
2258 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2263 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2264 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2265 g_object_set_data_full (G_OBJECT (parent),
2266 I_("gtk-about-dialog"),
2267 dialog, g_object_unref);
2270 global_about_dialog = dialog;
2274 gtk_window_present (GTK_WINDOW (dialog));
2277 #define __GTK_ABOUT_DIALOG_C__
2278 #include "gtkaliasdef.c"