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