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,
108 static void gtk_about_dialog_finalize (GObject *object);
109 static void gtk_about_dialog_get_property (GObject *object,
113 static void gtk_about_dialog_set_property (GObject *object,
117 static void update_name_version (GtkAboutDialog *about);
118 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
119 static void activate_url (GtkWidget *widget,
121 static void set_link_button_text (GtkWidget *about,
124 static GtkWidget * create_link_button (GtkWidget *about,
129 static void follow_if_link (GtkAboutDialog *about,
131 static void set_cursor_if_appropriate (GtkAboutDialog *about,
132 GtkTextView *text_view,
135 static void add_credits_page (GtkAboutDialog *about,
139 static gboolean credits_key_press_event (GtkWidget *text_view,
141 GtkAboutDialog *about);
142 static gboolean credits_event_after (GtkWidget *text_view,
144 GtkAboutDialog *about);
145 static gboolean credits_motion_notify_event (GtkWidget *text_view,
146 GdkEventMotion *event,
147 GtkAboutDialog *about);
148 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
149 GdkEventVisibility *event,
150 GtkAboutDialog *about);
151 static void display_credits_dialog (GtkWidget *button,
153 static void display_license_dialog (GtkWidget *button,
157 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
158 static gpointer activate_email_hook_data = NULL;
159 static GDestroyNotify activate_email_hook_destroy = NULL;
161 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
162 static gpointer activate_url_hook_data = NULL;
163 static GDestroyNotify activate_url_hook_destroy = NULL;
165 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
168 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
170 GObjectClass *object_class;
171 GtkWidgetClass *widget_class;
172 GtkDialogClass *dialog_class;
174 object_class = (GObjectClass *)klass;
175 widget_class = (GtkWidgetClass *)klass;
176 dialog_class = (GtkDialogClass *)klass;
178 object_class->set_property = gtk_about_dialog_set_property;
179 object_class->get_property = gtk_about_dialog_get_property;
181 object_class->finalize = gtk_about_dialog_finalize;
183 g_object_class_install_property (object_class,
185 g_param_spec_string ("name",
187 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
191 g_object_class_install_property (object_class,
193 g_param_spec_string ("version",
194 P_("Program version"),
195 P_("The version of the program"),
198 g_object_class_install_property (object_class,
200 g_param_spec_string ("copyright",
201 P_("Copyright string"),
202 P_("Copyright information for the program"),
206 g_object_class_install_property (object_class,
208 g_param_spec_string ("comments",
209 P_("Comments string"),
210 P_("Comments about the program"),
213 g_object_class_install_property (object_class,
215 g_param_spec_string ("license",
217 _("The license of the program"),
221 g_object_class_install_property (object_class,
223 g_param_spec_string ("website",
225 P_("The URL for the link to the website of the program"),
229 g_object_class_install_property (object_class,
231 g_param_spec_string ("website_label",
233 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
237 g_object_class_install_property (object_class,
239 g_param_spec_boxed ("authors",
241 P_("List of authors of the programs"),
244 g_object_class_install_property (object_class,
246 g_param_spec_boxed ("documenters",
248 P_("List of people documenting the program"),
252 g_object_class_install_property (object_class,
254 g_param_spec_boxed ("artists",
256 P_("List of people who have contributed artwork to the program"),
260 g_object_class_install_property (object_class,
261 PROP_TRANSLATOR_CREDITS,
262 g_param_spec_string ("translator_credits",
263 P_("Translator credits"),
264 P_("Credits to the translators. This string should be marked as translatable"),
268 g_object_class_install_property (object_class,
270 g_param_spec_object ("logo",
272 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
276 /* Style properties */
277 gtk_widget_class_install_style_property (widget_class,
278 g_param_spec_boxed ("link_color",
280 P_("Color of hyperlinks"),
284 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
288 gtk_about_dialog_init (GtkAboutDialog *about)
290 GtkAboutDialogPrivate *priv;
291 GtkWidget *vbox, *hbox, *button;
294 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
295 about->private_data = priv;
298 priv->version = NULL;
299 priv->copyright = NULL;
300 priv->comments = NULL;
301 priv->website = NULL;
302 priv->website_label = NULL;
303 priv->translator_credits = NULL;
304 priv->authors = NULL;
305 priv->documenters = NULL;
306 priv->artists = NULL;
308 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
309 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
310 priv->hovering_over_link = FALSE;
312 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
315 gtk_widget_push_composite_child ();
316 vbox = gtk_vbox_new (FALSE, 8);
317 gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
319 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
321 priv->logo_image = gtk_image_new ();
322 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
324 priv->name_label = gtk_label_new (NULL);
325 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
326 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
327 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
329 priv->comments_label = gtk_label_new (NULL);
330 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
331 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
332 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
333 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
335 priv->copyright_label = gtk_label_new (NULL);
336 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
337 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
338 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
340 button = create_link_button (GTK_WIDGET (about), "", "",
341 G_CALLBACK (activate_url), about);
343 hbox = gtk_hbox_new (TRUE, 0);
344 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
345 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
346 priv->website_button = button;
348 gtk_widget_show (vbox);
349 gtk_widget_show (priv->logo_image);
350 gtk_widget_show (priv->name_label);
351 gtk_widget_show (hbox);
353 /* Add the OK button */
354 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
355 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CLOSE);
357 /* Add the credits button */
358 button = gtk_button_new_from_stock (_("_Credits"));
359 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
360 button, FALSE, TRUE, 0);
361 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
362 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
363 priv->credits_button = button;
364 priv->credits_dialog = NULL;
366 /* Add the license button */
367 button = gtk_button_new_from_stock (_("_License"));
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_license_dialog), about);
372 priv->license_button = button;
373 priv->license_dialog = NULL;
375 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
377 gtk_widget_pop_composite_child ();
381 gtk_about_dialog_finalize (GObject *object)
383 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
384 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
387 g_free (priv->version);
388 g_free (priv->copyright);
389 g_free (priv->comments);
390 g_free (priv->license);
391 g_free (priv->website);
392 g_free (priv->website_label);
393 g_free (priv->translator_credits);
395 g_strfreev (priv->authors);
396 g_strfreev (priv->documenters);
397 g_strfreev (priv->artists);
400 about->private_data = NULL;
402 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
406 gtk_about_dialog_set_property (GObject *object,
411 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
416 gtk_about_dialog_set_name (about, g_value_get_string (value));
419 gtk_about_dialog_set_version (about, g_value_get_string (value));
422 gtk_about_dialog_set_comments (about, g_value_get_string (value));
425 gtk_about_dialog_set_website (about, g_value_get_string (value));
427 case PROP_WEBSITE_LABEL:
428 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
431 gtk_about_dialog_set_license (about, g_value_get_string (value));
434 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
437 gtk_about_dialog_set_logo (about, g_value_get_object (value));
440 gtk_about_dialog_set_authors (about, (gchar**)g_value_get_boxed (value));
442 case PROP_DOCUMENTERS:
443 gtk_about_dialog_set_documenters (about, (gchar**)g_value_get_boxed (value));
446 gtk_about_dialog_set_artists (about, (gchar**)g_value_get_boxed (value));
448 case PROP_TRANSLATOR_CREDITS:
449 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
452 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
458 gtk_about_dialog_get_property (GObject *object,
463 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
464 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
469 g_value_set_string (value, priv->name);
472 g_value_set_string (value, priv->version);
475 g_value_set_string (value, priv->copyright);
478 g_value_set_string (value, priv->comments);
481 g_value_set_string (value, priv->website);
483 case PROP_WEBSITE_LABEL:
484 g_value_set_string (value, priv->website_label);
487 g_value_set_string (value, priv->license);
489 case PROP_TRANSLATOR_CREDITS:
490 g_value_set_string (value, priv->translator_credits);
493 g_value_set_boxed (value, priv->authors);
495 case PROP_DOCUMENTERS:
496 g_value_set_boxed (value, priv->documenters);
499 g_value_set_boxed (value, priv->artists);
502 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
505 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
511 * gtk_about_dialog_get_name:
512 * @about: a #GtkAboutDialog
514 * Returns the program name displayed in the about dialog.
516 * Return value: The program name. The string is owned by the about
517 * dialog and must not be modified.
521 G_CONST_RETURN gchar *
522 gtk_about_dialog_get_name (GtkAboutDialog *about)
524 GtkAboutDialogPrivate *priv;
526 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
528 priv = (GtkAboutDialogPrivate *)about->private_data;
534 update_name_version (GtkAboutDialog *about)
536 GtkAboutDialogPrivate *priv;
537 gchar *title_string, *name_string;
539 priv = (GtkAboutDialogPrivate *)about->private_data;
541 title_string = g_strdup_printf (_("About %s"), priv->name);
542 gtk_window_set_title (GTK_WINDOW (about), title_string);
543 g_free (title_string);
545 if (priv->version != NULL)
546 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
547 priv->name, priv->version);
549 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
552 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
554 g_free (name_string);
558 * gtk_about_dialog_set_name:
559 * @about: a #GtkAboutDialog
560 * @name: the program name
562 * Sets the name to display in the about dialog.
563 * If this is not set, it defaults to g_get_application_name().
568 gtk_about_dialog_set_name (GtkAboutDialog *about,
571 GtkAboutDialogPrivate *priv;
574 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
576 priv = (GtkAboutDialogPrivate *)about->private_data;
578 priv->name = g_strdup (name ? name : g_get_application_name ());
581 update_name_version (about);
583 g_object_notify (G_OBJECT (about), "name");
587 * gtk_about_dialog_get_version:
588 * @about: a #GtkAboutDialog
590 * Returns the version string.
592 * Return value: The version string. The string is owned by the about
593 * dialog and must not be modified.
597 G_CONST_RETURN gchar *
598 gtk_about_dialog_get_version (GtkAboutDialog *about)
600 GtkAboutDialogPrivate *priv;
602 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
604 priv = (GtkAboutDialogPrivate *)about->private_data;
606 return priv->version;
610 * gtk_about_dialog_set_version:
611 * @about: a #GtkAboutDialog
612 * @version: the version string
614 * Sets the version string to display in the about dialog.
619 gtk_about_dialog_set_version (GtkAboutDialog *about,
620 const gchar *version)
622 GtkAboutDialogPrivate *priv;
625 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
627 priv = (GtkAboutDialogPrivate *)about->private_data;
630 priv->version = version ? g_strdup (version) : NULL;
633 update_name_version (about);
635 g_object_notify (G_OBJECT (about), "version");
639 * gtk_about_dialog_get_copyright:
640 * @about: a #GtkAboutDialog
642 * Returns the copyright string.
644 * Return value: The copyright string. The string is owned by the about
645 * dialog and must not be modified.
649 G_CONST_RETURN gchar *
650 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
652 GtkAboutDialogPrivate *priv;
654 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
656 priv = (GtkAboutDialogPrivate *)about->private_data;
658 return priv->copyright;
662 * gtk_about_dialog_set_copyright:
663 * @about: a #GtkAboutDialog
664 * @copyright: the copyright string
666 * Sets the copyright string to display in the about dialog.
667 * This should be a short string of one or two lines.
672 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
673 const gchar *copyright)
675 GtkAboutDialogPrivate *priv;
676 gchar *copyright_string, *tmp;
678 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
680 priv = (GtkAboutDialogPrivate *)about->private_data;
682 tmp = priv->copyright;
683 priv->copyright = copyright ? g_strdup (copyright) : NULL;
686 if (priv->copyright != NULL)
688 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
690 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
691 g_free (copyright_string);
693 gtk_widget_show (priv->copyright_label);
696 gtk_widget_hide (priv->copyright_label);
698 g_object_notify (G_OBJECT (about), "copyright");
702 * gtk_about_dialog_get_comments:
703 * @about: a #GtkAboutDialog
705 * Returns the comments string.
707 * Return value: The comments. The string is owned by the about
708 * dialog and must not be modified.
712 G_CONST_RETURN gchar *
713 gtk_about_dialog_get_comments (GtkAboutDialog *about)
715 GtkAboutDialogPrivate *priv;
717 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
719 priv = (GtkAboutDialogPrivate *)about->private_data;
721 return priv->comments;
725 * gtk_about_dialog_set_comments:
726 * @about: a #GtkAboutDialog
727 * @comments: a comments string
729 * Sets the comments string to display in the about
730 * dialog. This should be a short string of one or
736 gtk_about_dialog_set_comments (GtkAboutDialog *about,
737 const gchar *comments)
739 GtkAboutDialogPrivate *priv;
742 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
744 priv = (GtkAboutDialogPrivate *)about->private_data;
746 tmp = priv->comments;
749 priv->comments = g_strdup (comments);
750 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
751 gtk_widget_show (priv->comments_label);
755 priv->comments = NULL;
756 gtk_widget_hide (priv->comments_label);
760 g_object_notify (G_OBJECT (about), "comments");
764 * gtk_about_dialog_get_license:
765 * @about: a #GtkAboutDialog
767 * Returns the license information.
769 * Return value: The license information. The string is owned by the about
770 * dialog and must not be modified.
774 G_CONST_RETURN gchar *
775 gtk_about_dialog_get_license (GtkAboutDialog *about)
777 GtkAboutDialogPrivate *priv;
779 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
781 priv = (GtkAboutDialogPrivate *)about->private_data;
783 return priv->license;
787 * gtk_about_dialog_set_license:
788 * @about: a #GtkAboutDialog
789 * @license: the license information or %NULL
791 * Sets the license information to be displayed in the secondary
792 * license dialog. If @license is %NULL, the license button is
798 gtk_about_dialog_set_license (GtkAboutDialog *about,
799 const gchar *license)
801 GtkAboutDialogPrivate *priv;
804 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
806 priv = (GtkAboutDialogPrivate *)about->private_data;
811 priv->license = g_strdup (license);
812 gtk_widget_show (priv->license_button);
816 priv->license = NULL;
817 gtk_widget_hide (priv->license_button);
821 g_object_notify (G_OBJECT (about), "license");
825 * gtk_about_dialog_get_website:
826 * @about: a #GtkAboutDialog
828 * Returns the website URL.
830 * Return value: The website URL. The string is owned by the about
831 * dialog and must not be modified.
835 G_CONST_RETURN gchar *
836 gtk_about_dialog_get_website (GtkAboutDialog *about)
838 GtkAboutDialogPrivate *priv;
840 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
842 priv = (GtkAboutDialogPrivate *)about->private_data;
844 return priv->website;
848 * gtk_about_dialog_set_website:
849 * @about: a #GtkAboutDialog
850 * @website: a URL string starting with "http://"
852 * Sets the URL to use for the website link.
857 gtk_about_dialog_set_website (GtkAboutDialog *about,
858 const gchar *website)
860 GtkAboutDialogPrivate *priv;
863 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
865 priv = (GtkAboutDialogPrivate *)about->private_data;
870 priv->website = g_strdup (website);
871 if (activate_url_hook != NULL)
873 g_object_set_data_full (G_OBJECT (priv->website_button),
874 "url", g_strdup (website), g_free);
875 if (priv->website_label == NULL)
876 gtk_about_dialog_set_website_label (about, website);
880 GtkWidget *hbox = priv->website_button->parent;
881 gtk_widget_destroy (priv->website_button);
882 priv->website_button = gtk_label_new (website);
883 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
884 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
885 gtk_widget_show (priv->website_button);
890 priv->website = NULL;
891 g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
895 g_object_notify (G_OBJECT (about), "website");
899 * gtk_about_dialog_get_website_label:
900 * @about: a #GtkAboutDialog
902 * Returns the label used for the website link.
904 * Return value: The label used for the website link. The string is owned by the about
905 * dialog and must not be modified.
909 G_CONST_RETURN gchar *
910 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
912 GtkAboutDialogPrivate *priv;
914 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
916 priv = (GtkAboutDialogPrivate *)about->private_data;
918 return priv->website_label;
922 * gtk_about_dialog_set_website_label:
923 * @about: a #GtkAboutDialog
924 * @website_label: the label used for the website link
926 * Sets the label to be used for the website link.
927 * It defaults to the website URL.
932 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
933 const gchar *website_label)
935 GtkAboutDialogPrivate *priv;
938 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
940 priv = (GtkAboutDialogPrivate *)about->private_data;
942 tmp = priv->website_label;
943 if (activate_url_hook != NULL)
945 if (website_label != NULL)
947 priv->website_label = g_strdup (website_label);
948 set_link_button_text (GTK_WIDGET (about),
949 priv->website_button,
950 priv->website_label);
951 gtk_widget_show (priv->website_button);
955 priv->website_label = NULL;
956 gtk_widget_hide (priv->website_button);
961 g_object_notify (G_OBJECT (about), "website_label");
965 * gtk_about_dialog_get_authors:
966 * @about: a #GtkAboutDialog
968 * Returns the string which are displayed in the authors tab
969 * of the secondary credits dialog.
971 * Return value: A %NULL-terminated string array containing
972 * the authors. The array is owned by the about dialog
973 * and must not be modified.
978 gtk_about_dialog_get_authors (GtkAboutDialog *about)
980 GtkAboutDialogPrivate *priv;
982 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
984 priv = (GtkAboutDialogPrivate *)about->private_data;
986 return priv->authors;
990 * gtk_about_dialog_set_authors:
991 * @about: a #GtkAboutDialog
992 * @authors: a %NULL-terminated array of strings
994 * Sets the strings which are displayed in the authors tab
995 * of the secondary credits dialog.
1000 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1003 GtkAboutDialogPrivate *priv;
1006 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1008 priv = (GtkAboutDialogPrivate *)about->private_data;
1010 tmp = priv->authors;
1011 priv->authors = g_strdupv (authors);
1014 if (priv->authors != NULL)
1015 gtk_widget_show (priv->credits_button);
1017 g_object_notify (G_OBJECT (about), "authors");
1021 * gtk_about_dialog_get_documenters:
1022 * @about: a #GtkAboutDialog
1024 * Returns the string which are displayed in the documenters
1025 * tab of the secondary credits dialog.
1027 * Return value: A %NULL-terminated string array containing
1028 * the documenters. The array is owned by the about dialog
1029 * and must not be modified.
1034 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1036 GtkAboutDialogPrivate *priv;
1038 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1040 priv = (GtkAboutDialogPrivate *)about->private_data;
1042 return priv->documenters;
1046 * gtk_about_dialog_set_documenters:
1047 * @about: a #GtkAboutDialog
1048 * @documenters: a %NULL-terminated array of strings
1050 * Sets the strings which are displayed in the documenters tab
1051 * of the secondary credits dialog.
1056 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1057 gchar **documenters)
1059 GtkAboutDialogPrivate *priv;
1062 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1064 priv = (GtkAboutDialogPrivate *)about->private_data;
1066 tmp = priv->documenters;
1067 priv->documenters = g_strdupv (documenters);
1070 if (priv->documenters != NULL)
1071 gtk_widget_show (priv->credits_button);
1073 g_object_notify (G_OBJECT (about), "documenters");
1077 * gtk_about_dialog_get_artists:
1078 * @about: a #GtkAboutDialog
1080 * Returns the string which are displayed in the artists tab
1081 * of the secondary credits dialog.
1083 * Return value: A %NULL-terminated string array containing
1084 * the artists. The array is owned by the about dialog
1085 * and must not be modified.
1090 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1092 GtkAboutDialogPrivate *priv;
1094 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1096 priv = (GtkAboutDialogPrivate *)about->private_data;
1098 return priv->artists;
1102 * gtk_about_dialog_set_artists:
1103 * @about: a #GtkAboutDialog
1104 * @artists: a %NULL-terminated array of strings
1106 * Sets the strings which are displayed in the artists tab
1107 * of the secondary credits dialog.
1112 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1115 GtkAboutDialogPrivate *priv;
1118 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1120 priv = (GtkAboutDialogPrivate *)about->private_data;
1122 tmp = priv->artists;
1123 priv->artists = g_strdupv (artists);
1126 if (priv->artists != NULL)
1127 gtk_widget_show (priv->credits_button);
1129 g_object_notify (G_OBJECT (about), "artists");
1133 * gtk_about_dialog_get_translator_credits:
1134 * @about: a #GtkAboutDialog
1136 * Returns the translator credits string which is displayed
1137 * in the translators tab of the secondary credits dialog.
1139 * Return value: The translator credits string. The string is
1140 * owned by the about dialog and must not be modified.
1144 G_CONST_RETURN gchar *
1145 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1147 GtkAboutDialogPrivate *priv;
1149 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1151 priv = (GtkAboutDialogPrivate *)about->private_data;
1153 return priv->translator_credits;
1157 * gtk_about_dialog_set_translator_credits:
1158 * @about: a #GtkAboutDialog
1159 * @translator_credits: the translator credits
1161 * Sets the translator credits string which is displayed in
1162 * the translators tab of the secondary credits dialog.
1164 * The intended use for this string is to display the translator
1165 * of the language which is currently used in the user interface.
1166 * Using gettext(), a simple way to achieve that is to mark the
1167 * string for translation:
1168 * <informalexample><programlisting>
1169 * gtk_about_dialog_set_translator_credits (about, _("translator_credits"));
1170 * </programlisting></informalexample>
1171 * It is a good idea to use the customary msgid "translator_credits" for this
1172 * purpose, since translators will already know the purpose of that msgid, and
1173 * since #GtkAboutDialog will detect if "translator_credits" is untranslated
1179 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1180 const gchar *translator_credits)
1182 GtkAboutDialogPrivate *priv;
1185 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1187 priv = (GtkAboutDialogPrivate *)about->private_data;
1189 tmp = priv->translator_credits;
1190 priv->translator_credits = g_strdup (translator_credits);
1193 if (priv->translator_credits != NULL)
1194 gtk_widget_show (priv->credits_button);
1196 g_object_notify (G_OBJECT (about), "translator-credits");
1200 * gtk_about_dialog_get_logo:
1201 * @about: a #GtkAboutDialog
1203 * Returns the pixbuf displayed as logo in the about dialog.
1205 * Return value: the pixbuf displayed as logo. The pixbuf is
1206 * owned by the about dialog. If you want to keep a reference
1207 * to it, you have to call g_object_ref() on it.
1212 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1214 GtkAboutDialogPrivate *priv;
1216 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1218 priv = (GtkAboutDialogPrivate *)about->private_data;
1220 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1224 icon_set_new_from_pixbufs (GList *pixbufs)
1226 GtkIconSet *icon_set = gtk_icon_set_new ();
1228 for (; pixbufs; pixbufs = pixbufs->next)
1230 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1232 GtkIconSource *icon_source = gtk_icon_source_new ();
1233 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1234 gtk_icon_set_add_source (icon_set, icon_source);
1235 gtk_icon_source_free (icon_source);
1242 * gtk_about_dialog_set_logo:
1243 * @about: a #GtkAboutDialog
1244 * @logo: a #GdkPixbuf, or %NULL
1246 * Sets the pixbuf to be displayed as logo in
1247 * the about dialog. If it is %NULL, the default
1248 * window icon set with gtk_window_set_default_icon ()
1254 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1257 GtkAboutDialogPrivate *priv;
1259 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1261 priv = (GtkAboutDialogPrivate *)about->private_data;
1264 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1267 GList *pixbufs = gtk_window_get_default_icon_list ();
1269 if (pixbufs != NULL)
1271 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1273 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1274 icon_set, GTK_ICON_SIZE_DIALOG);
1276 gtk_icon_set_unref (icon_set);
1277 g_list_free (pixbufs);
1281 g_object_notify (G_OBJECT (about), "logo");
1285 activate_url (GtkWidget *widget,
1288 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1289 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1291 if (activate_url_hook != NULL)
1292 (* activate_url_hook) (about, url, activate_url_hook_data);
1296 set_link_button_text (GtkWidget *about,
1302 GdkColor *style_link_color;
1303 GdkColor link_color = { 0, 0, 0, 0xffff };
1305 gtk_widget_ensure_style (about);
1306 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1307 if (style_link_color)
1309 link_color = *style_link_color;
1310 gdk_color_free (style_link_color);
1313 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1314 link_color.red, link_color.green, link_color.blue, text);
1316 label = gtk_bin_get_child (GTK_BIN (button));
1317 gtk_label_set_markup (GTK_LABEL (label), link);
1322 create_link_button (GtkWidget *about,
1330 button = gtk_button_new_with_label ("");
1331 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1332 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1334 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1335 set_link_button_text (about, button, text);
1337 g_signal_connect (G_OBJECT (button), "clicked", callback, data);
1343 follow_if_link (GtkAboutDialog *about,
1346 GSList *tags = NULL, *tagp = NULL;
1348 tags = gtk_text_iter_get_tags (iter);
1349 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1351 GtkTextTag *tag = tagp->data;
1352 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1353 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1355 if (email != NULL && activate_email_hook != NULL)
1357 (* activate_email_hook) (about, email, activate_email_hook_data);
1361 if (url != NULL && activate_url_hook != NULL)
1363 (* activate_url_hook) (about, url, activate_url_hook_data);
1369 g_slist_free (tags);
1373 credits_key_press_event (GtkWidget *text_view,
1375 GtkAboutDialog *about)
1378 GtkTextBuffer *buffer;
1380 switch (event->keyval)
1384 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1385 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1386 gtk_text_buffer_get_insert (buffer));
1387 follow_if_link (about, &iter);
1398 credits_event_after (GtkWidget *text_view,
1400 GtkAboutDialog *about)
1402 GtkTextIter start, end, iter;
1403 GtkTextBuffer *buffer;
1404 GdkEventButton *button_event;
1407 if (event->type != GDK_BUTTON_RELEASE)
1410 button_event = (GdkEventButton *)event;
1412 if (button_event->button != 1)
1415 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1417 /* we shouldn't follow a link if the user has selected something */
1418 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1419 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1422 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1423 GTK_TEXT_WINDOW_WIDGET,
1424 button_event->x, button_event->y, &x, &y);
1426 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1428 follow_if_link (about, &iter);
1434 set_cursor_if_appropriate (GtkAboutDialog *about,
1435 GtkTextView *text_view,
1439 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1440 GSList *tags = NULL, *tagp = NULL;
1441 GtkTextBuffer *buffer;
1443 gboolean hovering_over_link = FALSE;
1445 buffer = gtk_text_view_get_buffer (text_view);
1447 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1449 tags = gtk_text_iter_get_tags (&iter);
1450 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1452 GtkTextTag *tag = tagp->data;
1453 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1454 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1456 if (email != NULL || url != NULL)
1458 hovering_over_link = TRUE;
1463 if (hovering_over_link != priv->hovering_over_link)
1465 priv->hovering_over_link = hovering_over_link;
1467 if (hovering_over_link)
1468 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1470 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1474 g_slist_free (tags);
1478 credits_motion_notify_event (GtkWidget *text_view,
1479 GdkEventMotion *event,
1480 GtkAboutDialog *about)
1484 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1485 GTK_TEXT_WINDOW_WIDGET,
1486 event->x, event->y, &x, &y);
1488 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1490 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1497 credits_visibility_notify_event (GtkWidget *text_view,
1498 GdkEventVisibility *event,
1499 GtkAboutDialog *about)
1501 gint wx, wy, bx, by;
1503 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1505 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1506 GTK_TEXT_WINDOW_WIDGET,
1509 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1515 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1517 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1518 &widget->style->bg[GTK_STATE_NORMAL]);
1522 add_credits_page (GtkAboutDialog *about,
1523 GtkWidget *notebook,
1528 gchar *q0, *q1, *q2, *r1, *r2;
1529 GtkWidget *sw, *view;
1530 GtkTextBuffer *buffer;
1531 gboolean linkify_email, linkify_urls;
1532 GdkColor *style_link_color;
1533 GdkColor link_color = { 0, 0, 0, 0xffff };
1535 linkify_email = (activate_email_hook != NULL);
1536 linkify_urls = (activate_url_hook != NULL);
1538 gtk_widget_ensure_style (GTK_WIDGET (about));
1539 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1540 if (style_link_color)
1542 link_color = *style_link_color;
1543 gdk_color_free (style_link_color);
1546 view = gtk_text_view_new ();
1547 g_signal_connect (about, "style_set",
1548 G_CALLBACK (text_view_style_set), view);
1550 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1551 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1552 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1553 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1554 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1556 g_signal_connect (G_OBJECT (view), "key-press-event",
1557 G_CALLBACK (credits_key_press_event), about);
1558 g_signal_connect (G_OBJECT (view), "event-after",
1559 G_CALLBACK (credits_event_after), about);
1560 g_signal_connect (G_OBJECT (view), "motion-notify-event",
1561 G_CALLBACK (credits_motion_notify_event), about);
1562 g_signal_connect (G_OBJECT (view), "visibility-notify-event",
1563 G_CALLBACK (credits_visibility_notify_event), about);
1565 sw = gtk_scrolled_window_new (NULL, NULL);
1566 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1567 GTK_POLICY_AUTOMATIC,
1568 GTK_POLICY_AUTOMATIC);
1569 gtk_container_add (GTK_CONTAINER (sw), view);
1571 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1572 sw, gtk_label_new (title));
1576 gtk_widget_hide (view);
1580 gtk_widget_show (view);
1582 for (p = people; *p; p++)
1587 q1 = linkify_email ? strchr (q0, '<') : NULL;
1588 q2 = q1 ? strchr (q1, '>') : NULL;
1589 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1592 r2 = strpbrk (r1, " \n\t");
1594 r2 = strchr (r1, '\0');
1599 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1612 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1613 gtk_text_buffer_get_end_iter (buffer, &end);
1621 link_type = "email";
1626 link = g_strndup (q1, q2 - q1);
1627 tag = gtk_text_buffer_create_tag (buffer, NULL,
1628 "foreground_gdk", &link_color,
1629 "underline", PANGO_UNDERLINE_SINGLE,
1631 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1632 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1638 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1644 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1649 display_credits_dialog (GtkWidget *button,
1652 GtkAboutDialog *about = (GtkAboutDialog *)data;
1653 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1654 GtkWidget *dialog, *notebook;
1656 if (priv->credits_dialog != NULL)
1658 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1662 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1664 GTK_DIALOG_DESTROY_WITH_PARENT,
1665 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1667 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1669 priv->credits_dialog = dialog;
1670 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1671 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1673 gtk_window_set_modal (GTK_WINDOW (dialog),
1674 gtk_window_get_modal (GTK_WINDOW (about)));
1676 g_signal_connect (dialog, "response",
1677 G_CALLBACK (gtk_widget_destroy), dialog);
1678 g_signal_connect (dialog, "destroy",
1679 G_CALLBACK (gtk_widget_destroyed),
1680 &(priv->credits_dialog));
1682 notebook = gtk_notebook_new ();
1683 gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
1684 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1686 if (priv->authors != NULL)
1687 add_credits_page (about, notebook, _("Written by"), priv->authors);
1689 if (priv->documenters != NULL)
1690 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1692 if (priv->translator_credits != NULL &&
1693 !strcmp (priv->translator_credits, "translator_credits") &&
1694 !strcmp (priv->translator_credits, "translator-credits"))
1696 gchar *translators[2];
1698 translators[0] = priv->translator_credits;
1699 translators[1] = NULL;
1701 add_credits_page (about, notebook, _("Translated by"), translators);
1704 if (priv->artists != NULL)
1705 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1707 gtk_widget_show_all (dialog);
1711 display_license_dialog (GtkWidget *button,
1714 GtkAboutDialog *about = (GtkAboutDialog *)data;
1715 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1716 GtkWidget *dialog, *view, *sw;
1718 if (priv->license_dialog != NULL)
1720 gtk_window_present (GTK_WINDOW (priv->license_dialog));
1724 dialog = gtk_dialog_new_with_buttons (_("License"),
1726 GTK_DIALOG_DESTROY_WITH_PARENT,
1727 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1729 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1730 priv->license_dialog = dialog;
1731 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
1732 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1734 gtk_window_set_modal (GTK_WINDOW (dialog),
1735 gtk_window_get_modal (GTK_WINDOW (about)));
1737 g_signal_connect (dialog, "response",
1738 G_CALLBACK (gtk_widget_destroy), dialog);
1739 g_signal_connect (dialog, "destroy",
1740 G_CALLBACK (gtk_widget_destroyed),
1741 &(priv->license_dialog));
1743 sw = gtk_scrolled_window_new (NULL, NULL);
1744 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1746 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1747 GTK_POLICY_AUTOMATIC,
1748 GTK_POLICY_AUTOMATIC);
1749 gtk_container_set_border_width (GTK_CONTAINER (sw), 8);
1750 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
1752 view = gtk_text_view_new ();
1753 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
1756 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1757 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1758 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1759 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1761 gtk_container_add (GTK_CONTAINER (sw), view);
1763 gtk_widget_show_all (dialog);
1767 * gtk_about_dialog_new:
1769 * Creates a new #GtkAboutDialog.
1771 * Returns: a newly created #GtkAboutDialog
1776 gtk_about_dialog_new (void)
1778 GtkAboutDialog *dialog = GTK_ABOUT_DIALOG (g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL));
1780 /* force defaults */
1781 gtk_about_dialog_set_name (dialog, NULL);
1782 gtk_about_dialog_set_logo (dialog, NULL);
1784 /* Close dialog on user response */
1785 g_signal_connect (G_OBJECT (dialog),
1787 G_CALLBACK (gtk_widget_hide),
1790 return GTK_WIDGET (dialog);
1794 * gtk_about_dialog_set_email_hook:
1795 * @func: a function to call when an email link is activated.
1796 * @data: data to pass to @func
1797 * @destroy: #GDestroyNotify for @data
1799 * Installs a global function to be called whenever the user activates an
1800 * email link in an about dialog.
1802 * Return value: the previous email hook.
1806 GtkAboutDialogActivateLinkFunc
1807 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
1809 GDestroyNotify destroy)
1811 GtkAboutDialogActivateLinkFunc old;
1813 if (activate_email_hook_destroy != NULL)
1814 (* activate_email_hook_destroy) (activate_url_hook_data);
1816 old = activate_email_hook;
1818 activate_email_hook = func;
1819 activate_email_hook_data = data;
1820 activate_email_hook_destroy = destroy;
1826 * gtk_about_dialog_set_url_hook:
1827 * @func: a function to call when a URL link is activated.
1828 * @data: data to pass to @func
1829 * @destroy: #GDestroyNotify for @data
1831 * Installs a global function to be called whenever the user activates a
1832 * URL link in an about dialog.
1834 * Return value: the previous URL hook.
1838 GtkAboutDialogActivateLinkFunc
1839 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
1841 GDestroyNotify destroy)
1843 GtkAboutDialogActivateLinkFunc old;
1845 if (activate_url_hook_destroy != NULL)
1846 (* activate_url_hook_destroy) (activate_email_hook_data);
1848 old = activate_url_hook;
1850 activate_url_hook = func;
1851 activate_url_hook_data = data;
1852 activate_url_hook_destroy = destroy;
1858 * gtk_show_about_dialog:
1859 * @parent: transient parent, or %NULL for none
1860 * @first_property_name: the name of the first property
1861 * @Varargs: value of first property, followed by more properties, %NULL-terminated
1863 * This is a convenience function for showing an application's about box.
1868 gtk_show_about_dialog (GtkWindow *parent,
1869 const gchar *first_property_name,
1872 static GtkWidget *global_about_dialog = NULL;
1873 GtkWidget *dialog = NULL;
1877 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
1879 dialog = global_about_dialog;
1883 dialog = gtk_about_dialog_new ();
1885 g_object_ref (G_OBJECT (dialog));
1886 gtk_object_sink (GTK_OBJECT (dialog));
1888 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
1890 va_start (var_args, first_property_name);
1891 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
1896 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
1897 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
1898 dialog, g_object_unref);
1901 global_about_dialog = dialog;
1905 gtk_window_present (GTK_WINDOW (dialog));