2005-10-23 [wwp] 1.9.15cvs97
[claws.git] / src / gtk / about.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2005 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <glib/gi18n.h>
28 #include <gdk/gdkkeysyms.h>
29 #include <gtk/gtkwidget.h>
30 #include <gtk/gtkwindow.h>
31 #include <gtk/gtksignal.h>
32 #include <gtk/gtkvbox.h>
33 #include <gtk/gtkhbox.h>
34 #include <gtk/gtklabel.h>
35 #include <gtk/gtkhseparator.h>
36 #include <gtk/gtkscrolledwindow.h>
37 #include <gtk/gtktext.h>
38 #include <gtk/gtkbutton.h>
39 #if HAVE_SYS_UTSNAME_H
40 #  include <sys/utsname.h>
41 #endif
42
43 #include "about.h"
44 #include "gtkutils.h"
45 #include "stock_pixmap.h"
46 #include "prefs_common.h"
47 #include "utils.h"
48 #include "version.h"
49 #include "authors.h"
50 #include "codeconv.h"
51
52 static GtkWidget *window;
53
54 static void about_create(void);
55 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
56 static void about_uri_clicked(GtkButton *button, gpointer data);
57
58 void about_show(void)
59 {
60         if (!window)
61                 about_create();
62         else
63                 gtk_window_present(GTK_WINDOW(window));
64 }
65
66 static void about_create(void)
67 {
68         GtkWidget *vbox1;
69         GtkWidget *table;
70         GtkWidget *table2;
71         GtkWidget *image;       
72         GtkWidget *vbox2;
73         GtkWidget *label;
74         GtkWidget *button;
75         GtkWidget *scrolledwin;
76         GtkWidget *notebook;
77         GtkStyle *style;
78         GdkColormap *cmap;
79         GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
80         gboolean success[2];
81         char *markup;
82         GtkWidget *text;
83         GtkWidget *confirm_area;
84         GtkWidget *close_button;
85         GtkTextBuffer *buffer;
86         GtkTextIter iter, start_iter;
87         GtkTextMark *mark;
88
89 #if HAVE_SYS_UTSNAME_H
90         struct utsname utsbuf;
91 #endif
92         gchar buf[1024];
93         gint i;
94
95         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
96         gtk_window_set_title(GTK_WINDOW(window), _("About Sylpheed-Claws"));
97         gtk_container_set_border_width(GTK_CONTAINER(window), 8);
98         gtk_widget_set_size_request(window, -1, 458);
99         g_signal_connect(G_OBJECT(window), "delete_event",
100                          G_CALLBACK(gtk_widget_hide_on_delete), NULL);
101         g_signal_connect(G_OBJECT(window), "key_press_event",
102                          G_CALLBACK(key_pressed), NULL);
103         gtk_widget_realize(window);
104
105         vbox1 = gtk_vbox_new(FALSE, 0);
106         gtk_container_add(GTK_CONTAINER(window), vbox1);
107
108         table = gtk_table_new (1, 2, FALSE);
109         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
110
111         image = stock_pixmap_widget(window, STOCK_PIXMAP_SYLPHEED_LOGO);
112         gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 1,
113                          (GtkAttachOptions) (GTK_SHRINK),
114                          (GtkAttachOptions) (GTK_SHRINK), 8, 0);
115
116         vbox2 = gtk_vbox_new (TRUE, 0);
117         gtk_table_attach(GTK_TABLE(table), vbox2, 1, 2, 0, 1,
118                          (GtkAttachOptions) (GTK_EXPAND),
119                          (GtkAttachOptions) (GTK_FILL), 0, 0);
120
121         label = gtk_label_new("");
122         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
123         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
124         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
125         markup = g_markup_printf_escaped
126                 ("<span weight=\"bold\" size=\"xx-large\">Sylpheed-Claws</span>\nversion %s",
127                  VERSION);
128         gtk_label_set_markup(GTK_LABEL(label), markup);
129         g_free(markup);
130
131         button = gtk_button_new_with_label(" "HOMEPAGE_URI" ");
132         gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
133         gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
134         g_signal_connect(G_OBJECT(button), "clicked",
135                          G_CALLBACK(about_uri_clicked), NULL);
136         buf[0] = ' ';
137         for (i = 1; i <= strlen(HOMEPAGE_URI); i++) buf[i] = '_';
138         strcpy(buf + i, " ");
139         gtk_label_set_pattern(GTK_LABEL(GTK_BIN(button)->child), buf);
140         cmap = gdk_drawable_get_colormap(window->window);
141         gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
142         if (success[0] == TRUE && success[1] == TRUE) {
143                 gtk_widget_ensure_style(GTK_BIN(button)->child);
144                 style = gtk_style_copy
145                         (gtk_widget_get_style(GTK_BIN(button)->child));
146                 style->fg[GTK_STATE_NORMAL]   = uri_color[0];
147                 style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
148                 style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
149                 gtk_widget_set_style(GTK_BIN(button)->child, style);
150         } else
151                 g_warning("about_create(): color allocation failed.\n");
152
153 #if HAVE_SYS_UTSNAME_H
154         uname(&utsbuf);
155         g_snprintf(buf, sizeof(buf),
156                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
157                    "Operating System: %s %s (%s)"),
158                    gtk_major_version, gtk_minor_version, gtk_micro_version,
159                    glib_major_version, glib_minor_version, glib_micro_version,
160                    utsbuf.sysname, utsbuf.release, utsbuf.machine);
161 #elif defined(G_OS_WIN32)
162         g_snprintf(buf, sizeof(buf),
163                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
164                    "Operating System: %s"),
165                    gtk_major_version, gtk_minor_version, gtk_micro_version,
166                    glib_major_version, glib_minor_version, glib_micro_version,
167                    "Win32");
168 #else
169         g_snprintf(buf, sizeof(buf),
170                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
171                    "Operating System: unknown"),
172                    gtk_major_version, gtk_minor_version, gtk_micro_version,
173                    glib_major_version, glib_minor_version, glib_micro_version);
174 #endif
175
176         label = gtk_label_new(buf);
177         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
178         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
179         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
180         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
181
182         g_snprintf(buf, sizeof(buf),
183                    _("Compiled-in features:\n%s"),
184 #if USE_THREADS
185                    " gthread"
186 #endif
187 #if INET6
188                    " IPv6"
189 #endif
190 #if HAVE_ICONV
191                    " iconv"
192 #endif
193 #if HAVE_LIBCOMPFACE
194                    " compface"
195 #endif
196 #if USE_OPENSSL
197                    " OpenSSL"
198 #endif
199 #if USE_LDAP
200                    " LDAP"
201 #endif
202 #if USE_JPILOT
203                    " JPilot"
204 #endif
205 #if USE_ASPELL
206                    " GNU/aspell"
207 #endif
208 #if HAVE_LIBETPAN
209                    " libetpan"
210 #endif
211 #if USE_GNOMEPRINT
212                    " libgnomeprint"
213 #endif
214         "");
215
216         label = gtk_label_new(buf);
217         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
218         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
219         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
220         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
221
222         table2 = gtk_table_new (2, 3, FALSE);
223         gtk_box_pack_start(GTK_BOX(vbox1), table2, FALSE, FALSE, 0);
224
225         label = gtk_label_new
226                 ("Copyright (C) 1999-2005 Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>\n"
227                  "and the Sylpheed-Claws team");
228         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
229         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
230         gtk_table_attach(GTK_TABLE(table2), label, 0, 1, 0, 1,
231                          (GtkAttachOptions) (GTK_EXPAND),
232                          (GtkAttachOptions) (GTK_SHRINK), 0, 6);
233
234         notebook = gtk_notebook_new();
235         gtk_widget_set_size_request(notebook, -1, 200);
236         gtk_widget_show(notebook);
237
238         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
239         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
240                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
241         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
242                                             GTK_SHADOW_IN);
243
244         text = gtk_text_view_new();
245         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
246         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
247         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
248         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
249         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
250         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
251
252         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
253         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
254
255         /* textview link style (based upon main prefs) */
256         gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
257                                        (GdkColor*)&uri_color);
258         gtk_text_buffer_create_tag(buffer, "link",
259                                 "foreground-gdk", &uri_color,
260                                 NULL);
261
262         gtk_text_buffer_insert(buffer, &iter, _("Sylpheed-Claws is a lightweight, fast and "
263                                 "highly-configurable e-mail client.\n\n"
264                                 "For further information visit the Sylpheed-"
265                                 "Claws website, "), -1);
266         mark = gtk_text_buffer_create_mark(buffer, "mark", &iter, TRUE);
267         gtk_text_buffer_insert(buffer, &iter, HOMEPAGE_URI, -1);
268         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
269         gtk_text_buffer_apply_tag_by_name(buffer, "link", &start_iter, &iter);
270         gtk_text_buffer_insert(buffer, &iter, _(".\n\n"
271                                 "Sylpheed-Claws is free software released "
272                                 "under the GPL license. If you wish to donate "
273                                 "to the Sylpheed-Claws project you can do "
274                                 "so at "), -1);
275         gtk_text_buffer_move_mark(buffer, mark, &iter);
276         gtk_text_buffer_insert(buffer, &iter, DONATE_URI, -1);
277         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
278         gtk_text_buffer_apply_tag_by_name(buffer, "link", &start_iter, &iter);
279         gtk_text_buffer_insert(buffer, &iter, _(".\n\n"), -1);
280
281         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
282                                 scrolledwin,
283                                 gtk_label_new(_("Info")));
284
285         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
286         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
287                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
288         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
289                                             GTK_SHADOW_IN);
290
291         text = gtk_text_view_new();
292         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
293         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
294         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
295         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
296         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
297         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
298
299         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
300         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
301
302         /* init formatting tag: indentation  for list items */
303         gtk_text_buffer_create_tag(buffer, "indented-list-item",
304                                 "indent", 24,
305                                 NULL);
306         gtk_text_buffer_create_tag(buffer, "underlined-list-title",
307                                 "underline", PANGO_UNDERLINE_SINGLE,
308                                 NULL);
309
310         mark = gtk_text_buffer_create_mark(buffer, "mark", &iter, TRUE);
311         gtk_text_buffer_insert(buffer, &iter, (_("The Sylpheed-Claws Team\n")), -1);
312         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
313         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
314
315         for (i = 0; TEAM_LIST[i] != NULL; i++) {
316                 gtk_text_buffer_move_mark(buffer, mark, &iter);
317                 if (g_utf8_validate(TEAM_LIST[i], -1, NULL))
318                         gtk_text_buffer_insert(buffer, &iter, TEAM_LIST[i], -1);
319                 else {
320                         gchar *conv = conv_codeset_strdup(TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
321                         if (conv)
322                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
323                         g_free(conv);
324                 }
325                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
326                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
327                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
328         }
329
330         gtk_text_buffer_move_mark(buffer, mark, &iter);
331         gtk_text_buffer_insert(buffer, &iter, (_("\nPrevious team members\n")), -1);
332         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
333         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
334
335         for (i = 0; EX_TEAM_LIST[i] != NULL; i++) {
336                 gtk_text_buffer_move_mark(buffer, mark, &iter);
337                 if (g_utf8_validate(EX_TEAM_LIST[i], -1, NULL))
338                         gtk_text_buffer_insert(buffer, &iter, EX_TEAM_LIST[i], -1);
339                 else {
340                         gchar *conv = conv_codeset_strdup(EX_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
341                         if (conv)
342                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
343                         g_free(conv);
344                 }
345                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
346                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
347                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
348         }
349
350         gtk_text_buffer_move_mark(buffer, mark, &iter);
351         gtk_text_buffer_insert(buffer, &iter, (_("\nThe translation team\n")), -1);
352         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
353         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
354
355         for (i = 0; TRANS_TEAM_LIST[i] != NULL; i++) {
356                 gtk_text_buffer_move_mark(buffer, mark, &iter);
357                 if (g_utf8_validate(TRANS_TEAM_LIST[i], -1, NULL))
358                         gtk_text_buffer_insert(buffer, &iter, TRANS_TEAM_LIST[i], -1);
359                 else {
360                         gchar *conv = conv_codeset_strdup(TRANS_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
361                         if (conv)
362                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
363                         g_free(conv);
364                 }
365                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
366                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
367                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
368         }
369
370         gtk_text_buffer_move_mark(buffer, mark, &iter);
371         gtk_text_buffer_insert(buffer, &iter, (_("\nDocumentation team\n")), -1);
372         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
373         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
374
375         for (i = 0; DOC_TEAM_LIST[i] != NULL; i++) {
376                 gtk_text_buffer_move_mark(buffer, mark, &iter);
377                 if (g_utf8_validate(DOC_TEAM_LIST[i], -1, NULL))
378                         gtk_text_buffer_insert(buffer, &iter, DOC_TEAM_LIST[i], -1);
379                 else {
380                         gchar *conv = conv_codeset_strdup(DOC_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
381                         if (conv)
382                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
383                         g_free(conv);
384                 }
385                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
386                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
387                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
388         }
389
390         gtk_text_buffer_move_mark(buffer, mark, &iter);
391         gtk_text_buffer_insert(buffer, &iter, (_("\nLogo\n")), -1);
392         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
393         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
394
395         for (i = 0; LOGO_LIST[i] != NULL; i++) {
396                 gtk_text_buffer_move_mark(buffer, mark, &iter);
397                 if (g_utf8_validate(LOGO_LIST[i], -1, NULL))
398                         gtk_text_buffer_insert(buffer, &iter, LOGO_LIST[i], -1);
399                 else {
400                         gchar *conv = conv_codeset_strdup(LOGO_LIST[i], CS_ISO_8859_1, CS_UTF_8);
401                         if (conv)
402                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
403                         g_free(conv);
404                 }
405                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
406                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
407                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
408         }
409
410         gtk_text_buffer_move_mark(buffer, mark, &iter);
411         gtk_text_buffer_insert(buffer, &iter, (_("\nIcons\n")), -1);
412         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
413         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
414
415         for (i = 0; ICONS_LIST[i] != NULL; i++) {
416                 gtk_text_buffer_move_mark(buffer, mark, &iter);
417                 if (g_utf8_validate(ICONS_LIST[i], -1, NULL))
418                         gtk_text_buffer_insert(buffer, &iter, ICONS_LIST[i], -1);
419                 else {
420                         gchar *conv = conv_codeset_strdup(ICONS_LIST[i], CS_ISO_8859_1, CS_UTF_8);
421                         if (conv)
422                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
423                         g_free(conv);
424                 }
425                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
426                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
427                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
428         }
429
430         gtk_text_buffer_move_mark(buffer, mark, &iter);
431         gtk_text_buffer_insert(buffer, &iter, (_("\nContributors\n")), -1);
432         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
433         gtk_text_buffer_apply_tag_by_name(buffer, "underlined-list-title", &start_iter, &iter);
434
435         for (i = 0; CONTRIBS_LIST[i] != NULL; i++) {
436                 gtk_text_buffer_move_mark(buffer, mark, &iter);
437                 if (g_utf8_validate(CONTRIBS_LIST[i], -1, NULL))
438                         gtk_text_buffer_insert(buffer, &iter, CONTRIBS_LIST[i], -1);
439                 else {
440                         gchar *conv = conv_codeset_strdup(CONTRIBS_LIST[i], CS_ISO_8859_1, CS_UTF_8);
441                         if (conv)
442                                 gtk_text_buffer_insert(buffer, &iter, conv, -1);
443                         g_free(conv);
444                 }
445                 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
446                 gtk_text_buffer_apply_tag_by_name(buffer, "indented-list-item", &start_iter, &iter);
447                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
448         }
449
450         gtk_text_buffer_delete_mark(buffer, mark);      
451
452         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
453                                  scrolledwin,
454                                  gtk_label_new(_("Authors")));
455
456         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
457         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
458                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
459         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
460                                             GTK_SHADOW_IN);
461
462         text = gtk_text_view_new();
463         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
464         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
465         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
466         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
467         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
468         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
469
470         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
471         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
472
473         gtk_text_buffer_insert(buffer, &iter,
474                 _("This program is free software; you can redistribute it and/or modify "
475                   "it under the terms of the GNU General Public License as published by "
476                   "the Free Software Foundation; either version 2, or (at your option) "
477                   "any later version.\n\n"), -1);
478
479         gtk_text_buffer_insert(buffer, &iter,
480                 _("This program is distributed in the hope that it will be useful, "
481                   "but WITHOUT ANY WARRANTY; without even the implied warranty of "
482                   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
483                   "See the GNU General Public License for more details.\n\n"), -1);
484
485         gtk_text_buffer_insert(buffer, &iter,
486                 _("You should have received a copy of the GNU General Public License "
487                   "along with this program; if not, write to the Free Software "
488                   "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
489                   "MA 02110-1301, USA.\n\n"), -1);
490 #ifdef USE_OPENSSL
491         gtk_text_buffer_create_tag(buffer, "link",
492                                 "foreground-gdk", &uri_color,
493                                 NULL);
494
495         gtk_text_buffer_insert(buffer, &iter,
496                 _("This product includes software developed by the OpenSSL Project "
497                   "for use in the OpenSSL Toolkit ("), -1);
498         mark = gtk_text_buffer_create_mark(buffer, "mark", &iter, TRUE);
499         gtk_text_buffer_insert(buffer, &iter, _("http://www.openssl.org/"), -1);
500         gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
501         gtk_text_buffer_apply_tag_by_name(buffer, "link", &start_iter, &iter);
502         gtk_text_buffer_insert(buffer, &iter, _(").\n\n"), -1);
503 #endif
504
505         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
506                                  scrolledwin,
507                                  gtk_label_new(_("License")));
508
509         gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
510
511         gtkut_stock_button_set_create(&confirm_area, &close_button, GTK_STOCK_CLOSE,
512                                       NULL, NULL, NULL, NULL);
513         gtk_box_pack_end(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 4);
514         gtk_widget_grab_default(close_button);
515         gtk_widget_grab_focus(close_button);
516         g_signal_connect_closure
517                 (G_OBJECT(close_button), "clicked",
518                  g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete),
519                                      window, NULL), FALSE);
520
521         gtk_widget_show_all(window);
522 }
523
524 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
525 {
526         if (event && event->keyval == GDK_Escape)
527                 gtk_widget_hide(window);
528         return FALSE;
529 }
530
531 static void about_uri_clicked(GtkButton *button, gpointer data)
532 {
533         open_uri(HOMEPAGE_URI, prefs_common.uri_cmd);
534 }