]> Pileus Git - ~andy/gtk/blob - gtk/gtkaboutdialog.c
Documentation updates.
[~andy/gtk] / gtk / gtkaboutdialog.c
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>
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 /*
23  * Author: Anders Carlsson <andersca@gnome.org>
24  *
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/. 
29  */
30
31 #include <config.h>
32
33 #include <gdk/gdkkeysyms.h>
34
35 #include "gtkalias.h"
36
37 #include "gtkaboutdialog.h"
38 #include "gtkbutton.h"
39 #include "gtkbbox.h"
40 #include "gtkdialog.h"
41 #include "gtkhbox.h"
42 #include "gtkimage.h"
43 #include "gtklabel.h"
44 #include "gtkmarshalers.h"
45 #include "gtknotebook.h"
46 #include "gtkscrolledwindow.h"
47 #include "gtkstock.h"
48 #include "gtktextview.h"
49 #include "gtkvbox.h"
50 #include "gtkviewport.h"
51 #include "gtkiconfactory.h"
52 #include "gtkintl.h"
53
54 #include <string.h>
55
56 typedef struct _GtkAboutDialogPrivate GtkAboutDialogPrivate;
57 struct _GtkAboutDialogPrivate 
58 {
59   gchar *name;
60   gchar *version;
61   gchar *copyright;
62   gchar *comments;
63   gchar *website;
64   gchar *website_label;
65   gchar *translator_credits;
66   gchar *license;
67   
68   gchar **authors;
69   gchar **documenters;
70   gchar **artists;
71   
72   GtkWidget *logo_image;
73   GtkWidget *name_label;
74   GtkWidget *comments_label;
75   GtkWidget *copyright_label;
76   GtkWidget *website_button;
77
78   GtkWidget *credits_button;
79   GtkWidget *credits_dialog;
80   GtkWidget *license_button;
81   GtkWidget *license_dialog;
82   
83   GdkCursor *hand_cursor;
84   GdkCursor *regular_cursor;
85   gboolean hovering_over_link;
86 };
87
88 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
89
90
91 enum 
92 {
93   PROP_0,
94   PROP_NAME,
95   PROP_VERSION,
96   PROP_COPYRIGHT,
97   PROP_COMMENTS,
98   PROP_WEBSITE,
99   PROP_WEBSITE_LABEL,
100   PROP_LICENSE,
101   PROP_AUTHORS,
102   PROP_DOCUMENTERS,
103   PROP_TRANSLATOR_CREDITS,
104   PROP_ARTISTS,
105   PROP_LOGO,
106   PROP_LOGO_ICON_NAME
107 };
108
109 static void                 gtk_about_dialog_finalize       (GObject            *object);
110 static void                 gtk_about_dialog_get_property   (GObject            *object,
111                                                              guint               prop_id,
112                                                              GValue             *value,
113                                                              GParamSpec         *pspec);
114 static void                 gtk_about_dialog_set_property   (GObject            *object,
115                                                              guint               prop_id,
116                                                              const GValue       *value,
117                                                              GParamSpec         *pspec);
118 static void                 update_name_version             (GtkAboutDialog     *about);
119 static GtkIconSet *         icon_set_new_from_pixbufs       (GList              *pixbufs);
120 static void                 activate_url                    (GtkWidget          *widget,
121                                                              gpointer            data);
122 static void                 set_link_button_text            (GtkWidget          *about,
123                                                              GtkWidget          *button,
124                                                              gchar              *text);
125 static GtkWidget *          create_link_button              (GtkWidget          *about,
126                                                              gchar              *text,
127                                                              gchar              *url,
128                                                              GCallback           callback,
129                                                              gpointer            data);
130 static void                 follow_if_link                  (GtkAboutDialog     *about,
131                                                              GtkTextIter        *iter);
132 static void                 set_cursor_if_appropriate       (GtkAboutDialog     *about,
133                                                              GtkTextView        *text_view,
134                                                              gint                x,
135                                                              gint                y);
136 static void                 add_credits_page                (GtkAboutDialog     *about,
137                                                              GtkWidget          *notebook,
138                                                              gchar              *title,
139                                                              gchar             **people);
140 static gboolean             credits_key_press_event         (GtkWidget          *text_view,
141                                                              GdkEventKey        *event,
142                                                              GtkAboutDialog     *about);
143 static gboolean             credits_event_after             (GtkWidget          *text_view,
144                                                              GdkEvent           *event,
145                                                              GtkAboutDialog     *about);
146 static gboolean             credits_motion_notify_event     (GtkWidget          *text_view,
147                                                              GdkEventMotion     *event,
148                                                              GtkAboutDialog     *about);
149 static gboolean             credits_visibility_notify_event (GtkWidget          *text_view,
150                                                              GdkEventVisibility *event,
151                                                              GtkAboutDialog     *about);
152 static void                 display_credits_dialog          (GtkWidget          *button,
153                                                              gpointer            data);
154 static void                 display_license_dialog          (GtkWidget          *button,
155                                                              gpointer            data);
156                                  
157                                                                        
158 static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
159 static gpointer activate_email_hook_data = NULL;
160 static GDestroyNotify activate_email_hook_destroy = NULL;
161
162 static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
163 static gpointer activate_url_hook_data = NULL;
164 static GDestroyNotify activate_url_hook_destroy = NULL;
165
166 G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG);
167
168 static void
169 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
170 {
171   GObjectClass *object_class;
172   GtkWidgetClass *widget_class;
173   GtkDialogClass *dialog_class;
174         
175   object_class = (GObjectClass *)klass;
176   widget_class = (GtkWidgetClass *)klass;
177   dialog_class = (GtkDialogClass *)klass;
178         
179   object_class->set_property = gtk_about_dialog_set_property;
180   object_class->get_property = gtk_about_dialog_get_property;
181
182   object_class->finalize = gtk_about_dialog_finalize;
183
184   /**
185    * GtkAboutDialog:name:
186    *
187    * The name of the program. 
188    * If this is not set, it defaults to g_get_application_name().
189    *
190    * Since: 2.6
191    */  
192   g_object_class_install_property (object_class,
193                                    PROP_NAME,
194                                    g_param_spec_string ("name",
195                                                         P_("Program name"),
196                                                         P_("The name of the program. If this is not set, it defaults to g_get_application_name()"),
197                                                         NULL,
198                                                         G_PARAM_READWRITE));
199
200   /**
201    * GtkAboutDialog:version:
202    *
203    * The version of the program. 
204    *
205    * Since: 2.6
206    */  
207   g_object_class_install_property (object_class,
208                                    PROP_VERSION,
209                                    g_param_spec_string ("version",
210                                                         P_("Program version"),
211                                                         P_("The version of the program"),
212                                                         NULL,
213                                                         G_PARAM_READWRITE));
214
215   /**
216    * GtkAboutDialog:copyright:
217    *
218    * Copyright information for the program. 
219    *
220    * Since: 2.6
221    */  
222   g_object_class_install_property (object_class,
223                                    PROP_COPYRIGHT,
224                                    g_param_spec_string ("copyright",
225                                                         P_("Copyright string"),
226                                                         P_("Copyright information for the program"),
227                                                         NULL,
228                                                         G_PARAM_READWRITE));
229         
230
231   /**
232    * GtkAboutDialog:comments:
233    *
234    * Comments about the program. This string is displayed in a label 
235    * in the main dialog, thus it should be a short explanation of
236    * the main purpose of the program, not a detailed list of features.
237    *
238    * Since: 2.6
239    */  
240   g_object_class_install_property (object_class,
241                                    PROP_COMMENTS,
242                                    g_param_spec_string ("comments",
243                                                         P_("Comments string"),
244                                                         P_("Comments about the program"),
245                                                         NULL,
246                                                         G_PARAM_READWRITE));
247
248   /**
249    * GtkAboutDialog:license:
250    *
251    * The license of the program. This string is displayed in a 
252    * text view in a secondary dialog, therefore it is fine to use
253    * a long multi-paragraph text.
254    *
255    * Since: 2.6
256    */  
257   g_object_class_install_property (object_class,
258                                    PROP_LICENSE,
259                                    g_param_spec_string ("license",
260                                                         _("License"),
261                                                         _("The license of the program"),
262                                                         NULL,
263                                                         G_PARAM_READWRITE));
264
265   /**
266    * GtkAboutDialog:website:
267    *
268    * The URL for the link to the website of the program. 
269    * This should be a string starting with "http://.
270    *
271    * Since: 2.6
272    */  
273   g_object_class_install_property (object_class,
274                                    PROP_WEBSITE,
275                                    g_param_spec_string ("website",
276                                                         P_("Website URL"),
277                                                         P_("The URL for the link to the website of the program"),
278                                                         NULL,
279                                                         G_PARAM_READWRITE));
280
281   /**
282    * GtkAboutDialog:website-label:
283    *
284    * The label for the link to the website of the program. If this is not set, 
285    * it defaults to the URL specified in the 
286    * <link linkend="GtkAboutDialog--website">website</link> property.
287    *
288    * Since: 2.6
289    */  
290   g_object_class_install_property (object_class,
291                                    PROP_WEBSITE_LABEL,
292                                    g_param_spec_string ("website_label",
293                                                         P_("Website label"),
294                                                         P_("The label for the link to the website of the program. If this is not set, it defaults to the URL"),
295                                                         NULL,
296                                                         G_PARAM_READWRITE));
297
298   /**
299    * GtkAboutDialog:authors:
300    *
301    * The authors of the program, as a %NULL-terminated array of strings.
302    * Each string may contain email addresses and URLs, which will be displayed
303    * as links, see the introduction for more details.
304    *
305    * Since: 2.6
306    */  
307   g_object_class_install_property (object_class,
308                                    PROP_AUTHORS,
309                                    g_param_spec_boxed ("authors",
310                                                        P_("Authors"),
311                                                        P_("List of authors of the program"),
312                                                        G_TYPE_STRV,
313                                                        G_PARAM_READWRITE));
314
315   /**
316    * GtkAboutDialog:documenters:
317    *
318    * The people documenting the program, as a %NULL-terminated array of strings.
319    * Each string may contain email addresses and URLs, which will be displayed
320    * as links, see the introduction for more details.
321    *
322    * Since: 2.6
323    */  
324   g_object_class_install_property (object_class,
325                                    PROP_DOCUMENTERS,
326                                    g_param_spec_boxed ("documenters",
327                                                        P_("Documenters"),
328                                                        P_("List of people documenting the program"),
329                                                        G_TYPE_STRV,
330                                                        G_PARAM_READWRITE));
331
332   /**
333    * GtkAboutDialog:artists:
334    *
335    * The people who contributed artwork to the program, as a %NULL-terminated array of strings.
336    * Each string may contain email addresses and URLs, which will be displayed
337    * as links, see the introduction for more details.
338    *
339    * Since: 2.6
340    */  
341   g_object_class_install_property (object_class,
342                                    PROP_ARTISTS,
343                                    g_param_spec_boxed ("artists",
344                                                        P_("Artists"),
345                                                        P_("List of people who have contributed artwork to the program"),
346                                                        G_TYPE_STRV,
347                                                        G_PARAM_READWRITE));
348
349
350   /**
351    * GtkAboutDialog:translator-credits:
352    *
353    * Credits to the translators. This string should be marked as translatable.
354    * The string may contain email addresses and URLs, which will be displayed
355    * as links, see the introduction for more details.
356    *
357    * Since: 2.6
358    */  
359   g_object_class_install_property (object_class,
360                                    PROP_TRANSLATOR_CREDITS,
361                                    g_param_spec_string ("translator_credits",
362                                                         P_("Translator credits"),
363                                                         P_("Credits to the translators. This string should be marked as translatable"),
364                                                         NULL,
365                                                         G_PARAM_READWRITE));
366         
367   /**
368    * GtkAboutDialog:logo:
369    *
370    * A logo for the about box. If this is not set, it defaults to 
371    * gtk_window_get_default_icon_list().
372    *
373    * Since: 2.6
374    */  
375   g_object_class_install_property (object_class,
376                                    PROP_LOGO,
377                                    g_param_spec_object ("logo",
378                                                         P_("Logo"),
379                                                         P_("A logo for the about box. If this is not set, it defaults to gtk_window_get_default_icon_list()"),
380                                                         GDK_TYPE_PIXBUF,
381                                                         G_PARAM_READWRITE));
382
383   /**
384    * GtkAboutDialog:logo-icon-name:
385    *
386    * A named icon to use as the logo for the about box. This property
387    * overrides the <link linkend="GtkAboutDialog--logo">logo</link> property.
388    *
389    * Since: 2.6
390    */  
391   g_object_class_install_property (object_class,
392                                    PROP_LOGO_ICON_NAME,
393                                    g_param_spec_string ("logo_icon_name",
394                                                         P_("Logo Icon Name"),
395                                                         P_("A named icon to use as the logo for the about box."),
396                                                         NULL,
397                                                         G_PARAM_READWRITE));
398
399   /* Style properties */
400   gtk_widget_class_install_style_property (widget_class,
401                                            g_param_spec_boxed ("link_color",
402                                                                P_("Link Color"),
403                                                                P_("Color of hyperlinks"),
404                                                                GDK_TYPE_COLOR,
405                                                                G_PARAM_READABLE));
406
407   g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
408 }
409
410 static void
411 gtk_about_dialog_init (GtkAboutDialog *about)
412 {
413   GtkAboutDialogPrivate *priv;
414   GtkWidget *vbox, *hbox, *button;
415
416   /* Data */
417   priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
418   about->private_data = priv;
419
420   priv->name = NULL;
421   priv->version = NULL;
422   priv->copyright = NULL;
423   priv->comments = NULL;
424   priv->website = NULL;
425   priv->website_label = NULL;
426   priv->translator_credits = NULL;
427   priv->authors = NULL;
428   priv->documenters = NULL;
429   priv->artists = NULL;
430
431   priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
432   priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
433   priv->hovering_over_link = FALSE;
434
435   gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE);
436   
437   /* Widgets */
438   gtk_widget_push_composite_child ();
439   vbox = gtk_vbox_new (FALSE, 8);
440   gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
441
442   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about)->vbox), vbox, TRUE, TRUE, 0);
443
444   priv->logo_image = gtk_image_new ();
445   gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
446
447   priv->name_label = gtk_label_new (NULL);
448   gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
449   gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
450   gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
451
452   priv->comments_label = gtk_label_new (NULL);
453   gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
454   gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
455   gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
456   gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0);
457
458   priv->copyright_label = gtk_label_new (NULL);
459   gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);   
460   gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
461   gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0);
462
463   button = create_link_button (GTK_WIDGET (about), "", "", 
464                                G_CALLBACK (activate_url), about);
465
466   hbox = gtk_hbox_new (TRUE, 0);
467   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
468   gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0); 
469   priv->website_button = button;
470   
471   gtk_widget_show (vbox);
472   gtk_widget_show (priv->logo_image);
473   gtk_widget_show (priv->name_label);
474   gtk_widget_show (hbox);
475
476   /* Add the OK button */
477   gtk_dialog_add_button (GTK_DIALOG (about), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
478   gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CLOSE);
479
480   /* Add the credits button */
481   button = gtk_button_new_from_stock (_("_Credits"));
482   gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area), 
483                     button, FALSE, TRUE, 0); 
484   gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
485   g_signal_connect (button, "clicked", G_CALLBACK (display_credits_dialog), about);
486   priv->credits_button = button;
487   priv->credits_dialog = NULL;
488
489   /* Add the license button */
490   button = gtk_button_new_from_stock (_("_License"));
491   gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area), 
492                     button, FALSE, TRUE, 0); 
493   gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (about)->action_area), button, TRUE);
494   g_signal_connect (button, "clicked", G_CALLBACK (display_license_dialog), about);
495   priv->license_button = button;
496   priv->license_dialog = NULL;
497
498   gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
499
500   gtk_widget_pop_composite_child ();
501 }
502
503 static void
504 gtk_about_dialog_finalize (GObject *object)
505 {
506   GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
507   GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
508
509   g_free (priv->name);
510   g_free (priv->version);
511   g_free (priv->copyright);
512   g_free (priv->comments);
513   g_free (priv->license);
514   g_free (priv->website);
515   g_free (priv->website_label);
516   g_free (priv->translator_credits);
517
518   g_strfreev (priv->authors);
519   g_strfreev (priv->documenters);
520   g_strfreev (priv->artists);
521
522   gdk_cursor_unref (priv->hand_cursor);
523   gdk_cursor_unref (priv->regular_cursor);
524
525   G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
526 }
527
528 static void
529 gtk_about_dialog_set_property (GObject      *object, 
530                                guint         prop_id, 
531                                const GValue *value, 
532                                GParamSpec   *pspec)
533 {
534   GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
535
536   switch (prop_id) 
537     {
538     case PROP_NAME:
539       gtk_about_dialog_set_name (about, g_value_get_string (value));
540       break;
541     case PROP_VERSION:
542       gtk_about_dialog_set_version (about, g_value_get_string (value));
543       break;
544     case PROP_COMMENTS:
545       gtk_about_dialog_set_comments (about, g_value_get_string (value));
546       break;
547     case PROP_WEBSITE:
548       gtk_about_dialog_set_website (about, g_value_get_string (value));
549       break;
550     case PROP_WEBSITE_LABEL:
551       gtk_about_dialog_set_website_label (about, g_value_get_string (value));
552       break;
553     case PROP_LICENSE:
554       gtk_about_dialog_set_license (about, g_value_get_string (value));
555       break;
556     case PROP_COPYRIGHT:
557       gtk_about_dialog_set_copyright (about, g_value_get_string (value));
558       break;
559     case PROP_LOGO:
560       gtk_about_dialog_set_logo (about, g_value_get_object (value));
561       break; 
562     case PROP_AUTHORS:
563       gtk_about_dialog_set_authors (about, (gchar**)g_value_get_boxed (value));
564       break;
565     case PROP_DOCUMENTERS:
566       gtk_about_dialog_set_documenters (about, (gchar**)g_value_get_boxed (value));
567       break;    
568     case PROP_ARTISTS:
569       gtk_about_dialog_set_artists (about, (gchar**)g_value_get_boxed (value));
570       break;    
571     case PROP_TRANSLATOR_CREDITS:
572       gtk_about_dialog_set_translator_credits (about, g_value_get_string (value));
573       break;
574     case PROP_LOGO_ICON_NAME:
575       gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value));
576       break;
577     default:
578       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
579       break;
580     }
581 }
582
583 static void
584 gtk_about_dialog_get_property (GObject    *object, 
585                                guint       prop_id, 
586                                GValue     *value, 
587                                GParamSpec *pspec)
588 {
589   GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
590   GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
591         
592   switch (prop_id) 
593     {
594     case PROP_NAME:
595       g_value_set_string (value, priv->name);
596       break;
597     case PROP_VERSION:
598       g_value_set_string (value, priv->version);
599       break;
600     case PROP_COPYRIGHT:
601       g_value_set_string (value, priv->copyright);
602       break;
603     case PROP_COMMENTS:
604       g_value_set_string (value, priv->comments);
605       break;
606     case PROP_WEBSITE:
607       g_value_set_string (value, priv->website);
608       break;
609     case PROP_WEBSITE_LABEL:
610       g_value_set_string (value, priv->website_label);
611       break;
612     case PROP_LICENSE:
613       g_value_set_string (value, priv->license);
614       break;
615     case PROP_TRANSLATOR_CREDITS:
616       g_value_set_string (value, priv->translator_credits);
617       break;
618     case PROP_AUTHORS:
619       g_value_set_boxed (value, priv->authors);
620       break;
621     case PROP_DOCUMENTERS:
622       g_value_set_boxed (value, priv->documenters);
623       break;
624     case PROP_ARTISTS:
625       g_value_set_boxed (value, priv->artists);
626       break;
627     case PROP_LOGO:
628       if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
629         g_value_set_object (value, gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image)));
630       else
631         g_value_set_object (value, NULL);
632       break;
633     case PROP_LOGO_ICON_NAME:
634       if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
635         {
636           const gchar *icon_name;
637
638           gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
639           g_value_set_string (value, icon_name);
640         }
641       else
642         g_value_set_string (value, NULL);
643       break;
644     default:
645       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
646       break;
647     }
648 }
649
650 /**
651  * gtk_about_dialog_get_name:
652  * @about: a #GtkAboutDialog
653  * 
654  * Returns the program name displayed in the about dialog.
655  * 
656  * Return value: The program name. The string is owned by the about
657  *  dialog and must not be modified.
658  *
659  * Since: 2.6
660  **/
661 G_CONST_RETURN gchar *
662 gtk_about_dialog_get_name (GtkAboutDialog *about)
663 {
664   GtkAboutDialogPrivate *priv;
665   
666   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
667
668   priv = (GtkAboutDialogPrivate *)about->private_data;
669
670   return priv->name;
671 }
672
673 static void
674 update_name_version (GtkAboutDialog *about)
675 {
676   GtkAboutDialogPrivate *priv;
677   gchar *title_string, *name_string;
678
679   priv = (GtkAboutDialogPrivate *)about->private_data;
680
681   title_string = g_strdup_printf (_("About %s"), priv->name);
682   gtk_window_set_title (GTK_WINDOW (about), title_string);
683   g_free (title_string);
684
685   if (priv->version != NULL) 
686     name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", 
687                                              priv->name, priv->version);
688   else
689     name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>", 
690                                            priv->name);
691
692   gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string);
693
694   g_free (name_string);
695 }
696
697 /**
698  * gtk_about_dialog_set_name:
699  * @about: a #GtkAboutDialog
700  * @name: the program name
701  *
702  * Sets the name to display in the about dialog. 
703  * If this is not set, it defaults to g_get_application_name().
704  * 
705  * Since: 2.6
706  **/
707 void
708 gtk_about_dialog_set_name (GtkAboutDialog *about, 
709                            const gchar    *name)
710 {
711   GtkAboutDialogPrivate *priv;
712   gchar *tmp;
713
714   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
715         
716   priv = (GtkAboutDialogPrivate *)about->private_data;
717   tmp = priv->name;
718   priv->name = g_strdup (name ? name : g_get_application_name ());
719   g_free (tmp);
720
721   update_name_version (about);
722
723   g_object_notify (G_OBJECT (about), "name");
724 }
725
726 /**
727  * gtk_about_dialog_get_version:
728  * @about: a #GtkAboutDialog
729  * 
730  * Returns the version string.
731  * 
732  * Return value: The version string. The string is owned by the about
733  *  dialog and must not be modified.
734  *
735  * Since: 2.6
736  **/
737 G_CONST_RETURN gchar *
738 gtk_about_dialog_get_version (GtkAboutDialog *about)
739 {
740   GtkAboutDialogPrivate *priv;
741   
742   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
743
744   priv = (GtkAboutDialogPrivate *)about->private_data;
745
746   return priv->version;
747 }
748
749 /**
750  * gtk_about_dialog_set_version:
751  * @about: a #GtkAboutDialog
752  * @version: the version string 
753  *
754  * Sets the version string to display in the about dialog.
755  * 
756  * Since: 2.6
757  **/
758 void
759 gtk_about_dialog_set_version (GtkAboutDialog *about, 
760                               const gchar    *version)
761 {
762   GtkAboutDialogPrivate *priv;
763   gchar *tmp;
764
765   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
766
767   priv = (GtkAboutDialogPrivate *)about->private_data;
768   
769   tmp = priv->version;
770   priv->version = version ? g_strdup (version) : NULL;
771   g_free (tmp);
772
773   update_name_version (about);
774
775   g_object_notify (G_OBJECT (about), "version");
776 }
777
778 /**
779  * gtk_about_dialog_get_copyright:
780  * @about: a #GtkAboutDialog
781  * 
782  * Returns the copyright string.
783  * 
784  * Return value: The copyright string. The string is owned by the about
785  *  dialog and must not be modified.
786  *
787  * Since: 2.6
788  **/
789 G_CONST_RETURN gchar *
790 gtk_about_dialog_get_copyright (GtkAboutDialog *about)
791 {
792   GtkAboutDialogPrivate *priv;
793   
794   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
795
796   priv = (GtkAboutDialogPrivate *)about->private_data;
797
798   return priv->copyright;
799 }
800
801 /**
802  * gtk_about_dialog_set_copyright:
803  * @about: a #GtkAboutDialog
804  * @copyright: the copyright string
805  * 
806  * Sets the copyright string to display in the about dialog.
807  * This should be a short string of one or two lines. 
808  *
809  * Since: 2.6
810  **/
811 void
812 gtk_about_dialog_set_copyright (GtkAboutDialog *about, 
813                                 const gchar    *copyright)
814 {
815   GtkAboutDialogPrivate *priv;
816   gchar *copyright_string, *tmp;
817
818   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
819
820   priv = (GtkAboutDialogPrivate *)about->private_data;
821         
822   tmp = priv->copyright;
823   priv->copyright = copyright ? g_strdup (copyright) : NULL;
824   g_free (tmp);
825   
826   if (priv->copyright != NULL) 
827     {
828       copyright_string = g_markup_printf_escaped ("<span size=\"small\">%s</span>", 
829                                                   priv->copyright);
830       gtk_label_set_markup (GTK_LABEL (priv->copyright_label), copyright_string);
831       g_free (copyright_string);
832   
833       gtk_widget_show (priv->copyright_label);
834     }
835   else 
836     gtk_widget_hide (priv->copyright_label);
837   
838   g_object_notify (G_OBJECT (about), "copyright");
839 }
840
841 /**
842  * gtk_about_dialog_get_comments:
843  * @about: a #GtkAboutDialog
844  * 
845  * Returns the comments string.
846  * 
847  * Return value: The comments. The string is owned by the about
848  *  dialog and must not be modified.
849  *
850  * Since: 2.6
851  **/
852 G_CONST_RETURN gchar *
853 gtk_about_dialog_get_comments (GtkAboutDialog *about)
854 {
855   GtkAboutDialogPrivate *priv;
856   
857   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
858
859   priv = (GtkAboutDialogPrivate *)about->private_data;
860
861   return priv->comments;
862 }
863
864 /**
865  * gtk_about_dialog_set_comments:
866  * @about: a #GtkAboutDialog
867  * @comments: a comments string
868  * 
869  * Sets the comments string to display in the about 
870  * dialog. This should be a short string of one or
871  * two lines.
872  *
873  * Since: 2.6
874  **/
875 void
876 gtk_about_dialog_set_comments (GtkAboutDialog *about, 
877                                const gchar    *comments)
878 {
879   GtkAboutDialogPrivate *priv;
880   gchar *tmp;
881
882   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
883
884   priv = (GtkAboutDialogPrivate *)about->private_data;
885   
886   tmp = priv->comments;
887   if (comments) 
888     {
889       priv->comments = g_strdup (comments);
890       gtk_label_set_text (GTK_LABEL (priv->comments_label), priv->comments);
891       gtk_widget_show (priv->comments_label);
892     }
893   else
894     {
895       priv->comments = NULL;
896       gtk_widget_hide (priv->comments_label);
897     }
898   g_free (tmp);
899
900   g_object_notify (G_OBJECT (about), "comments");
901 }
902
903 /**
904  * gtk_about_dialog_get_license:
905  * @about: a #GtkAboutDialog
906  * 
907  * Returns the license information.
908  * 
909  * Return value: The license information. The string is owned by the about
910  *  dialog and must not be modified.
911  *
912  * Since: 2.6
913  **/
914 G_CONST_RETURN gchar *
915 gtk_about_dialog_get_license (GtkAboutDialog *about)
916 {
917   GtkAboutDialogPrivate *priv;
918   
919   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
920
921   priv = (GtkAboutDialogPrivate *)about->private_data;
922
923   return priv->license;
924 }
925
926 /**
927  * gtk_about_dialog_set_license:
928  * @about: a #GtkAboutDialog
929  * @license: the license information or %NULL
930  *
931  * Sets the license information to be displayed in the secondary
932  * license dialog. If @license is %NULL, the license button is
933  * hidden.
934  * 
935  * Since: 2.6
936  **/
937 void
938 gtk_about_dialog_set_license (GtkAboutDialog *about, 
939                               const gchar    *license)
940 {
941   GtkAboutDialogPrivate *priv;
942   gchar *tmp;
943
944   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
945
946   priv = (GtkAboutDialogPrivate *)about->private_data;
947
948   tmp = priv->license;
949   if (license) 
950     {
951       priv->license = g_strdup (license);
952       gtk_widget_show (priv->license_button);
953     }
954   else
955     {
956       priv->license = NULL;
957       gtk_widget_hide (priv->license_button);
958     }
959   g_free (tmp);
960
961   g_object_notify (G_OBJECT (about), "license");
962 }
963
964 /**
965  * gtk_about_dialog_get_website:
966  * @about: a #GtkAboutDialog
967  * 
968  * Returns the website URL.
969  * 
970  * Return value: The website URL. The string is owned by the about
971  *  dialog and must not be modified.
972  *
973  * Since: 2.6
974  **/
975 G_CONST_RETURN gchar *
976 gtk_about_dialog_get_website (GtkAboutDialog *about)
977 {
978   GtkAboutDialogPrivate *priv;
979   
980   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
981
982   priv = (GtkAboutDialogPrivate *)about->private_data;
983
984   return priv->website;
985 }
986
987 /**
988  * gtk_about_dialog_set_website:
989  * @about: a #GtkAboutDialog
990  * @website: a URL string starting with "http://"
991  * 
992  * Sets the URL to use for the website link.
993  *
994  * Since: 2.6
995  **/
996 void
997 gtk_about_dialog_set_website (GtkAboutDialog *about, 
998                               const gchar    *website)
999 {
1000   GtkAboutDialogPrivate *priv;
1001   gchar *tmp;
1002
1003   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1004
1005   priv = (GtkAboutDialogPrivate *)about->private_data;
1006   
1007   tmp = priv->website;
1008   if (website != NULL)
1009     {
1010       priv->website = g_strdup (website);
1011       if (activate_url_hook != NULL)
1012         {
1013           g_object_set_data_full (G_OBJECT (priv->website_button), 
1014                                   "url", g_strdup (website), g_free);  
1015           if (priv->website_label == NULL) 
1016             gtk_about_dialog_set_website_label (about, website);
1017         }
1018       else 
1019         {
1020           GtkWidget *hbox = priv->website_button->parent;
1021           gtk_widget_destroy (priv->website_button);
1022           priv->website_button = gtk_label_new (website);
1023           gtk_label_set_selectable (GTK_LABEL (priv->website_button), TRUE);
1024           gtk_container_add (GTK_CONTAINER (hbox), priv->website_button);
1025           gtk_widget_show (priv->website_button);
1026         }
1027     }
1028   else 
1029     {
1030       priv->website = NULL;
1031       g_object_set_data (G_OBJECT (priv->website_button), "url", NULL);
1032     }
1033   g_free (tmp);
1034
1035   g_object_notify (G_OBJECT (about), "website");
1036 }
1037
1038 /**
1039  * gtk_about_dialog_get_website_label:
1040  * @about: a #GtkAboutDialog
1041  * 
1042  * Returns the label used for the website link. 
1043  * 
1044  * Return value: The label used for the website link. The string is owned by the about
1045  *  dialog and must not be modified.
1046  *
1047  * Since: 2.6
1048  **/
1049 G_CONST_RETURN gchar *
1050 gtk_about_dialog_get_website_label (GtkAboutDialog *about)
1051 {
1052   GtkAboutDialogPrivate *priv;
1053   
1054   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1055
1056   priv = (GtkAboutDialogPrivate *)about->private_data;
1057
1058   return priv->website_label;
1059 }
1060
1061 /**
1062  * gtk_about_dialog_set_website_label:
1063  * @about: a #GtkAboutDialog
1064  * @website_label: the label used for the website link
1065  * 
1066  * Sets the label to be used for the website link.
1067  * It defaults to the website URL.
1068  *
1069  * Since: 2.6
1070  **/
1071 void
1072 gtk_about_dialog_set_website_label (GtkAboutDialog *about, 
1073                                     const gchar    *website_label)
1074 {
1075   GtkAboutDialogPrivate *priv;
1076   gchar *tmp;
1077
1078   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1079
1080   priv = (GtkAboutDialogPrivate *)about->private_data;
1081
1082   tmp = priv->website_label;
1083   if (activate_url_hook != NULL)
1084     {
1085       if (website_label != NULL) 
1086         {
1087           priv->website_label = g_strdup (website_label);
1088           set_link_button_text (GTK_WIDGET (about),
1089                                 priv->website_button, 
1090                                 priv->website_label);
1091           gtk_widget_show (priv->website_button);
1092         }
1093       else 
1094         {
1095           priv->website_label = NULL;
1096           gtk_widget_hide (priv->website_button);
1097         }
1098     }
1099   g_free (tmp);
1100
1101   g_object_notify (G_OBJECT (about), "website_label");
1102 }
1103
1104 /**
1105  * gtk_about_dialog_get_authors:
1106  * @about: a #GtkAboutDialog
1107  * 
1108  * Returns the string which are displayed in the authors tab
1109  * of the secondary credits dialog.
1110  * 
1111  * Return value: A %NULL-terminated string array containing
1112  *  the authors. The array is owned by the about dialog 
1113  *  and must not be modified.
1114  *
1115  * Since: 2.6
1116  **/
1117 gchar **
1118 gtk_about_dialog_get_authors (GtkAboutDialog *about)
1119 {
1120   GtkAboutDialogPrivate *priv;
1121   
1122   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1123
1124   priv = (GtkAboutDialogPrivate *)about->private_data;
1125
1126   return priv->authors;
1127 }
1128
1129 /**
1130  * gtk_about_dialog_set_authors:
1131  * @about: a #GtkAboutDialog
1132  * @authors: a %NULL-terminated array of strings 
1133  *
1134  * Sets the strings which are displayed in the authors tab
1135  * of the secondary credits dialog. 
1136  * 
1137  * Since: 2.6
1138  **/
1139 void
1140 gtk_about_dialog_set_authors (GtkAboutDialog  *about, 
1141                               gchar          **authors)
1142 {
1143   GtkAboutDialogPrivate *priv;
1144   gchar **tmp;
1145
1146   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1147
1148   priv = (GtkAboutDialogPrivate *)about->private_data;
1149
1150   tmp = priv->authors;
1151   priv->authors = g_strdupv (authors);
1152   g_strfreev (tmp);
1153
1154   if (priv->authors != NULL)
1155     gtk_widget_show (priv->credits_button);
1156
1157   g_object_notify (G_OBJECT (about), "authors");
1158 }
1159
1160 /**
1161  * gtk_about_dialog_get_documenters:
1162  * @about: a #GtkAboutDialog
1163  * 
1164  * Returns the string which are displayed in the documenters 
1165  * tab of the secondary credits dialog.
1166  * 
1167  * Return value: A %NULL-terminated string array containing
1168  *  the documenters. The array is owned by the about dialog 
1169  *  and must not be modified.
1170  *
1171  * Since: 2.6
1172  **/
1173 gchar **
1174 gtk_about_dialog_get_documenters (GtkAboutDialog *about)
1175 {
1176   GtkAboutDialogPrivate *priv;
1177   
1178   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1179
1180   priv = (GtkAboutDialogPrivate *)about->private_data;
1181
1182   return priv->documenters;
1183 }
1184
1185 /**
1186  * gtk_about_dialog_set_documenters:
1187  * @about: a #GtkAboutDialog
1188  * @documenters: a %NULL-terminated array of strings 
1189  *
1190  * Sets the strings which are displayed in the documenters tab
1191  * of the secondary credits dialog. 
1192  * 
1193  * Since: 2.6
1194  **/
1195 void
1196 gtk_about_dialog_set_documenters (GtkAboutDialog *about, 
1197                                   gchar         **documenters)
1198 {
1199   GtkAboutDialogPrivate *priv;
1200   gchar **tmp;
1201
1202   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1203
1204   priv = (GtkAboutDialogPrivate *)about->private_data;
1205   
1206   tmp = priv->documenters;
1207   priv->documenters = g_strdupv (documenters);
1208   g_strfreev (tmp);
1209
1210   if (priv->documenters != NULL)
1211     gtk_widget_show (priv->credits_button);
1212
1213   g_object_notify (G_OBJECT (about), "documenters");
1214 }
1215
1216 /**
1217  * gtk_about_dialog_get_artists:
1218  * @about: a #GtkAboutDialog
1219  * 
1220  * Returns the string which are displayed in the artists tab
1221  * of the secondary credits dialog.
1222  * 
1223  * Return value: A %NULL-terminated string array containing
1224  *  the artists. The array is owned by the about dialog 
1225  *  and must not be modified.
1226  *
1227  * Since: 2.6
1228  **/
1229 gchar **
1230 gtk_about_dialog_get_artists (GtkAboutDialog *about)
1231 {
1232   GtkAboutDialogPrivate *priv;
1233   
1234   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1235
1236   priv = (GtkAboutDialogPrivate *)about->private_data;
1237
1238   return priv->artists;
1239 }
1240
1241 /**
1242  * gtk_about_dialog_set_artists:
1243  * @about: a #GtkAboutDialog
1244  * @artists: a %NULL-terminated array of strings 
1245  *
1246  * Sets the strings which are displayed in the artists tab
1247  * of the secondary credits dialog. 
1248  * 
1249  * Since: 2.6
1250  **/
1251 void
1252 gtk_about_dialog_set_artists (GtkAboutDialog *about, 
1253                               gchar         **artists)
1254 {
1255   GtkAboutDialogPrivate *priv;
1256   gchar **tmp;
1257
1258   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1259
1260   priv = (GtkAboutDialogPrivate *)about->private_data;
1261   
1262   tmp = priv->artists;
1263   priv->artists = g_strdupv (artists);
1264   g_strfreev (tmp);
1265
1266   if (priv->artists != NULL)
1267     gtk_widget_show (priv->credits_button);
1268
1269   g_object_notify (G_OBJECT (about), "artists");
1270 }
1271
1272 /**
1273  * gtk_about_dialog_get_translator_credits:
1274  * @about: a #GtkAboutDialog
1275  * 
1276  * Returns the translator credits string which is displayed
1277  * in the translators tab of the secondary credits dialog.
1278  * 
1279  * Return value: The translator credits string. The string is
1280  *   owned by the about dialog and must not be modified.
1281  *
1282  * Since: 2.6
1283  **/
1284 G_CONST_RETURN gchar *
1285 gtk_about_dialog_get_translator_credits (GtkAboutDialog *about)
1286 {
1287   GtkAboutDialogPrivate *priv;
1288   
1289   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1290
1291   priv = (GtkAboutDialogPrivate *)about->private_data;
1292
1293   return priv->translator_credits;
1294 }
1295
1296 /**
1297  * gtk_about_dialog_set_translator_credits:
1298  * @about: a #GtkAboutDialog
1299  * @translator_credits: the translator credits
1300  * 
1301  * Sets the translator credits string which is displayed in
1302  * the translators tab of the secondary credits dialog.
1303  * 
1304  * The intended use for this string is to display the translator
1305  * of the language which is currently used in the user interface.
1306  * Using gettext(), a simple way to achieve that is to mark the
1307  * string for translation:
1308  * <informalexample><programlisting>
1309  *  gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
1310  * </programlisting></informalexample>
1311  * It is a good idea to use the customary msgid "translator-credits" for this
1312  * purpose, since translators will already know the purpose of that msgid, and
1313  * since #GtkAboutDialog will detect if "translator-credits" is untranslated
1314  * and hide the tab.
1315  *
1316  * Since: 2.6
1317  **/
1318 void
1319 gtk_about_dialog_set_translator_credits (GtkAboutDialog *about, 
1320                                          const gchar    *translator_credits)
1321 {
1322   GtkAboutDialogPrivate *priv;
1323   gchar *tmp;
1324
1325   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1326
1327   priv = (GtkAboutDialogPrivate *)about->private_data;
1328
1329   tmp = priv->translator_credits;
1330   priv->translator_credits = g_strdup (translator_credits);
1331   g_free (tmp);
1332
1333   if (priv->translator_credits != NULL)
1334     gtk_widget_show (priv->credits_button);
1335
1336   g_object_notify (G_OBJECT (about), "translator-credits");
1337 }
1338
1339 /**
1340  * gtk_about_dialog_get_logo:
1341  * @about: a #GtkAboutDialog
1342  * 
1343  * Returns the pixbuf displayed as logo in the about dialog.
1344  * 
1345  * Return value: the pixbuf displayed as logo. The pixbuf is
1346  *   owned by the about dialog. If you want to keep a reference
1347  *   to it, you have to call g_object_ref() on it.
1348  *
1349  * Since: 2.6
1350  **/
1351 GdkPixbuf *
1352 gtk_about_dialog_get_logo (GtkAboutDialog *about)
1353 {
1354   GtkAboutDialogPrivate *priv;
1355   
1356   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1357
1358   priv = (GtkAboutDialogPrivate *)about->private_data;
1359
1360   if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1361     return gtk_image_get_pixbuf (GTK_IMAGE (priv->logo_image));
1362   else
1363     return NULL;
1364 }
1365
1366 static GtkIconSet *
1367 icon_set_new_from_pixbufs (GList *pixbufs)
1368 {
1369   GtkIconSet *icon_set = gtk_icon_set_new ();
1370   
1371   for (; pixbufs; pixbufs = pixbufs->next)
1372     {
1373       GdkPixbuf *pixbuf = GDK_PIXBUF (pixbufs->data);
1374
1375       GtkIconSource *icon_source = gtk_icon_source_new ();
1376       gtk_icon_source_set_pixbuf (icon_source, pixbuf);
1377       gtk_icon_set_add_source (icon_set, icon_source);
1378       gtk_icon_source_free (icon_source);
1379     }
1380   
1381   return icon_set;
1382 }
1383
1384 /**
1385  * gtk_about_dialog_set_logo:
1386  * @about: a #GtkAboutDialog
1387  * @logo: a #GdkPixbuf, or %NULL
1388  * 
1389  * Sets the pixbuf to be displayed as logo in 
1390  * the about dialog. If it is %NULL, the default
1391  * window icon set with gtk_window_set_default_icon ()
1392  * will be used.
1393  *
1394  * Since: 2.6
1395  **/
1396 void
1397 gtk_about_dialog_set_logo (GtkAboutDialog *about,
1398                            GdkPixbuf      *logo)
1399 {
1400   GtkAboutDialogPrivate *priv;
1401
1402   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1403
1404   priv = (GtkAboutDialogPrivate *)about->private_data;
1405
1406   g_object_freeze_notify (G_OBJECT (about));
1407
1408   if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1409     g_object_notify (G_OBJECT (about), "logo_icon_name");
1410
1411   if (logo != NULL) 
1412     gtk_image_set_from_pixbuf (GTK_IMAGE (priv->logo_image), logo);
1413   else 
1414     {
1415       GList *pixbufs = gtk_window_get_default_icon_list ();
1416
1417       if (pixbufs != NULL)
1418         {
1419           GtkIconSet *icon_set = icon_set_new_from_pixbufs (pixbufs); 
1420           
1421           gtk_image_set_from_icon_set (GTK_IMAGE (priv->logo_image),
1422                                        icon_set, GTK_ICON_SIZE_DIALOG);
1423           
1424           gtk_icon_set_unref (icon_set);
1425           g_list_free (pixbufs);
1426         }
1427     }
1428
1429   g_object_notify (G_OBJECT (about), "logo");
1430
1431   g_object_thaw_notify (G_OBJECT (about));
1432 }
1433
1434 /**
1435  * gtk_about_dialog_get_logo_icon_name:
1436  * @about: a #GtkAboutDialog
1437  * 
1438  * Returns the icon name displayed as logo in the about dialog.
1439  * 
1440  * Return value: the icon name displayed as logo. The string is
1441  *   owned by the about dialog. If you want to keep a reference
1442  *   to it, you have to call g_strdup() on it.
1443  *
1444  * Since: 2.6
1445  **/
1446 G_CONST_RETURN gchar *
1447 gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about)
1448 {
1449   GtkAboutDialogPrivate *priv;
1450   const gchar *icon_name;
1451   
1452   g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
1453
1454   priv = (GtkAboutDialogPrivate *)about->private_data;
1455
1456   if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_ICON_NAME)
1457     gtk_image_get_icon_name (GTK_IMAGE (priv->logo_image), &icon_name, NULL);
1458
1459   return icon_name;
1460 }
1461
1462 /**
1463  * gtk_about_dialog_set_logo_icon_name:
1464  * @about: a #GtkAboutDialog
1465  * @icon_name: an icon name, or %NULL
1466  * 
1467  * Sets the pixbuf to be displayed as logo in 
1468  * the about dialog. If it is %NULL, the default
1469  * window icon set with gtk_window_set_default_icon()
1470  * will be used.
1471  *
1472  * Since: 2.6
1473  **/
1474 void
1475 gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
1476                                      const gchar    *icon_name)
1477 {
1478   GtkAboutDialogPrivate *priv;
1479
1480   g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
1481
1482   priv = (GtkAboutDialogPrivate *)about->private_data;
1483
1484   g_object_freeze_notify (G_OBJECT (about));
1485
1486   if (gtk_image_get_storage_type (GTK_IMAGE (priv->logo_image)) == GTK_IMAGE_PIXBUF)
1487     g_object_notify (G_OBJECT (about), "logo");
1488
1489   gtk_image_set_from_icon_name (GTK_IMAGE (priv->logo_image), icon_name,
1490                                 GTK_ICON_SIZE_DIALOG);
1491   g_object_notify (G_OBJECT (about), "logo_icon_name");
1492
1493   g_object_thaw_notify (G_OBJECT (about));
1494 }
1495
1496 static void
1497 activate_url (GtkWidget *widget, 
1498               gpointer   data)
1499 {
1500   GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
1501   gchar *url = g_object_get_data (G_OBJECT (widget), "url");
1502   
1503   if (activate_url_hook != NULL)
1504     (* activate_url_hook) (about, url, activate_url_hook_data);
1505 }
1506
1507 static void
1508 set_link_button_text (GtkWidget *about,
1509                       GtkWidget *button, 
1510                       gchar     *text)
1511 {
1512   GtkWidget *label;
1513   gchar *link;
1514   GdkColor *style_link_color;
1515   GdkColor link_color = { 0, 0, 0, 0xffff };
1516
1517   gtk_widget_ensure_style (about);
1518   gtk_widget_style_get (about, "link_color", &style_link_color, NULL);
1519   if (style_link_color)
1520     {
1521       link_color = *style_link_color;
1522       gdk_color_free (style_link_color);
1523     }
1524
1525   link = g_markup_printf_escaped ("<span foreground=\"#%04x%04x%04x\" underline=\"single\">%s</span>", 
1526                                   link_color.red, link_color.green, link_color.blue, text);
1527
1528   label = gtk_bin_get_child (GTK_BIN (button));  
1529   gtk_label_set_markup (GTK_LABEL (label), link);
1530   g_free (link);
1531 }
1532
1533 static GtkWidget *
1534 create_link_button (GtkWidget *about,
1535                     gchar     *text,
1536                     gchar     *url, 
1537                     GCallback  callback, 
1538                     gpointer   data)
1539 {
1540   GtkWidget *button;
1541
1542   button = gtk_button_new_with_label ("");
1543   GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
1544   gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1545
1546   g_object_set_data_full (G_OBJECT (button), "url", g_strdup (url), g_free);
1547   set_link_button_text (about, button, text);
1548   
1549   g_signal_connect (G_OBJECT (button), "clicked", callback, data);
1550
1551   return button;
1552 }
1553
1554 static void
1555 follow_if_link (GtkAboutDialog *about,
1556                 GtkTextIter    *iter)
1557 {
1558   GSList *tags = NULL, *tagp = NULL;
1559
1560   tags = gtk_text_iter_get_tags (iter);
1561   for (tagp = tags;  tagp != NULL;  tagp = tagp->next)
1562     {
1563       GtkTextTag *tag = tagp->data;
1564       gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1565       gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1566
1567       if (email != NULL && activate_email_hook != NULL)
1568         {
1569           (* activate_email_hook) (about, email, activate_email_hook_data);
1570           break;
1571         }
1572
1573       if (url != NULL && activate_url_hook != NULL)
1574         {
1575           (* activate_url_hook) (about, url, activate_url_hook_data);
1576           break;
1577         }
1578     }
1579
1580   if (tags) 
1581     g_slist_free (tags);
1582 }
1583
1584 static gboolean
1585 credits_key_press_event (GtkWidget      *text_view,
1586                          GdkEventKey    *event,
1587                          GtkAboutDialog *about)
1588 {
1589   GtkTextIter iter;
1590   GtkTextBuffer *buffer;
1591
1592   switch (event->keyval)
1593     {
1594       case GDK_Return: 
1595       case GDK_KP_Enter:
1596         buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1597         gtk_text_buffer_get_iter_at_mark (buffer, &iter, 
1598                                           gtk_text_buffer_get_insert (buffer));
1599         follow_if_link (about, &iter);
1600         break;
1601
1602       default:
1603         break;
1604     }
1605
1606   return FALSE;
1607 }
1608
1609 static gboolean
1610 credits_event_after (GtkWidget      *text_view,
1611                      GdkEvent       *event,
1612                      GtkAboutDialog *about)
1613 {
1614   GtkTextIter start, end, iter;
1615   GtkTextBuffer *buffer;
1616   GdkEventButton *button_event;
1617   gint x, y;
1618
1619   if (event->type != GDK_BUTTON_RELEASE)
1620     return FALSE;
1621
1622   button_event = (GdkEventButton *)event;
1623
1624   if (button_event->button != 1)
1625     return FALSE;
1626
1627   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
1628
1629   /* we shouldn't follow a link if the user has selected something */
1630   gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
1631   if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
1632     return FALSE;
1633
1634   gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), 
1635                                          GTK_TEXT_WINDOW_WIDGET,
1636                                          button_event->x, button_event->y, &x, &y);
1637
1638   gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
1639
1640   follow_if_link (about, &iter);
1641
1642   return FALSE;
1643 }
1644
1645 static void
1646 set_cursor_if_appropriate (GtkAboutDialog *about,
1647                            GtkTextView    *text_view,
1648                            gint            x,
1649                            gint            y)
1650 {
1651   GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1652   GSList *tags = NULL, *tagp = NULL;
1653   GtkTextBuffer *buffer;
1654   GtkTextIter iter;
1655   gboolean hovering_over_link = FALSE;
1656
1657   buffer = gtk_text_view_get_buffer (text_view);
1658
1659   gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
1660   
1661   tags = gtk_text_iter_get_tags (&iter);
1662   for (tagp = tags;  tagp != NULL;  tagp = tagp->next)
1663     {
1664       GtkTextTag *tag = tagp->data;
1665       gchar *email = g_object_get_data (G_OBJECT (tag), "email");
1666       gchar *url = g_object_get_data (G_OBJECT (tag), "url");
1667
1668       if (email != NULL || url != NULL) 
1669         {
1670           hovering_over_link = TRUE;
1671           break;
1672         }
1673     }
1674
1675   if (hovering_over_link != priv->hovering_over_link)
1676     {
1677       priv->hovering_over_link = hovering_over_link;
1678
1679       if (hovering_over_link)
1680         gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
1681       else
1682         gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
1683     }
1684
1685   if (tags) 
1686     g_slist_free (tags);
1687 }
1688
1689 static gboolean
1690 credits_motion_notify_event (GtkWidget *text_view,
1691                              GdkEventMotion *event,
1692                              GtkAboutDialog *about)
1693 {
1694   gint x, y;
1695
1696   gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), 
1697                                          GTK_TEXT_WINDOW_WIDGET,
1698                                          event->x, event->y, &x, &y);
1699
1700   set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
1701
1702   gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
1703
1704   return FALSE;
1705 }
1706
1707
1708 static gboolean
1709 credits_visibility_notify_event (GtkWidget          *text_view,
1710                                  GdkEventVisibility *event,
1711                                  GtkAboutDialog     *about)
1712 {
1713   gint wx, wy, bx, by;
1714
1715   gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
1716
1717   gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), 
1718                                          GTK_TEXT_WINDOW_WIDGET,
1719                                          wx, wy, &bx, &by);
1720
1721   set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
1722
1723   return FALSE;
1724 }
1725
1726 static void
1727 text_view_style_set (GtkWidget *widget, GtkStyle *prev_style, GtkWidget *text_view)
1728 {
1729   gtk_widget_modify_base (text_view, GTK_STATE_NORMAL,
1730                           &widget->style->bg[GTK_STATE_NORMAL]);
1731 }
1732
1733 static void
1734 add_credits_page (GtkAboutDialog *about, 
1735                   GtkWidget      *notebook,
1736                   gchar          *title,
1737                   gchar         **people)
1738 {
1739   gchar **p;
1740   gchar *q0, *q1, *q2, *r1, *r2;
1741   GtkWidget *sw, *view;
1742   GtkTextBuffer *buffer;
1743   gboolean linkify_email, linkify_urls;
1744   GdkColor *style_link_color;
1745   GdkColor link_color = { 0, 0, 0, 0xffff };
1746
1747   linkify_email = (activate_email_hook != NULL);
1748   linkify_urls = (activate_url_hook != NULL);
1749
1750   gtk_widget_ensure_style (GTK_WIDGET (about));
1751   gtk_widget_style_get (GTK_WIDGET (about), "link_color", &style_link_color, NULL);
1752   if (style_link_color)
1753     {
1754       link_color = *style_link_color;
1755       gdk_color_free (style_link_color);
1756     }
1757
1758   view = gtk_text_view_new ();
1759   g_signal_connect (about, "style_set",
1760                     G_CALLBACK (text_view_style_set), view);
1761   
1762   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
1763   gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1764   gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1765   gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1766   gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1767
1768   g_signal_connect (G_OBJECT (view), "key-press-event",
1769                     G_CALLBACK (credits_key_press_event), about);
1770   g_signal_connect (G_OBJECT (view), "event-after",
1771                     G_CALLBACK (credits_event_after), about);
1772   g_signal_connect (G_OBJECT (view), "motion-notify-event", 
1773                     G_CALLBACK (credits_motion_notify_event), about);
1774   g_signal_connect (G_OBJECT (view), "visibility-notify-event", 
1775                     G_CALLBACK (credits_visibility_notify_event), about);
1776
1777   sw = gtk_scrolled_window_new (NULL, NULL);
1778   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1779                                   GTK_POLICY_AUTOMATIC,
1780                                   GTK_POLICY_AUTOMATIC);
1781   gtk_container_add (GTK_CONTAINER (sw), view);
1782   
1783   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), 
1784                             sw, gtk_label_new (title));
1785
1786   if (people == NULL) 
1787     {
1788       gtk_widget_hide (view);
1789       return;
1790     }
1791   else 
1792     gtk_widget_show (view);
1793   
1794   for (p = people; *p; p++) 
1795     {
1796       q0  = *p;
1797       while (*q0) 
1798         {
1799           q1 = linkify_email ? strchr (q0, '<') : NULL;
1800           q2 = q1 ? strchr (q1, '>') : NULL;
1801           r1 = linkify_urls ? strstr (q0, "http://") : NULL;
1802           if (r1)
1803             {
1804               r2 = strpbrk (r1, " \n\t");
1805               if (!r2)
1806                 r2 = strchr (r1, '\0');
1807             }
1808           else  
1809             r2 = NULL;
1810
1811           if (r1 && r2 && (!q1 || !q2 || (r1 < q1))) 
1812             {
1813               q1 = r1;
1814               q2 = r2;
1815             }
1816
1817           if (q1 && q2) 
1818             {
1819               GtkTextIter end;
1820               gchar *link;
1821               gchar *link_type;
1822               GtkTextTag *tag;
1823               
1824               gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
1825               gtk_text_buffer_get_end_iter (buffer, &end);
1826
1827               q0 = q2;
1828
1829               if (*q1 == '<') 
1830                 {
1831                   q1++;
1832                   q0++;
1833                   link_type = "email";
1834                 }
1835               else 
1836                 link_type = "url";
1837               
1838               link = g_strndup (q1, q2 - q1);
1839               tag = gtk_text_buffer_create_tag (buffer, NULL, 
1840                                                 "foreground_gdk", &link_color, 
1841                                                 "underline", PANGO_UNDERLINE_SINGLE, 
1842                                                 NULL);
1843               g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
1844               gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
1845
1846               g_free (link);
1847             }
1848           else
1849             {
1850               gtk_text_buffer_insert_at_cursor (buffer, q0, -1);
1851               break;
1852             }
1853         }
1854       
1855       if (p[1])
1856         gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
1857     }
1858 }
1859
1860 static void
1861 display_credits_dialog (GtkWidget *button, 
1862                         gpointer   data)
1863 {
1864   GtkAboutDialog *about = (GtkAboutDialog *)data;
1865   GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1866   GtkWidget *dialog, *notebook;
1867
1868   if (priv->credits_dialog != NULL)
1869     {
1870       gtk_window_present (GTK_WINDOW (priv->credits_dialog));
1871       return;
1872     }
1873         
1874   dialog = gtk_dialog_new_with_buttons (_("Credits"),
1875                                         GTK_WINDOW (about),
1876                                         GTK_DIALOG_DESTROY_WITH_PARENT,
1877                                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1878                                         NULL);
1879   gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1880   
1881   priv->credits_dialog = dialog;
1882   gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260);
1883   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1884
1885   gtk_window_set_modal (GTK_WINDOW (dialog), 
1886                         gtk_window_get_modal (GTK_WINDOW (about)));
1887
1888   g_signal_connect (dialog, "response",
1889                     G_CALLBACK (gtk_widget_destroy), dialog);
1890   g_signal_connect (dialog, "destroy",
1891                     G_CALLBACK (gtk_widget_destroyed),
1892                     &(priv->credits_dialog));
1893
1894   notebook = gtk_notebook_new ();
1895   gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
1896   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
1897
1898   if (priv->authors != NULL) 
1899     add_credits_page (about, notebook, _("Written by"), priv->authors);
1900   
1901   if (priv->documenters != NULL)
1902     add_credits_page (about, notebook, _("Documented by"), priv->documenters);
1903     
1904   /* Don't show an untranslated gettext msgid */
1905   if (priv->translator_credits != NULL &&
1906       strcmp (priv->translator_credits, "translator_credits") &&
1907       strcmp (priv->translator_credits, "translator-credits")) 
1908     {
1909       gchar *translators[2];
1910       
1911       translators[0] = priv->translator_credits;
1912       translators[1] = NULL;
1913
1914       add_credits_page (about, notebook, _("Translated by"), translators);
1915     }
1916
1917   if (priv->artists != NULL) 
1918     add_credits_page (about, notebook, _("Artwork by"), priv->artists);
1919   
1920   gtk_widget_show_all (dialog);
1921 }
1922
1923 static void
1924 display_license_dialog (GtkWidget *button, 
1925                         gpointer   data)
1926 {
1927   GtkAboutDialog *about = (GtkAboutDialog *)data;
1928   GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1929   GtkWidget *dialog, *view, *sw;
1930
1931   if (priv->license_dialog != NULL)
1932     {
1933       gtk_window_present (GTK_WINDOW (priv->license_dialog));
1934       return;
1935     }
1936         
1937   dialog = gtk_dialog_new_with_buttons (_("License"),
1938                                         GTK_WINDOW (about),
1939                                         GTK_DIALOG_DESTROY_WITH_PARENT,
1940                                         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1941                                         NULL);
1942   gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1943   priv->license_dialog = dialog;
1944   gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320);
1945   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
1946
1947   gtk_window_set_modal (GTK_WINDOW (dialog), 
1948                         gtk_window_get_modal (GTK_WINDOW (about)));
1949
1950   g_signal_connect (dialog, "response",
1951                     G_CALLBACK (gtk_widget_destroy), dialog);
1952   g_signal_connect (dialog, "destroy",
1953                     G_CALLBACK (gtk_widget_destroyed),
1954                     &(priv->license_dialog));
1955
1956   sw = gtk_scrolled_window_new (NULL, NULL);
1957   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1958                                        GTK_SHADOW_IN);
1959   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1960                                   GTK_POLICY_AUTOMATIC,
1961                                   GTK_POLICY_AUTOMATIC);
1962   gtk_container_set_border_width (GTK_CONTAINER (sw), 8);
1963   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0);
1964
1965   view = gtk_text_view_new ();
1966   gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)), 
1967                             priv->license, -1);
1968
1969   gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
1970   gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
1971   gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 8);
1972   gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 8);
1973
1974   gtk_container_add (GTK_CONTAINER (sw), view);
1975
1976   gtk_widget_show_all (dialog);
1977 }
1978
1979 static void 
1980 close_cb (GtkAboutDialog *about)
1981 {
1982   GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data;
1983
1984   if (priv->license_dialog != NULL)
1985     {
1986       gtk_widget_destroy (priv->license_dialog);
1987       priv->license_dialog = NULL;
1988     }
1989
1990   if (priv->credits_dialog != NULL)
1991     {
1992       gtk_widget_destroy (priv->credits_dialog);
1993       priv->credits_dialog = NULL;
1994     }
1995
1996   gtk_widget_hide (GTK_WIDGET (about));
1997   
1998 }
1999
2000 /**
2001  * gtk_about_dialog_new:
2002  *
2003  * Creates a new #GtkAboutDialog.
2004  *
2005  * Returns: a newly created #GtkAboutDialog
2006  *
2007  * Since: 2.6
2008  */
2009 GtkWidget *
2010 gtk_about_dialog_new (void)
2011 {
2012   GtkAboutDialog *dialog = GTK_ABOUT_DIALOG (g_object_new (GTK_TYPE_ABOUT_DIALOG, NULL));
2013
2014   /* force defaults */
2015   gtk_about_dialog_set_name (dialog, NULL);
2016   gtk_about_dialog_set_logo (dialog, NULL);
2017
2018   /* Close dialog on user response */
2019   g_signal_connect (G_OBJECT (dialog),
2020                     "response",
2021                     G_CALLBACK (close_cb),
2022                     NULL);
2023
2024   return GTK_WIDGET (dialog);
2025 }
2026
2027 /**
2028  * gtk_about_dialog_set_email_hook:
2029  * @func: a function to call when an email link is activated.
2030  * @data: data to pass to @func
2031  * @destroy: #GDestroyNotify for @data
2032  * 
2033  * Installs a global function to be called whenever the user activates an
2034  * email link in an about dialog. 
2035  * 
2036  * Return value: the previous email hook.
2037  *
2038  * Since: 2.6
2039  */
2040 GtkAboutDialogActivateLinkFunc      
2041 gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func, 
2042                                  gpointer                       data, 
2043                                  GDestroyNotify                 destroy)
2044 {
2045   GtkAboutDialogActivateLinkFunc old;
2046
2047   if (activate_email_hook_destroy != NULL)
2048     (* activate_email_hook_destroy) (activate_url_hook_data);
2049
2050   old = activate_email_hook;
2051
2052   activate_email_hook = func;
2053   activate_email_hook_data = data;
2054   activate_email_hook_destroy = destroy;
2055
2056   return old;
2057 }
2058
2059 /**
2060  * gtk_about_dialog_set_url_hook:
2061  * @func: a function to call when a URL link is activated.
2062  * @data: data to pass to @func
2063  * @destroy: #GDestroyNotify for @data
2064  * 
2065  * Installs a global function to be called whenever the user activates a
2066  * URL link in an about dialog.
2067  * 
2068  * Return value: the previous URL hook.
2069  *
2070  * Since: 2.6
2071  */
2072 GtkAboutDialogActivateLinkFunc      
2073 gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func, 
2074                                gpointer                       data, 
2075                                GDestroyNotify                 destroy)
2076 {
2077   GtkAboutDialogActivateLinkFunc old;
2078
2079   if (activate_url_hook_destroy != NULL)
2080     (* activate_url_hook_destroy) (activate_email_hook_data);
2081
2082   old = activate_url_hook;
2083
2084   activate_url_hook = func;
2085   activate_url_hook_data = data;
2086   activate_url_hook_destroy = destroy;
2087
2088   return old;
2089 }
2090
2091 /**
2092  * gtk_show_about_dialog:
2093  * @parent: transient parent, or %NULL for none
2094  * @first_property_name: the name of the first property 
2095  * @Varargs: value of first property, followed by more properties, %NULL-terminated
2096  *
2097  * This is a convenience function for showing an application's about box.
2098  * The constructed dialog is associated with the parent window and 
2099  * reused for future invocations of this function.
2100  *
2101  * Since: 2.6
2102  */
2103 void
2104 gtk_show_about_dialog (GtkWindow   *parent,
2105                        const gchar *first_property_name,
2106                        ...)
2107 {
2108   static GtkWidget *global_about_dialog = NULL;
2109   GtkWidget *dialog = NULL;
2110   va_list var_args;
2111
2112   if (parent)
2113     dialog = g_object_get_data (G_OBJECT (parent), "gtk-about-dialog");
2114   else 
2115     dialog = global_about_dialog;
2116
2117   if (!dialog) 
2118     {
2119       dialog = gtk_about_dialog_new ();
2120
2121       g_object_ref (G_OBJECT (dialog));
2122       gtk_object_sink (GTK_OBJECT (dialog));
2123
2124       g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);
2125
2126       va_start (var_args, first_property_name);
2127       g_object_set_valist (G_OBJECT (dialog), first_property_name, var_args);
2128       va_end (var_args);
2129
2130       if (parent) 
2131         {
2132           gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
2133           gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
2134           g_object_set_data_full (G_OBJECT (parent), "gtk-about-dialog", 
2135                                   dialog, g_object_unref);
2136         }
2137       else 
2138         global_about_dialog = dialog;
2139       
2140     }
2141   
2142   gtk_window_present (GTK_WINDOW (dialog));
2143 }