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