1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2001 CodeFactory AB
3 * Copyright (C) 2001, 2002 Anders Carlsson
4 * Copyright (C) 2003, 2004 Matthias Clasen <mclasen@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * Author: Anders Carlsson <andersca@gnome.org>
25 * Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
33 #include <gdk/gdkkeysyms.h>
35 #include "gtkaboutdialog.h"
36 #include "gtkbutton.h"
38 #include "gtkdialog.h"
42 #include "gtkmarshalers.h"
43 #include "gtknotebook.h"
44 #include "gtkscrolledwindow.h"
46 #include "gtktextview.h"
48 #include "gtkviewport.h"
49 #include "gtkiconfactory.h"
50 #include "gtkprivate.h"
57 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
58 struct _GtkAboutDialogPrivate
66 gchar *translator_credits;
73 GtkWidget *logo_image;
74 GtkWidget *name_label;
75 GtkWidget *comments_label;
76 GtkWidget *copyright_label;
77 GtkWidget *website_button;
79 GtkWidget *credits_button;
80 GtkWidget *credits_dialog;
81 GtkWidget *license_button;
82 GtkWidget *license_dialog;
84 GdkCursor *hand_cursor;
85 GdkCursor *regular_cursor;
86 gboolean hovering_over_link;
89 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
104 PROP_TRANSLATOR_CREDITS,
110 static void gtk_about_dialog_finalize (GObject *object);
111 static void gtk_about_dialog_get_property (GObject *object,
115 static void gtk_about_dialog_set_property (GObject *object,
119 static void gtk_about_dialog_style_set (GtkWidget *widget,
120 GtkStyle *previous_style);
121 static void dialog_style_set (GtkWidget *widget,
122 GtkStyle *previous_style,
124 static void update_name_version (GtkAboutDialog *about);
125 static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs);
126 static void activate_url (GtkWidget *widget,
128 static void set_link_button_text (GtkWidget *about,
131 static GtkWidget * create_link_button (GtkWidget *about,
136 static void follow_if_link (GtkAboutDialog *about,
138 static void set_cursor_if_appropriate (GtkAboutDialog *about,
139 GtkTextView *text_view,
142 static void add_credits_page (GtkAboutDialog *about,
146 static gboolean credits_key_press_event (GtkWidget *text_view,
148 GtkAboutDialog *about);
149 static gboolean credits_event_after (GtkWidget *text_view,
151 GtkAboutDialog *about);
152 static gboolean credits_motion_notify_event (GtkWidget *text_view,
153 GdkEventMotion *event,
154 GtkAboutDialog *about);
155 static gboolean credits_visibility_notify_event (GtkWidget *text_view,
156 GdkEventVisibility *event,
157 GtkAboutDialog *about);
158 static void display_credits_dialog (GtkWidget *button,
160 static void display_license_dialog (GtkWidget *button,
162 static void close_cb (GtkAboutDialog *about);
165 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
166 static gpointer activate_email_hook_data = NULL;
167 static GDestroyNotify activate_email_hook_destroy = NULL;
169 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
170 static gpointer activate_url_hook_data = NULL;
171 static GDestroyNotify activate_url_hook_destroy = NULL;
173 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
176 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
178 GObjectClass *object_class;
179 GtkWidgetClass *widget_class;
180 GtkDialogClass *dialog_class;
182 object_class = (GObjectClass *)klass;
183 widget_class = (GtkWidgetClass *)klass;
184 dialog_class = (GtkDialogClass *)klass;
186 object_class->set_property = gtk_about_dialog_set_property;
187 object_class->get_property = gtk_about_dialog_get_property;
189 object_class->finalize = gtk_about_dialog_finalize;
191 widget_class->style_set = gtk_about_dialog_style_set;
194 * GtkAboutDialog:name:
196 * The name of the program.
197 * If this is not set, it defaults to g_get_application_name().
201 g_object_class_install_property (object_class,
203 g_param_spec_string ("name",
205 P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
207 GTK_PARAM_READWRITE));
210 * GtkAboutDialog:version:
212 * The version of the program.
216 g_object_class_install_property (object_class,
218 g_param_spec_string ("version",
219 P_("Program version"),
220 P_("The version of the program"),
222 GTK_PARAM_READWRITE));
225 * GtkAboutDialog:copyright:
227 * Copyright information for the program.
231 g_object_class_install_property (object_class,
233 g_param_spec_string ("copyright",
234 P_("Copyright string"),
235 P_("Copyright information for the program"),
237 GTK_PARAM_READWRITE));
241 * GtkAboutDialog:comments:
243 * Comments about the program. This string is displayed in a label
244 * in the main dialog, thus it should be a short explanation of
245 * the main purpose of the program, not a detailed list of features.
249 g_object_class_install_property (object_class,
251 g_param_spec_string ("comments",
252 P_("Comments string"),
253 P_("Comments about the program"),
255 GTK_PARAM_READWRITE));
258 * GtkAboutDialog:license:
260 * The license of the program. This string is displayed in a
261 * text view in a secondary dialog, therefore it is fine to use
262 * a long multi-paragraph text. Note that the text is not wrapped
263 * in the text view, thus it must contain the intended linebreaks.
267 g_object_class_install_property (object_class,
269 g_param_spec_string ("license",
271 _("The license of the program"),
273 GTK_PARAM_READWRITE));
276 * GtkAboutDialog:website:
278 * The URL for the link to the website of the program.
279 * This should be a string starting with "http://.
283 g_object_class_install_property (object_class,
285 g_param_spec_string ("website",
287 P_("The URL for the link to the website of the program"),
289 GTK_PARAM_READWRITE));
292 * GtkAboutDialog:website-label:
294 * The label for the link to the website of the program. If this is not set,
295 * it defaults to the URL specified in the
296 * <link linkend="GtkAboutDialog--website">website</link> property.
300 g_object_class_install_property (object_class,
302 g_param_spec_string ("website-label",
304 P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
306 GTK_PARAM_READWRITE));
309 * GtkAboutDialog:authors:
311 * The authors of the program, as a %NULL-terminated array of strings.
312 * Each string may contain email addresses and URLs, which will be displayed
313 * as links, see the introduction for more details.
317 g_object_class_install_property (object_class,
319 g_param_spec_boxed ("authors",
321 P_("List of authors of the program"),
323 GTK_PARAM_READWRITE));
326 * GtkAboutDialog:documenters:
328 * The people documenting the program, as a %NULL-terminated array of strings.
329 * Each string may contain email addresses and URLs, which will be displayed
330 * as links, see the introduction for more details.
334 g_object_class_install_property (object_class,
336 g_param_spec_boxed ("documenters",
338 P_("List of people documenting the program"),
340 GTK_PARAM_READWRITE));
343 * GtkAboutDialog:artists:
345 * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
346 * Each string may contain email addresses and URLs, which will be displayed
347 * as links, see the introduction for more details.
351 g_object_class_install_property (object_class,
353 g_param_spec_boxed ("artists",
355 P_("List of people who have contributed artwork to the program"),
357 GTK_PARAM_READWRITE));
361 * GtkAboutDialog:translator-credits:
363 * Credits to the translators. This string should be marked as translatable.
364 * The string may contain email addresses and URLs, which will be displayed
365 * as links, see the introduction for more details.
369 g_object_class_install_property (object_class,
370 PROP_TRANSLATOR_CREDITS,
371 g_param_spec_string ("translator-credits",
372 P_("Translator credits"),
373 P_("Credits to the translators. This string should be marked as translatable"),
375 GTK_PARAM_READWRITE));
378 * GtkAboutDialog:logo:
380 * A logo for the about box. If this is not set, it defaults to
381 * gtk_window_get_default_icon_list().
385 g_object_class_install_property (object_class,
387 g_param_spec_object ("logo",
389 P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
391 GTK_PARAM_READWRITE));
394 * GtkAboutDialog:logo-icon-name:
396 * A named icon to use as the logo for the about box. This property
397 * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
401 g_object_class_install_property (object_class,
403 g_param_spec_string ("logo-icon-name",
404 P_("Logo Icon Name"),
405 P_("A named icon to use as the logo for the about box."),
407 GTK_PARAM_READWRITE));
409 /* Style properties */
410 gtk_widget_class_install_style_property (widget_class,
411 g_param_spec_boxed ("link-color",
413 P_("Color of hyperlinks"),
415 GTK_PARAM_READABLE));
417 g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
421 gtk_about_dialog_init (GtkAboutDialog *about)
423 GtkAboutDialogPrivate *priv;
424 GtkWidget *vbox, *hbox, *button;
427 priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
428 about->private_data = priv;
431 priv->version = NULL;
432 priv->copyright = NULL;
433 priv->comments = NULL;
434 priv->website = NULL;
435 priv->website_label = NULL;
436 priv->translator_credits = NULL;
437 priv->license = NULL;
438 priv->authors = NULL;
439 priv->documenters = NULL;
440 priv->artists = NULL;
442 priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
443 priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
444 priv->hovering_over_link = FALSE;
446 gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
449 gtk_widget_push_composite_child ();
450 vbox = gtk_vbox_new (FALSE, 8);
452 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
454 priv->logo_image = gtk_image_new ();
455 gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
457 priv->name_label = gtk_label_new (NULL);
458 gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
459 gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
460 gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
462 priv->comments_label = gtk_label_new (NULL);
463 gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
464 gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
465 gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
466 gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
468 priv->copyright_label = gtk_label_new (NULL);
469 gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
470 gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
471 gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
473 button = create_link_button (GTK_WIDGET (about), "", "",
474 G_CALLBACK (activate_url), about);
476 hbox = gtk_hbox_new (TRUE, 0);
477 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
478 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
479 priv->website_button = button;
481 gtk_widget_show (vbox);
482 gtk_widget_show (priv->logo_image);
483 gtk_widget_show (priv->name_label);
484 gtk_widget_show (hbox);
486 /* Add the OK button */
487 gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
488 gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CLOSE);
490 /* Add the credits button */
491 button = gtk_button_new_from_stock (_("C_redits"));
492 gtk_widget_set_no_show_all (button, TRUE);
493 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
494 button, FALSE, TRUE, 0);
495 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
496 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
497 priv->credits_button = button;
498 priv->credits_dialog = NULL;
500 /* Add the license button */
501 button = gtk_button_new_from_stock (_("_License"));
502 gtk_widget_set_no_show_all (button, TRUE);
503 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
504 button, FALSE, TRUE, 0);
505 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
506 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
507 priv->license_button = button;
508 priv->license_dialog = NULL;
510 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
512 gtk_widget_pop_composite_child ();
515 gtk_about_dialog_set_name (about, NULL);
516 gtk_about_dialog_set_logo (about, NULL);
518 /* Close dialog on user response */
519 g_signal_connect (about, "response", G_CALLBACK (close_cb), NULL);
523 gtk_about_dialog_finalize (GObject *object)
525 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
526 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
529 g_free (priv->version);
530 g_free (priv->copyright);
531 g_free (priv->comments);
532 g_free (priv->license);
533 g_free (priv->website);
534 g_free (priv->website_label);
535 g_free (priv->translator_credits);
537 g_strfreev (priv->authors);
538 g_strfreev (priv->documenters);
539 g_strfreev (priv->artists);
541 gdk_cursor_unref (priv->hand_cursor);
542 gdk_cursor_unref (priv->regular_cursor);
544 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
548 gtk_about_dialog_set_property (GObject *object,
553 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
558 gtk_about_dialog_set_name (about, g_value_get_string (value));
561 gtk_about_dialog_set_version (about, g_value_get_string (value));
564 gtk_about_dialog_set_comments (about, g_value_get_string (value));
567 gtk_about_dialog_set_website (about, g_value_get_string (value));
569 case PROP_WEBSITE_LABEL:
570 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
573 gtk_about_dialog_set_license (about, g_value_get_string (value));
576 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
579 gtk_about_dialog_set_logo (about, g_value_get_object (value));
582 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
584 case PROP_DOCUMENTERS:
585 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
588 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
590 case PROP_TRANSLATOR_CREDITS:
591 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
593 case PROP_LOGO_ICON_NAME:
594 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
597 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
603 gtk_about_dialog_get_property (GObject *object,
608 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
609 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
614 g_value_set_string (value, priv->name);
617 g_value_set_string (value, priv->version);
620 g_value_set_string (value, priv->copyright);
623 g_value_set_string (value, priv->comments);
626 g_value_set_string (value, priv->website);
628 case PROP_WEBSITE_LABEL:
629 g_value_set_string (value, priv->website_label);
632 g_value_set_string (value, priv->license);
634 case PROP_TRANSLATOR_CREDITS:
635 g_value_set_string (value, priv->translator_credits);
638 g_value_set_boxed (value, priv->authors);
640 case PROP_DOCUMENTERS:
641 g_value_set_boxed (value, priv->documenters);
644 g_value_set_boxed (value, priv->artists);
647 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
648 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
650 g_value_set_object (value, NULL);
652 case PROP_LOGO_ICON_NAME:
653 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
655 const gchar *icon_name;
657 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
658 g_value_set_string (value, icon_name);
661 g_value_set_string (value, NULL);
664 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
670 dialog_style_set (GtkWidget *widget,
671 GtkStyle *previous_style,
676 dialog = GTK_DIALOG (widget);
678 /* Override the style properties with HIG-compliant spacings. Ugh.
679 * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
680 * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
683 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
684 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 12);
686 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
687 gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
691 gtk_about_dialog_style_set (GtkWidget *widget,
692 GtkStyle *previous_style)
694 if (GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set)
695 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set (widget, previous_style);
697 dialog_style_set (widget, previous_style, NULL);
701 * gtk_about_dialog_get_name:
702 * @about: a #GtkAboutDialog
704 * Returns the program name displayed in the about dialog.
706 * Return value: The program name. The string is owned by the about
707 * dialog and must not be modified.
711 G_CONST_RETURN gchar *
712 gtk_about_dialog_get_name (GtkAboutDialog *about)
714 GtkAboutDialogPrivate *priv;
716 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
718 priv = (GtkAboutDialogPrivate *)about->private_data;
724 update_name_version (GtkAboutDialog *about)
726 GtkAboutDialogPrivate *priv;
727 gchar *title_string, *name_string;
729 priv = (GtkAboutDialogPrivate *)about->private_data;
731 title_string = g_strdup_printf (_("About %s"), priv->name);
732 gtk_window_set_title (GTK_WINDOW (about), title_string);
733 g_free (title_string);
735 if (priv->version != NULL)
736 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
737 priv->name, priv->version);
739 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
742 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
744 g_free (name_string);
748 * gtk_about_dialog_set_name:
749 * @about: a #GtkAboutDialog
750 * @name: the program name
752 * Sets the name to display in the about dialog.
753 * If this is not set, it defaults to g_get_application_name().
758 gtk_about_dialog_set_name (GtkAboutDialog *about,
761 GtkAboutDialogPrivate *priv;
764 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
766 priv = (GtkAboutDialogPrivate *)about->private_data;
768 priv->name = g_strdup (name ? name : g_get_application_name ());
771 update_name_version (about);
773 g_object_notify (G_OBJECT (about), "name");
777 * gtk_about_dialog_get_version:
778 * @about: a #GtkAboutDialog
780 * Returns the version string.
782 * Return value: The version string. The string is owned by the about
783 * dialog and must not be modified.
787 G_CONST_RETURN gchar *
788 gtk_about_dialog_get_version (GtkAboutDialog *about)
790 GtkAboutDialogPrivate *priv;
792 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
794 priv = (GtkAboutDialogPrivate *)about->private_data;
796 return priv->version;
800 * gtk_about_dialog_set_version:
801 * @about: a #GtkAboutDialog
802 * @version: the version string
804 * Sets the version string to display in the about dialog.
809 gtk_about_dialog_set_version (GtkAboutDialog *about,
810 const gchar *version)
812 GtkAboutDialogPrivate *priv;
815 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
817 priv = (GtkAboutDialogPrivate *)about->private_data;
820 priv->version = version ? g_strdup (version) : NULL;
823 update_name_version (about);
825 g_object_notify (G_OBJECT (about), "version");
829 * gtk_about_dialog_get_copyright:
830 * @about: a #GtkAboutDialog
832 * Returns the copyright string.
834 * Return value: The copyright string. The string is owned by the about
835 * dialog and must not be modified.
839 G_CONST_RETURN gchar *
840 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
842 GtkAboutDialogPrivate *priv;
844 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
846 priv = (GtkAboutDialogPrivate *)about->private_data;
848 return priv->copyright;
852 * gtk_about_dialog_set_copyright:
853 * @about: a #GtkAboutDialog
854 * @copyright: the copyright string
856 * Sets the copyright string to display in the about dialog.
857 * This should be a short string of one or two lines.
862 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
863 const gchar *copyright)
865 GtkAboutDialogPrivate *priv;
866 gchar *copyright_string, *tmp;
868 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
870 priv = (GtkAboutDialogPrivate *)about->private_data;
872 tmp = priv->copyright;
873 priv->copyright = copyright ? g_strdup (copyright) : NULL;
876 if (priv->copyright != NULL)
878 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
880 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
881 g_free (copyright_string);
883 gtk_widget_show (priv->copyright_label);
886 gtk_widget_hide (priv->copyright_label);
888 g_object_notify (G_OBJECT (about), "copyright");
892 * gtk_about_dialog_get_comments:
893 * @about: a #GtkAboutDialog
895 * Returns the comments string.
897 * Return value: The comments. The string is owned by the about
898 * dialog and must not be modified.
902 G_CONST_RETURN gchar *
903 gtk_about_dialog_get_comments (GtkAboutDialog *about)
905 GtkAboutDialogPrivate *priv;
907 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
909 priv = (GtkAboutDialogPrivate *)about->private_data;
911 return priv->comments;
915 * gtk_about_dialog_set_comments:
916 * @about: a #GtkAboutDialog
917 * @comments: a comments string
919 * Sets the comments string to display in the about
920 * dialog. This should be a short string of one or
926 gtk_about_dialog_set_comments (GtkAboutDialog *about,
927 const gchar *comments)
929 GtkAboutDialogPrivate *priv;
932 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
934 priv = (GtkAboutDialogPrivate *)about->private_data;
936 tmp = priv->comments;
939 priv->comments = g_strdup (comments);
940 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
941 gtk_widget_show (priv->comments_label);
945 priv->comments = NULL;
946 gtk_widget_hide (priv->comments_label);
950 g_object_notify (G_OBJECT (about), "comments");
954 * gtk_about_dialog_get_license:
955 * @about: a #GtkAboutDialog
957 * Returns the license information.
959 * Return value: The license information. The string is owned by the about
960 * dialog and must not be modified.
964 G_CONST_RETURN gchar *
965 gtk_about_dialog_get_license (GtkAboutDialog *about)
967 GtkAboutDialogPrivate *priv;
969 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
971 priv = (GtkAboutDialogPrivate *)about->private_data;
973 return priv->license;
977 * gtk_about_dialog_set_license:
978 * @about: a #GtkAboutDialog
979 * @license: the license information or %NULL
981 * Sets the license information to be displayed in the secondary
982 * license dialog. If @license is %NULL, the license button is
988 gtk_about_dialog_set_license (GtkAboutDialog *about,
989 const gchar *license)
991 GtkAboutDialogPrivate *priv;
994 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
996 priv = (GtkAboutDialogPrivate *)about->private_data;
1001 priv->license = g_strdup (license);
1002 gtk_widget_show (priv->license_button);
1006 priv->license = NULL;
1007 gtk_widget_hide (priv->license_button);
1011 g_object_notify (G_OBJECT (about), "license");
1015 * gtk_about_dialog_get_website:
1016 * @about: a #GtkAboutDialog
1018 * Returns the website URL.
1020 * Return value: The website URL. The string is owned by the about
1021 * dialog and must not be modified.
1025 G_CONST_RETURN gchar *
1026 gtk_about_dialog_get_website (GtkAboutDialog *about)
1028 GtkAboutDialogPrivate *priv;
1030 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1032 priv = (GtkAboutDialogPrivate *)about->private_data;
1034 return priv->website;
1038 * gtk_about_dialog_set_website:
1039 * @about: a #GtkAboutDialog
1040 * @website: a URL string starting with "http://"
1042 * Sets the URL to use for the website link.
1047 gtk_about_dialog_set_website (GtkAboutDialog *about,
1048 const gchar *website)
1050 GtkAboutDialogPrivate *priv;
1053 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1055 priv = (GtkAboutDialogPrivate *)about->private_data;
1057 tmp = priv->website;
1058 if (website != NULL)
1060 priv->website = g_strdup (website);
1061 if (activate_url_hook != NULL)
1063 g_object_set_data_full (G_OBJECT (priv->website_button),
1064 "url", g_strdup (website), g_free);
1065 if (priv->website_label == NULL)
1066 gtk_about_dialog_set_website_label (about, website);
1070 GtkWidget *hbox = priv->website_button->parent;
1071 gtk_widget_destroy (priv->website_button);
1072 priv->website_button = gtk_label_new (website);
1073 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1074 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1075 gtk_widget_show (priv->website_button);
1080 priv->website = NULL;
1081 g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
1082 gtk_widget_hide (priv->website_button);
1086 g_object_notify (G_OBJECT (about), "website");
1090 * gtk_about_dialog_get_website_label:
1091 * @about: a #GtkAboutDialog
1093 * Returns the label used for the website link.
1095 * Return value: The label used for the website link. The string is owned by the about
1096 * dialog and must not be modified.
1100 G_CONST_RETURN gchar *
1101 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1103 GtkAboutDialogPrivate *priv;
1105 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1107 priv = (GtkAboutDialogPrivate *)about->private_data;
1109 return priv->website_label;
1113 * gtk_about_dialog_set_website_label:
1114 * @about: a #GtkAboutDialog
1115 * @website_label: the label used for the website link
1117 * Sets the label to be used for the website link.
1118 * It defaults to the website URL.
1123 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1124 const gchar *website_label)
1126 GtkAboutDialogPrivate *priv;
1129 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1131 priv = (GtkAboutDialogPrivate *)about->private_data;
1133 tmp = priv->website_label;
1134 if (activate_url_hook != NULL)
1136 if (website_label != NULL)
1138 priv->website_label = g_strdup (website_label);
1139 set_link_button_text (GTK_WIDGET (about),
1140 priv->website_button,
1141 priv->website_label);
1142 gtk_widget_show (priv->website_button);
1146 priv->website_label = NULL;
1147 gtk_widget_hide (priv->website_button);
1152 g_object_notify (G_OBJECT (about), "website-label");
1156 * gtk_about_dialog_get_authors:
1157 * @about: a #GtkAboutDialog
1159 * Returns the string which are displayed in the authors tab
1160 * of the secondary credits dialog.
1162 * Return value: A %NULL-terminated string array containing
1163 * the authors. The array is owned by the about dialog
1164 * and must not be modified.
1168 G_CONST_RETURN gchar * G_CONST_RETURN *
1169 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1171 GtkAboutDialogPrivate *priv;
1173 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1175 priv = (GtkAboutDialogPrivate *)about->private_data;
1177 return (const gchar * const *) priv->authors;
1181 * gtk_about_dialog_set_authors:
1182 * @about: a #GtkAboutDialog
1183 * @authors: a %NULL-terminated array of strings
1185 * Sets the strings which are displayed in the authors tab
1186 * of the secondary credits dialog.
1191 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1192 const gchar **authors)
1194 GtkAboutDialogPrivate *priv;
1197 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1199 priv = (GtkAboutDialogPrivate *)about->private_data;
1201 tmp = priv->authors;
1202 priv->authors = g_strdupv ((gchar **)authors);
1205 if (priv->authors != NULL)
1206 gtk_widget_show (priv->credits_button);
1208 g_object_notify (G_OBJECT (about), "authors");
1212 * gtk_about_dialog_get_documenters:
1213 * @about: a #GtkAboutDialog
1215 * Returns the string which are displayed in the documenters
1216 * tab of the secondary credits dialog.
1218 * Return value: A %NULL-terminated string array containing
1219 * the documenters. The array is owned by the about dialog
1220 * and must not be modified.
1224 G_CONST_RETURN gchar * G_CONST_RETURN *
1225 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1227 GtkAboutDialogPrivate *priv;
1229 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1231 priv = (GtkAboutDialogPrivate *)about->private_data;
1233 return (const gchar * const *)priv->documenters;
1237 * gtk_about_dialog_set_documenters:
1238 * @about: a #GtkAboutDialog
1239 * @documenters: a %NULL-terminated array of strings
1241 * Sets the strings which are displayed in the documenters tab
1242 * of the secondary credits dialog.
1247 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1248 const gchar **documenters)
1250 GtkAboutDialogPrivate *priv;
1253 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1255 priv = (GtkAboutDialogPrivate *)about->private_data;
1257 tmp = priv->documenters;
1258 priv->documenters = g_strdupv ((gchar **)documenters);
1261 if (priv->documenters != NULL)
1262 gtk_widget_show (priv->credits_button);
1264 g_object_notify (G_OBJECT (about), "documenters");
1268 * gtk_about_dialog_get_artists:
1269 * @about: a #GtkAboutDialog
1271 * Returns the string which are displayed in the artists tab
1272 * of the secondary credits dialog.
1274 * Return value: A %NULL-terminated string array containing
1275 * the artists. The array is owned by the about dialog
1276 * and must not be modified.
1280 G_CONST_RETURN gchar * G_CONST_RETURN *
1281 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1283 GtkAboutDialogPrivate *priv;
1285 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1287 priv = (GtkAboutDialogPrivate *)about->private_data;
1289 return (const gchar * const *)priv->artists;
1293 * gtk_about_dialog_set_artists:
1294 * @about: a #GtkAboutDialog
1295 * @artists: a %NULL-terminated array of strings
1297 * Sets the strings which are displayed in the artists tab
1298 * of the secondary credits dialog.
1303 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1304 const gchar **artists)
1306 GtkAboutDialogPrivate *priv;
1309 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1311 priv = (GtkAboutDialogPrivate *)about->private_data;
1313 tmp = priv->artists;
1314 priv->artists = g_strdupv ((gchar **)artists);
1317 if (priv->artists != NULL)
1318 gtk_widget_show (priv->credits_button);
1320 g_object_notify (G_OBJECT (about), "artists");
1324 * gtk_about_dialog_get_translator_credits:
1325 * @about: a #GtkAboutDialog
1327 * Returns the translator credits string which is displayed
1328 * in the translators tab of the secondary credits dialog.
1330 * Return value: The translator credits string. The string is
1331 * owned by the about dialog and must not be modified.
1335 G_CONST_RETURN gchar *
1336 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1338 GtkAboutDialogPrivate *priv;
1340 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1342 priv = (GtkAboutDialogPrivate *)about->private_data;
1344 return priv->translator_credits;
1348 * gtk_about_dialog_set_translator_credits:
1349 * @about: a #GtkAboutDialog
1350 * @translator_credits: the translator credits
1352 * Sets the translator credits string which is displayed in
1353 * the translators tab of the secondary credits dialog.
1355 * The intended use for this string is to display the translator
1356 * of the language which is currently used in the user interface.
1357 * Using gettext(), a simple way to achieve that is to mark the
1358 * string for translation:
1359 * <informalexample><programlisting>
1360 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1361 * </programlisting></informalexample>
1362 * It is a good idea to use the customary msgid "translator-credits" for this
1363 * purpose, since translators will already know the purpose of that msgid, and
1364 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1370 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1371 const gchar *translator_credits)
1373 GtkAboutDialogPrivate *priv;
1376 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1378 priv = (GtkAboutDialogPrivate *)about->private_data;
1380 tmp = priv->translator_credits;
1381 priv->translator_credits = g_strdup (translator_credits);
1384 if (priv->translator_credits != NULL)
1385 gtk_widget_show (priv->credits_button);
1387 g_object_notify (G_OBJECT (about), "translator-credits");
1391 * gtk_about_dialog_get_logo:
1392 * @about: a #GtkAboutDialog
1394 * Returns the pixbuf displayed as logo in the about dialog.
1396 * Return value: the pixbuf displayed as logo. The pixbuf is
1397 * owned by the about dialog. If you want to keep a reference
1398 * to it, you have to call g_object_ref() on it.
1403 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1405 GtkAboutDialogPrivate *priv;
1407 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1409 priv = (GtkAboutDialogPrivate *)about->private_data;
1411 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1412 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1418 icon_set_new_from_pixbufs (GList *pixbufs)
1420 GtkIconSet *icon_set = gtk_icon_set_new ();
1422 for (; pixbufs; pixbufs = pixbufs->next)
1424 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1426 GtkIconSource *icon_source = gtk_icon_source_new ();
1427 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1428 gtk_icon_set_add_source (icon_set, icon_source);
1429 gtk_icon_source_free (icon_source);
1436 * gtk_about_dialog_set_logo:
1437 * @about: a #GtkAboutDialog
1438 * @logo: a #GdkPixbuf, or %NULL
1440 * Sets the pixbuf to be displayed as logo in
1441 * the about dialog. If it is %NULL, the default
1442 * window icon set with gtk_window_set_default_icon ()
1448 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1451 GtkAboutDialogPrivate *priv;
1453 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1455 priv = (GtkAboutDialogPrivate *)about->private_data;
1457 g_object_freeze_notify (G_OBJECT (about));
1459 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1460 g_object_notify (G_OBJECT (about), "logo-icon-name");
1463 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1466 GList *pixbufs = gtk_window_get_default_icon_list ();
1468 if (pixbufs != NULL)
1470 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1472 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1473 icon_set, GTK_ICON_SIZE_DIALOG);
1475 gtk_icon_set_unref (icon_set);
1476 g_list_free (pixbufs);
1480 g_object_notify (G_OBJECT (about), "logo");
1482 g_object_thaw_notify (G_OBJECT (about));
1486 * gtk_about_dialog_get_logo_icon_name:
1487 * @about: a #GtkAboutDialog
1489 * Returns the icon name displayed as logo in the about dialog.
1491 * Return value: the icon name displayed as logo. The string is
1492 * owned by the dialog. If you want to keep a reference
1493 * to it, you have to call g_strdup() on it.
1497 G_CONST_RETURN gchar *
1498 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1500 GtkAboutDialogPrivate *priv;
1501 const gchar *icon_name = NULL;
1503 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1505 priv = (GtkAboutDialogPrivate *)about->private_data;
1507 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1508 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1514 * gtk_about_dialog_set_logo_icon_name:
1515 * @about: a #GtkAboutDialog
1516 * @icon_name: an icon name, or %NULL
1518 * Sets the pixbuf to be displayed as logo in
1519 * the about dialog. If it is %NULL, the default
1520 * window icon set with gtk_window_set_default_icon()
1526 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1527 const gchar *icon_name)
1529 GtkAboutDialogPrivate *priv;
1531 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1533 priv = (GtkAboutDialogPrivate *)about->private_data;
1535 g_object_freeze_notify (G_OBJECT (about));
1537 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1538 g_object_notify (G_OBJECT (about), "logo");
1540 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1541 GTK_ICON_SIZE_DIALOG);
1542 g_object_notify (G_OBJECT (about), "logo-icon-name");
1544 g_object_thaw_notify (G_OBJECT (about));
1548 activate_url (GtkWidget *widget,
1551 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1552 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1554 if (activate_url_hook != NULL)
1555 (* activate_url_hook) (about, url, activate_url_hook_data);
1559 set_link_button_text (GtkWidget *about,
1565 GdkColor *style_link_color;
1566 GdkColor link_color = { 0, 0, 0, 0xffff };
1568 gtk_widget_ensure_style (about);
1569 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1570 if (style_link_color)
1572 link_color = *style_link_color;
1573 gdk_color_free (style_link_color);
1576 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1577 link_color.red, link_color.green, link_color.blue, text);
1579 label = gtk_bin_get_child (GTK_BIN (button));
1580 gtk_label_set_markup (GTK_LABEL (label), link);
1585 link_button_enter (GtkWidget *widget,
1586 GdkEventCrossing *event,
1587 GtkAboutDialog *about)
1589 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1590 gdk_window_set_cursor (widget->window, priv->hand_cursor);
1596 link_button_leave (GtkWidget *widget,
1597 GdkEventCrossing *event,
1598 GtkAboutDialog *about)
1600 gdk_window_set_cursor (widget->window, NULL);
1606 create_link_button (GtkWidget *about,
1614 button = gtk_button_new_with_label ("");
1615 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1616 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1618 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1619 set_link_button_text (about, button, text);
1621 g_signal_connect (button, "clicked", callback, data);
1622 g_signal_connect (button, "enter_notify_event",
1623 G_CALLBACK (link_button_enter), data);
1624 g_signal_connect (button, "leave_notify_event",
1625 G_CALLBACK (link_button_leave), data);
1631 follow_if_link (GtkAboutDialog *about,
1634 GSList *tags = NULL, *tagp = NULL;
1636 tags = gtk_text_iter_get_tags (iter);
1637 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1639 GtkTextTag *tag = tagp->data;
1640 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1641 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1643 if (email != NULL && activate_email_hook != NULL)
1645 (* activate_email_hook) (about, email, activate_email_hook_data);
1649 if (url != NULL && activate_url_hook != NULL)
1651 (* activate_url_hook) (about, url, activate_url_hook_data);
1657 g_slist_free (tags);
1661 credits_key_press_event (GtkWidget *text_view,
1663 GtkAboutDialog *about)
1666 GtkTextBuffer *buffer;
1668 switch (event->keyval)
1672 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1673 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1674 gtk_text_buffer_get_insert (buffer));
1675 follow_if_link (about, &iter);
1686 credits_event_after (GtkWidget *text_view,
1688 GtkAboutDialog *about)
1690 GtkTextIter start, end, iter;
1691 GtkTextBuffer *buffer;
1692 GdkEventButton *button_event;
1695 if (event->type != GDK_BUTTON_RELEASE)
1698 button_event = (GdkEventButton *)event;
1700 if (button_event->button != 1)
1703 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1705 /* we shouldn't follow a link if the user has selected something */
1706 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1707 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1710 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1711 GTK_TEXT_WINDOW_WIDGET,
1712 button_event->x, button_event->y, &x, &y);
1714 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1716 follow_if_link (about, &iter);
1722 set_cursor_if_appropriate (GtkAboutDialog *about,
1723 GtkTextView *text_view,
1727 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1728 GSList *tags = NULL, *tagp = NULL;
1729 GtkTextBuffer *buffer;
1731 gboolean hovering_over_link = FALSE;
1733 buffer = gtk_text_view_get_buffer (text_view);
1735 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1737 tags = gtk_text_iter_get_tags (&iter);
1738 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1740 GtkTextTag *tag = tagp->data;
1741 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1742 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1744 if (email != NULL || url != NULL)
1746 hovering_over_link = TRUE;
1751 if (hovering_over_link != priv->hovering_over_link)
1753 priv->hovering_over_link = hovering_over_link;
1755 if (hovering_over_link)
1756 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1758 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1762 g_slist_free (tags);
1766 credits_motion_notify_event (GtkWidget *text_view,
1767 GdkEventMotion *event,
1768 GtkAboutDialog *about)
1772 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1773 GTK_TEXT_WINDOW_WIDGET,
1774 event->x, event->y, &x, &y);
1776 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1778 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1785 credits_visibility_notify_event (GtkWidget *text_view,
1786 GdkEventVisibility *event,
1787 GtkAboutDialog *about)
1789 gint wx, wy, bx, by;
1791 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1793 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1794 GTK_TEXT_WINDOW_WIDGET,
1797 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1803 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1805 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1806 &widget->style->bg[GTK_STATE_NORMAL]);
1810 add_credits_page (GtkAboutDialog *about,
1811 GtkWidget *notebook,
1816 gchar *q0, *q1, *q2, *r1, *r2;
1817 GtkWidget *sw, *view;
1818 GtkTextBuffer *buffer;
1819 gboolean linkify_email, linkify_urls;
1820 GdkColor *style_link_color;
1821 GdkColor link_color = { 0, 0, 0, 0xffff };
1823 linkify_email = (activate_email_hook != NULL);
1824 linkify_urls = (activate_url_hook != NULL);
1826 gtk_widget_ensure_style (GTK_WIDGET (about));
1827 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1828 if (style_link_color)
1830 link_color = *style_link_color;
1831 gdk_color_free (style_link_color);
1834 view = gtk_text_view_new ();
1835 g_signal_connect_object (about, "style_set",
1836 G_CALLBACK (text_view_style_set), view, 0);
1838 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1839 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1840 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1842 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1843 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1845 g_signal_connect (view, "key-press-event",
1846 G_CALLBACK (credits_key_press_event), about);
1847 g_signal_connect (view, "event-after",
1848 G_CALLBACK (credits_event_after), about);
1849 g_signal_connect (view, "motion-notify-event",
1850 G_CALLBACK (credits_motion_notify_event), about);
1851 g_signal_connect (view, "visibility-notify-event",
1852 G_CALLBACK (credits_visibility_notify_event), about);
1854 sw = gtk_scrolled_window_new (NULL, NULL);
1855 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1857 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1858 GTK_POLICY_AUTOMATIC,
1859 GTK_POLICY_AUTOMATIC);
1860 gtk_container_add (GTK_CONTAINER (sw), view);
1862 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1863 sw, gtk_label_new (title));
1867 gtk_widget_hide (view);
1871 gtk_widget_show (view);
1873 for (p = people; *p; p++)
1878 q1 = linkify_email ? strchr (q0, '<') : NULL;
1879 q2 = q1 ? strchr (q1, '>') : NULL;
1880 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1883 r2 = strpbrk (r1, " \n\t");
1885 r2 = strchr (r1, '\0');
1890 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1903 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1904 gtk_text_buffer_get_end_iter (buffer, &end);
1912 link_type = "email";
1917 link = g_strndup (q1, q2 - q1);
1918 tag = gtk_text_buffer_create_tag (buffer, NULL,
1919 "foreground_gdk", &link_color,
1920 "underline", PANGO_UNDERLINE_SINGLE,
1922 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1923 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1929 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1935 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1940 display_credits_dialog (GtkWidget *button,
1943 GtkAboutDialog *about = (GtkAboutDialog *)data;
1944 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1945 GtkWidget *dialog, *notebook;
1947 if (priv->credits_dialog != NULL)
1949 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1953 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1955 GTK_DIALOG_DESTROY_WITH_PARENT,
1956 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1958 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1960 priv->credits_dialog = dialog;
1961 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1962 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1964 gtk_window_set_modal (GTK_WINDOW (dialog),
1965 gtk_window_get_modal (GTK_WINDOW (about)));
1967 g_signal_connect (dialog, "response",
1968 G_CALLBACK (gtk_widget_destroy), dialog);
1969 g_signal_connect (dialog, "destroy",
1970 G_CALLBACK (gtk_widget_destroyed),
1971 &(priv->credits_dialog));
1972 g_signal_connect (dialog, "style_set",
1973 G_CALLBACK (dialog_style_set), NULL);
1975 notebook = gtk_notebook_new ();
1976 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1978 if (priv->authors != NULL)
1979 add_credits_page (about, notebook, _("Written by"), priv->authors);
1981 if (priv->documenters != NULL)
1982 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1984 /* Don't show an untranslated gettext msgid */
1985 if (priv->translator_credits != NULL &&
1986 strcmp (priv->translator_credits, "translator_credits") &&
1987 strcmp (priv->translator_credits, "translator-credits"))
1989 gchar *translators[2];
1991 translators[0] = priv->translator_credits;
1992 translators[1] = NULL;
1994 add_credits_page (about, notebook, _("Translated by"), translators);
1997 if (priv->artists != NULL)
1998 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
2000 gtk_widget_show_all (dialog);
2004 set_policy (GtkWidget *sw)
2006 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2007 GTK_POLICY_AUTOMATIC,
2008 GTK_POLICY_AUTOMATIC);
2012 display_license_dialog (GtkWidget *button,
2015 GtkAboutDialog *about = (GtkAboutDialog *)data;
2016 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2017 GtkWidget *dialog, *view, *sw;
2019 if (priv->license_dialog != NULL)
2021 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2025 dialog = gtk_dialog_new_with_buttons (_("License"),
2027 GTK_DIALOG_DESTROY_WITH_PARENT,
2028 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2030 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2031 priv->license_dialog = dialog;
2032 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2033 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
2035 gtk_window_set_modal (GTK_WINDOW (dialog),
2036 gtk_window_get_modal (GTK_WINDOW (about)));
2038 g_signal_connect (dialog, "response",
2039 G_CALLBACK (gtk_widget_destroy), dialog);
2040 g_signal_connect (dialog, "destroy",
2041 G_CALLBACK (gtk_widget_destroyed),
2042 &(priv->license_dialog));
2043 g_signal_connect (dialog, "style_set",
2044 G_CALLBACK (dialog_style_set), NULL);
2046 sw = gtk_scrolled_window_new (NULL, NULL);
2047 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2049 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2051 GTK_POLICY_AUTOMATIC);
2052 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2053 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2055 view = gtk_text_view_new ();
2056 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2059 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2060 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2062 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2063 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2065 gtk_container_add (GTK_CONTAINER (sw), view);
2067 gtk_widget_show_all (dialog);
2071 close_cb (GtkAboutDialog *about)
2073 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2075 if (priv->license_dialog != NULL)
2077 gtk_widget_destroy (priv->license_dialog);
2078 priv->license_dialog = NULL;
2081 if (priv->credits_dialog != NULL)
2083 gtk_widget_destroy (priv->credits_dialog);
2084 priv->credits_dialog = NULL;
2087 gtk_widget_hide (GTK_WIDGET (about));
2092 * gtk_about_dialog_new:
2094 * Creates a new #GtkAboutDialog.
2096 * Returns: a newly created #GtkAboutDialog
2101 gtk_about_dialog_new (void)
2103 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2105 return GTK_WIDGET (dialog);
2109 * gtk_about_dialog_set_email_hook:
2110 * @func: a function to call when an email link is activated.
2111 * @data: data to pass to @func
2112 * @destroy: #GDestroyNotify for @data
2114 * Installs a global function to be called whenever the user activates an
2115 * email link in an about dialog.
2117 * Return value: the previous email hook.
2121 GtkAboutDialogActivateLinkFunc
2122 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2124 GDestroyNotify destroy)
2126 GtkAboutDialogActivateLinkFunc old;
2128 if (activate_email_hook_destroy != NULL)
2129 (* activate_email_hook_destroy) (activate_email_hook_data);
2131 old = activate_email_hook;
2133 activate_email_hook = func;
2134 activate_email_hook_data = data;
2135 activate_email_hook_destroy = destroy;
2141 * gtk_about_dialog_set_url_hook:
2142 * @func: a function to call when a URL link is activated.
2143 * @data: data to pass to @func
2144 * @destroy: #GDestroyNotify for @data
2146 * Installs a global function to be called whenever the user activates a
2147 * URL link in an about dialog.
2149 * Return value: the previous URL hook.
2153 GtkAboutDialogActivateLinkFunc
2154 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2156 GDestroyNotify destroy)
2158 GtkAboutDialogActivateLinkFunc old;
2160 if (activate_url_hook_destroy != NULL)
2161 (* activate_url_hook_destroy) (activate_url_hook_data);
2163 old = activate_url_hook;
2165 activate_url_hook = func;
2166 activate_url_hook_data = data;
2167 activate_url_hook_destroy = destroy;
2173 * gtk_show_about_dialog:
2174 * @parent: transient parent, or %NULL for none
2175 * @first_property_name: the name of the first property
2176 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2178 * This is a convenience function for showing an application's about box.
2179 * The constructed dialog is associated with the parent window and
2180 * reused for future invocations of this function.
2185 gtk_show_about_dialog (GtkWindow *parent,
2186 const gchar *first_property_name,
2189 static GtkWidget *global_about_dialog = NULL;
2190 GtkWidget *dialog = NULL;
2194 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2196 dialog = global_about_dialog;
2200 dialog = gtk_about_dialog_new ();
2202 g_object_ref (dialog);
2203 gtk_object_sink (GTK_OBJECT (dialog));
2205 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2207 va_start (var_args, first_property_name);
2208 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2213 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2214 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2215 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
2216 dialog, g_object_unref);
2219 global_about_dialog = dialog;
2223 gtk_window_present (GTK_WINDOW (dialog));
2226 #define __GTK_ABOUT_DIALOG_C__
2227 #include "gtkaliasdef.c"