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>
37 #include "gtkaboutdialog.h"
38 #include "gtkbutton.h"
40 #include "gtkdialog.h"
44 #include "gtkmarshalers.h"
45 #include "gtknotebook.h"
46 #include "gtkscrolledwindow.h"
48 #include "gtktextview.h"
50 #include "gtkviewport.h"
51 #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 update_name_version (GtkAboutDialog *about);
119 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
120 static void activate_url (GtkWidget *widget,
122 static void set_link_button_text (GtkWidget *about,
125 static GtkWidget * create_link_button (GtkWidget *about,
130 static void follow_if_link (GtkAboutDialog *about,
132 static void set_cursor_if_appropriate (GtkAboutDialog *about,
133 GtkTextView *text_view,
136 static void add_credits_page (GtkAboutDialog *about,
140 static gboolean credits_key_press_event (GtkWidget *text_view,
142 GtkAboutDialog *about);
143 static gboolean credits_event_after (GtkWidget *text_view,
145 GtkAboutDialog *about);
146 static gboolean credits_motion_notify_event (GtkWidget *text_view,
147 GdkEventMotion *event,
148 GtkAboutDialog *about);
149 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
150 GdkEventVisibility *event,
151 GtkAboutDialog *about);
152 static void display_credits_dialog (GtkWidget *button,
154 static void display_license_dialog (GtkWidget *button,
158 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
159 static gpointer activate_email_hook_data = NULL;
160 static GDestroyNotify activate_email_hook_destroy = NULL;
162 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
163 static gpointer activate_url_hook_data = NULL;
164 static GDestroyNotify activate_url_hook_destroy = NULL;
166 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
169 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
171 GObjectClass *object_class;
172 GtkWidgetClass *widget_class;
173 GtkDialogClass *dialog_class;
175 object_class = (GObjectClass *)klass;
176 widget_class = (GtkWidgetClass *)klass;
177 dialog_class = (GtkDialogClass *)klass;
179 object_class->set_property = gtk_about_dialog_set_property;
180 object_class->get_property = gtk_about_dialog_get_property;
182 object_class->finalize = gtk_about_dialog_finalize;
184 g_object_class_install_property (object_class,
186 g_param_spec_string ("name",
188 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
192 g_object_class_install_property (object_class,
194 g_param_spec_string ("version",
195 P_("Program version"),
196 P_("The version of the program"),
199 g_object_class_install_property (object_class,
201 g_param_spec_string ("copyright",
202 P_("Copyright string"),
203 P_("Copyright information for the program"),
207 g_object_class_install_property (object_class,
209 g_param_spec_string ("comments",
210 P_("Comments string"),
211 P_("Comments about the program"),
214 g_object_class_install_property (object_class,
216 g_param_spec_string ("license",
218 _("The license of the program"),
222 g_object_class_install_property (object_class,
224 g_param_spec_string ("website",
226 P_("The URL for the link to the website of the program"),
230 g_object_class_install_property (object_class,
232 g_param_spec_string ("website_label",
234 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
238 g_object_class_install_property (object_class,
240 g_param_spec_boxed ("authors",
242 P_("List of authors of the programs"),
245 g_object_class_install_property (object_class,
247 g_param_spec_boxed ("documenters",
249 P_("List of people documenting the program"),
253 g_object_class_install_property (object_class,
255 g_param_spec_boxed ("artists",
257 P_("List of people who have contributed artwork to the program"),
261 g_object_class_install_property (object_class,
262 PROP_TRANSLATOR_CREDITS,
263 g_param_spec_string ("translator_credits",
264 P_("Translator credits"),
265 P_("Credits to the translators. This string should be marked as translatable"),
269 g_object_class_install_property (object_class,
271 g_param_spec_object ("logo",
273 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
277 g_object_class_install_property (object_class,
279 g_param_spec_string ("logo_icon_name",
280 P_("Logo Icon Name"),
281 P_("A named icon to use as the logo for the about box."),
285 /* Style properties */
286 gtk_widget_class_install_style_property (widget_class,
287 g_param_spec_boxed ("link_color",
289 P_("Color of hyperlinks"),
293 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
297 gtk_about_dialog_init (GtkAboutDialog *about)
299 GtkAboutDialogPrivate *priv;
300 GtkWidget *vbox, *hbox, *button;
303 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
304 about->private_data = priv;
307 priv->version = NULL;
308 priv->copyright = NULL;
309 priv->comments = NULL;
310 priv->website = NULL;
311 priv->website_label = NULL;
312 priv->translator_credits = NULL;
313 priv->authors = NULL;
314 priv->documenters = NULL;
315 priv->artists = NULL;
317 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
318 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
319 priv->hovering_over_link = FALSE;
321 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
324 gtk_widget_push_composite_child ();
325 vbox = gtk_vbox_new (FALSE, 8);
326 gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
328 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
330 priv->logo_image = gtk_image_new ();
331 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
333 priv->name_label = gtk_label_new (NULL);
334 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
335 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
336 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
338 priv->comments_label = gtk_label_new (NULL);
339 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
340 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
341 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
342 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
344 priv->copyright_label = gtk_label_new (NULL);
345 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
346 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
347 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
349 button = create_link_button (GTK_WIDGET (about), "", "",
350 G_CALLBACK (activate_url), about);
352 hbox = gtk_hbox_new (TRUE, 0);
353 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
354 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
355 priv->website_button = button;
357 gtk_widget_show (vbox);
358 gtk_widget_show (priv->logo_image);
359 gtk_widget_show (priv->name_label);
360 gtk_widget_show (hbox);
362 /* Add the OK button */
363 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
364 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CLOSE);
366 /* Add the credits button */
367 button = gtk_button_new_from_stock (_("_Credits"));
368 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
369 button, FALSE, TRUE, 0);
370 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
371 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
372 priv->credits_button = button;
373 priv->credits_dialog = NULL;
375 /* Add the license button */
376 button = gtk_button_new_from_stock (_("_License"));
377 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
378 button, FALSE, TRUE, 0);
379 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
380 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
381 priv->license_button = button;
382 priv->license_dialog = NULL;
384 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
386 gtk_widget_pop_composite_child ();
390 gtk_about_dialog_finalize (GObject *object)
392 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
393 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
396 g_free (priv->version);
397 g_free (priv->copyright);
398 g_free (priv->comments);
399 g_free (priv->license);
400 g_free (priv->website);
401 g_free (priv->website_label);
402 g_free (priv->translator_credits);
404 g_strfreev (priv->authors);
405 g_strfreev (priv->documenters);
406 g_strfreev (priv->artists);
408 gdk_cursor_unref (priv->hand_cursor);
409 gdk_cursor_unref (priv->regular_cursor);
411 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
415 gtk_about_dialog_set_property (GObject *object,
420 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
425 gtk_about_dialog_set_name (about, g_value_get_string (value));
428 gtk_about_dialog_set_version (about, g_value_get_string (value));
431 gtk_about_dialog_set_comments (about, g_value_get_string (value));
434 gtk_about_dialog_set_website (about, g_value_get_string (value));
436 case PROP_WEBSITE_LABEL:
437 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
440 gtk_about_dialog_set_license (about, g_value_get_string (value));
443 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
446 gtk_about_dialog_set_logo (about, g_value_get_object (value));
449 gtk_about_dialog_set_authors (about, (gchar**)g_value_get_boxed (value));
451 case PROP_DOCUMENTERS:
452 gtk_about_dialog_set_documenters (about, (gchar**)g_value_get_boxed (value));
455 gtk_about_dialog_set_artists (about, (gchar**)g_value_get_boxed (value));
457 case PROP_TRANSLATOR_CREDITS:
458 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
460 case PROP_LOGO_ICON_NAME:
461 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
464 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
470 gtk_about_dialog_get_property (GObject *object,
475 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
476 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
481 g_value_set_string (value, priv->name);
484 g_value_set_string (value, priv->version);
487 g_value_set_string (value, priv->copyright);
490 g_value_set_string (value, priv->comments);
493 g_value_set_string (value, priv->website);
495 case PROP_WEBSITE_LABEL:
496 g_value_set_string (value, priv->website_label);
499 g_value_set_string (value, priv->license);
501 case PROP_TRANSLATOR_CREDITS:
502 g_value_set_string (value, priv->translator_credits);
505 g_value_set_boxed (value, priv->authors);
507 case PROP_DOCUMENTERS:
508 g_value_set_boxed (value, priv->documenters);
511 g_value_set_boxed (value, priv->artists);
514 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
515 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
517 g_value_set_object (value, NULL);
519 case PROP_LOGO_ICON_NAME:
520 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
522 const gchar *icon_name;
524 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
525 g_value_set_string (value, icon_name);
528 g_value_set_string (value, NULL);
531 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
537 * gtk_about_dialog_get_name:
538 * @about: a #GtkAboutDialog
540 * Returns the program name displayed in the about dialog.
542 * Return value: The program name. The string is owned by the about
543 * dialog and must not be modified.
547 G_CONST_RETURN gchar *
548 gtk_about_dialog_get_name (GtkAboutDialog *about)
550 GtkAboutDialogPrivate *priv;
552 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
554 priv = (GtkAboutDialogPrivate *)about->private_data;
560 update_name_version (GtkAboutDialog *about)
562 GtkAboutDialogPrivate *priv;
563 gchar *title_string, *name_string;
565 priv = (GtkAboutDialogPrivate *)about->private_data;
567 title_string = g_strdup_printf (_("About %s"), priv->name);
568 gtk_window_set_title (GTK_WINDOW (about), title_string);
569 g_free (title_string);
571 if (priv->version != NULL)
572 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
573 priv->name, priv->version);
575 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
578 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
580 g_free (name_string);
584 * gtk_about_dialog_set_name:
585 * @about: a #GtkAboutDialog
586 * @name: the program name
588 * Sets the name to display in the about dialog.
589 * If this is not set, it defaults to g_get_application_name().
594 gtk_about_dialog_set_name (GtkAboutDialog *about,
597 GtkAboutDialogPrivate *priv;
600 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
602 priv = (GtkAboutDialogPrivate *)about->private_data;
604 priv->name = g_strdup (name ? name : g_get_application_name ());
607 update_name_version (about);
609 g_object_notify (G_OBJECT (about), "name");
613 * gtk_about_dialog_get_version:
614 * @about: a #GtkAboutDialog
616 * Returns the version string.
618 * Return value: The version string. The string is owned by the about
619 * dialog and must not be modified.
623 G_CONST_RETURN gchar *
624 gtk_about_dialog_get_version (GtkAboutDialog *about)
626 GtkAboutDialogPrivate *priv;
628 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
630 priv = (GtkAboutDialogPrivate *)about->private_data;
632 return priv->version;
636 * gtk_about_dialog_set_version:
637 * @about: a #GtkAboutDialog
638 * @version: the version string
640 * Sets the version string to display in the about dialog.
645 gtk_about_dialog_set_version (GtkAboutDialog *about,
646 const gchar *version)
648 GtkAboutDialogPrivate *priv;
651 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
653 priv = (GtkAboutDialogPrivate *)about->private_data;
656 priv->version = version ? g_strdup (version) : NULL;
659 update_name_version (about);
661 g_object_notify (G_OBJECT (about), "version");
665 * gtk_about_dialog_get_copyright:
666 * @about: a #GtkAboutDialog
668 * Returns the copyright string.
670 * Return value: The copyright string. The string is owned by the about
671 * dialog and must not be modified.
675 G_CONST_RETURN gchar *
676 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
678 GtkAboutDialogPrivate *priv;
680 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
682 priv = (GtkAboutDialogPrivate *)about->private_data;
684 return priv->copyright;
688 * gtk_about_dialog_set_copyright:
689 * @about: a #GtkAboutDialog
690 * @copyright: the copyright string
692 * Sets the copyright string to display in the about dialog.
693 * This should be a short string of one or two lines.
698 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
699 const gchar *copyright)
701 GtkAboutDialogPrivate *priv;
702 gchar *copyright_string, *tmp;
704 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
706 priv = (GtkAboutDialogPrivate *)about->private_data;
708 tmp = priv->copyright;
709 priv->copyright = copyright ? g_strdup (copyright) : NULL;
712 if (priv->copyright != NULL)
714 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
716 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
717 g_free (copyright_string);
719 gtk_widget_show (priv->copyright_label);
722 gtk_widget_hide (priv->copyright_label);
724 g_object_notify (G_OBJECT (about), "copyright");
728 * gtk_about_dialog_get_comments:
729 * @about: a #GtkAboutDialog
731 * Returns the comments string.
733 * Return value: The comments. The string is owned by the about
734 * dialog and must not be modified.
738 G_CONST_RETURN gchar *
739 gtk_about_dialog_get_comments (GtkAboutDialog *about)
741 GtkAboutDialogPrivate *priv;
743 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
745 priv = (GtkAboutDialogPrivate *)about->private_data;
747 return priv->comments;
751 * gtk_about_dialog_set_comments:
752 * @about: a #GtkAboutDialog
753 * @comments: a comments string
755 * Sets the comments string to display in the about
756 * dialog. This should be a short string of one or
762 gtk_about_dialog_set_comments (GtkAboutDialog *about,
763 const gchar *comments)
765 GtkAboutDialogPrivate *priv;
768 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
770 priv = (GtkAboutDialogPrivate *)about->private_data;
772 tmp = priv->comments;
775 priv->comments = g_strdup (comments);
776 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
777 gtk_widget_show (priv->comments_label);
781 priv->comments = NULL;
782 gtk_widget_hide (priv->comments_label);
786 g_object_notify (G_OBJECT (about), "comments");
790 * gtk_about_dialog_get_license:
791 * @about: a #GtkAboutDialog
793 * Returns the license information.
795 * Return value: The license information. The string is owned by the about
796 * dialog and must not be modified.
800 G_CONST_RETURN gchar *
801 gtk_about_dialog_get_license (GtkAboutDialog *about)
803 GtkAboutDialogPrivate *priv;
805 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
807 priv = (GtkAboutDialogPrivate *)about->private_data;
809 return priv->license;
813 * gtk_about_dialog_set_license:
814 * @about: a #GtkAboutDialog
815 * @license: the license information or %NULL
817 * Sets the license information to be displayed in the secondary
818 * license dialog. If @license is %NULL, the license button is
824 gtk_about_dialog_set_license (GtkAboutDialog *about,
825 const gchar *license)
827 GtkAboutDialogPrivate *priv;
830 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
832 priv = (GtkAboutDialogPrivate *)about->private_data;
837 priv->license = g_strdup (license);
838 gtk_widget_show (priv->license_button);
842 priv->license = NULL;
843 gtk_widget_hide (priv->license_button);
847 g_object_notify (G_OBJECT (about), "license");
851 * gtk_about_dialog_get_website:
852 * @about: a #GtkAboutDialog
854 * Returns the website URL.
856 * Return value: The website URL. The string is owned by the about
857 * dialog and must not be modified.
861 G_CONST_RETURN gchar *
862 gtk_about_dialog_get_website (GtkAboutDialog *about)
864 GtkAboutDialogPrivate *priv;
866 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
868 priv = (GtkAboutDialogPrivate *)about->private_data;
870 return priv->website;
874 * gtk_about_dialog_set_website:
875 * @about: a #GtkAboutDialog
876 * @website: a URL string starting with "http://"
878 * Sets the URL to use for the website link.
883 gtk_about_dialog_set_website (GtkAboutDialog *about,
884 const gchar *website)
886 GtkAboutDialogPrivate *priv;
889 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
891 priv = (GtkAboutDialogPrivate *)about->private_data;
896 priv->website = g_strdup (website);
897 if (activate_url_hook != NULL)
899 g_object_set_data_full (G_OBJECT (priv->website_button),
900 "url", g_strdup (website), g_free);
901 if (priv->website_label == NULL)
902 gtk_about_dialog_set_website_label (about, website);
906 GtkWidget *hbox = priv->website_button->parent;
907 gtk_widget_destroy (priv->website_button);
908 priv->website_button = gtk_label_new (website);
909 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
910 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
911 gtk_widget_show (priv->website_button);
916 priv->website = NULL;
917 g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
921 g_object_notify (G_OBJECT (about), "website");
925 * gtk_about_dialog_get_website_label:
926 * @about: a #GtkAboutDialog
928 * Returns the label used for the website link.
930 * Return value: The label used for the website link. The string is owned by the about
931 * dialog and must not be modified.
935 G_CONST_RETURN gchar *
936 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
938 GtkAboutDialogPrivate *priv;
940 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
942 priv = (GtkAboutDialogPrivate *)about->private_data;
944 return priv->website_label;
948 * gtk_about_dialog_set_website_label:
949 * @about: a #GtkAboutDialog
950 * @website_label: the label used for the website link
952 * Sets the label to be used for the website link.
953 * It defaults to the website URL.
958 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
959 const gchar *website_label)
961 GtkAboutDialogPrivate *priv;
964 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
966 priv = (GtkAboutDialogPrivate *)about->private_data;
968 tmp = priv->website_label;
969 if (activate_url_hook != NULL)
971 if (website_label != NULL)
973 priv->website_label = g_strdup (website_label);
974 set_link_button_text (GTK_WIDGET (about),
975 priv->website_button,
976 priv->website_label);
977 gtk_widget_show (priv->website_button);
981 priv->website_label = NULL;
982 gtk_widget_hide (priv->website_button);
987 g_object_notify (G_OBJECT (about), "website_label");
991 * gtk_about_dialog_get_authors:
992 * @about: a #GtkAboutDialog
994 * Returns the string which are displayed in the authors tab
995 * of the secondary credits dialog.
997 * Return value: A %NULL-terminated string array containing
998 * the authors. The array is owned by the about dialog
999 * and must not be modified.
1004 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1006 GtkAboutDialogPrivate *priv;
1008 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1010 priv = (GtkAboutDialogPrivate *)about->private_data;
1012 return priv->authors;
1016 * gtk_about_dialog_set_authors:
1017 * @about: a #GtkAboutDialog
1018 * @authors: a %NULL-terminated array of strings
1020 * Sets the strings which are displayed in the authors tab
1021 * of the secondary credits dialog.
1026 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1029 GtkAboutDialogPrivate *priv;
1032 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1034 priv = (GtkAboutDialogPrivate *)about->private_data;
1036 tmp = priv->authors;
1037 priv->authors = g_strdupv (authors);
1040 if (priv->authors != NULL)
1041 gtk_widget_show (priv->credits_button);
1043 g_object_notify (G_OBJECT (about), "authors");
1047 * gtk_about_dialog_get_documenters:
1048 * @about: a #GtkAboutDialog
1050 * Returns the string which are displayed in the documenters
1051 * tab of the secondary credits dialog.
1053 * Return value: A %NULL-terminated string array containing
1054 * the documenters. The array is owned by the about dialog
1055 * and must not be modified.
1060 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1062 GtkAboutDialogPrivate *priv;
1064 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1066 priv = (GtkAboutDialogPrivate *)about->private_data;
1068 return priv->documenters;
1072 * gtk_about_dialog_set_documenters:
1073 * @about: a #GtkAboutDialog
1074 * @documenters: a %NULL-terminated array of strings
1076 * Sets the strings which are displayed in the documenters tab
1077 * of the secondary credits dialog.
1082 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1083 gchar **documenters)
1085 GtkAboutDialogPrivate *priv;
1088 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1090 priv = (GtkAboutDialogPrivate *)about->private_data;
1092 tmp = priv->documenters;
1093 priv->documenters = g_strdupv (documenters);
1096 if (priv->documenters != NULL)
1097 gtk_widget_show (priv->credits_button);
1099 g_object_notify (G_OBJECT (about), "documenters");
1103 * gtk_about_dialog_get_artists:
1104 * @about: a #GtkAboutDialog
1106 * Returns the string which are displayed in the artists tab
1107 * of the secondary credits dialog.
1109 * Return value: A %NULL-terminated string array containing
1110 * the artists. The array is owned by the about dialog
1111 * and must not be modified.
1116 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1118 GtkAboutDialogPrivate *priv;
1120 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1122 priv = (GtkAboutDialogPrivate *)about->private_data;
1124 return priv->artists;
1128 * gtk_about_dialog_set_artists:
1129 * @about: a #GtkAboutDialog
1130 * @artists: a %NULL-terminated array of strings
1132 * Sets the strings which are displayed in the artists tab
1133 * of the secondary credits dialog.
1138 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1141 GtkAboutDialogPrivate *priv;
1144 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1146 priv = (GtkAboutDialogPrivate *)about->private_data;
1148 tmp = priv->artists;
1149 priv->artists = g_strdupv (artists);
1152 if (priv->artists != NULL)
1153 gtk_widget_show (priv->credits_button);
1155 g_object_notify (G_OBJECT (about), "artists");
1159 * gtk_about_dialog_get_translator_credits:
1160 * @about: a #GtkAboutDialog
1162 * Returns the translator credits string which is displayed
1163 * in the translators tab of the secondary credits dialog.
1165 * Return value: The translator credits string. The string is
1166 * owned by the about dialog and must not be modified.
1170 G_CONST_RETURN gchar *
1171 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1173 GtkAboutDialogPrivate *priv;
1175 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1177 priv = (GtkAboutDialogPrivate *)about->private_data;
1179 return priv->translator_credits;
1183 * gtk_about_dialog_set_translator_credits:
1184 * @about: a #GtkAboutDialog
1185 * @translator_credits: the translator credits
1187 * Sets the translator credits string which is displayed in
1188 * the translators tab of the secondary credits dialog.
1190 * The intended use for this string is to display the translator
1191 * of the language which is currently used in the user interface.
1192 * Using gettext(), a simple way to achieve that is to mark the
1193 * string for translation:
1194 * <informalexample><programlisting>
1195 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1196 * </programlisting></informalexample>
1197 * It is a good idea to use the customary msgid "translator-credits" for this
1198 * purpose, since translators will already know the purpose of that msgid, and
1199 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1205 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1206 const gchar *translator_credits)
1208 GtkAboutDialogPrivate *priv;
1211 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1213 priv = (GtkAboutDialogPrivate *)about->private_data;
1215 tmp = priv->translator_credits;
1216 priv->translator_credits = g_strdup (translator_credits);
1219 if (priv->translator_credits != NULL)
1220 gtk_widget_show (priv->credits_button);
1222 g_object_notify (G_OBJECT (about), "translator-credits");
1226 * gtk_about_dialog_get_logo:
1227 * @about: a #GtkAboutDialog
1229 * Returns the pixbuf displayed as logo in the about dialog.
1231 * Return value: the pixbuf displayed as logo. The pixbuf is
1232 * owned by the about dialog. If you want to keep a reference
1233 * to it, you have to call g_object_ref() on it.
1238 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1240 GtkAboutDialogPrivate *priv;
1242 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1244 priv = (GtkAboutDialogPrivate *)about->private_data;
1246 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1247 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1253 icon_set_new_from_pixbufs (GList *pixbufs)
1255 GtkIconSet *icon_set = gtk_icon_set_new ();
1257 for (; pixbufs; pixbufs = pixbufs->next)
1259 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1261 GtkIconSource *icon_source = gtk_icon_source_new ();
1262 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1263 gtk_icon_set_add_source (icon_set, icon_source);
1264 gtk_icon_source_free (icon_source);
1271 * gtk_about_dialog_set_logo:
1272 * @about: a #GtkAboutDialog
1273 * @logo: a #GdkPixbuf, or %NULL
1275 * Sets the pixbuf to be displayed as logo in
1276 * the about dialog. If it is %NULL, the default
1277 * window icon set with gtk_window_set_default_icon ()
1283 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1286 GtkAboutDialogPrivate *priv;
1288 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1290 priv = (GtkAboutDialogPrivate *)about->private_data;
1292 g_object_freeze_notify (G_OBJECT (about));
1294 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1295 g_object_notify (G_OBJECT (about), "logo_icon_name");
1298 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1301 GList *pixbufs = gtk_window_get_default_icon_list ();
1303 if (pixbufs != NULL)
1305 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1307 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1308 icon_set, GTK_ICON_SIZE_DIALOG);
1310 gtk_icon_set_unref (icon_set);
1311 g_list_free (pixbufs);
1315 g_object_notify (G_OBJECT (about), "logo");
1317 g_object_thaw_notify (G_OBJECT (about));
1321 * gtk_about_dialog_get_logo_icon_name:
1322 * @about: a #GtkAboutDialog
1324 * Returns the icon name displayed as logo in the about dialog.
1326 * Return value: the icon name displayed as logo. The string is
1327 * owned by the about dialog. If you want to keep a reference
1328 * to it, you have to call g_strdup() on it.
1332 G_CONST_RETURN gchar *
1333 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1335 GtkAboutDialogPrivate *priv;
1336 const gchar *icon_name;
1338 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1340 priv = (GtkAboutDialogPrivate *)about->private_data;
1342 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1343 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1349 * gtk_about_dialog_set_logo_icon_name:
1350 * @about: a #GtkAboutDialog
1351 * @icon_name: an icon name, or %NULL
1353 * Sets the pixbuf to be displayed as logo in
1354 * the about dialog. If it is %NULL, the default
1355 * window icon set with gtk_window_set_default_icon()
1361 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1362 const gchar *icon_name)
1364 GtkAboutDialogPrivate *priv;
1366 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1368 priv = (GtkAboutDialogPrivate *)about->private_data;
1370 g_object_freeze_notify (G_OBJECT (about));
1372 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1373 g_object_notify (G_OBJECT (about), "logo");
1375 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1376 GTK_ICON_SIZE_DIALOG);
1377 g_object_notify (G_OBJECT (about), "logo_icon_name");
1379 g_object_thaw_notify (G_OBJECT (about));
1383 activate_url (GtkWidget *widget,
1386 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1387 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1389 if (activate_url_hook != NULL)
1390 (* activate_url_hook) (about, url, activate_url_hook_data);
1394 set_link_button_text (GtkWidget *about,
1400 GdkColor *style_link_color;
1401 GdkColor link_color = { 0, 0, 0, 0xffff };
1403 gtk_widget_ensure_style (about);
1404 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1405 if (style_link_color)
1407 link_color = *style_link_color;
1408 gdk_color_free (style_link_color);
1411 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1412 link_color.red, link_color.green, link_color.blue, text);
1414 label = gtk_bin_get_child (GTK_BIN (button));
1415 gtk_label_set_markup (GTK_LABEL (label), link);
1420 create_link_button (GtkWidget *about,
1428 button = gtk_button_new_with_label ("");
1429 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1430 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1432 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1433 set_link_button_text (about, button, text);
1435 g_signal_connect (G_OBJECT (button), "clicked", callback, data);
1441 follow_if_link (GtkAboutDialog *about,
1444 GSList *tags = NULL, *tagp = NULL;
1446 tags = gtk_text_iter_get_tags (iter);
1447 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1449 GtkTextTag *tag = tagp->data;
1450 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1451 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1453 if (email != NULL && activate_email_hook != NULL)
1455 (* activate_email_hook) (about, email, activate_email_hook_data);
1459 if (url != NULL && activate_url_hook != NULL)
1461 (* activate_url_hook) (about, url, activate_url_hook_data);
1467 g_slist_free (tags);
1471 credits_key_press_event (GtkWidget *text_view,
1473 GtkAboutDialog *about)
1476 GtkTextBuffer *buffer;
1478 switch (event->keyval)
1482 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1483 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1484 gtk_text_buffer_get_insert (buffer));
1485 follow_if_link (about, &iter);
1496 credits_event_after (GtkWidget *text_view,
1498 GtkAboutDialog *about)
1500 GtkTextIter start, end, iter;
1501 GtkTextBuffer *buffer;
1502 GdkEventButton *button_event;
1505 if (event->type != GDK_BUTTON_RELEASE)
1508 button_event = (GdkEventButton *)event;
1510 if (button_event->button != 1)
1513 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1515 /* we shouldn't follow a link if the user has selected something */
1516 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1517 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1520 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1521 GTK_TEXT_WINDOW_WIDGET,
1522 button_event->x, button_event->y, &x, &y);
1524 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1526 follow_if_link (about, &iter);
1532 set_cursor_if_appropriate (GtkAboutDialog *about,
1533 GtkTextView *text_view,
1537 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1538 GSList *tags = NULL, *tagp = NULL;
1539 GtkTextBuffer *buffer;
1541 gboolean hovering_over_link = FALSE;
1543 buffer = gtk_text_view_get_buffer (text_view);
1545 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1547 tags = gtk_text_iter_get_tags (&iter);
1548 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1550 GtkTextTag *tag = tagp->data;
1551 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1552 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1554 if (email != NULL || url != NULL)
1556 hovering_over_link = TRUE;
1561 if (hovering_over_link != priv->hovering_over_link)
1563 priv->hovering_over_link = hovering_over_link;
1565 if (hovering_over_link)
1566 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1568 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1572 g_slist_free (tags);
1576 credits_motion_notify_event (GtkWidget *text_view,
1577 GdkEventMotion *event,
1578 GtkAboutDialog *about)
1582 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1583 GTK_TEXT_WINDOW_WIDGET,
1584 event->x, event->y, &x, &y);
1586 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1588 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1595 credits_visibility_notify_event (GtkWidget *text_view,
1596 GdkEventVisibility *event,
1597 GtkAboutDialog *about)
1599 gint wx, wy, bx, by;
1601 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1603 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1604 GTK_TEXT_WINDOW_WIDGET,
1607 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1613 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1615 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1616 &widget->style->bg[GTK_STATE_NORMAL]);
1620 add_credits_page (GtkAboutDialog *about,
1621 GtkWidget *notebook,
1626 gchar *q0, *q1, *q2, *r1, *r2;
1627 GtkWidget *sw, *view;
1628 GtkTextBuffer *buffer;
1629 gboolean linkify_email, linkify_urls;
1630 GdkColor *style_link_color;
1631 GdkColor link_color = { 0, 0, 0, 0xffff };
1633 linkify_email = (activate_email_hook != NULL);
1634 linkify_urls = (activate_url_hook != NULL);
1636 gtk_widget_ensure_style (GTK_WIDGET (about));
1637 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1638 if (style_link_color)
1640 link_color = *style_link_color;
1641 gdk_color_free (style_link_color);
1644 view = gtk_text_view_new ();
1645 g_signal_connect (about, "style_set",
1646 G_CALLBACK (text_view_style_set), view);
1648 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1649 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1650 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1651 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1652 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1654 g_signal_connect (G_OBJECT (view), "key-press-event",
1655 G_CALLBACK (credits_key_press_event), about);
1656 g_signal_connect (G_OBJECT (view), "event-after",
1657 G_CALLBACK (credits_event_after), about);
1658 g_signal_connect (G_OBJECT (view), "motion-notify-event",
1659 G_CALLBACK (credits_motion_notify_event), about);
1660 g_signal_connect (G_OBJECT (view), "visibility-notify-event",
1661 G_CALLBACK (credits_visibility_notify_event), about);
1663 sw = gtk_scrolled_window_new (NULL, NULL);
1664 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1665 GTK_POLICY_AUTOMATIC,
1666 GTK_POLICY_AUTOMATIC);
1667 gtk_container_add (GTK_CONTAINER (sw), view);
1669 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1670 sw, gtk_label_new (title));
1674 gtk_widget_hide (view);
1678 gtk_widget_show (view);
1680 for (p = people; *p; p++)
1685 q1 = linkify_email ? strchr (q0, '<') : NULL;
1686 q2 = q1 ? strchr (q1, '>') : NULL;
1687 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1690 r2 = strpbrk (r1, " \n\t");
1692 r2 = strchr (r1, '\0');
1697 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1710 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1711 gtk_text_buffer_get_end_iter (buffer, &end);
1719 link_type = "email";
1724 link = g_strndup (q1, q2 - q1);
1725 tag = gtk_text_buffer_create_tag (buffer, NULL,
1726 "foreground_gdk", &link_color,
1727 "underline", PANGO_UNDERLINE_SINGLE,
1729 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1730 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1736 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1742 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1747 display_credits_dialog (GtkWidget *button,
1750 GtkAboutDialog *about = (GtkAboutDialog *)data;
1751 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1752 GtkWidget *dialog, *notebook;
1754 if (priv->credits_dialog != NULL)
1756 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1760 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1762 GTK_DIALOG_DESTROY_WITH_PARENT,
1763 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1765 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1767 priv->credits_dialog = dialog;
1768 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1769 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1771 gtk_window_set_modal (GTK_WINDOW (dialog),
1772 gtk_window_get_modal (GTK_WINDOW (about)));
1774 g_signal_connect (dialog, "response",
1775 G_CALLBACK (gtk_widget_destroy), dialog);
1776 g_signal_connect (dialog, "destroy",
1777 G_CALLBACK (gtk_widget_destroyed),
1778 &(priv->credits_dialog));
1780 notebook = gtk_notebook_new ();
1781 gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
1782 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1784 if (priv->authors != NULL)
1785 add_credits_page (about, notebook, _("Written by"), priv->authors);
1787 if (priv->documenters != NULL)
1788 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1790 /* Don't show an untranslated gettext msgid */
1791 if (priv->translator_credits != NULL &&
1792 strcmp (priv->translator_credits, "translator_credits") &&
1793 strcmp (priv->translator_credits, "translator-credits"))
1795 gchar *translators[2];
1797 translators[0] = priv->translator_credits;
1798 translators[1] = NULL;
1800 add_credits_page (about, notebook, _("Translated by"), translators);
1803 if (priv->artists != NULL)
1804 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1806 gtk_widget_show_all (dialog);
1810 display_license_dialog (GtkWidget *button,
1813 GtkAboutDialog *about = (GtkAboutDialog *)data;
1814 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1815 GtkWidget *dialog, *view, *sw;
1817 if (priv->license_dialog != NULL)
1819 gtk_window_present (GTK_WINDOW (priv->license_dialog));
1823 dialog = gtk_dialog_new_with_buttons (_("License"),
1825 GTK_DIALOG_DESTROY_WITH_PARENT,
1826 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1828 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1829 priv->license_dialog = dialog;
1830 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
1831 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1833 gtk_window_set_modal (GTK_WINDOW (dialog),
1834 gtk_window_get_modal (GTK_WINDOW (about)));
1836 g_signal_connect (dialog, "response",
1837 G_CALLBACK (gtk_widget_destroy), dialog);
1838 g_signal_connect (dialog, "destroy",
1839 G_CALLBACK (gtk_widget_destroyed),
1840 &(priv->license_dialog));
1842 sw = gtk_scrolled_window_new (NULL, NULL);
1843 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1845 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1846 GTK_POLICY_AUTOMATIC,
1847 GTK_POLICY_AUTOMATIC);
1848 gtk_container_set_border_width (GTK_CONTAINER (sw), 8);
1849 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
1851 view = gtk_text_view_new ();
1852 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
1855 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1856 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1857 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1858 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1860 gtk_container_add (GTK_CONTAINER (sw), view);
1862 gtk_widget_show_all (dialog);
1866 close_cb (GtkAboutDialog *about)
1868 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1870 if (priv->license_dialog != NULL)
1872 gtk_widget_destroy (priv->license_dialog);
1873 priv->license_dialog = NULL;
1876 if (priv->credits_dialog != NULL)
1878 gtk_widget_destroy (priv->credits_dialog);
1879 priv->credits_dialog = NULL;
1882 gtk_widget_hide (GTK_WIDGET (about));
1887 * gtk_about_dialog_new:
1889 * Creates a new #GtkAboutDialog.
1891 * Returns: a newly created #GtkAboutDialog
1896 gtk_about_dialog_new (void)
1898 GtkAboutDialog *dialog = GTK_ABOUT_DIALOG (g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL));
1900 /* force defaults */
1901 gtk_about_dialog_set_name (dialog, NULL);
1902 gtk_about_dialog_set_logo (dialog, NULL);
1904 /* Close dialog on user response */
1905 g_signal_connect (G_OBJECT (dialog),
1907 G_CALLBACK (close_cb),
1910 return GTK_WIDGET (dialog);
1914 * gtk_about_dialog_set_email_hook:
1915 * @func: a function to call when an email link is activated.
1916 * @data: data to pass to @func
1917 * @destroy: #GDestroyNotify for @data
1919 * Installs a global function to be called whenever the user activates an
1920 * email link in an about dialog.
1922 * Return value: the previous email hook.
1926 GtkAboutDialogActivateLinkFunc
1927 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
1929 GDestroyNotify destroy)
1931 GtkAboutDialogActivateLinkFunc old;
1933 if (activate_email_hook_destroy != NULL)
1934 (* activate_email_hook_destroy) (activate_url_hook_data);
1936 old = activate_email_hook;
1938 activate_email_hook = func;
1939 activate_email_hook_data = data;
1940 activate_email_hook_destroy = destroy;
1946 * gtk_about_dialog_set_url_hook:
1947 * @func: a function to call when a URL link is activated.
1948 * @data: data to pass to @func
1949 * @destroy: #GDestroyNotify for @data
1951 * Installs a global function to be called whenever the user activates a
1952 * URL link in an about dialog.
1954 * Return value: the previous URL hook.
1958 GtkAboutDialogActivateLinkFunc
1959 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
1961 GDestroyNotify destroy)
1963 GtkAboutDialogActivateLinkFunc old;
1965 if (activate_url_hook_destroy != NULL)
1966 (* activate_url_hook_destroy) (activate_email_hook_data);
1968 old = activate_url_hook;
1970 activate_url_hook = func;
1971 activate_url_hook_data = data;
1972 activate_url_hook_destroy = destroy;
1978 * gtk_show_about_dialog:
1979 * @parent: transient parent, or %NULL for none
1980 * @first_property_name: the name of the first property
1981 * @Varargs: value of first property, followed by more properties, %NULL-terminated
1983 * This is a convenience function for showing an application's about box.
1988 gtk_show_about_dialog (GtkWindow *parent,
1989 const gchar *first_property_name,
1992 static GtkWidget *global_about_dialog = NULL;
1993 GtkWidget *dialog = NULL;
1997 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
1999 dialog = global_about_dialog;
2003 dialog = gtk_about_dialog_new ();
2005 g_object_ref (G_OBJECT (dialog));
2006 gtk_object_sink (GTK_OBJECT (dialog));
2008 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2010 va_start (var_args, first_property_name);
2011 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2016 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2017 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2018 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
2019 dialog, g_object_unref);
2022 global_about_dialog = dialog;
2026 gtk_window_present (GTK_WINDOW (dialog));