1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2001 CodeFactory AB
3 * Copyright (C) 2001, 2002 Anders Carlsson
4 * Copyright (C) 2003, 2004 Matthias Clasen <mclasen@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * Author: Anders Carlsson <andersca@gnome.org>
25 * Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
33 #include <gdk/gdkkeysyms.h>
35 #include "gtkaboutdialog.h"
36 #include "gtkbutton.h"
38 #include "gtkdialog.h"
42 #include "gtkmarshalers.h"
43 #include "gtknotebook.h"
44 #include "gtkscrolledwindow.h"
46 #include "gtktextview.h"
48 #include "gtkviewport.h"
49 #include "gtkiconfactory.h"
56 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
57 struct _GtkAboutDialogPrivate
65 gchar *translator_credits;
72 GtkWidget *logo_image;
73 GtkWidget *name_label;
74 GtkWidget *comments_label;
75 GtkWidget *copyright_label;
76 GtkWidget *website_button;
78 GtkWidget *credits_button;
79 GtkWidget *credits_dialog;
80 GtkWidget *license_button;
81 GtkWidget *license_dialog;
83 GdkCursor *hand_cursor;
84 GdkCursor *regular_cursor;
85 gboolean hovering_over_link;
88 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
103 PROP_TRANSLATOR_CREDITS,
109 static void gtk_about_dialog_finalize (GObject *object);
110 static void gtk_about_dialog_get_property (GObject *object,
114 static void gtk_about_dialog_set_property (GObject *object,
118 static void gtk_about_dialog_style_set (GtkWidget *widget,
119 GtkStyle *previous_style);
120 static void dialog_style_set (GtkWidget *widget,
121 GtkStyle *previous_style,
123 static void update_name_version (GtkAboutDialog *about);
124 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
125 static void activate_url (GtkWidget *widget,
127 static void set_link_button_text (GtkWidget *about,
130 static GtkWidget * create_link_button (GtkWidget *about,
135 static void follow_if_link (GtkAboutDialog *about,
137 static void set_cursor_if_appropriate (GtkAboutDialog *about,
138 GtkTextView *text_view,
141 static void add_credits_page (GtkAboutDialog *about,
145 static gboolean credits_key_press_event (GtkWidget *text_view,
147 GtkAboutDialog *about);
148 static gboolean credits_event_after (GtkWidget *text_view,
150 GtkAboutDialog *about);
151 static gboolean credits_motion_notify_event (GtkWidget *text_view,
152 GdkEventMotion *event,
153 GtkAboutDialog *about);
154 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
155 GdkEventVisibility *event,
156 GtkAboutDialog *about);
157 static void display_credits_dialog (GtkWidget *button,
159 static void display_license_dialog (GtkWidget *button,
161 static void close_cb (GtkAboutDialog *about);
164 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
165 static gpointer activate_email_hook_data = NULL;
166 static GDestroyNotify activate_email_hook_destroy = NULL;
168 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
169 static gpointer activate_url_hook_data = NULL;
170 static GDestroyNotify activate_url_hook_destroy = NULL;
172 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
175 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
177 GObjectClass *object_class;
178 GtkWidgetClass *widget_class;
179 GtkDialogClass *dialog_class;
181 object_class = (GObjectClass *)klass;
182 widget_class = (GtkWidgetClass *)klass;
183 dialog_class = (GtkDialogClass *)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;
192 #define STATIC_STRINGS G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
195 * GtkAboutDialog:name:
197 * The name of the program.
198 * If this is not set, it defaults to g_get_application_name().
202 g_object_class_install_property (object_class,
204 g_param_spec_string ("name",
206 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
208 G_PARAM_READWRITE|STATIC_STRINGS));
211 * GtkAboutDialog:version:
213 * The version of the program.
217 g_object_class_install_property (object_class,
219 g_param_spec_string ("version",
220 P_("Program version"),
221 P_("The version of the program"),
223 G_PARAM_READWRITE|STATIC_STRINGS));
226 * GtkAboutDialog:copyright:
228 * Copyright information for the program.
232 g_object_class_install_property (object_class,
234 g_param_spec_string ("copyright",
235 P_("Copyright string"),
236 P_("Copyright information for the program"),
238 G_PARAM_READWRITE|STATIC_STRINGS));
242 * GtkAboutDialog:comments:
244 * Comments about the program. This string is displayed in a label
245 * in the main dialog, thus it should be a short explanation of
246 * the main purpose of the program, not a detailed list of features.
250 g_object_class_install_property (object_class,
252 g_param_spec_string ("comments",
253 P_("Comments string"),
254 P_("Comments about the program"),
256 G_PARAM_READWRITE|STATIC_STRINGS));
259 * GtkAboutDialog:license:
261 * The license of the program. This string is displayed in a
262 * text view in a secondary dialog, therefore it is fine to use
263 * a long multi-paragraph text. Note that the text is not wrapped
264 * in the text view, thus it 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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
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 G_PARAM_READWRITE|STATIC_STRINGS));
410 /* Style properties */
411 gtk_widget_class_install_style_property (widget_class,
412 g_param_spec_boxed ("link-color",
414 P_("Color of hyperlinks"),
416 G_PARAM_READABLE|STATIC_STRINGS));
418 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
422 gtk_about_dialog_init (GtkAboutDialog *about)
424 GtkAboutDialogPrivate *priv;
425 GtkWidget *vbox, *hbox, *button;
428 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
429 about->private_data = priv;
432 priv->version = NULL;
433 priv->copyright = NULL;
434 priv->comments = NULL;
435 priv->website = NULL;
436 priv->website_label = NULL;
437 priv->translator_credits = NULL;
438 priv->license = NULL;
439 priv->authors = NULL;
440 priv->documenters = NULL;
441 priv->artists = NULL;
443 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
444 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
445 priv->hovering_over_link = FALSE;
447 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
450 gtk_widget_push_composite_child ();
451 vbox = gtk_vbox_new (FALSE, 8);
453 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
455 priv->logo_image = gtk_image_new ();
456 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
458 priv->name_label = gtk_label_new (NULL);
459 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
460 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
461 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
463 priv->comments_label = gtk_label_new (NULL);
464 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
465 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
466 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
467 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
469 priv->copyright_label = gtk_label_new (NULL);
470 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
471 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
472 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
474 button = create_link_button (GTK_WIDGET (about), "", "",
475 G_CALLBACK (activate_url), about);
477 hbox = gtk_hbox_new (TRUE, 0);
478 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
479 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
480 priv->website_button = button;
482 gtk_widget_show (vbox);
483 gtk_widget_show (priv->logo_image);
484 gtk_widget_show (priv->name_label);
485 gtk_widget_show (hbox);
487 /* Add the OK button */
488 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
489 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CLOSE);
491 /* Add the credits button */
492 button = gtk_button_new_from_stock (_("C_redits"));
493 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
494 button, FALSE, TRUE, 0);
495 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
496 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
497 priv->credits_button = button;
498 priv->credits_dialog = NULL;
500 /* Add the license button */
501 button = gtk_button_new_from_stock (_("_License"));
502 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
503 button, FALSE, TRUE, 0);
504 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
505 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
506 priv->license_button = button;
507 priv->license_dialog = NULL;
509 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
511 gtk_widget_pop_composite_child ();
514 gtk_about_dialog_set_name (about, NULL);
515 gtk_about_dialog_set_logo (about, NULL);
517 /* Close dialog on user response */
518 g_signal_connect (about, "response", G_CALLBACK (close_cb), NULL);
522 gtk_about_dialog_finalize (GObject *object)
524 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
525 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
528 g_free (priv->version);
529 g_free (priv->copyright);
530 g_free (priv->comments);
531 g_free (priv->license);
532 g_free (priv->website);
533 g_free (priv->website_label);
534 g_free (priv->translator_credits);
536 g_strfreev (priv->authors);
537 g_strfreev (priv->documenters);
538 g_strfreev (priv->artists);
540 gdk_cursor_unref (priv->hand_cursor);
541 gdk_cursor_unref (priv->regular_cursor);
543 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
547 gtk_about_dialog_set_property (GObject *object,
552 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
557 gtk_about_dialog_set_name (about, g_value_get_string (value));
560 gtk_about_dialog_set_version (about, g_value_get_string (value));
563 gtk_about_dialog_set_comments (about, g_value_get_string (value));
566 gtk_about_dialog_set_website (about, g_value_get_string (value));
568 case PROP_WEBSITE_LABEL:
569 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
572 gtk_about_dialog_set_license (about, g_value_get_string (value));
575 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
578 gtk_about_dialog_set_logo (about, g_value_get_object (value));
581 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
583 case PROP_DOCUMENTERS:
584 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
587 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
589 case PROP_TRANSLATOR_CREDITS:
590 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
592 case PROP_LOGO_ICON_NAME:
593 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
596 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
602 gtk_about_dialog_get_property (GObject *object,
607 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
608 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
613 g_value_set_string (value, priv->name);
616 g_value_set_string (value, priv->version);
619 g_value_set_string (value, priv->copyright);
622 g_value_set_string (value, priv->comments);
625 g_value_set_string (value, priv->website);
627 case PROP_WEBSITE_LABEL:
628 g_value_set_string (value, priv->website_label);
631 g_value_set_string (value, priv->license);
633 case PROP_TRANSLATOR_CREDITS:
634 g_value_set_string (value, priv->translator_credits);
637 g_value_set_boxed (value, priv->authors);
639 case PROP_DOCUMENTERS:
640 g_value_set_boxed (value, priv->documenters);
643 g_value_set_boxed (value, priv->artists);
646 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
647 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
649 g_value_set_object (value, NULL);
651 case PROP_LOGO_ICON_NAME:
652 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
654 const gchar *icon_name;
656 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
657 g_value_set_string (value, icon_name);
660 g_value_set_string (value, NULL);
663 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
669 dialog_style_set (GtkWidget *widget,
670 GtkStyle *previous_style,
675 dialog = GTK_DIALOG (widget);
677 /* Override the style properties with HIG-compliant spacings. Ugh.
678 * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
679 * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
682 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
683 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 12);
685 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
686 gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
690 gtk_about_dialog_style_set (GtkWidget *widget,
691 GtkStyle *previous_style)
693 if (GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set)
694 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set (widget, previous_style);
696 dialog_style_set (widget, previous_style, NULL);
700 * gtk_about_dialog_get_name:
701 * @about: a #GtkAboutDialog
703 * Returns the program name displayed in the about dialog.
705 * Return value: The program name. The string is owned by the about
706 * dialog and must not be modified.
710 G_CONST_RETURN gchar *
711 gtk_about_dialog_get_name (GtkAboutDialog *about)
713 GtkAboutDialogPrivate *priv;
715 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
717 priv = (GtkAboutDialogPrivate *)about->private_data;
723 update_name_version (GtkAboutDialog *about)
725 GtkAboutDialogPrivate *priv;
726 gchar *title_string, *name_string;
728 priv = (GtkAboutDialogPrivate *)about->private_data;
730 title_string = g_strdup_printf (_("About %s"), priv->name);
731 gtk_window_set_title (GTK_WINDOW (about), title_string);
732 g_free (title_string);
734 if (priv->version != NULL)
735 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
736 priv->name, priv->version);
738 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
741 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
743 g_free (name_string);
747 * gtk_about_dialog_set_name:
748 * @about: a #GtkAboutDialog
749 * @name: the program name
751 * Sets the name to display in the about dialog.
752 * If this is not set, it defaults to g_get_application_name().
757 gtk_about_dialog_set_name (GtkAboutDialog *about,
760 GtkAboutDialogPrivate *priv;
763 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
765 priv = (GtkAboutDialogPrivate *)about->private_data;
767 priv->name = g_strdup (name ? name : g_get_application_name ());
770 update_name_version (about);
772 g_object_notify (G_OBJECT (about), "name");
776 * gtk_about_dialog_get_version:
777 * @about: a #GtkAboutDialog
779 * Returns the version string.
781 * Return value: The version string. The string is owned by the about
782 * dialog and must not be modified.
786 G_CONST_RETURN gchar *
787 gtk_about_dialog_get_version (GtkAboutDialog *about)
789 GtkAboutDialogPrivate *priv;
791 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
793 priv = (GtkAboutDialogPrivate *)about->private_data;
795 return priv->version;
799 * gtk_about_dialog_set_version:
800 * @about: a #GtkAboutDialog
801 * @version: the version string
803 * Sets the version string to display in the about dialog.
808 gtk_about_dialog_set_version (GtkAboutDialog *about,
809 const gchar *version)
811 GtkAboutDialogPrivate *priv;
814 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
816 priv = (GtkAboutDialogPrivate *)about->private_data;
819 priv->version = version ? g_strdup (version) : NULL;
822 update_name_version (about);
824 g_object_notify (G_OBJECT (about), "version");
828 * gtk_about_dialog_get_copyright:
829 * @about: a #GtkAboutDialog
831 * Returns the copyright string.
833 * Return value: The copyright string. The string is owned by the about
834 * dialog and must not be modified.
838 G_CONST_RETURN gchar *
839 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
841 GtkAboutDialogPrivate *priv;
843 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
845 priv = (GtkAboutDialogPrivate *)about->private_data;
847 return priv->copyright;
851 * gtk_about_dialog_set_copyright:
852 * @about: a #GtkAboutDialog
853 * @copyright: the copyright string
855 * Sets the copyright string to display in the about dialog.
856 * This should be a short string of one or two lines.
861 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
862 const gchar *copyright)
864 GtkAboutDialogPrivate *priv;
865 gchar *copyright_string, *tmp;
867 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
869 priv = (GtkAboutDialogPrivate *)about->private_data;
871 tmp = priv->copyright;
872 priv->copyright = copyright ? g_strdup (copyright) : NULL;
875 if (priv->copyright != NULL)
877 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
879 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
880 g_free (copyright_string);
882 gtk_widget_show (priv->copyright_label);
885 gtk_widget_hide (priv->copyright_label);
887 g_object_notify (G_OBJECT (about), "copyright");
891 * gtk_about_dialog_get_comments:
892 * @about: a #GtkAboutDialog
894 * Returns the comments string.
896 * Return value: The comments. The string is owned by the about
897 * dialog and must not be modified.
901 G_CONST_RETURN gchar *
902 gtk_about_dialog_get_comments (GtkAboutDialog *about)
904 GtkAboutDialogPrivate *priv;
906 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
908 priv = (GtkAboutDialogPrivate *)about->private_data;
910 return priv->comments;
914 * gtk_about_dialog_set_comments:
915 * @about: a #GtkAboutDialog
916 * @comments: a comments string
918 * Sets the comments string to display in the about
919 * dialog. This should be a short string of one or
925 gtk_about_dialog_set_comments (GtkAboutDialog *about,
926 const gchar *comments)
928 GtkAboutDialogPrivate *priv;
931 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
933 priv = (GtkAboutDialogPrivate *)about->private_data;
935 tmp = priv->comments;
938 priv->comments = g_strdup (comments);
939 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
940 gtk_widget_show (priv->comments_label);
944 priv->comments = NULL;
945 gtk_widget_hide (priv->comments_label);
949 g_object_notify (G_OBJECT (about), "comments");
953 * gtk_about_dialog_get_license:
954 * @about: a #GtkAboutDialog
956 * Returns the license information.
958 * Return value: The license information. The string is owned by the about
959 * dialog and must not be modified.
963 G_CONST_RETURN gchar *
964 gtk_about_dialog_get_license (GtkAboutDialog *about)
966 GtkAboutDialogPrivate *priv;
968 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
970 priv = (GtkAboutDialogPrivate *)about->private_data;
972 return priv->license;
976 * gtk_about_dialog_set_license:
977 * @about: a #GtkAboutDialog
978 * @license: the license information or %NULL
980 * Sets the license information to be displayed in the secondary
981 * license dialog. If @license is %NULL, the license button is
987 gtk_about_dialog_set_license (GtkAboutDialog *about,
988 const gchar *license)
990 GtkAboutDialogPrivate *priv;
993 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
995 priv = (GtkAboutDialogPrivate *)about->private_data;
1000 priv->license = g_strdup (license);
1001 gtk_widget_show (priv->license_button);
1005 priv->license = NULL;
1006 gtk_widget_hide (priv->license_button);
1010 g_object_notify (G_OBJECT (about), "license");
1014 * gtk_about_dialog_get_website:
1015 * @about: a #GtkAboutDialog
1017 * Returns the website URL.
1019 * Return value: The website URL. The string is owned by the about
1020 * dialog and must not be modified.
1024 G_CONST_RETURN gchar *
1025 gtk_about_dialog_get_website (GtkAboutDialog *about)
1027 GtkAboutDialogPrivate *priv;
1029 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1031 priv = (GtkAboutDialogPrivate *)about->private_data;
1033 return priv->website;
1037 * gtk_about_dialog_set_website:
1038 * @about: a #GtkAboutDialog
1039 * @website: a URL string starting with "http://"
1041 * Sets the URL to use for the website link.
1046 gtk_about_dialog_set_website (GtkAboutDialog *about,
1047 const gchar *website)
1049 GtkAboutDialogPrivate *priv;
1052 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1054 priv = (GtkAboutDialogPrivate *)about->private_data;
1056 tmp = priv->website;
1057 if (website != NULL)
1059 priv->website = g_strdup (website);
1060 if (activate_url_hook != NULL)
1062 g_object_set_data_full (G_OBJECT (priv->website_button),
1063 "url", g_strdup (website), g_free);
1064 if (priv->website_label == NULL)
1065 gtk_about_dialog_set_website_label (about, website);
1069 GtkWidget *hbox = priv->website_button->parent;
1070 gtk_widget_destroy (priv->website_button);
1071 priv->website_button = gtk_label_new (website);
1072 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1073 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1074 gtk_widget_show (priv->website_button);
1079 priv->website = NULL;
1080 g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
1081 gtk_widget_hide (priv->website_button);
1085 g_object_notify (G_OBJECT (about), "website");
1089 * gtk_about_dialog_get_website_label:
1090 * @about: a #GtkAboutDialog
1092 * Returns the label used for the website link.
1094 * Return value: The label used for the website link. 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_label (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_label;
1112 * gtk_about_dialog_set_website_label:
1113 * @about: a #GtkAboutDialog
1114 * @website_label: the label used for the website link
1116 * Sets the label to be used for the website link.
1117 * It defaults to the website URL.
1122 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1123 const gchar *website_label)
1125 GtkAboutDialogPrivate *priv;
1128 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1130 priv = (GtkAboutDialogPrivate *)about->private_data;
1132 tmp = priv->website_label;
1133 if (activate_url_hook != NULL)
1135 if (website_label != NULL)
1137 priv->website_label = g_strdup (website_label);
1138 set_link_button_text (GTK_WIDGET (about),
1139 priv->website_button,
1140 priv->website_label);
1141 gtk_widget_show (priv->website_button);
1145 priv->website_label = NULL;
1146 gtk_widget_hide (priv->website_button);
1151 g_object_notify (G_OBJECT (about), "website_label");
1155 * gtk_about_dialog_get_authors:
1156 * @about: a #GtkAboutDialog
1158 * Returns the string which are displayed in the authors tab
1159 * of the secondary credits dialog.
1161 * Return value: A %NULL-terminated string array containing
1162 * the authors. The array is owned by the about dialog
1163 * and must not be modified.
1167 G_CONST_RETURN gchar * G_CONST_RETURN *
1168 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1170 GtkAboutDialogPrivate *priv;
1172 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1174 priv = (GtkAboutDialogPrivate *)about->private_data;
1176 return (const gchar * const *) priv->authors;
1180 * gtk_about_dialog_set_authors:
1181 * @about: a #GtkAboutDialog
1182 * @authors: a %NULL-terminated array of strings
1184 * Sets the strings which are displayed in the authors tab
1185 * of the secondary credits dialog.
1190 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1191 const gchar **authors)
1193 GtkAboutDialogPrivate *priv;
1196 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1198 priv = (GtkAboutDialogPrivate *)about->private_data;
1200 tmp = priv->authors;
1201 priv->authors = g_strdupv ((gchar **)authors);
1204 if (priv->authors != NULL)
1205 gtk_widget_show (priv->credits_button);
1207 g_object_notify (G_OBJECT (about), "authors");
1211 * gtk_about_dialog_get_documenters:
1212 * @about: a #GtkAboutDialog
1214 * Returns the string which are displayed in the documenters
1215 * tab of the secondary credits dialog.
1217 * Return value: A %NULL-terminated string array containing
1218 * the documenters. The array is owned by the about dialog
1219 * and must not be modified.
1223 G_CONST_RETURN gchar * G_CONST_RETURN *
1224 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1226 GtkAboutDialogPrivate *priv;
1228 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1230 priv = (GtkAboutDialogPrivate *)about->private_data;
1232 return (const gchar * const *)priv->documenters;
1236 * gtk_about_dialog_set_documenters:
1237 * @about: a #GtkAboutDialog
1238 * @documenters: a %NULL-terminated array of strings
1240 * Sets the strings which are displayed in the documenters tab
1241 * of the secondary credits dialog.
1246 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1247 const gchar **documenters)
1249 GtkAboutDialogPrivate *priv;
1252 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1254 priv = (GtkAboutDialogPrivate *)about->private_data;
1256 tmp = priv->documenters;
1257 priv->documenters = g_strdupv ((gchar **)documenters);
1260 if (priv->documenters != NULL)
1261 gtk_widget_show (priv->credits_button);
1263 g_object_notify (G_OBJECT (about), "documenters");
1267 * gtk_about_dialog_get_artists:
1268 * @about: a #GtkAboutDialog
1270 * Returns the string which are displayed in the artists tab
1271 * of the secondary credits dialog.
1273 * Return value: A %NULL-terminated string array containing
1274 * the artists. The array is owned by the about dialog
1275 * and must not be modified.
1279 G_CONST_RETURN gchar * G_CONST_RETURN *
1280 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1282 GtkAboutDialogPrivate *priv;
1284 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1286 priv = (GtkAboutDialogPrivate *)about->private_data;
1288 return (const gchar * const *)priv->artists;
1292 * gtk_about_dialog_set_artists:
1293 * @about: a #GtkAboutDialog
1294 * @artists: a %NULL-terminated array of strings
1296 * Sets the strings which are displayed in the artists tab
1297 * of the secondary credits dialog.
1302 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1303 const gchar **artists)
1305 GtkAboutDialogPrivate *priv;
1308 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1310 priv = (GtkAboutDialogPrivate *)about->private_data;
1312 tmp = priv->artists;
1313 priv->artists = g_strdupv ((gchar **)artists);
1316 if (priv->artists != NULL)
1317 gtk_widget_show (priv->credits_button);
1319 g_object_notify (G_OBJECT (about), "artists");
1323 * gtk_about_dialog_get_translator_credits:
1324 * @about: a #GtkAboutDialog
1326 * Returns the translator credits string which is displayed
1327 * in the translators tab of the secondary credits dialog.
1329 * Return value: The translator credits string. The string is
1330 * owned by the about dialog and must not be modified.
1334 G_CONST_RETURN gchar *
1335 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1337 GtkAboutDialogPrivate *priv;
1339 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1341 priv = (GtkAboutDialogPrivate *)about->private_data;
1343 return priv->translator_credits;
1347 * gtk_about_dialog_set_translator_credits:
1348 * @about: a #GtkAboutDialog
1349 * @translator_credits: the translator credits
1351 * Sets the translator credits string which is displayed in
1352 * the translators tab of the secondary credits dialog.
1354 * The intended use for this string is to display the translator
1355 * of the language which is currently used in the user interface.
1356 * Using gettext(), a simple way to achieve that is to mark the
1357 * string for translation:
1358 * <informalexample><programlisting>
1359 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1360 * </programlisting></informalexample>
1361 * It is a good idea to use the customary msgid "translator-credits" for this
1362 * purpose, since translators will already know the purpose of that msgid, and
1363 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1369 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1370 const gchar *translator_credits)
1372 GtkAboutDialogPrivate *priv;
1375 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1377 priv = (GtkAboutDialogPrivate *)about->private_data;
1379 tmp = priv->translator_credits;
1380 priv->translator_credits = g_strdup (translator_credits);
1383 if (priv->translator_credits != NULL)
1384 gtk_widget_show (priv->credits_button);
1386 g_object_notify (G_OBJECT (about), "translator-credits");
1390 * gtk_about_dialog_get_logo:
1391 * @about: a #GtkAboutDialog
1393 * Returns the pixbuf displayed as logo in the about dialog.
1395 * Return value: the pixbuf displayed as logo. The pixbuf is
1396 * owned by the about dialog. If you want to keep a reference
1397 * to it, you have to call g_object_ref() on it.
1402 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1404 GtkAboutDialogPrivate *priv;
1406 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1408 priv = (GtkAboutDialogPrivate *)about->private_data;
1410 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1411 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1417 icon_set_new_from_pixbufs (GList *pixbufs)
1419 GtkIconSet *icon_set = gtk_icon_set_new ();
1421 for (; pixbufs; pixbufs = pixbufs->next)
1423 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1425 GtkIconSource *icon_source = gtk_icon_source_new ();
1426 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1427 gtk_icon_set_add_source (icon_set, icon_source);
1428 gtk_icon_source_free (icon_source);
1435 * gtk_about_dialog_set_logo:
1436 * @about: a #GtkAboutDialog
1437 * @logo: a #GdkPixbuf, or %NULL
1439 * Sets the pixbuf to be displayed as logo in
1440 * the about dialog. If it is %NULL, the default
1441 * window icon set with gtk_window_set_default_icon ()
1447 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1450 GtkAboutDialogPrivate *priv;
1452 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1454 priv = (GtkAboutDialogPrivate *)about->private_data;
1456 g_object_freeze_notify (G_OBJECT (about));
1458 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1459 g_object_notify (G_OBJECT (about), "logo_icon_name");
1462 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1465 GList *pixbufs = gtk_window_get_default_icon_list ();
1467 if (pixbufs != NULL)
1469 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1471 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1472 icon_set, GTK_ICON_SIZE_DIALOG);
1474 gtk_icon_set_unref (icon_set);
1475 g_list_free (pixbufs);
1479 g_object_notify (G_OBJECT (about), "logo");
1481 g_object_thaw_notify (G_OBJECT (about));
1485 * gtk_about_dialog_get_logo_icon_name:
1486 * @about: a #GtkAboutDialog
1488 * Returns the icon name displayed as logo in the about dialog.
1490 * Return value: the icon name displayed as logo. The string is
1491 * owned by the dialog. If you want to keep a reference
1492 * to it, you have to call g_strdup() on it.
1496 G_CONST_RETURN gchar *
1497 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1499 GtkAboutDialogPrivate *priv;
1500 const gchar *icon_name = NULL;
1502 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1504 priv = (GtkAboutDialogPrivate *)about->private_data;
1506 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1507 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1513 * gtk_about_dialog_set_logo_icon_name:
1514 * @about: a #GtkAboutDialog
1515 * @icon_name: an icon name, or %NULL
1517 * Sets the pixbuf to be displayed as logo in
1518 * the about dialog. If it is %NULL, the default
1519 * window icon set with gtk_window_set_default_icon()
1525 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1526 const gchar *icon_name)
1528 GtkAboutDialogPrivate *priv;
1530 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1532 priv = (GtkAboutDialogPrivate *)about->private_data;
1534 g_object_freeze_notify (G_OBJECT (about));
1536 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1537 g_object_notify (G_OBJECT (about), "logo");
1539 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1540 GTK_ICON_SIZE_DIALOG);
1541 g_object_notify (G_OBJECT (about), "logo_icon_name");
1543 g_object_thaw_notify (G_OBJECT (about));
1547 activate_url (GtkWidget *widget,
1550 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1551 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1553 if (activate_url_hook != NULL)
1554 (* activate_url_hook) (about, url, activate_url_hook_data);
1558 set_link_button_text (GtkWidget *about,
1564 GdkColor *style_link_color;
1565 GdkColor link_color = { 0, 0, 0, 0xffff };
1567 gtk_widget_ensure_style (about);
1568 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1569 if (style_link_color)
1571 link_color = *style_link_color;
1572 gdk_color_free (style_link_color);
1575 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1576 link_color.red, link_color.green, link_color.blue, text);
1578 label = gtk_bin_get_child (GTK_BIN (button));
1579 gtk_label_set_markup (GTK_LABEL (label), link);
1584 link_button_enter (GtkWidget *widget,
1585 GdkEventCrossing *event,
1586 GtkAboutDialog *about)
1588 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1589 gdk_window_set_cursor (widget->window, priv->hand_cursor);
1595 link_button_leave (GtkWidget *widget,
1596 GdkEventCrossing *event,
1597 GtkAboutDialog *about)
1599 gdk_window_set_cursor (widget->window, NULL);
1605 create_link_button (GtkWidget *about,
1613 button = gtk_button_new_with_label ("");
1614 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1615 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1617 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1618 set_link_button_text (about, button, text);
1620 g_signal_connect (button, "clicked", callback, data);
1621 g_signal_connect (button, "enter_notify_event",
1622 G_CALLBACK (link_button_enter), data);
1623 g_signal_connect (button, "leave_notify_event",
1624 G_CALLBACK (link_button_leave), data);
1630 follow_if_link (GtkAboutDialog *about,
1633 GSList *tags = NULL, *tagp = NULL;
1635 tags = gtk_text_iter_get_tags (iter);
1636 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1638 GtkTextTag *tag = tagp->data;
1639 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1640 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1642 if (email != NULL && activate_email_hook != NULL)
1644 (* activate_email_hook) (about, email, activate_email_hook_data);
1648 if (url != NULL && activate_url_hook != NULL)
1650 (* activate_url_hook) (about, url, activate_url_hook_data);
1656 g_slist_free (tags);
1660 credits_key_press_event (GtkWidget *text_view,
1662 GtkAboutDialog *about)
1665 GtkTextBuffer *buffer;
1667 switch (event->keyval)
1671 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1672 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1673 gtk_text_buffer_get_insert (buffer));
1674 follow_if_link (about, &iter);
1685 credits_event_after (GtkWidget *text_view,
1687 GtkAboutDialog *about)
1689 GtkTextIter start, end, iter;
1690 GtkTextBuffer *buffer;
1691 GdkEventButton *button_event;
1694 if (event->type != GDK_BUTTON_RELEASE)
1697 button_event = (GdkEventButton *)event;
1699 if (button_event->button != 1)
1702 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1704 /* we shouldn't follow a link if the user has selected something */
1705 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1706 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1709 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1710 GTK_TEXT_WINDOW_WIDGET,
1711 button_event->x, button_event->y, &x, &y);
1713 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1715 follow_if_link (about, &iter);
1721 set_cursor_if_appropriate (GtkAboutDialog *about,
1722 GtkTextView *text_view,
1726 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1727 GSList *tags = NULL, *tagp = NULL;
1728 GtkTextBuffer *buffer;
1730 gboolean hovering_over_link = FALSE;
1732 buffer = gtk_text_view_get_buffer (text_view);
1734 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1736 tags = gtk_text_iter_get_tags (&iter);
1737 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1739 GtkTextTag *tag = tagp->data;
1740 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1741 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1743 if (email != NULL || url != NULL)
1745 hovering_over_link = TRUE;
1750 if (hovering_over_link != priv->hovering_over_link)
1752 priv->hovering_over_link = hovering_over_link;
1754 if (hovering_over_link)
1755 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1757 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1761 g_slist_free (tags);
1765 credits_motion_notify_event (GtkWidget *text_view,
1766 GdkEventMotion *event,
1767 GtkAboutDialog *about)
1771 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1772 GTK_TEXT_WINDOW_WIDGET,
1773 event->x, event->y, &x, &y);
1775 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1777 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1784 credits_visibility_notify_event (GtkWidget *text_view,
1785 GdkEventVisibility *event,
1786 GtkAboutDialog *about)
1788 gint wx, wy, bx, by;
1790 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1792 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1793 GTK_TEXT_WINDOW_WIDGET,
1796 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1802 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1804 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1805 &widget->style->bg[GTK_STATE_NORMAL]);
1809 add_credits_page (GtkAboutDialog *about,
1810 GtkWidget *notebook,
1815 gchar *q0, *q1, *q2, *r1, *r2;
1816 GtkWidget *sw, *view;
1817 GtkTextBuffer *buffer;
1818 gboolean linkify_email, linkify_urls;
1819 GdkColor *style_link_color;
1820 GdkColor link_color = { 0, 0, 0, 0xffff };
1822 linkify_email = (activate_email_hook != NULL);
1823 linkify_urls = (activate_url_hook != NULL);
1825 gtk_widget_ensure_style (GTK_WIDGET (about));
1826 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1827 if (style_link_color)
1829 link_color = *style_link_color;
1830 gdk_color_free (style_link_color);
1833 view = gtk_text_view_new ();
1834 g_signal_connect_object (about, "style_set",
1835 G_CALLBACK (text_view_style_set), view, 0);
1837 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1838 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1839 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1841 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1842 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1844 g_signal_connect (view, "key-press-event",
1845 G_CALLBACK (credits_key_press_event), about);
1846 g_signal_connect (view, "event-after",
1847 G_CALLBACK (credits_event_after), about);
1848 g_signal_connect (view, "motion-notify-event",
1849 G_CALLBACK (credits_motion_notify_event), about);
1850 g_signal_connect (view, "visibility-notify-event",
1851 G_CALLBACK (credits_visibility_notify_event), about);
1853 sw = gtk_scrolled_window_new (NULL, NULL);
1854 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1856 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1857 GTK_POLICY_AUTOMATIC,
1858 GTK_POLICY_AUTOMATIC);
1859 gtk_container_add (GTK_CONTAINER (sw), view);
1861 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1862 sw, gtk_label_new (title));
1866 gtk_widget_hide (view);
1870 gtk_widget_show (view);
1872 for (p = people; *p; p++)
1877 q1 = linkify_email ? strchr (q0, '<') : NULL;
1878 q2 = q1 ? strchr (q1, '>') : NULL;
1879 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1882 r2 = strpbrk (r1, " \n\t");
1884 r2 = strchr (r1, '\0');
1889 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1902 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1903 gtk_text_buffer_get_end_iter (buffer, &end);
1911 link_type = "email";
1916 link = g_strndup (q1, q2 - q1);
1917 tag = gtk_text_buffer_create_tag (buffer, NULL,
1918 "foreground_gdk", &link_color,
1919 "underline", PANGO_UNDERLINE_SINGLE,
1921 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1922 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1928 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1934 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1939 display_credits_dialog (GtkWidget *button,
1942 GtkAboutDialog *about = (GtkAboutDialog *)data;
1943 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1944 GtkWidget *dialog, *notebook;
1946 if (priv->credits_dialog != NULL)
1948 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1952 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1954 GTK_DIALOG_DESTROY_WITH_PARENT,
1955 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1957 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1959 priv->credits_dialog = dialog;
1960 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1961 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1963 gtk_window_set_modal (GTK_WINDOW (dialog),
1964 gtk_window_get_modal (GTK_WINDOW (about)));
1966 g_signal_connect (dialog, "response",
1967 G_CALLBACK (gtk_widget_destroy), dialog);
1968 g_signal_connect (dialog, "destroy",
1969 G_CALLBACK (gtk_widget_destroyed),
1970 &(priv->credits_dialog));
1971 g_signal_connect (dialog, "style_set",
1972 G_CALLBACK (dialog_style_set), NULL);
1974 notebook = gtk_notebook_new ();
1975 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1977 if (priv->authors != NULL)
1978 add_credits_page (about, notebook, _("Written by"), priv->authors);
1980 if (priv->documenters != NULL)
1981 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1983 /* Don't show an untranslated gettext msgid */
1984 if (priv->translator_credits != NULL &&
1985 strcmp (priv->translator_credits, "translator_credits") &&
1986 strcmp (priv->translator_credits, "translator-credits"))
1988 gchar *translators[2];
1990 translators[0] = priv->translator_credits;
1991 translators[1] = NULL;
1993 add_credits_page (about, notebook, _("Translated by"), translators);
1996 if (priv->artists != NULL)
1997 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1999 gtk_widget_show_all (dialog);
2003 set_policy (GtkWidget *sw)
2005 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2006 GTK_POLICY_AUTOMATIC,
2007 GTK_POLICY_AUTOMATIC);
2011 display_license_dialog (GtkWidget *button,
2014 GtkAboutDialog *about = (GtkAboutDialog *)data;
2015 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2016 GtkWidget *dialog, *view, *sw;
2018 if (priv->license_dialog != NULL)
2020 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2024 dialog = gtk_dialog_new_with_buttons (_("License"),
2026 GTK_DIALOG_DESTROY_WITH_PARENT,
2027 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2029 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2030 priv->license_dialog = dialog;
2031 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2032 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
2034 gtk_window_set_modal (GTK_WINDOW (dialog),
2035 gtk_window_get_modal (GTK_WINDOW (about)));
2037 g_signal_connect (dialog, "response",
2038 G_CALLBACK (gtk_widget_destroy), dialog);
2039 g_signal_connect (dialog, "destroy",
2040 G_CALLBACK (gtk_widget_destroyed),
2041 &(priv->license_dialog));
2042 g_signal_connect (dialog, "style_set",
2043 G_CALLBACK (dialog_style_set), NULL);
2045 sw = gtk_scrolled_window_new (NULL, NULL);
2046 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2048 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2050 GTK_POLICY_AUTOMATIC);
2051 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2052 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2054 view = gtk_text_view_new ();
2055 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2058 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2059 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2061 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2062 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2064 gtk_container_add (GTK_CONTAINER (sw), view);
2066 gtk_widget_show_all (dialog);
2070 close_cb (GtkAboutDialog *about)
2072 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2074 if (priv->license_dialog != NULL)
2076 gtk_widget_destroy (priv->license_dialog);
2077 priv->license_dialog = NULL;
2080 if (priv->credits_dialog != NULL)
2082 gtk_widget_destroy (priv->credits_dialog);
2083 priv->credits_dialog = NULL;
2086 gtk_widget_hide (GTK_WIDGET (about));
2091 * gtk_about_dialog_new:
2093 * Creates a new #GtkAboutDialog.
2095 * Returns: a newly created #GtkAboutDialog
2100 gtk_about_dialog_new (void)
2102 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2104 return GTK_WIDGET (dialog);
2108 * gtk_about_dialog_set_email_hook:
2109 * @func: a function to call when an email link is activated.
2110 * @data: data to pass to @func
2111 * @destroy: #GDestroyNotify for @data
2113 * Installs a global function to be called whenever the user activates an
2114 * email link in an about dialog.
2116 * Return value: the previous email hook.
2120 GtkAboutDialogActivateLinkFunc
2121 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2123 GDestroyNotify destroy)
2125 GtkAboutDialogActivateLinkFunc old;
2127 if (activate_email_hook_destroy != NULL)
2128 (* activate_email_hook_destroy) (activate_email_hook_data);
2130 old = activate_email_hook;
2132 activate_email_hook = func;
2133 activate_email_hook_data = data;
2134 activate_email_hook_destroy = destroy;
2140 * gtk_about_dialog_set_url_hook:
2141 * @func: a function to call when a URL link is activated.
2142 * @data: data to pass to @func
2143 * @destroy: #GDestroyNotify for @data
2145 * Installs a global function to be called whenever the user activates a
2146 * URL link in an about dialog.
2148 * Return value: the previous URL hook.
2152 GtkAboutDialogActivateLinkFunc
2153 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2155 GDestroyNotify destroy)
2157 GtkAboutDialogActivateLinkFunc old;
2159 if (activate_url_hook_destroy != NULL)
2160 (* activate_url_hook_destroy) (activate_url_hook_data);
2162 old = activate_url_hook;
2164 activate_url_hook = func;
2165 activate_url_hook_data = data;
2166 activate_url_hook_destroy = destroy;
2172 * gtk_show_about_dialog:
2173 * @parent: transient parent, or %NULL for none
2174 * @first_property_name: the name of the first property
2175 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2177 * This is a convenience function for showing an application's about box.
2178 * The constructed dialog is associated with the parent window and
2179 * reused for future invocations of this function.
2184 gtk_show_about_dialog (GtkWindow *parent,
2185 const gchar *first_property_name,
2188 static GtkWidget *global_about_dialog = NULL;
2189 GtkWidget *dialog = NULL;
2193 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2195 dialog = global_about_dialog;
2199 dialog = gtk_about_dialog_new ();
2201 g_object_ref (dialog);
2202 gtk_object_sink (GTK_OBJECT (dialog));
2204 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2206 va_start (var_args, first_property_name);
2207 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2212 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2213 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2214 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
2215 dialog, g_object_unref);
2218 global_about_dialog = dialog;
2222 gtk_window_present (GTK_WINDOW (dialog));
2225 #define __GTK_ABOUT_DIALOG_C__
2226 #include "gtkaliasdef.c"