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_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
493 button, FALSE, TRUE, 0);
494 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
495 g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
496 priv->credits_button = button;
497 priv->credits_dialog = NULL;
499 /* Add the license button */
500 button = gtk_button_new_from_stock (_("_License"));
501 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area),
502 button, FALSE, TRUE, 0);
503 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
504 g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
505 priv->license_button = button;
506 priv->license_dialog = NULL;
508 gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
510 gtk_widget_pop_composite_child ();
513 gtk_about_dialog_set_name (about, NULL);
514 gtk_about_dialog_set_logo (about, NULL);
516 /* Close dialog on user response */
517 g_signal_connect (about, "response", G_CALLBACK (close_cb), NULL);
521 gtk_about_dialog_finalize (GObject *object)
523 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
524 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
527 g_free (priv->version);
528 g_free (priv->copyright);
529 g_free (priv->comments);
530 g_free (priv->license);
531 g_free (priv->website);
532 g_free (priv->website_label);
533 g_free (priv->translator_credits);
535 g_strfreev (priv->authors);
536 g_strfreev (priv->documenters);
537 g_strfreev (priv->artists);
539 gdk_cursor_unref (priv->hand_cursor);
540 gdk_cursor_unref (priv->regular_cursor);
542 G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
546 gtk_about_dialog_set_property (GObject *object,
551 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
556 gtk_about_dialog_set_name (about, g_value_get_string (value));
559 gtk_about_dialog_set_version (about, g_value_get_string (value));
562 gtk_about_dialog_set_comments (about, g_value_get_string (value));
565 gtk_about_dialog_set_website (about, g_value_get_string (value));
567 case PROP_WEBSITE_LABEL:
568 gtk_about_dialog_set_website_label (about, g_value_get_string (value));
571 gtk_about_dialog_set_license (about, g_value_get_string (value));
574 gtk_about_dialog_set_copyright (about, g_value_get_string (value));
577 gtk_about_dialog_set_logo (about, g_value_get_object (value));
580 gtk_about_dialog_set_authors (about, (const gchar**)g_value_get_boxed (value));
582 case PROP_DOCUMENTERS:
583 gtk_about_dialog_set_documenters (about, (const gchar**)g_value_get_boxed (value));
586 gtk_about_dialog_set_artists (about, (const gchar**)g_value_get_boxed (value));
588 case PROP_TRANSLATOR_CREDITS:
589 gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
591 case PROP_LOGO_ICON_NAME:
592 gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
595 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
601 gtk_about_dialog_get_property (GObject *object,
606 GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
607 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
612 g_value_set_string (value, priv->name);
615 g_value_set_string (value, priv->version);
618 g_value_set_string (value, priv->copyright);
621 g_value_set_string (value, priv->comments);
624 g_value_set_string (value, priv->website);
626 case PROP_WEBSITE_LABEL:
627 g_value_set_string (value, priv->website_label);
630 g_value_set_string (value, priv->license);
632 case PROP_TRANSLATOR_CREDITS:
633 g_value_set_string (value, priv->translator_credits);
636 g_value_set_boxed (value, priv->authors);
638 case PROP_DOCUMENTERS:
639 g_value_set_boxed (value, priv->documenters);
642 g_value_set_boxed (value, priv->artists);
645 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
646 g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
648 g_value_set_object (value, NULL);
650 case PROP_LOGO_ICON_NAME:
651 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
653 const gchar *icon_name;
655 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
656 g_value_set_string (value, icon_name);
659 g_value_set_string (value, NULL);
662 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
668 dialog_style_set (GtkWidget *widget,
669 GtkStyle *previous_style,
674 dialog = GTK_DIALOG (widget);
676 /* Override the style properties with HIG-compliant spacings. Ugh.
677 * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
678 * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
681 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
682 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 12);
684 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
685 gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
689 gtk_about_dialog_style_set (GtkWidget *widget,
690 GtkStyle *previous_style)
692 if (GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set)
693 GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->style_set (widget, previous_style);
695 dialog_style_set (widget, previous_style, NULL);
699 * gtk_about_dialog_get_name:
700 * @about: a #GtkAboutDialog
702 * Returns the program name displayed in the about dialog.
704 * Return value: The program name. The string is owned by the about
705 * dialog and must not be modified.
709 G_CONST_RETURN gchar *
710 gtk_about_dialog_get_name (GtkAboutDialog *about)
712 GtkAboutDialogPrivate *priv;
714 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
716 priv = (GtkAboutDialogPrivate *)about->private_data;
722 update_name_version (GtkAboutDialog *about)
724 GtkAboutDialogPrivate *priv;
725 gchar *title_string, *name_string;
727 priv = (GtkAboutDialogPrivate *)about->private_data;
729 title_string = g_strdup_printf (_("About %s"), priv->name);
730 gtk_window_set_title (GTK_WINDOW (about), title_string);
731 g_free (title_string);
733 if (priv->version != NULL)
734 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>",
735 priv->name, priv->version);
737 name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>",
740 gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
742 g_free (name_string);
746 * gtk_about_dialog_set_name:
747 * @about: a #GtkAboutDialog
748 * @name: the program name
750 * Sets the name to display in the about dialog.
751 * If this is not set, it defaults to g_get_application_name().
756 gtk_about_dialog_set_name (GtkAboutDialog *about,
759 GtkAboutDialogPrivate *priv;
762 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
764 priv = (GtkAboutDialogPrivate *)about->private_data;
766 priv->name = g_strdup (name ? name : g_get_application_name ());
769 update_name_version (about);
771 g_object_notify (G_OBJECT (about), "name");
775 * gtk_about_dialog_get_version:
776 * @about: a #GtkAboutDialog
778 * Returns the version string.
780 * Return value: The version string. The string is owned by the about
781 * dialog and must not be modified.
785 G_CONST_RETURN gchar *
786 gtk_about_dialog_get_version (GtkAboutDialog *about)
788 GtkAboutDialogPrivate *priv;
790 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
792 priv = (GtkAboutDialogPrivate *)about->private_data;
794 return priv->version;
798 * gtk_about_dialog_set_version:
799 * @about: a #GtkAboutDialog
800 * @version: the version string
802 * Sets the version string to display in the about dialog.
807 gtk_about_dialog_set_version (GtkAboutDialog *about,
808 const gchar *version)
810 GtkAboutDialogPrivate *priv;
813 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
815 priv = (GtkAboutDialogPrivate *)about->private_data;
818 priv->version = version ? g_strdup (version) : NULL;
821 update_name_version (about);
823 g_object_notify (G_OBJECT (about), "version");
827 * gtk_about_dialog_get_copyright:
828 * @about: a #GtkAboutDialog
830 * Returns the copyright string.
832 * Return value: The copyright string. The string is owned by the about
833 * dialog and must not be modified.
837 G_CONST_RETURN gchar *
838 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
840 GtkAboutDialogPrivate *priv;
842 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
844 priv = (GtkAboutDialogPrivate *)about->private_data;
846 return priv->copyright;
850 * gtk_about_dialog_set_copyright:
851 * @about: a #GtkAboutDialog
852 * @copyright: the copyright string
854 * Sets the copyright string to display in the about dialog.
855 * This should be a short string of one or two lines.
860 gtk_about_dialog_set_copyright (GtkAboutDialog *about,
861 const gchar *copyright)
863 GtkAboutDialogPrivate *priv;
864 gchar *copyright_string, *tmp;
866 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
868 priv = (GtkAboutDialogPrivate *)about->private_data;
870 tmp = priv->copyright;
871 priv->copyright = copyright ? g_strdup (copyright) : NULL;
874 if (priv->copyright != NULL)
876 copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
878 gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
879 g_free (copyright_string);
881 gtk_widget_show (priv->copyright_label);
884 gtk_widget_hide (priv->copyright_label);
886 g_object_notify (G_OBJECT (about), "copyright");
890 * gtk_about_dialog_get_comments:
891 * @about: a #GtkAboutDialog
893 * Returns the comments string.
895 * Return value: The comments. The string is owned by the about
896 * dialog and must not be modified.
900 G_CONST_RETURN gchar *
901 gtk_about_dialog_get_comments (GtkAboutDialog *about)
903 GtkAboutDialogPrivate *priv;
905 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
907 priv = (GtkAboutDialogPrivate *)about->private_data;
909 return priv->comments;
913 * gtk_about_dialog_set_comments:
914 * @about: a #GtkAboutDialog
915 * @comments: a comments string
917 * Sets the comments string to display in the about
918 * dialog. This should be a short string of one or
924 gtk_about_dialog_set_comments (GtkAboutDialog *about,
925 const gchar *comments)
927 GtkAboutDialogPrivate *priv;
930 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
932 priv = (GtkAboutDialogPrivate *)about->private_data;
934 tmp = priv->comments;
937 priv->comments = g_strdup (comments);
938 gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
939 gtk_widget_show (priv->comments_label);
943 priv->comments = NULL;
944 gtk_widget_hide (priv->comments_label);
948 g_object_notify (G_OBJECT (about), "comments");
952 * gtk_about_dialog_get_license:
953 * @about: a #GtkAboutDialog
955 * Returns the license information.
957 * Return value: The license information. The string is owned by the about
958 * dialog and must not be modified.
962 G_CONST_RETURN gchar *
963 gtk_about_dialog_get_license (GtkAboutDialog *about)
965 GtkAboutDialogPrivate *priv;
967 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
969 priv = (GtkAboutDialogPrivate *)about->private_data;
971 return priv->license;
975 * gtk_about_dialog_set_license:
976 * @about: a #GtkAboutDialog
977 * @license: the license information or %NULL
979 * Sets the license information to be displayed in the secondary
980 * license dialog. If @license is %NULL, the license button is
986 gtk_about_dialog_set_license (GtkAboutDialog *about,
987 const gchar *license)
989 GtkAboutDialogPrivate *priv;
992 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
994 priv = (GtkAboutDialogPrivate *)about->private_data;
999 priv->license = g_strdup (license);
1000 gtk_widget_show (priv->license_button);
1004 priv->license = NULL;
1005 gtk_widget_hide (priv->license_button);
1009 g_object_notify (G_OBJECT (about), "license");
1013 * gtk_about_dialog_get_website:
1014 * @about: a #GtkAboutDialog
1016 * Returns the website URL.
1018 * Return value: The website URL. The string is owned by the about
1019 * dialog and must not be modified.
1023 G_CONST_RETURN gchar *
1024 gtk_about_dialog_get_website (GtkAboutDialog *about)
1026 GtkAboutDialogPrivate *priv;
1028 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1030 priv = (GtkAboutDialogPrivate *)about->private_data;
1032 return priv->website;
1036 * gtk_about_dialog_set_website:
1037 * @about: a #GtkAboutDialog
1038 * @website: a URL string starting with "http://"
1040 * Sets the URL to use for the website link.
1045 gtk_about_dialog_set_website (GtkAboutDialog *about,
1046 const gchar *website)
1048 GtkAboutDialogPrivate *priv;
1051 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1053 priv = (GtkAboutDialogPrivate *)about->private_data;
1055 tmp = priv->website;
1056 if (website != NULL)
1058 priv->website = g_strdup (website);
1059 if (activate_url_hook != NULL)
1061 g_object_set_data_full (G_OBJECT (priv->website_button),
1062 "url", g_strdup (website), g_free);
1063 if (priv->website_label == NULL)
1064 gtk_about_dialog_set_website_label (about, website);
1068 GtkWidget *hbox = priv->website_button->parent;
1069 gtk_widget_destroy (priv->website_button);
1070 priv->website_button = gtk_label_new (website);
1071 gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1072 gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1073 gtk_widget_show (priv->website_button);
1078 priv->website = NULL;
1079 g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
1080 gtk_widget_hide (priv->website_button);
1084 g_object_notify (G_OBJECT (about), "website");
1088 * gtk_about_dialog_get_website_label:
1089 * @about: a #GtkAboutDialog
1091 * Returns the label used for the website link.
1093 * Return value: The label used for the website link. The string is owned by the about
1094 * dialog and must not be modified.
1098 G_CONST_RETURN gchar *
1099 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1101 GtkAboutDialogPrivate *priv;
1103 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1105 priv = (GtkAboutDialogPrivate *)about->private_data;
1107 return priv->website_label;
1111 * gtk_about_dialog_set_website_label:
1112 * @about: a #GtkAboutDialog
1113 * @website_label: the label used for the website link
1115 * Sets the label to be used for the website link.
1116 * It defaults to the website URL.
1121 gtk_about_dialog_set_website_label (GtkAboutDialog *about,
1122 const gchar *website_label)
1124 GtkAboutDialogPrivate *priv;
1127 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1129 priv = (GtkAboutDialogPrivate *)about->private_data;
1131 tmp = priv->website_label;
1132 if (activate_url_hook != NULL)
1134 if (website_label != NULL)
1136 priv->website_label = g_strdup (website_label);
1137 set_link_button_text (GTK_WIDGET (about),
1138 priv->website_button,
1139 priv->website_label);
1140 gtk_widget_show (priv->website_button);
1144 priv->website_label = NULL;
1145 gtk_widget_hide (priv->website_button);
1150 g_object_notify (G_OBJECT (about), "website-label");
1154 * gtk_about_dialog_get_authors:
1155 * @about: a #GtkAboutDialog
1157 * Returns the string which are displayed in the authors tab
1158 * of the secondary credits dialog.
1160 * Return value: A %NULL-terminated string array containing
1161 * the authors. The array is owned by the about dialog
1162 * and must not be modified.
1166 G_CONST_RETURN gchar * G_CONST_RETURN *
1167 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1169 GtkAboutDialogPrivate *priv;
1171 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1173 priv = (GtkAboutDialogPrivate *)about->private_data;
1175 return (const gchar * const *) priv->authors;
1179 * gtk_about_dialog_set_authors:
1180 * @about: a #GtkAboutDialog
1181 * @authors: a %NULL-terminated array of strings
1183 * Sets the strings which are displayed in the authors tab
1184 * of the secondary credits dialog.
1189 gtk_about_dialog_set_authors (GtkAboutDialog *about,
1190 const gchar **authors)
1192 GtkAboutDialogPrivate *priv;
1195 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1197 priv = (GtkAboutDialogPrivate *)about->private_data;
1199 tmp = priv->authors;
1200 priv->authors = g_strdupv ((gchar **)authors);
1203 if (priv->authors != NULL)
1204 gtk_widget_show (priv->credits_button);
1206 g_object_notify (G_OBJECT (about), "authors");
1210 * gtk_about_dialog_get_documenters:
1211 * @about: a #GtkAboutDialog
1213 * Returns the string which are displayed in the documenters
1214 * tab of the secondary credits dialog.
1216 * Return value: A %NULL-terminated string array containing
1217 * the documenters. The array is owned by the about dialog
1218 * and must not be modified.
1222 G_CONST_RETURN gchar * G_CONST_RETURN *
1223 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1225 GtkAboutDialogPrivate *priv;
1227 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1229 priv = (GtkAboutDialogPrivate *)about->private_data;
1231 return (const gchar * const *)priv->documenters;
1235 * gtk_about_dialog_set_documenters:
1236 * @about: a #GtkAboutDialog
1237 * @documenters: a %NULL-terminated array of strings
1239 * Sets the strings which are displayed in the documenters tab
1240 * of the secondary credits dialog.
1245 gtk_about_dialog_set_documenters (GtkAboutDialog *about,
1246 const gchar **documenters)
1248 GtkAboutDialogPrivate *priv;
1251 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1253 priv = (GtkAboutDialogPrivate *)about->private_data;
1255 tmp = priv->documenters;
1256 priv->documenters = g_strdupv ((gchar **)documenters);
1259 if (priv->documenters != NULL)
1260 gtk_widget_show (priv->credits_button);
1262 g_object_notify (G_OBJECT (about), "documenters");
1266 * gtk_about_dialog_get_artists:
1267 * @about: a #GtkAboutDialog
1269 * Returns the string which are displayed in the artists tab
1270 * of the secondary credits dialog.
1272 * Return value: A %NULL-terminated string array containing
1273 * the artists. The array is owned by the about dialog
1274 * and must not be modified.
1278 G_CONST_RETURN gchar * G_CONST_RETURN *
1279 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1281 GtkAboutDialogPrivate *priv;
1283 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1285 priv = (GtkAboutDialogPrivate *)about->private_data;
1287 return (const gchar * const *)priv->artists;
1291 * gtk_about_dialog_set_artists:
1292 * @about: a #GtkAboutDialog
1293 * @artists: a %NULL-terminated array of strings
1295 * Sets the strings which are displayed in the artists tab
1296 * of the secondary credits dialog.
1301 gtk_about_dialog_set_artists (GtkAboutDialog *about,
1302 const gchar **artists)
1304 GtkAboutDialogPrivate *priv;
1307 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1309 priv = (GtkAboutDialogPrivate *)about->private_data;
1311 tmp = priv->artists;
1312 priv->artists = g_strdupv ((gchar **)artists);
1315 if (priv->artists != NULL)
1316 gtk_widget_show (priv->credits_button);
1318 g_object_notify (G_OBJECT (about), "artists");
1322 * gtk_about_dialog_get_translator_credits:
1323 * @about: a #GtkAboutDialog
1325 * Returns the translator credits string which is displayed
1326 * in the translators tab of the secondary credits dialog.
1328 * Return value: The translator credits string. The string is
1329 * owned by the about dialog and must not be modified.
1333 G_CONST_RETURN gchar *
1334 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1336 GtkAboutDialogPrivate *priv;
1338 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1340 priv = (GtkAboutDialogPrivate *)about->private_data;
1342 return priv->translator_credits;
1346 * gtk_about_dialog_set_translator_credits:
1347 * @about: a #GtkAboutDialog
1348 * @translator_credits: the translator credits
1350 * Sets the translator credits string which is displayed in
1351 * the translators tab of the secondary credits dialog.
1353 * The intended use for this string is to display the translator
1354 * of the language which is currently used in the user interface.
1355 * Using gettext(), a simple way to achieve that is to mark the
1356 * string for translation:
1357 * <informalexample><programlisting>
1358 * gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1359 * </programlisting></informalexample>
1360 * It is a good idea to use the customary msgid "translator-credits" for this
1361 * purpose, since translators will already know the purpose of that msgid, and
1362 * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1368 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
1369 const gchar *translator_credits)
1371 GtkAboutDialogPrivate *priv;
1374 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1376 priv = (GtkAboutDialogPrivate *)about->private_data;
1378 tmp = priv->translator_credits;
1379 priv->translator_credits = g_strdup (translator_credits);
1382 if (priv->translator_credits != NULL)
1383 gtk_widget_show (priv->credits_button);
1385 g_object_notify (G_OBJECT (about), "translator-credits");
1389 * gtk_about_dialog_get_logo:
1390 * @about: a #GtkAboutDialog
1392 * Returns the pixbuf displayed as logo in the about dialog.
1394 * Return value: the pixbuf displayed as logo. The pixbuf is
1395 * owned by the about dialog. If you want to keep a reference
1396 * to it, you have to call g_object_ref() on it.
1401 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1403 GtkAboutDialogPrivate *priv;
1405 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1407 priv = (GtkAboutDialogPrivate *)about->private_data;
1409 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1410 return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1416 icon_set_new_from_pixbufs (GList *pixbufs)
1418 GtkIconSet *icon_set = gtk_icon_set_new ();
1420 for (; pixbufs; pixbufs = pixbufs->next)
1422 GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1424 GtkIconSource *icon_source = gtk_icon_source_new ();
1425 gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1426 gtk_icon_set_add_source (icon_set, icon_source);
1427 gtk_icon_source_free (icon_source);
1434 * gtk_about_dialog_set_logo:
1435 * @about: a #GtkAboutDialog
1436 * @logo: a #GdkPixbuf, or %NULL
1438 * Sets the pixbuf to be displayed as logo in
1439 * the about dialog. If it is %NULL, the default
1440 * window icon set with gtk_window_set_default_icon ()
1446 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1449 GtkAboutDialogPrivate *priv;
1451 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1453 priv = (GtkAboutDialogPrivate *)about->private_data;
1455 g_object_freeze_notify (G_OBJECT (about));
1457 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1458 g_object_notify (G_OBJECT (about), "logo-icon-name");
1461 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1464 GList *pixbufs = gtk_window_get_default_icon_list ();
1466 if (pixbufs != NULL)
1468 GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs);
1470 gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1471 icon_set, GTK_ICON_SIZE_DIALOG);
1473 gtk_icon_set_unref (icon_set);
1474 g_list_free (pixbufs);
1478 g_object_notify (G_OBJECT (about), "logo");
1480 g_object_thaw_notify (G_OBJECT (about));
1484 * gtk_about_dialog_get_logo_icon_name:
1485 * @about: a #GtkAboutDialog
1487 * Returns the icon name displayed as logo in the about dialog.
1489 * Return value: the icon name displayed as logo. The string is
1490 * owned by the dialog. If you want to keep a reference
1491 * to it, you have to call g_strdup() on it.
1495 G_CONST_RETURN gchar *
1496 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1498 GtkAboutDialogPrivate *priv;
1499 const gchar *icon_name = NULL;
1501 g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1503 priv = (GtkAboutDialogPrivate *)about->private_data;
1505 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1506 gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1512 * gtk_about_dialog_set_logo_icon_name:
1513 * @about: a #GtkAboutDialog
1514 * @icon_name: an icon name, or %NULL
1516 * Sets the pixbuf to be displayed as logo in
1517 * the about dialog. If it is %NULL, the default
1518 * window icon set with gtk_window_set_default_icon()
1524 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1525 const gchar *icon_name)
1527 GtkAboutDialogPrivate *priv;
1529 g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1531 priv = (GtkAboutDialogPrivate *)about->private_data;
1533 g_object_freeze_notify (G_OBJECT (about));
1535 if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1536 g_object_notify (G_OBJECT (about), "logo");
1538 gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1539 GTK_ICON_SIZE_DIALOG);
1540 g_object_notify (G_OBJECT (about), "logo-icon-name");
1542 g_object_thaw_notify (G_OBJECT (about));
1546 activate_url (GtkWidget *widget,
1549 GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1550 gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1552 if (activate_url_hook != NULL)
1553 (* activate_url_hook) (about, url, activate_url_hook_data);
1557 set_link_button_text (GtkWidget *about,
1563 GdkColor *style_link_color;
1564 GdkColor link_color = { 0, 0, 0, 0xffff };
1566 gtk_widget_ensure_style (about);
1567 gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1568 if (style_link_color)
1570 link_color = *style_link_color;
1571 gdk_color_free (style_link_color);
1574 link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>",
1575 link_color.red, link_color.green, link_color.blue, text);
1577 label = gtk_bin_get_child (GTK_BIN (button));
1578 gtk_label_set_markup (GTK_LABEL (label), link);
1583 link_button_enter (GtkWidget *widget,
1584 GdkEventCrossing *event,
1585 GtkAboutDialog *about)
1587 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1588 gdk_window_set_cursor (widget->window, priv->hand_cursor);
1594 link_button_leave (GtkWidget *widget,
1595 GdkEventCrossing *event,
1596 GtkAboutDialog *about)
1598 gdk_window_set_cursor (widget->window, NULL);
1604 create_link_button (GtkWidget *about,
1612 button = gtk_button_new_with_label ("");
1613 GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1614 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1616 g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1617 set_link_button_text (about, button, text);
1619 g_signal_connect (button, "clicked", callback, data);
1620 g_signal_connect (button, "enter_notify_event",
1621 G_CALLBACK (link_button_enter), data);
1622 g_signal_connect (button, "leave_notify_event",
1623 G_CALLBACK (link_button_leave), data);
1629 follow_if_link (GtkAboutDialog *about,
1632 GSList *tags = NULL, *tagp = NULL;
1634 tags = gtk_text_iter_get_tags (iter);
1635 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1637 GtkTextTag *tag = tagp->data;
1638 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1639 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1641 if (email != NULL && activate_email_hook != NULL)
1643 (* activate_email_hook) (about, email, activate_email_hook_data);
1647 if (url != NULL && activate_url_hook != NULL)
1649 (* activate_url_hook) (about, url, activate_url_hook_data);
1655 g_slist_free (tags);
1659 credits_key_press_event (GtkWidget *text_view,
1661 GtkAboutDialog *about)
1664 GtkTextBuffer *buffer;
1666 switch (event->keyval)
1670 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1671 gtk_text_buffer_get_iter_at_mark (buffer, &iter,
1672 gtk_text_buffer_get_insert (buffer));
1673 follow_if_link (about, &iter);
1684 credits_event_after (GtkWidget *text_view,
1686 GtkAboutDialog *about)
1688 GtkTextIter start, end, iter;
1689 GtkTextBuffer *buffer;
1690 GdkEventButton *button_event;
1693 if (event->type != GDK_BUTTON_RELEASE)
1696 button_event = (GdkEventButton *)event;
1698 if (button_event->button != 1)
1701 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1703 /* we shouldn't follow a link if the user has selected something */
1704 gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1705 if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1708 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1709 GTK_TEXT_WINDOW_WIDGET,
1710 button_event->x, button_event->y, &x, &y);
1712 gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1714 follow_if_link (about, &iter);
1720 set_cursor_if_appropriate (GtkAboutDialog *about,
1721 GtkTextView *text_view,
1725 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1726 GSList *tags = NULL, *tagp = NULL;
1727 GtkTextBuffer *buffer;
1729 gboolean hovering_over_link = FALSE;
1731 buffer = gtk_text_view_get_buffer (text_view);
1733 gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1735 tags = gtk_text_iter_get_tags (&iter);
1736 for (tagp = tags; tagp != NULL; tagp = tagp->next)
1738 GtkTextTag *tag = tagp->data;
1739 gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1740 gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1742 if (email != NULL || url != NULL)
1744 hovering_over_link = TRUE;
1749 if (hovering_over_link != priv->hovering_over_link)
1751 priv->hovering_over_link = hovering_over_link;
1753 if (hovering_over_link)
1754 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1756 gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1760 g_slist_free (tags);
1764 credits_motion_notify_event (GtkWidget *text_view,
1765 GdkEventMotion *event,
1766 GtkAboutDialog *about)
1770 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1771 GTK_TEXT_WINDOW_WIDGET,
1772 event->x, event->y, &x, &y);
1774 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1776 gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1783 credits_visibility_notify_event (GtkWidget *text_view,
1784 GdkEventVisibility *event,
1785 GtkAboutDialog *about)
1787 gint wx, wy, bx, by;
1789 gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1791 gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
1792 GTK_TEXT_WINDOW_WIDGET,
1795 set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1801 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1803 gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1804 &widget->style->bg[GTK_STATE_NORMAL]);
1808 add_credits_page (GtkAboutDialog *about,
1809 GtkWidget *notebook,
1814 gchar *q0, *q1, *q2, *r1, *r2;
1815 GtkWidget *sw, *view;
1816 GtkTextBuffer *buffer;
1817 gboolean linkify_email, linkify_urls;
1818 GdkColor *style_link_color;
1819 GdkColor link_color = { 0, 0, 0, 0xffff };
1821 linkify_email = (activate_email_hook != NULL);
1822 linkify_urls = (activate_url_hook != NULL);
1824 gtk_widget_ensure_style (GTK_WIDGET (about));
1825 gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1826 if (style_link_color)
1828 link_color = *style_link_color;
1829 gdk_color_free (style_link_color);
1832 view = gtk_text_view_new ();
1833 g_signal_connect_object (about, "style_set",
1834 G_CALLBACK (text_view_style_set), view, 0);
1836 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1837 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1838 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1840 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1841 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1843 g_signal_connect (view, "key-press-event",
1844 G_CALLBACK (credits_key_press_event), about);
1845 g_signal_connect (view, "event-after",
1846 G_CALLBACK (credits_event_after), about);
1847 g_signal_connect (view, "motion-notify-event",
1848 G_CALLBACK (credits_motion_notify_event), about);
1849 g_signal_connect (view, "visibility-notify-event",
1850 G_CALLBACK (credits_visibility_notify_event), about);
1852 sw = gtk_scrolled_window_new (NULL, NULL);
1853 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1855 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1856 GTK_POLICY_AUTOMATIC,
1857 GTK_POLICY_AUTOMATIC);
1858 gtk_container_add (GTK_CONTAINER (sw), view);
1860 gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
1861 sw, gtk_label_new (title));
1865 gtk_widget_hide (view);
1869 gtk_widget_show (view);
1871 for (p = people; *p; p++)
1876 q1 = linkify_email ? strchr (q0, '<') : NULL;
1877 q2 = q1 ? strchr (q1, '>') : NULL;
1878 r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1881 r2 = strpbrk (r1, " \n\t");
1883 r2 = strchr (r1, '\0');
1888 if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
1901 gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1902 gtk_text_buffer_get_end_iter (buffer, &end);
1910 link_type = "email";
1915 link = g_strndup (q1, q2 - q1);
1916 tag = gtk_text_buffer_create_tag (buffer, NULL,
1917 "foreground_gdk", &link_color,
1918 "underline", PANGO_UNDERLINE_SINGLE,
1920 g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1921 gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1927 gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1933 gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1938 display_credits_dialog (GtkWidget *button,
1941 GtkAboutDialog *about = (GtkAboutDialog *)data;
1942 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1943 GtkWidget *dialog, *notebook;
1945 if (priv->credits_dialog != NULL)
1947 gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1951 dialog = gtk_dialog_new_with_buttons (_("Credits"),
1953 GTK_DIALOG_DESTROY_WITH_PARENT,
1954 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1956 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1958 priv->credits_dialog = dialog;
1959 gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1960 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1962 gtk_window_set_modal (GTK_WINDOW (dialog),
1963 gtk_window_get_modal (GTK_WINDOW (about)));
1965 g_signal_connect (dialog, "response",
1966 G_CALLBACK (gtk_widget_destroy), dialog);
1967 g_signal_connect (dialog, "destroy",
1968 G_CALLBACK (gtk_widget_destroyed),
1969 &(priv->credits_dialog));
1970 g_signal_connect (dialog, "style_set",
1971 G_CALLBACK (dialog_style_set), NULL);
1973 notebook = gtk_notebook_new ();
1974 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1976 if (priv->authors != NULL)
1977 add_credits_page (about, notebook, _("Written by"), priv->authors);
1979 if (priv->documenters != NULL)
1980 add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1982 /* Don't show an untranslated gettext msgid */
1983 if (priv->translator_credits != NULL &&
1984 strcmp (priv->translator_credits, "translator_credits") &&
1985 strcmp (priv->translator_credits, "translator-credits"))
1987 gchar *translators[2];
1989 translators[0] = priv->translator_credits;
1990 translators[1] = NULL;
1992 add_credits_page (about, notebook, _("Translated by"), translators);
1995 if (priv->artists != NULL)
1996 add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1998 gtk_widget_show_all (dialog);
2002 set_policy (GtkWidget *sw)
2004 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2005 GTK_POLICY_AUTOMATIC,
2006 GTK_POLICY_AUTOMATIC);
2010 display_license_dialog (GtkWidget *button,
2013 GtkAboutDialog *about = (GtkAboutDialog *)data;
2014 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2015 GtkWidget *dialog, *view, *sw;
2017 if (priv->license_dialog != NULL)
2019 gtk_window_present (GTK_WINDOW (priv->license_dialog));
2023 dialog = gtk_dialog_new_with_buttons (_("License"),
2025 GTK_DIALOG_DESTROY_WITH_PARENT,
2026 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2028 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2029 priv->license_dialog = dialog;
2030 gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
2031 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
2033 gtk_window_set_modal (GTK_WINDOW (dialog),
2034 gtk_window_get_modal (GTK_WINDOW (about)));
2036 g_signal_connect (dialog, "response",
2037 G_CALLBACK (gtk_widget_destroy), dialog);
2038 g_signal_connect (dialog, "destroy",
2039 G_CALLBACK (gtk_widget_destroyed),
2040 &(priv->license_dialog));
2041 g_signal_connect (dialog, "style_set",
2042 G_CALLBACK (dialog_style_set), NULL);
2044 sw = gtk_scrolled_window_new (NULL, NULL);
2045 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
2047 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
2049 GTK_POLICY_AUTOMATIC);
2050 g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL);
2051 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
2053 view = gtk_text_view_new ();
2054 gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
2057 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
2058 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
2060 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
2061 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
2063 gtk_container_add (GTK_CONTAINER (sw), view);
2065 gtk_widget_show_all (dialog);
2069 close_cb (GtkAboutDialog *about)
2071 GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
2073 if (priv->license_dialog != NULL)
2075 gtk_widget_destroy (priv->license_dialog);
2076 priv->license_dialog = NULL;
2079 if (priv->credits_dialog != NULL)
2081 gtk_widget_destroy (priv->credits_dialog);
2082 priv->credits_dialog = NULL;
2085 gtk_widget_hide (GTK_WIDGET (about));
2090 * gtk_about_dialog_new:
2092 * Creates a new #GtkAboutDialog.
2094 * Returns: a newly created #GtkAboutDialog
2099 gtk_about_dialog_new (void)
2101 GtkAboutDialog *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL);
2103 return GTK_WIDGET (dialog);
2107 * gtk_about_dialog_set_email_hook:
2108 * @func: a function to call when an email link is activated.
2109 * @data: data to pass to @func
2110 * @destroy: #GDestroyNotify for @data
2112 * Installs a global function to be called whenever the user activates an
2113 * email link in an about dialog.
2115 * Return value: the previous email hook.
2119 GtkAboutDialogActivateLinkFunc
2120 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
2122 GDestroyNotify destroy)
2124 GtkAboutDialogActivateLinkFunc old;
2126 if (activate_email_hook_destroy != NULL)
2127 (* activate_email_hook_destroy) (activate_email_hook_data);
2129 old = activate_email_hook;
2131 activate_email_hook = func;
2132 activate_email_hook_data = data;
2133 activate_email_hook_destroy = destroy;
2139 * gtk_about_dialog_set_url_hook:
2140 * @func: a function to call when a URL link is activated.
2141 * @data: data to pass to @func
2142 * @destroy: #GDestroyNotify for @data
2144 * Installs a global function to be called whenever the user activates a
2145 * URL link in an about dialog.
2147 * Return value: the previous URL hook.
2151 GtkAboutDialogActivateLinkFunc
2152 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
2154 GDestroyNotify destroy)
2156 GtkAboutDialogActivateLinkFunc old;
2158 if (activate_url_hook_destroy != NULL)
2159 (* activate_url_hook_destroy) (activate_url_hook_data);
2161 old = activate_url_hook;
2163 activate_url_hook = func;
2164 activate_url_hook_data = data;
2165 activate_url_hook_destroy = destroy;
2171 * gtk_show_about_dialog:
2172 * @parent: transient parent, or %NULL for none
2173 * @first_property_name: the name of the first property
2174 * @Varargs: value of first property, followed by more properties, %NULL-terminated
2176 * This is a convenience function for showing an application's about box.
2177 * The constructed dialog is associated with the parent window and
2178 * reused for future invocations of this function.
2183 gtk_show_about_dialog (GtkWindow *parent,
2184 const gchar *first_property_name,
2187 static GtkWidget *global_about_dialog = NULL;
2188 GtkWidget *dialog = NULL;
2192 dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2194 dialog = global_about_dialog;
2198 dialog = gtk_about_dialog_new ();
2200 g_object_ref (dialog);
2201 gtk_object_sink (GTK_OBJECT (dialog));
2203 g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2205 va_start (var_args, first_property_name);
2206 g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2211 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2212 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2213 g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog",
2214 dialog, g_object_unref);
2217 global_about_dialog = dialog;
2221 gtk_window_present (GTK_WINDOW (dialog));
2224 #define __GTK_ABOUT_DIALOG_C__
2225 #include "gtkaliasdef.c"