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