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