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