3b64e5644ff9d600d9e06b0c5fd699044c81c657
[claws.git] / src / gtk / about.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
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 #include "menu.h"
52 #include "textview.h"
53
54 static GtkWidget *window;
55 static gchar* uri_hover = NULL;
56 static GtkTextIter uri_hover_start_iter;
57 static GtkTextIter uri_hover_end_iter;
58 static GdkCursor *hand_cursor = NULL;
59 static GdkCursor *text_cursor = NULL;
60
61 static void about_create(void);
62 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
63 static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj,
64                                         GdkEvent *event, GtkTextIter *iter,
65                                         GtkWidget *textview);
66 static void about_open_link_cb(GtkWidget *widget, guint action, void *data);
67 static void about_copy_link_cb(GtkWidget *widget, guint action, void *data);
68 static gboolean about_textview_motion_notify(GtkWidget *widget,
69                                         GdkEventMotion *event,
70                                         GtkWidget *textview);
71 static gboolean about_textview_leave_notify(GtkWidget *widget,
72                                         GdkEventCrossing *event,
73                                         GtkWidget *textview);
74 static void about_textview_uri_update(GtkWidget *textview, gint x, gint y);
75
76 static GtkItemFactoryEntry textview_link_popup_entries[] = 
77 {
78         {N_("/_Open with Web browser"), NULL, about_open_link_cb, 0, NULL},
79         {N_("/Copy this _link"),        NULL, about_copy_link_cb, 0, NULL},
80 };
81
82 static GtkWidget *link_popupmenu;
83
84
85 void about_show(void)
86 {
87         if (!window)
88                 about_create();
89         else
90                 gtk_window_present(GTK_WINDOW(window));
91 }
92
93 static void about_create(void)
94 {
95         GtkWidget *vbox1;
96         GtkWidget *image;       
97         GtkWidget *vbox2;
98         GtkWidget *label;
99         GtkWidget *button;
100         GtkWidget *scrolledwin;
101         GtkWidget *notebook;
102         GtkWidget *hbox;
103         char *markup;
104         GtkWidget *text;
105         GtkWidget *confirm_area;
106         GtkWidget *close_button;
107         GtkTextBuffer *buffer;
108         GtkTextIter iter;
109         GtkTextTag *tag;
110         GdkColor uri_color;
111         GdkPixbuf *active_pixbuf;
112         GdkPixbuf *inactive_pixbuf;
113 #if HAVE_SYS_UTSNAME_H
114         struct utsname utsbuf;
115 #endif
116         gchar buf[1024];
117         gint i;
118
119         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
120         gtk_window_set_title(GTK_WINDOW(window), _("About Claws Mail"));
121         gtk_container_set_border_width(GTK_CONTAINER(window), 8);
122         gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
123         gtk_widget_set_size_request(window, 450, -1);
124         g_signal_connect(G_OBJECT(window), "delete_event",
125                          G_CALLBACK(gtk_widget_hide_on_delete), NULL);
126         g_signal_connect(G_OBJECT(window), "key_press_event",
127                          G_CALLBACK(key_pressed), NULL);
128         gtk_widget_realize(window);
129
130         vbox1 = gtk_vbox_new(FALSE, 8);
131         gtk_container_add(GTK_CONTAINER(window), vbox1);
132
133         hbox = gtk_hbox_new(FALSE, 0);
134         gtk_widget_show (hbox);
135         gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0);
136
137         image = stock_pixmap_widget(window, STOCK_PIXMAP_CLAWS_MAIL_LOGO);
138         gtk_box_pack_start(GTK_BOX(hbox), image, TRUE, TRUE, 0);
139
140         vbox2 = gtk_vbox_new (FALSE, 0);
141         gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
142
143         label = gtk_label_new("");
144         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
145         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
146         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
147         markup = g_markup_printf_escaped
148                 ("<span weight=\"bold\" size=\"xx-large\">Claws Mail</span>\nversion %s",
149                  VERSION);
150         gtk_label_set_markup(GTK_LABEL(label), markup);
151         g_free(markup);
152
153         button = gtkut_get_link_btn(window, HOMEPAGE_URI, " "HOMEPAGE_URI" ");
154         gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
155
156         label = gtk_label_new
157                 (_("Copyright (C) 1999-2006 Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>\n"
158                  "and the Claws Mail team"));
159         gtk_misc_set_padding(GTK_MISC(label), 0, 12);
160         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
161         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
162         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
163         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
164
165         notebook = gtk_notebook_new();
166         gtk_widget_set_size_request(notebook, -1, 220);
167         gtk_widget_show(notebook);
168
169         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
170         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
171                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
172         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
173                                             GTK_SHADOW_IN);
174
175         text = gtk_text_view_new();
176         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
177         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
178         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
179         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
180         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
181         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
182         gtk_widget_add_events(text, GDK_LEAVE_NOTIFY_MASK);
183
184         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
185         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
186
187         /* textview link style (based upon main prefs) */
188         gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
189                                 (GdkColor*)&uri_color);
190         tag = gtk_text_buffer_create_tag(buffer, "link",
191                                 "foreground-gdk", &uri_color,
192                                 "wrap-mode", GTK_WRAP_NONE,
193                                 NULL);
194         gtk_text_buffer_create_tag(buffer, "link-hover",
195                                 "foreground-gdk", &uri_color,
196                                 "underline", PANGO_UNDERLINE_SINGLE,
197                                 NULL);
198
199         gtk_text_buffer_insert(buffer, &iter, _(
200                                 "Claws Mail is a lightweight, fast and "
201                                 "highly-configurable email client.\n\n"
202                                 "For further information visit the Claws Mail "
203                                 "website:\n"), -1);
204         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, HOMEPAGE_URI, -1,
205                                 "link", NULL);
206         gtk_text_buffer_insert(buffer, &iter, _("\n\n"
207                                 "Claws Mail is free software released "
208                                 "under the GPL license. If you wish to donate "
209                                 "to the Claws Mail project you can do "
210                                 "so at:\n"), -1);
211         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, DONATE_URI, -1,
212                                 "link", NULL);
213
214         gtk_text_buffer_create_tag(buffer, "indented-list-item",
215                                 "indent", 8,
216                                 NULL);
217         gtk_text_buffer_create_tag(buffer, "underlined-list-title",
218                                 "underline", PANGO_UNDERLINE_SINGLE,
219                                 NULL);
220
221         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\n\nSystem Information\n")), -1,
222                         "underlined-list-title", NULL);
223
224 #if HAVE_SYS_UTSNAME_H
225         uname(&utsbuf);
226         g_snprintf(buf, sizeof(buf),
227                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
228                      "Locale: %s (charset: %s)\n"
229                      "Operating System: %s %s (%s)"),
230                    gtk_major_version, gtk_minor_version, gtk_micro_version,
231                    glib_major_version, glib_minor_version, glib_micro_version,
232                    conv_get_current_locale(), conv_get_locale_charset_str(),
233                    utsbuf.sysname, utsbuf.release, utsbuf.machine);
234 #elif defined(G_OS_WIN32)
235         g_snprintf(buf, sizeof(buf),
236                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
237                      "Locale: %s (charset: %s)\n"
238                      "Operating System: %s"),
239                    gtk_major_version, gtk_minor_version, gtk_micro_version,
240                    glib_major_version, glib_minor_version, glib_micro_version,
241                    conv_get_current_locale(), conv_get_locale_charset_str(),
242                    "Win32");
243 #else
244         g_snprintf(buf, sizeof(buf),
245                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
246                      "Locale: %s (charset: %s)\n"
247                      "Operating System: unknown"),
248                    gtk_major_version, gtk_minor_version, gtk_micro_version,
249                    glib_major_version, glib_minor_version, glib_micro_version,
250                    conv_get_current_locale(), conv_get_locale_charset_str());
251 #endif
252
253         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, buf, -1,
254                                                  "indented-list-item", NULL);
255
256         gtk_text_buffer_insert(buffer, &iter, "\n", -1);
257
258         g_signal_connect(G_OBJECT(tag), "event",
259                                 G_CALLBACK(about_textview_uri_clicked), text);
260         g_signal_connect(G_OBJECT(text), "motion-notify-event",
261                                 G_CALLBACK(about_textview_motion_notify), text);
262         g_signal_connect(G_OBJECT(text), "leave-notify-event",
263                                 G_CALLBACK(about_textview_leave_notify), text);
264
265         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
266                                 scrolledwin,
267                                 gtk_label_new_with_mnemonic(_("_Info")));
268
269         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
270         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
271                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
272         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
273                                             GTK_SHADOW_IN);
274
275         text = gtk_text_view_new();
276         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
277         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
278         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
279         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
280         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
281         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
282         gtk_widget_add_events(text, GDK_LEAVE_NOTIFY_MASK);
283
284         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
285         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
286
287         /* init formatting tag: indentation  for list items */
288         gtk_text_buffer_create_tag(buffer, "indented-list-item",
289                                 "indent", 8,
290                                 NULL);
291         gtk_text_buffer_create_tag(buffer, "underlined-list-title",
292                                 "underline", PANGO_UNDERLINE_SINGLE,
293                                 NULL);
294
295         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("The Claws Mail Team\n")), -1,
296                         "underlined-list-title", NULL);
297
298         for (i = 0; TEAM_LIST[i] != NULL; i++) {
299                 if (g_utf8_validate(TEAM_LIST[i], -1, NULL))
300                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, TEAM_LIST[i], -1,
301                                         "indented-list-item", NULL);
302                 else {
303                         gchar *conv = conv_codeset_strdup(TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
304                         if (conv)
305                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
306                                                 "indented-list-item", NULL);
307                         g_free(conv);
308                 }
309                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
310         }
311
312         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\nPrevious team members\n")), -1,
313                         "underlined-list-title", NULL);
314
315         for (i = 0; EX_TEAM_LIST[i] != NULL; i++) {
316                 if (g_utf8_validate(EX_TEAM_LIST[i], -1, NULL))
317                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, EX_TEAM_LIST[i], -1,
318                                         "indented-list-item", NULL);
319                 else {
320                         gchar *conv = conv_codeset_strdup(EX_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
321                         if (conv)
322                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
323                                                 "indented-list-item", NULL);
324                         g_free(conv);
325                 }
326                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
327         }
328
329         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\nThe translation team\n")), -1,
330                         "underlined-list-title", NULL);
331
332         for (i = 0; TRANS_TEAM_LIST[i] != NULL; i++) {
333                 if (g_utf8_validate(TRANS_TEAM_LIST[i], -1, NULL))
334                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, TRANS_TEAM_LIST[i], -1,
335                                         "indented-list-item", NULL);
336                 else {
337                         gchar *conv = conv_codeset_strdup(TRANS_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
338                         if (conv)
339                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
340                                                 "indented-list-item", NULL);
341                         g_free(conv);
342                 }
343                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
344         }
345
346         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\nDocumentation team\n")), -1,
347                         "underlined-list-title", NULL);
348
349         for (i = 0; DOC_TEAM_LIST[i] != NULL; i++) {
350                 if (g_utf8_validate(DOC_TEAM_LIST[i], -1, NULL))
351                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, DOC_TEAM_LIST[i], -1,
352                                         "indented-list-item", NULL);
353                 else {
354                         gchar *conv = conv_codeset_strdup(DOC_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
355                         if (conv)
356                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
357                                                 "indented-list-item", NULL);
358                         g_free(conv);
359                 }
360                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
361         }
362
363         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\nLogo\n")), -1,
364                         "underlined-list-title", NULL);
365
366         for (i = 0; LOGO_LIST[i] != NULL; i++) {
367                 if (g_utf8_validate(LOGO_LIST[i], -1, NULL))
368                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, LOGO_LIST[i], -1,
369                                         "indented-list-item", NULL);
370                 else {
371                         gchar *conv = conv_codeset_strdup(LOGO_LIST[i], CS_ISO_8859_1, CS_UTF_8);
372                         if (conv)
373                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
374                                                 "indented-list-item", NULL);
375                         g_free(conv);
376                 }
377                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
378         }
379
380         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\nIcons\n")), -1,
381                         "underlined-list-title", NULL);
382
383         for (i = 0; ICONS_LIST[i] != NULL; i++) {
384                 if (g_utf8_validate(ICONS_LIST[i], -1, NULL))
385                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, ICONS_LIST[i], -1,
386                                         "indented-list-item", NULL);
387                 else {
388                         gchar *conv = conv_codeset_strdup(ICONS_LIST[i], CS_ISO_8859_1, CS_UTF_8);
389                         if (conv)
390                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
391                                                 "indented-list-item", NULL);
392                         g_free(conv);
393                 }
394                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
395         }
396
397         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\nContributors\n")), -1,
398                         "underlined-list-title", NULL);
399
400         for (i = 0; CONTRIBS_LIST[i] != NULL; i++) {
401                 if (g_utf8_validate(CONTRIBS_LIST[i], -1, NULL))
402                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, CONTRIBS_LIST[i], -1,
403                                         "indented-list-item", NULL);
404                 else {
405                         gchar *conv = conv_codeset_strdup(CONTRIBS_LIST[i], CS_ISO_8859_1, CS_UTF_8);
406                         if (conv)
407                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
408                                                 "indented-list-item", NULL);
409                         g_free(conv);
410                 }
411                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
412         }
413
414         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
415                                  scrolledwin,
416                                  gtk_label_new_with_mnemonic(_("_Authors")));
417
418         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
419         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
420                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
421         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
422                                             GTK_SHADOW_IN);
423
424         text = gtk_text_view_new();
425         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
426         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
427         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
428         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
429         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
430         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
431         gtk_widget_add_events(text, GDK_LEAVE_NOTIFY_MASK);
432
433         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
434         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
435
436         gtk_text_buffer_insert(buffer, &iter, _("Compiled-in Features\n"), -1);
437
438         gtk_text_buffer_create_tag(buffer, "bold", "weight", PANGO_WEIGHT_BOLD,
439                                    NULL);
440
441         stock_pixbuf_gdk(window, STOCK_PIXMAP_ACTIVE, &active_pixbuf);
442         stock_pixbuf_gdk(window, STOCK_PIXMAP_INACTIVE, &inactive_pixbuf);
443
444 #if INET6
445         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
446 #else
447         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
448 #endif
449         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" IPv6 "), -1,
450                                                  "bold", NULL);
451         gtk_text_buffer_insert(buffer, &iter, 
452                 (gchar *)Q_("IPv6|adds support for IPv6 addresses, the new internet "
453                             "addressing protocol\n"), -1);
454
455 #if HAVE_ICONV
456         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
457 #else
458         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
459 #endif
460         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" iconv "), -1,
461                                                  "bold", NULL);
462         gtk_text_buffer_insert(buffer, &iter, 
463                 (gchar *)Q_("iconv|allows converting to and from different character sets\n"), -1);
464
465 #if HAVE_LIBCOMPFACE
466         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
467 #else
468         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
469 #endif
470         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" compface "), -1,
471                                                  "bold", NULL);
472         gtk_text_buffer_insert(buffer, &iter, 
473                 (gchar *)Q_("compface|adds support for the X-Face header\n"), -1);
474
475 #if USE_OPENSSL
476         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
477 #else
478         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
479 #endif
480         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" OpenSSL "), -1,
481                                                  "bold", NULL);
482         gtk_text_buffer_insert(buffer, &iter, 
483                 (gchar *)Q_("OpenSSL|adds support for encrypted connections to servers\n"), -1);
484
485 #if USE_LDAP
486         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
487 #else
488         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
489 #endif
490         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" LDAP "), -1,
491                                                  "bold", NULL);
492         gtk_text_buffer_insert(buffer, &iter, 
493                 (gchar *)Q_("LDAP|adds support for LDAP shared addressbooks\n"), -1);
494
495 #if USE_JPILOT
496         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
497 #else
498         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
499 #endif
500         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" JPilot "), -1,
501                                                  "bold", NULL);
502         gtk_text_buffer_insert(buffer, &iter, 
503                 (gchar *)Q_("JPilot|adds support for PalmOS addressbooks\n"), -1);
504
505 #if USE_ASPELL
506         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
507 #else
508         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
509 #endif
510         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" GNU/aspell "), -1,
511                                                  "bold", NULL);
512         gtk_text_buffer_insert(buffer, &iter, 
513                 (gchar *)Q_("GNU/aspell|adds support for spell checking\n"), -1);
514
515 #if HAVE_LIBETPAN
516         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
517 #else
518         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
519 #endif
520         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" libetpan "), -1,
521                                                  "bold", NULL);
522         gtk_text_buffer_insert(buffer, &iter, 
523                 (gchar *)Q_("libetpan|adds support for IMAP servers\n"), -1);
524
525 #if USE_GNOMEPRINT
526         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
527 #else
528         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
529 #endif
530         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" libgnomeprint "), -1,
531                                                  "bold", NULL);
532         gtk_text_buffer_insert(buffer, &iter, 
533                 (gchar *)Q_("libgnomeprint|adds support for a complete print dialog\n"), -1);
534
535 #if HAVE_LIBSM
536         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
537 #else
538         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
539 #endif
540         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" libSM "), -1,
541                                                  "bold", NULL);
542         gtk_text_buffer_insert(buffer, &iter, 
543                 (gchar *)Q_("libSM|adds support for session handling\n"), -1);
544
545         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
546                                  scrolledwin,
547                                  gtk_label_new_with_mnemonic(_("_Features")));
548
549         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
550         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
551                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
552         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
553                                             GTK_SHADOW_IN);
554
555         text = gtk_text_view_new();
556         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
557         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
558         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
559         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
560         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
561         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
562
563         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
564         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
565
566         gtk_text_buffer_insert(buffer, &iter,
567                 _("This program is free software; you can redistribute it and/or modify "
568                   "it under the terms of the GNU General Public License as published by "
569                   "the Free Software Foundation; either version 2, or (at your option) "
570                   "any later version.\n\n"), -1);
571
572         gtk_text_buffer_insert(buffer, &iter,
573                 _("This program is distributed in the hope that it will be useful, "
574                   "but WITHOUT ANY WARRANTY; without even the implied warranty of "
575                   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
576                   "See the GNU General Public License for more details.\n\n"), -1);
577
578         gtk_text_buffer_insert(buffer, &iter,
579                 _("You should have received a copy of the GNU General Public License "
580                   "along with this program; if not, write to the Free Software "
581                   "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
582                   "MA 02110-1301, USA.\n\n"), -1);
583 #ifdef USE_OPENSSL
584         tag = gtk_text_buffer_create_tag(buffer, "link",
585                 "foreground-gdk", &uri_color,
586                 NULL);
587         gtk_text_buffer_create_tag(buffer, "link-hover",
588                 "foreground-gdk", &uri_color,
589                 "underline", PANGO_UNDERLINE_SINGLE,
590                 NULL);
591
592         gtk_text_buffer_insert(buffer, &iter,
593                 _("This product includes software developed by the OpenSSL Project "
594                   "for use in the OpenSSL Toolkit ("), -1);
595         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, OPENSSL_URI, -1,
596                 "link", NULL);
597         gtk_text_buffer_insert(buffer, &iter, _(").\n"), -1);
598
599         g_signal_connect(G_OBJECT(tag), "event",
600                                 G_CALLBACK(about_textview_uri_clicked), text);
601         g_signal_connect(G_OBJECT(text), "motion-notify-event",
602                          G_CALLBACK(about_textview_motion_notify), text);
603         g_signal_connect(G_OBJECT(text), "leave-notify-event",
604                                 G_CALLBACK(about_textview_leave_notify), text);
605 #endif
606
607         gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
608                                  scrolledwin,
609                                  gtk_label_new_with_mnemonic(_("_License")));
610
611         gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
612
613         gtkut_stock_button_set_create(&confirm_area, &close_button, GTK_STOCK_CLOSE,
614                                       NULL, NULL, NULL, NULL);
615         gtk_box_pack_end(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 4);
616         gtk_widget_grab_default(close_button);
617         gtk_widget_grab_focus(close_button);
618         g_signal_connect_closure
619                 (G_OBJECT(close_button), "clicked",
620                  g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete),
621                                      window, NULL), FALSE);
622
623         gtk_widget_show_all(window);
624 }
625
626 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
627 {
628         if (event && event->keyval == GDK_Escape)
629                 gtk_widget_hide(window);
630         return FALSE;
631 }
632
633 static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj,
634                                         GdkEvent *event, GtkTextIter *iter,
635                                         GtkWidget *textview)
636 {
637         GtkTextIter start_iter, end_iter;
638         GdkEventButton *bevent;
639         gchar *link = NULL;
640
641         if (!event || !tag) {
642                 return FALSE;
643         }
644
645         if (event->type != GDK_BUTTON_PRESS && event->type != GDK_2BUTTON_PRESS
646                 && event->type != GDK_BUTTON_RELEASE) {
647                 return FALSE;
648         }
649
650         /* get link text from tag */
651         if (get_tag_range(iter, tag, &start_iter,
652                                    &end_iter) == FALSE) {
653                 return FALSE;
654         }
655         link = gtk_text_iter_get_text(&start_iter, &end_iter);
656         if (link == NULL) {
657                 return FALSE;
658         }
659
660         bevent = (GdkEventButton *) event;
661         if (bevent->button == 1 && event->type == GDK_BUTTON_RELEASE) {
662                 GtkTextBuffer *buffer;
663
664                 /* we shouldn't follow a link if the user has selected something */
665                 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
666                 gtk_text_buffer_get_selection_bounds(buffer, &start_iter, &end_iter);
667                 if (gtk_text_iter_get_offset(&start_iter) != gtk_text_iter_get_offset(&end_iter)) {
668                         return FALSE;
669                 }
670                 /* open link and do *not* return TRUE so that
671                    further gtk processing of the signal is done */
672                 open_uri(link, prefs_common.uri_cmd);
673
674         } else {
675                 if (bevent->button == 3 && event->type == GDK_BUTTON_PRESS) {
676                         GtkItemFactory *link_popupfactory;
677                         gint n_entries;
678
679                         n_entries = sizeof(textview_link_popup_entries) /
680                                         sizeof(textview_link_popup_entries[0]);
681                         link_popupmenu = menu_create_items(
682                                                         textview_link_popup_entries, n_entries,
683                                                 "<UriPopupMenu>", &link_popupfactory,
684                                                 textview);
685
686                         g_object_set_data(
687                                         G_OBJECT(link_popupmenu),
688                                         "menu_button", link);
689                         gtk_menu_popup(GTK_MENU(link_popupmenu), 
690                                         NULL, NULL, NULL, NULL, 
691                                         bevent->button, bevent->time);
692
693                         return TRUE;
694                 }
695         }
696         return FALSE;
697 }
698
699 static void about_open_link_cb(GtkWidget *widget, guint action, void *data)
700 {
701         gchar *link = g_object_get_data(G_OBJECT(link_popupmenu),
702                                            "menu_button");
703
704         if (link == NULL) {
705                 return;
706         }
707
708         open_uri(link, prefs_common.uri_cmd);
709         g_object_set_data(G_OBJECT(link_popupmenu), "menu_button",
710                           NULL);
711 }
712
713 static void about_copy_link_cb(GtkWidget *widget, guint action, void *data)
714 {
715         gchar *link = g_object_get_data(G_OBJECT(link_popupmenu),
716                                            "menu_button");
717
718         if (link == NULL) {
719                 return;
720         }
721
722         gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), link, -1);
723         gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), link, -1);
724         g_object_set_data(G_OBJECT(link_popupmenu), "menu_button", NULL);
725 }
726
727 static gboolean about_textview_motion_notify(GtkWidget *widget,
728                                         GdkEventMotion *event,
729                                         GtkWidget *textview)
730 {
731         about_textview_uri_update(textview, event->x, event->y);
732         gdk_window_get_pointer(widget->window, NULL, NULL, NULL);
733
734         return FALSE;
735 }
736
737 static gboolean about_textview_leave_notify(GtkWidget *widget,
738                                         GdkEventCrossing *event,
739                                         GtkWidget *textview)
740 {
741         about_textview_uri_update(textview, -1, -1);
742
743         return FALSE;
744 }
745
746 static void about_textview_uri_update(GtkWidget *textview, gint x, gint y)
747 {
748         GtkTextBuffer *buffer;
749         GtkTextIter start_iter, end_iter;
750         gchar *uri = NULL;
751         gboolean same;
752         
753         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
754
755         if (x != -1 && y != -1) {
756                 gint bx, by;
757                 GtkTextIter iter;
758                 GSList *tags;
759                 GSList *cur;
760             
761                 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(textview), 
762                                 GTK_TEXT_WINDOW_WIDGET,
763                                 x, y, &bx, &by);
764                 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(textview),
765                                 &iter, bx, by);
766
767                 tags = gtk_text_iter_get_tags(&iter);
768                 for (cur = tags; cur != NULL; cur = cur->next) {
769                         GtkTextTag *tag = cur->data;
770                         char *name;
771
772                         g_object_get(G_OBJECT(tag), "name", &name, NULL);
773                         if (strcmp(name, "link") == 0
774                             && get_tag_range(&iter, tag, &start_iter, &end_iter)) {
775                                 uri = gtk_text_iter_get_text(&start_iter, &end_iter);
776                         }
777                         g_free(name);
778
779                         if (uri) {
780                                 break;
781                         }
782                 }
783                 g_slist_free(tags);
784         }
785
786         /* compare previous hovered link and this one
787            (here links must be unique in text buffer otherwise ClickableText structures should be
788            used as in textview.c) */
789         same = (uri != NULL && uri_hover != NULL
790                 && strcmp((char*)uri, (char*)uri_hover) == 0);
791
792         if (same == FALSE) {
793                 GdkWindow *window;
794
795                 if (uri_hover) {
796                         gtk_text_buffer_remove_tag_by_name(buffer,
797                                         "link-hover",
798                                         &uri_hover_start_iter,
799                                         &uri_hover_end_iter);
800                 }
801                     
802                 uri_hover = uri;
803                 if (uri) {
804                         uri_hover_start_iter = start_iter;
805                         uri_hover_end_iter = end_iter;
806
807                         gtk_text_buffer_apply_tag_by_name(buffer,
808                                         "link-hover",
809                                         &start_iter,
810                                         &end_iter);
811                 }
812                 
813                 window = gtk_text_view_get_window(GTK_TEXT_VIEW(textview),
814                                                 GTK_TEXT_WINDOW_TEXT);
815                 if (!hand_cursor)
816                         hand_cursor = gdk_cursor_new(GDK_HAND2);
817                 if (!text_cursor)
818                         text_cursor = gdk_cursor_new(GDK_XTERM);
819                 gdk_window_set_cursor(window, uri ? hand_cursor : text_cursor);
820         }
821 }