2008-10-09 [colin] 3.6.0cvs20
[claws.git] / src / gtk / about.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2008 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 3 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, see <http://www.gnu.org/licenses/>.
17  * 
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/gtk.h>
30 #if HAVE_SYS_UTSNAME_H
31 #  include <sys/utsname.h>
32 #endif
33 #include <errno.h>
34
35 #include "about.h"
36 #include "gtkutils.h"
37 #include "stock_pixmap.h"
38 #include "prefs_common.h"
39 #include "utils.h"
40 #include "version.h"
41 #include "authors.h"
42 #include "codeconv.h"
43 #include "menu.h"
44 #include "textview.h"
45
46 static GtkWidget *window;
47 static gchar* uri_hover = NULL;
48 static GtkTextIter uri_hover_start_iter;
49 static GtkTextIter uri_hover_end_iter;
50 static GdkCursor *hand_cursor = NULL;
51 static GdkCursor *text_cursor = NULL;
52
53 static void about_create(void);
54 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
55 static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj,
56                                         GdkEvent *event, GtkTextIter *iter,
57                                         GtkWidget *textview);
58 static gboolean about_textview_motion_notify(GtkWidget *widget,
59                                         GdkEventMotion *event,
60                                         GtkWidget *textview);
61 static gboolean about_textview_leave_notify(GtkWidget *widget,
62                                         GdkEventCrossing *event,
63                                         GtkWidget *textview);
64 static void about_textview_uri_update(GtkWidget *textview, gint x, gint y);
65
66 static GtkWidget *link_popupmenu;
67
68
69 void about_show(void)
70 {
71         if (!window)
72                 about_create();
73         else 
74                 gtk_window_present(GTK_WINDOW(window));
75         
76 }
77
78 static GtkWidget *about_create_child_page_info(void)
79 {
80         GtkWidget *scrolledwin;
81         GtkWidget *text;
82         GtkTextBuffer *buffer;
83         GtkTextIter iter;
84         GdkColor uri_color;
85         gchar buf[1024];
86         GtkTextTag *tag;
87 #if HAVE_SYS_UTSNAME_H
88         struct utsname utsbuf;
89 #endif
90
91         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
92         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
93                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
94         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
95                                             GTK_SHADOW_IN);
96
97         text = gtk_text_view_new();
98         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
99         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
100         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
101         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
102         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
103         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
104         gtk_widget_add_events(text, GDK_LEAVE_NOTIFY_MASK);
105
106         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
107         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
108
109         /* textview link style (based upon main prefs) */
110         gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
111                                 (GdkColor*)&uri_color);
112         tag = gtk_text_buffer_create_tag(buffer, "link",
113                                 "foreground-gdk", &uri_color,
114                                 "wrap-mode", GTK_WRAP_NONE,
115                                 NULL);
116         gtk_text_buffer_create_tag(buffer, "link-hover",
117                                 "foreground-gdk", &uri_color,
118                                 "underline", PANGO_UNDERLINE_SINGLE,
119                                 NULL);
120
121         gtk_text_buffer_insert(buffer, &iter, _(
122                                 "Claws Mail is a lightweight, fast and "
123                                 "highly-configurable email client.\n\n"
124                                 "For further information visit the Claws Mail "
125                                 "website:\n"), -1);
126         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, HOMEPAGE_URI, -1,
127                                 "link", NULL);
128         gtk_text_buffer_insert(buffer, &iter, _("\n\n"
129                                 "Claws Mail is free software released "
130                                 "under the GPL license. If you wish to donate "
131                                 "to the Claws Mail project you can do "
132                                 "so at:\n"), -1);
133         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, DONATE_URI, -1,
134                                 "link", NULL);
135
136         gtk_text_buffer_create_tag(buffer, "indented-list-item",
137                                 "indent", 8,
138                                 NULL);
139         gtk_text_buffer_create_tag(buffer, "underlined-list-title",
140                                 "underline", PANGO_UNDERLINE_SINGLE,
141                                 NULL);
142 #ifdef GENERIC_UMPC
143         gtk_text_buffer_insert(buffer, &iter, _(
144                                 "\n\nCopyright (C) 1999-2008\nHiroyuki Yamamoto <hiro-y@kcn.ne.jp>\n"
145                                 "and the Claws Mail team"), -1);
146 #endif
147         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("\n\nSystem Information\n")), -1,
148                         "underlined-list-title", NULL);
149
150 #if HAVE_SYS_UTSNAME_H
151         uname(&utsbuf);
152         g_snprintf(buf, sizeof(buf),
153                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
154                      "Locale: %s (charset: %s)\n"
155                      "Operating System: %s %s (%s)"),
156                    gtk_major_version, gtk_minor_version, gtk_micro_version,
157                    glib_major_version, glib_minor_version, glib_micro_version,
158                    conv_get_current_locale(), conv_get_locale_charset_str(),
159                    utsbuf.sysname, utsbuf.release, utsbuf.machine);
160 #elif defined(G_OS_WIN32)
161         g_snprintf(buf, sizeof(buf),
162                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
163                      "Locale: %s (charset: %s)\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                    conv_get_current_locale(), conv_get_locale_charset_str(),
168                    "Win32");
169 #else
170         g_snprintf(buf, sizeof(buf),
171                    _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
172                      "Locale: %s (charset: %s)\n"
173                      "Operating System: unknown"),
174                    gtk_major_version, gtk_minor_version, gtk_micro_version,
175                    glib_major_version, glib_minor_version, glib_micro_version,
176                    conv_get_current_locale(), conv_get_locale_charset_str());
177 #endif
178
179         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, buf, -1,
180                                                  "indented-list-item", NULL);
181
182         gtk_text_buffer_insert(buffer, &iter, "\n", -1);
183
184         g_signal_connect(G_OBJECT(tag), "event",
185                                 G_CALLBACK(about_textview_uri_clicked), text);
186         g_signal_connect(G_OBJECT(text), "motion-notify-event",
187                                 G_CALLBACK(about_textview_motion_notify), text);
188         g_signal_connect(G_OBJECT(text), "leave-notify-event",
189                                 G_CALLBACK(about_textview_leave_notify), text);
190
191         return scrolledwin;
192 }
193
194 static GtkWidget *about_create_child_page_authors(void)
195 {
196         GtkWidget *scrolledwin;
197         GtkWidget *text;
198         GtkTextBuffer *buffer;
199         GtkTextIter iter;
200         gint i;
201
202         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
203         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
204                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
205         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
206                                             GTK_SHADOW_IN);
207
208         text = gtk_text_view_new();
209         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
210         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
211         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
212         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
213         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
214         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
215         gtk_widget_add_events(text, GDK_LEAVE_NOTIFY_MASK);
216
217         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
218         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
219
220         /* init formatting tag: indentation  for list items */
221         gtk_text_buffer_create_tag(buffer, "indented-list-item",
222                                 "indent", 8,
223                                 NULL);
224         gtk_text_buffer_create_tag(buffer, "underlined-list-title",
225                                 "underline", PANGO_UNDERLINE_SINGLE,
226                                 NULL);
227
228         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("The Claws Mail Team")), -1,
229                         "underlined-list-title", NULL);
230         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
231
232         for (i = 0; TEAM_LIST[i] != NULL; i++) {
233                 if (g_utf8_validate(TEAM_LIST[i], -1, NULL))
234                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, TEAM_LIST[i], -1,
235                                         "indented-list-item", NULL);
236                 else {
237                         gchar *conv = conv_codeset_strdup(TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
238                         if (conv)
239                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
240                                                 "indented-list-item", NULL);
241                         g_free(conv);
242                 }
243                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
244         }
245
246         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
247         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("Previous team members")), -1,
248                         "underlined-list-title", NULL);
249         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
250
251         for (i = 0; EX_TEAM_LIST[i] != NULL; i++) {
252                 if (g_utf8_validate(EX_TEAM_LIST[i], -1, NULL))
253                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, EX_TEAM_LIST[i], -1,
254                                         "indented-list-item", NULL);
255                 else {
256                         gchar *conv = conv_codeset_strdup(EX_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
257                         if (conv)
258                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
259                                                 "indented-list-item", NULL);
260                         g_free(conv);
261                 }
262                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
263         }
264
265         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
266         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("The translation team")), -1,
267                         "underlined-list-title", NULL);
268         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
269
270         for (i = 0; TRANS_TEAM_LIST[i] != NULL; i++) {
271                 if (g_utf8_validate(TRANS_TEAM_LIST[i], -1, NULL))
272                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, TRANS_TEAM_LIST[i], -1,
273                                         "indented-list-item", NULL);
274                 else {
275                         gchar *conv = conv_codeset_strdup(TRANS_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
276                         if (conv)
277                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
278                                                 "indented-list-item", NULL);
279                         g_free(conv);
280                 }
281                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
282         }
283
284         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
285         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("Documentation team")), -1,
286                         "underlined-list-title", NULL);
287         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
288
289         for (i = 0; DOC_TEAM_LIST[i] != NULL; i++) {
290                 if (g_utf8_validate(DOC_TEAM_LIST[i], -1, NULL))
291                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, DOC_TEAM_LIST[i], -1,
292                                         "indented-list-item", NULL);
293                 else {
294                         gchar *conv = conv_codeset_strdup(DOC_TEAM_LIST[i], CS_ISO_8859_1, CS_UTF_8);
295                         if (conv)
296                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
297                                                 "indented-list-item", NULL);
298                         g_free(conv);
299                 }
300                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
301         }
302
303         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
304         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("Logo")), -1,
305                         "underlined-list-title", NULL);
306         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
307
308         for (i = 0; LOGO_LIST[i] != NULL; i++) {
309                 if (g_utf8_validate(LOGO_LIST[i], -1, NULL))
310                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, LOGO_LIST[i], -1,
311                                         "indented-list-item", NULL);
312                 else {
313                         gchar *conv = conv_codeset_strdup(LOGO_LIST[i], CS_ISO_8859_1, CS_UTF_8);
314                         if (conv)
315                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
316                                                 "indented-list-item", NULL);
317                         g_free(conv);
318                 }
319                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
320         }
321
322         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
323         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("Icons")), -1,
324                         "underlined-list-title", NULL);
325         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
326
327         for (i = 0; ICONS_LIST[i] != NULL; i++) {
328                 if (g_utf8_validate(ICONS_LIST[i], -1, NULL))
329                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, ICONS_LIST[i], -1,
330                                         "indented-list-item", NULL);
331                 else {
332                         gchar *conv = conv_codeset_strdup(ICONS_LIST[i], CS_ISO_8859_1, CS_UTF_8);
333                         if (conv)
334                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
335                                                 "indented-list-item", NULL);
336                         g_free(conv);
337                 }
338                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
339         }
340
341         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
342         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (_("Contributors")), -1,
343                         "underlined-list-title", NULL);
344         gtk_text_buffer_insert(buffer, &iter, "\n", 1);
345
346         for (i = 0; CONTRIBS_LIST[i] != NULL; i++) {
347                 if (g_utf8_validate(CONTRIBS_LIST[i], -1, NULL))
348                         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, CONTRIBS_LIST[i], -1,
349                                         "indented-list-item", NULL);
350                 else {
351                         gchar *conv = conv_codeset_strdup(CONTRIBS_LIST[i], CS_ISO_8859_1, CS_UTF_8);
352                         if (conv)
353                                 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, conv, -1,
354                                                 "indented-list-item", NULL);
355                         g_free(conv);
356                 }
357                 gtk_text_buffer_insert(buffer, &iter, "\n", 1);
358         }
359
360         return scrolledwin;
361 }
362
363 static GtkWidget *about_create_child_page_features(void)
364 {
365         GtkWidget *scrolledwin;
366         GtkWidget *text;
367         GtkTextBuffer *buffer;
368         GtkTextIter iter;
369         GdkPixbuf *active_pixbuf;
370         GdkPixbuf *inactive_pixbuf;
371
372         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
373         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
374                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
375         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
376                                             GTK_SHADOW_IN);
377
378         text = gtk_text_view_new();
379         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
380         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
381         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
382         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
383         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
384         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
385         gtk_widget_add_events(text, GDK_LEAVE_NOTIFY_MASK);
386
387         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
388         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
389
390         gtk_text_buffer_insert(buffer, &iter, _("Compiled-in Features\n"), -1);
391
392         gtk_text_buffer_create_tag(buffer, "bold", "weight", PANGO_WEIGHT_BOLD,
393                                    NULL);
394
395         stock_pixbuf_gdk(window, STOCK_PIXMAP_CHECKBOX_ON, &active_pixbuf);
396         stock_pixbuf_gdk(window, STOCK_PIXMAP_CHECKBOX_OFF, &inactive_pixbuf);
397
398 #if HAVE_LIBCOMPFACE
399         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
400 #else
401         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
402 #endif
403         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" compface "), -1,
404                                                  "bold", NULL);
405         gtk_text_buffer_insert(buffer, &iter, 
406                 (gchar *)Q_("compface|adds support for the X-Face header\n"), -1);
407
408 #if USE_ENCHANT
409         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
410 #else
411         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
412 #endif
413         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" Enchant "), -1,
414                                                  "bold", NULL);
415         gtk_text_buffer_insert(buffer, &iter, 
416                 (gchar *)Q_("Enchant|adds support for spell checking\n"), -1);
417
418 #if USE_GNUTLS
419         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
420 #else
421         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
422 #endif
423         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" GnuTLS "), -1,
424                                                  "bold", NULL);
425         gtk_text_buffer_insert(buffer, &iter, 
426                 (gchar *)Q_("GnuTLS|adds support for encrypted connections to servers\n"), -1);
427
428 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
429         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
430 #else
431         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
432 #endif
433         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" GTK+ >= 2.10.0 "), -1,
434                                                  "bold", NULL);
435         gtk_text_buffer_insert(buffer, &iter, 
436                 (gchar *)Q_("GTK+ >= 2.10.0|adds support for a complete print dialog\n"), -1);
437
438 #if INET6
439         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
440 #else
441         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
442 #endif
443         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" IPv6 "), -1,
444                                                  "bold", NULL);
445         gtk_text_buffer_insert(buffer, &iter, 
446                 (gchar *)Q_("IPv6|adds support for IPv6 addresses, the new Internet "
447                             "addressing protocol\n"), -1);
448
449 #if HAVE_ICONV
450         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
451 #else
452         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
453 #endif
454         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" iconv "), -1,
455                                                  "bold", NULL);
456         gtk_text_buffer_insert(buffer, &iter, 
457                 (gchar *)Q_("iconv|allows converting to and from different character sets\n"), -1);
458
459 #if USE_JPILOT
460         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
461 #else
462         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
463 #endif
464         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" JPilot "), -1,
465                                                  "bold", NULL);
466         gtk_text_buffer_insert(buffer, &iter, 
467                 (gchar *)Q_("JPilot|adds support for PalmOS addressbooks\n"), -1);
468
469 #if USE_LDAP
470         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
471 #else
472         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
473 #endif
474         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" LDAP "), -1,
475                                                  "bold", NULL);
476         gtk_text_buffer_insert(buffer, &iter, 
477                 (gchar *)Q_("LDAP|adds support for LDAP shared addressbooks\n"), -1);
478
479 #if HAVE_LIBETPAN
480         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
481 #else
482         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
483 #endif
484         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" libetpan "), -1,
485                                                  "bold", NULL);
486         gtk_text_buffer_insert(buffer, &iter, 
487                 (gchar *)Q_("libetpan|adds support for IMAP and NNTP servers\n"), -1);
488
489 #if USE_GNOMEPRINT
490         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
491 #else
492         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
493 #endif
494         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" libgnomeprint "), -1,
495                                                  "bold", NULL);
496         gtk_text_buffer_insert(buffer, &iter, 
497                 (gchar *)Q_("libgnomeprint|adds support for a complete print dialog\n"), -1);
498
499 #if HAVE_LIBSM
500         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
501 #else
502         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
503 #endif
504         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" libSM "), -1,
505                                                  "bold", NULL);
506         gtk_text_buffer_insert(buffer, &iter, 
507                 (gchar *)Q_("libSM|adds support for session handling\n"), -1);
508
509 #if HAVE_NETWORKMANAGER_SUPPORT
510         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
511 #else
512         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
513 #endif
514         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" NetworkManager "), -1,
515                                                  "bold", NULL);
516         gtk_text_buffer_insert(buffer, &iter,
517                 (gchar *)Q_("NetworkManager|adds support for detection of network connection changes\n"), -1);
518
519 #if USE_OPENSSL
520         gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
521 #else
522         gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
523 #endif
524         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" OpenSSL "), -1,
525                                                  "bold", NULL);
526         gtk_text_buffer_insert(buffer, &iter, 
527                 (gchar *)Q_("OpenSSL|adds support for encrypted connections to servers\n"), -1);
528
529         return scrolledwin;
530 }
531
532 static GtkWidget *about_create_child_page_license(void)
533 {
534         GtkWidget *scrolledwin;
535         GtkWidget *text;
536         GtkTextBuffer *buffer;
537         GtkTextIter iter;
538         GdkColor uri_color;
539         GtkTextTag *tag;
540
541         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
542         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
543                                        GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
544         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
545                                             GTK_SHADOW_IN);
546
547         text = gtk_text_view_new();
548         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
549         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
550         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
551         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
552         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
553         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
554
555         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
556         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
557
558         gtk_text_buffer_insert(buffer, &iter,
559                 _("This program is free software; you can redistribute it and/or modify "
560                   "it under the terms of the GNU General Public License as published by "
561                   "the Free Software Foundation; either version 3, or (at your option) "
562                   "any later version.\n\n"), -1);
563
564         gtk_text_buffer_insert(buffer, &iter,
565                 _("This program is distributed in the hope that it will be useful, "
566                   "but WITHOUT ANY WARRANTY; without even the implied warranty of "
567                   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
568                   "See the GNU General Public License for more details.\n\n"), -1);
569
570         /* textview link style (based upon main prefs) */
571         gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
572                         (GdkColor*)&uri_color);
573
574         tag = gtk_text_buffer_create_tag(buffer, "link",
575                 "foreground-gdk", &uri_color,
576                 NULL);
577         gtk_text_buffer_create_tag(buffer, "link-hover",
578                 "foreground-gdk", &uri_color,
579                 "underline", PANGO_UNDERLINE_SINGLE,
580                 NULL);
581
582         gtk_text_buffer_insert(buffer, &iter,
583                 _("You should have received a copy of the GNU General Public License "
584                   "along with this program. If not, see <"), -1);
585         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, 
586                 "http://www.gnu.org/licenses/", -1,
587                 "link", NULL);
588         gtk_text_buffer_insert(buffer, &iter, _(">. \n\n"), -1);
589 #ifdef USE_OPENSSL
590         gtk_text_buffer_insert(buffer, &iter,
591                 _("This product includes software developed by the OpenSSL Project "
592                   "for use in the OpenSSL Toolkit ("), -1);
593         gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, OPENSSL_URI, -1,
594                 "link", NULL);
595         gtk_text_buffer_insert(buffer, &iter, _(").\n"), -1);
596 #endif
597
598         g_signal_connect(G_OBJECT(tag), "event",
599                                 G_CALLBACK(about_textview_uri_clicked), text);
600         g_signal_connect(G_OBJECT(text), "motion-notify-event",
601                          G_CALLBACK(about_textview_motion_notify), text);
602         g_signal_connect(G_OBJECT(text), "leave-notify-event",
603                                 G_CALLBACK(about_textview_leave_notify), text);
604
605         return scrolledwin;
606 }
607
608 static gboolean release_notes_available(void)
609 {
610         gboolean ret = FALSE;
611         gchar *path = NULL;
612
613         path = g_strconcat(DOCDIR, G_DIR_SEPARATOR_S, RELEASE_NOTES_FILE, NULL);
614         ret = (is_file_exist(path));
615         g_free(path);
616
617         return ret;
618 }
619
620 static GtkWidget *about_create_child_page_release_notes(void)
621 {
622         GtkWidget *scrolledwin;
623         GtkWidget *text;
624         GtkTextBuffer *buffer;
625         GtkTextIter iter;
626         gchar *path, buf[1024];
627         FILE *fp;
628
629         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
630         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
631                         GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
632         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
633                         GTK_SHADOW_IN);
634         text = gtk_text_view_new();
635         gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
636         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
637         gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
638         gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
639         gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
640         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
641
642         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
643         gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
644
645         path = g_strconcat(DOCDIR, G_DIR_SEPARATOR_S, RELEASE_NOTES_FILE, NULL);
646         if ((fp = g_fopen(path, "rb")) == NULL) {
647                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
648                 g_free(path);
649                 return scrolledwin;
650         }
651         g_free(path);
652
653         while (fgets(buf, sizeof(buf), fp) != NULL) {
654                 const gchar *src_codeset = conv_get_locale_charset_str();
655                 const gchar *dest_codeset = CS_UTF_8;
656                 gchar *tmp;
657
658                 tmp = conv_codeset_strdup(buf, src_codeset, dest_codeset);
659                 if (!tmp) {
660                         g_warning("Failed to convert character set of action configuration\n");
661                         tmp = g_strdup(buf);
662                 }
663
664                 gtk_text_buffer_insert(buffer, &iter, tmp, -1);
665                 g_free(tmp);
666         }
667         fclose(fp);
668
669         return scrolledwin;
670 }
671
672 static void about_create(void)
673 {
674         GtkWidget *vbox1;
675         GtkWidget *image;       
676         GtkWidget *vbox2;
677         GtkWidget *label;
678         GtkWidget *button;
679         GtkWidget *scrolledwin;
680         GtkWidget *notebook;
681         GtkWidget *table;
682         char *markup;
683         GtkWidget *confirm_area;
684         GtkWidget *close_button;
685         static GdkGeometry geometry;
686
687         window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "about");
688         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
689         gtk_window_set_title(GTK_WINDOW(window), _("About Claws Mail"));
690         gtk_container_set_border_width(GTK_CONTAINER(window), 8);
691         gtk_widget_set_size_request(window, -1, -1);
692         g_signal_connect(G_OBJECT(window), "delete_event",
693                          G_CALLBACK(gtk_widget_hide_on_delete), NULL);
694         g_signal_connect(G_OBJECT(window), "key_press_event",
695                          G_CALLBACK(key_pressed), NULL);
696         gtk_widget_realize(window);
697
698         if (!geometry.min_width) {
699                 geometry.min_width = 450;
700                 geometry.min_height = 500;
701         }
702
703         gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
704                                       GDK_HINT_MIN_SIZE);
705
706         vbox1 = gtk_vbox_new(FALSE, 8);
707         gtk_container_add(GTK_CONTAINER(window), vbox1);
708
709         table = gtk_table_new (2, 1, FALSE);
710         gtk_box_pack_start(GTK_BOX(vbox1), table,
711                         FALSE, FALSE, 0);
712         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
713         gtk_table_set_row_spacings (GTK_TABLE (table), 8);
714         gtk_table_set_col_spacings (GTK_TABLE (table), 8);
715
716         image = stock_pixmap_widget(window, STOCK_PIXMAP_CLAWS_MAIL_LOGO);
717         gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 1,
718                         (GtkAttachOptions) (GTK_EXPAND),
719                         (GtkAttachOptions) (0), 0, 0);
720
721         vbox2 = gtk_vbox_new (FALSE, 4);
722         gtk_table_attach (GTK_TABLE (table), vbox2, 1, 2, 0, 1,
723                         (GtkAttachOptions) (GTK_EXPAND),
724                         (GtkAttachOptions) (0), 0, 0);
725
726         label = gtk_label_new("");
727         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
728         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
729         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
730         markup = g_markup_printf_escaped
731                 ("<span weight=\"bold\" size=\"xx-large\">Claws Mail</span>\nversion %s",
732                  VERSION);
733         gtk_label_set_markup(GTK_LABEL(label), markup);
734         g_free(markup);
735
736         button = gtkut_get_link_btn(window, HOMEPAGE_URI, " "HOMEPAGE_URI" ");
737         gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
738 #ifndef GENERIC_UMPC
739         label = gtk_label_new
740                 (_("Copyright (C) 1999-2008\nHiroyuki Yamamoto <hiro-y@kcn.ne.jp>\n"
741                  "and the Claws Mail team"));
742         gtk_label_set_selectable(GTK_LABEL(label), TRUE);
743         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
744         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
745         gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
746 #endif
747         notebook = gtk_notebook_new();
748         gtk_widget_set_size_request(notebook, -1, 220);
749         gtk_widget_show(notebook);
750
751         if ((scrolledwin = about_create_child_page_info()) != NULL) {
752                 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
753                                 scrolledwin,
754                                 gtk_label_new_with_mnemonic(_("_Info")));
755         }
756
757         if ((scrolledwin = about_create_child_page_authors()) != NULL) {
758                 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
759                                 scrolledwin,
760                                 gtk_label_new_with_mnemonic(_("_Authors")));
761         }
762
763         if ((scrolledwin = about_create_child_page_features()) != NULL) {
764                 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
765                                 scrolledwin,
766                                 gtk_label_new_with_mnemonic(_("_Features")));
767         }
768
769         if ((scrolledwin = about_create_child_page_license()) != NULL) {
770                 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
771                                 scrolledwin,
772                                 gtk_label_new_with_mnemonic(_("_License")));
773         }
774
775         if (release_notes_available() &&
776                         (scrolledwin = about_create_child_page_release_notes()) != NULL) {
777
778                 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
779                                 scrolledwin,
780                                 gtk_label_new_with_mnemonic(_("_Release Notes")));
781         }
782
783         gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
784
785         gtkut_stock_button_set_create(&confirm_area, &close_button, GTK_STOCK_CLOSE,
786                                       NULL, NULL, NULL, NULL);
787         gtk_box_pack_end(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 4);
788         gtk_widget_grab_default(close_button);
789         gtk_widget_grab_focus(close_button);
790         g_signal_connect_closure
791                 (G_OBJECT(close_button), "clicked",
792                  g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete),
793                                      window, NULL), FALSE);
794
795         gtk_widget_show_all(window);
796 }
797
798 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
799 {
800         if (event && event->keyval == GDK_Escape)
801                 gtk_widget_hide(window);
802         return FALSE;
803 }
804
805 static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj,
806                                         GdkEvent *event, GtkTextIter *iter,
807                                         GtkWidget *textview)
808 {
809         GtkTextIter start_iter, end_iter;
810         GdkEventButton *bevent;
811         gchar *link = NULL;
812
813         if (!event || !tag) {
814                 return FALSE;
815         }
816
817         if (event->type != GDK_BUTTON_PRESS && event->type != GDK_2BUTTON_PRESS
818                 && event->type != GDK_BUTTON_RELEASE) {
819                 return FALSE;
820         }
821
822         /* get link text from tag */
823         if (get_tag_range(iter, tag, &start_iter,
824                                    &end_iter) == FALSE) {
825                 return FALSE;
826         }
827         link = gtk_text_iter_get_text(&start_iter, &end_iter);
828         if (link == NULL) {
829                 return FALSE;
830         }
831
832         bevent = (GdkEventButton *) event;
833         if (bevent->button == 1 && event->type == GDK_BUTTON_RELEASE) {
834                 GtkTextBuffer *buffer;
835
836                 /* we shouldn't follow a link if the user has selected something */
837                 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
838                 gtk_text_buffer_get_selection_bounds(buffer, &start_iter, &end_iter);
839                 if (gtk_text_iter_get_offset(&start_iter) != gtk_text_iter_get_offset(&end_iter)) {
840                         return FALSE;
841                 }
842                 /* open link and do *not* return TRUE so that
843                    further gtk processing of the signal is done */
844                 open_uri(link, prefs_common_get_uri_cmd());
845
846         } else {
847                 if (bevent->button == 3 && event->type == GDK_BUTTON_PRESS) {
848                         link_popupmenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
849                                 gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupLink")));
850
851                         g_object_set_data(
852                                         G_OBJECT(link_popupmenu),
853                                         "raw_url", link);
854                         gtk_menu_popup(GTK_MENU(link_popupmenu), 
855                                         NULL, NULL, NULL, NULL, 
856                                         bevent->button, bevent->time);
857
858                         return TRUE;
859                 }
860         }
861         return FALSE;
862 }
863
864 static gboolean about_textview_motion_notify(GtkWidget *widget,
865                                         GdkEventMotion *event,
866                                         GtkWidget *textview)
867 {
868         about_textview_uri_update(textview, event->x, event->y);
869         gdk_window_get_pointer(widget->window, NULL, NULL, NULL);
870
871         return FALSE;
872 }
873
874 static gboolean about_textview_leave_notify(GtkWidget *widget,
875                                         GdkEventCrossing *event,
876                                         GtkWidget *textview)
877 {
878         about_textview_uri_update(textview, -1, -1);
879
880         return FALSE;
881 }
882
883 static void about_textview_uri_update(GtkWidget *textview, gint x, gint y)
884 {
885         GtkTextBuffer *buffer;
886         GtkTextIter start_iter, end_iter;
887         gchar *uri = NULL;
888         gboolean same;
889         
890         buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
891
892         if (x != -1 && y != -1) {
893                 gint bx, by;
894                 GtkTextIter iter;
895                 GSList *tags;
896                 GSList *cur;
897             
898                 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(textview), 
899                                 GTK_TEXT_WINDOW_WIDGET,
900                                 x, y, &bx, &by);
901                 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(textview),
902                                 &iter, bx, by);
903
904                 tags = gtk_text_iter_get_tags(&iter);
905                 for (cur = tags; cur != NULL; cur = cur->next) {
906                         GtkTextTag *tag = cur->data;
907                         char *name;
908
909                         g_object_get(G_OBJECT(tag), "name", &name, NULL);
910                         if (strcmp(name, "link") == 0
911                             && get_tag_range(&iter, tag, &start_iter, &end_iter)) {
912                                 uri = gtk_text_iter_get_text(&start_iter, &end_iter);
913                         }
914                         g_free(name);
915
916                         if (uri) {
917                                 break;
918                         }
919                 }
920                 g_slist_free(tags);
921         }
922
923         /* compare previous hovered link and this one
924            (here links must be unique in text buffer otherwise ClickableText structures should be
925            used as in textview.c) */
926         same = (uri != NULL && uri_hover != NULL
927                 && strcmp((char*)uri, (char*)uri_hover) == 0);
928
929         if (same == FALSE) {
930                 GdkWindow *window;
931
932                 if (uri_hover) {
933                         gtk_text_buffer_remove_tag_by_name(buffer,
934                                         "link-hover",
935                                         &uri_hover_start_iter,
936                                         &uri_hover_end_iter);
937                 }
938                     
939                 uri_hover = uri;
940                 if (uri) {
941                         uri_hover_start_iter = start_iter;
942                         uri_hover_end_iter = end_iter;
943
944                         gtk_text_buffer_apply_tag_by_name(buffer,
945                                         "link-hover",
946                                         &start_iter,
947                                         &end_iter);
948                 }
949                 
950                 window = gtk_text_view_get_window(GTK_TEXT_VIEW(textview),
951                                                 GTK_TEXT_WINDOW_TEXT);
952                 if (!hand_cursor)
953                         hand_cursor = gdk_cursor_new(GDK_HAND2);
954                 if (!text_cursor)
955                         text_cursor = gdk_cursor_new(GDK_XTERM);
956                 gdk_window_set_cursor(window, uri ? hand_cursor : text_cursor);
957         }
958 }