2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
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.
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.
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/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
31 #if HAVE_SYS_UTSNAME_H
32 # include <sys/utsname.h>
38 #include "stock_pixmap.h"
39 #include "prefs_common.h"
48 extern SessionStats session_stats
;
49 static GtkTextBuffer
*stats_text_buffer
;
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
;
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
,
63 static gboolean
about_textview_motion_notify(GtkWidget
*widget
,
64 GdkEventMotion
*event
,
66 static gboolean
about_textview_leave_notify(GtkWidget
*widget
,
67 GdkEventCrossing
*event
,
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);
74 static GtkWidget
*link_popupmenu
;
83 gtk_window_present(GTK_WINDOW(window
));
88 static GtkWidget
*about_create_child_page_info(void)
90 GtkWidget
*scrolledwin
;
92 GtkTextBuffer
*buffer
;
97 #if HAVE_SYS_UTSNAME_H
98 struct utsname utsbuf
;
101 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
102 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
103 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
104 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
107 text
= gtk_text_view_new();
108 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
109 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
110 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
111 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
112 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
113 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
114 gtk_widget_add_events(text
, GDK_LEAVE_NOTIFY_MASK
);
116 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
117 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
119 /* textview link style (based upon main prefs) */
120 gtkut_convert_int_to_gdk_color(prefs_common
.uri_col
,
121 (GdkColor
*)&uri_color
);
122 tag
= gtk_text_buffer_create_tag(buffer
, "link",
123 "foreground-gdk", &uri_color
,
124 "wrap-mode", GTK_WRAP_NONE
,
126 gtk_text_buffer_create_tag(buffer
, "link-hover",
127 "foreground-gdk", &uri_color
,
128 "underline", PANGO_UNDERLINE_SINGLE
,
131 gtk_text_buffer_insert(buffer
, &iter
, _(
132 "Claws Mail is a lightweight, fast and "
133 "highly-configurable email client.\n\n"
134 "For further information visit the Claws Mail "
136 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, HOMEPAGE_URI
, -1,
138 gtk_text_buffer_insert(buffer
, &iter
, _("\n\n"
139 "For support and discussion subscribe to the Claws Mail "
140 "users' mailing list:\n"),-1);
141 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, USERS_ML_URI
, -1,
143 gtk_text_buffer_insert(buffer
, &iter
, _("\n\n"
144 "Claws Mail is free software released "
145 "under the GPL. If you wish to donate "
146 "to the Claws Mail project you can do "
148 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, DONATE_URI
, -1,
151 gtk_text_buffer_create_tag(buffer
, "indented-list-item",
154 gtk_text_buffer_create_tag(buffer
, "underlined-list-title",
155 "underline", PANGO_UNDERLINE_SINGLE
,
158 gtk_text_buffer_insert(buffer
, &iter
, _(
159 "\n\nCopyright (C) 1999-2013\nThe Claws Mail Team\n"
160 " and Hiroyuki Yamamoto"), -1);
162 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("\n\nSystem Information\n")), -1,
163 "underlined-list-title", NULL
);
165 #if HAVE_SYS_UTSNAME_H
167 g_snprintf(buf
, sizeof(buf
),
168 _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
169 "Locale: %s (charset: %s)\n"
170 "Operating System: %s %s (%s)"),
171 gtk_major_version
, gtk_minor_version
, gtk_micro_version
,
172 glib_major_version
, glib_minor_version
, glib_micro_version
,
173 conv_get_current_locale(), conv_get_locale_charset_str(),
174 utsbuf
.sysname
, utsbuf
.release
, utsbuf
.machine
);
175 #elif defined(G_OS_WIN32)
176 g_snprintf(buf
, sizeof(buf
),
177 _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
178 "Locale: %s (charset: %s)\n"
179 "Operating System: %s"),
180 gtk_major_version
, gtk_minor_version
, gtk_micro_version
,
181 glib_major_version
, glib_minor_version
, glib_micro_version
,
182 conv_get_current_locale(), conv_get_locale_charset_str(),
185 g_snprintf(buf
, sizeof(buf
),
186 _("GTK+ %d.%d.%d / GLib %d.%d.%d\n"
187 "Locale: %s (charset: %s)\n"
188 "Operating System: unknown"),
189 gtk_major_version
, gtk_minor_version
, gtk_micro_version
,
190 glib_major_version
, glib_minor_version
, glib_micro_version
,
191 conv_get_current_locale(), conv_get_locale_charset_str());
194 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, buf
, -1,
195 "indented-list-item", NULL
);
197 gtk_text_buffer_insert(buffer
, &iter
, "\n", -1);
199 g_signal_connect(G_OBJECT(tag
), "event",
200 G_CALLBACK(about_textview_uri_clicked
), text
);
201 g_signal_connect(G_OBJECT(text
), "motion-notify-event",
202 G_CALLBACK(about_textview_motion_notify
), text
);
203 g_signal_connect(G_OBJECT(text
), "leave-notify-event",
204 G_CALLBACK(about_textview_leave_notify
), text
);
209 static GtkWidget
*about_create_child_page_authors(void)
211 GtkWidget
*scrolledwin
;
213 GtkTextBuffer
*buffer
;
217 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
218 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
219 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
220 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
223 text
= gtk_text_view_new();
224 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
225 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
226 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
227 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
228 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
229 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
230 gtk_widget_add_events(text
, GDK_LEAVE_NOTIFY_MASK
);
232 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
233 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
235 /* init formatting tag: indentation for list items */
236 gtk_text_buffer_create_tag(buffer
, "indented-list-item",
239 gtk_text_buffer_create_tag(buffer
, "underlined-list-title",
240 "underline", PANGO_UNDERLINE_SINGLE
,
243 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("The Claws Mail Team")), -1,
244 "underlined-list-title", NULL
);
245 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
247 for (i
= 0; TEAM_LIST
[i
] != NULL
; i
++) {
248 if (g_utf8_validate(TEAM_LIST
[i
], -1, NULL
))
249 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, TEAM_LIST
[i
], -1,
250 "indented-list-item", NULL
);
252 gchar
*conv
= conv_codeset_strdup(TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
254 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
255 "indented-list-item", NULL
);
258 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
261 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
262 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Previous team members")), -1,
263 "underlined-list-title", NULL
);
264 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
266 for (i
= 0; EX_TEAM_LIST
[i
] != NULL
; i
++) {
267 if (g_utf8_validate(EX_TEAM_LIST
[i
], -1, NULL
))
268 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, EX_TEAM_LIST
[i
], -1,
269 "indented-list-item", NULL
);
271 gchar
*conv
= conv_codeset_strdup(EX_TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
273 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
274 "indented-list-item", NULL
);
277 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
280 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
281 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("The translation team")), -1,
282 "underlined-list-title", NULL
);
283 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
285 for (i
= 0; TRANS_TEAM_LIST
[i
] != NULL
; i
++) {
286 if (g_utf8_validate(TRANS_TEAM_LIST
[i
], -1, NULL
))
287 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, TRANS_TEAM_LIST
[i
], -1,
288 "indented-list-item", NULL
);
290 gchar
*conv
= conv_codeset_strdup(TRANS_TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
292 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
293 "indented-list-item", NULL
);
296 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
299 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
300 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Documentation team")), -1,
301 "underlined-list-title", NULL
);
302 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
304 for (i
= 0; DOC_TEAM_LIST
[i
] != NULL
; i
++) {
305 if (g_utf8_validate(DOC_TEAM_LIST
[i
], -1, NULL
))
306 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, DOC_TEAM_LIST
[i
], -1,
307 "indented-list-item", NULL
);
309 gchar
*conv
= conv_codeset_strdup(DOC_TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
311 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
312 "indented-list-item", NULL
);
315 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
318 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
319 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Logo")), -1,
320 "underlined-list-title", NULL
);
321 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
323 for (i
= 0; LOGO_LIST
[i
] != NULL
; i
++) {
324 if (g_utf8_validate(LOGO_LIST
[i
], -1, NULL
))
325 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, LOGO_LIST
[i
], -1,
326 "indented-list-item", NULL
);
328 gchar
*conv
= conv_codeset_strdup(LOGO_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
330 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
331 "indented-list-item", NULL
);
334 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
337 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
338 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Icons")), -1,
339 "underlined-list-title", NULL
);
340 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
342 for (i
= 0; ICONS_LIST
[i
] != NULL
; i
++) {
343 if (g_utf8_validate(ICONS_LIST
[i
], -1, NULL
))
344 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, ICONS_LIST
[i
], -1,
345 "indented-list-item", NULL
);
347 gchar
*conv
= conv_codeset_strdup(ICONS_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
349 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
350 "indented-list-item", NULL
);
353 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
356 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
357 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Contributors")), -1,
358 "underlined-list-title", NULL
);
359 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
361 for (i
= 0; CONTRIBS_LIST
[i
] != NULL
; i
++) {
362 if (g_utf8_validate(CONTRIBS_LIST
[i
], -1, NULL
))
363 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, CONTRIBS_LIST
[i
], -1,
364 "indented-list-item", NULL
);
366 gchar
*conv
= conv_codeset_strdup(CONTRIBS_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
368 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
369 "indented-list-item", NULL
);
372 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
378 static GtkWidget
*about_create_child_page_features(void)
380 GtkWidget
*scrolledwin
;
382 GtkTextBuffer
*buffer
;
384 GdkPixbuf
*active_pixbuf
;
385 GdkPixbuf
*inactive_pixbuf
;
387 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
388 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
389 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
390 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
393 text
= gtk_text_view_new();
394 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
395 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
396 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
397 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
398 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
399 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
400 gtk_widget_add_events(text
, GDK_LEAVE_NOTIFY_MASK
);
402 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
403 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
405 gtk_text_buffer_insert(buffer
, &iter
, _("Compiled-in Features\n"), -1);
407 gtk_text_buffer_create_tag(buffer
, "bold", "weight", PANGO_WEIGHT_BOLD
,
410 stock_pixbuf_gdk(window
, STOCK_PIXMAP_CHECKBOX_ON
, &active_pixbuf
);
411 stock_pixbuf_gdk(window
, STOCK_PIXMAP_CHECKBOX_OFF
, &inactive_pixbuf
);
414 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
416 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
418 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" compface "), -1,
420 gtk_text_buffer_insert(buffer
, &iter
,
421 (gchar
*)C_("compface", "adds support for the X-Face header\n"), -1);
424 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
426 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
428 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" Enchant "), -1,
430 gtk_text_buffer_insert(buffer
, &iter
,
431 (gchar
*)C_("Enchant", "adds support for spell checking\n"), -1);
434 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
436 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
438 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" GnuTLS "), -1,
440 gtk_text_buffer_insert(buffer
, &iter
,
441 (gchar
*)C_("GnuTLS", "adds support for encrypted connections to servers\n"), -1);
444 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
446 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
448 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" IPv6 "), -1,
450 gtk_text_buffer_insert(buffer
, &iter
,
451 (gchar
*)C_("IPv6", "adds support for IPv6 addresses, the new Internet "
452 "addressing protocol\n"), -1);
455 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
457 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
459 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" iconv "), -1,
461 gtk_text_buffer_insert(buffer
, &iter
,
462 (gchar
*)C_("iconv", "allows converting to and from different character sets\n"), -1);
465 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
467 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
469 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" JPilot "), -1,
471 gtk_text_buffer_insert(buffer
, &iter
,
472 (gchar
*)C_("JPilot", "adds support for PalmOS addressbooks\n"), -1);
475 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
477 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
479 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" LDAP "), -1,
481 gtk_text_buffer_insert(buffer
, &iter
,
482 (gchar
*)C_("LDAP", "adds support for LDAP shared addressbooks\n"), -1);
485 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
487 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
489 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" libetpan "), -1,
491 gtk_text_buffer_insert(buffer
, &iter
,
492 (gchar
*)C_("libetpan", "adds support for IMAP and NNTP servers\n"), -1);
495 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
497 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
499 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" libSM "), -1,
501 gtk_text_buffer_insert(buffer
, &iter
,
502 (gchar
*)C_("libSM", "adds support for session handling\n"), -1);
504 #if HAVE_NETWORKMANAGER_SUPPORT
505 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
507 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
509 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" NetworkManager "), -1,
511 gtk_text_buffer_insert(buffer
, &iter
,
512 (gchar
*)C_("NetworkManager", "adds support for detection of network connection changes\n"), -1);
517 static GtkWidget
*about_create_child_page_license(void)
519 GtkWidget
*scrolledwin
;
521 GtkTextBuffer
*buffer
;
526 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
527 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
528 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
529 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
532 text
= gtk_text_view_new();
533 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
534 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
535 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
536 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
537 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
538 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
540 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
541 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
543 gtk_text_buffer_insert(buffer
, &iter
,
544 _("This program is free software; you can redistribute it and/or modify "
545 "it under the terms of the GNU General Public License as published by "
546 "the Free Software Foundation; either version 3, or (at your option) "
547 "any later version.\n\n"), -1);
549 gtk_text_buffer_insert(buffer
, &iter
,
550 _("This program is distributed in the hope that it will be useful, "
551 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
552 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
553 "See the GNU General Public License for more details.\n\n"), -1);
555 /* textview link style (based upon main prefs) */
556 gtkut_convert_int_to_gdk_color(prefs_common
.uri_col
,
557 (GdkColor
*)&uri_color
);
559 tag
= gtk_text_buffer_create_tag(buffer
, "link",
560 "foreground-gdk", &uri_color
,
562 gtk_text_buffer_create_tag(buffer
, "link-hover",
563 "foreground-gdk", &uri_color
,
564 "underline", PANGO_UNDERLINE_SINGLE
,
567 gtk_text_buffer_insert(buffer
, &iter
,
568 _("You should have received a copy of the GNU General Public License "
569 "along with this program. If not, see <"), -1);
570 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
571 "http://www.gnu.org/licenses/", -1,
573 gtk_text_buffer_insert(buffer
, &iter
, _(">. \n\n"), -1);
575 g_signal_connect(G_OBJECT(tag
), "event",
576 G_CALLBACK(about_textview_uri_clicked
), text
);
577 g_signal_connect(G_OBJECT(text
), "motion-notify-event",
578 G_CALLBACK(about_textview_motion_notify
), text
);
579 g_signal_connect(G_OBJECT(text
), "leave-notify-event",
580 G_CALLBACK(about_textview_leave_notify
), text
);
585 static gboolean
release_notes_available(void)
587 gboolean ret
= FALSE
;
590 path
= g_strconcat(DOCDIR
, G_DIR_SEPARATOR_S
, RELEASE_NOTES_FILE
, NULL
);
591 ret
= (is_file_exist(path
));
597 static GtkWidget
*about_create_child_page_release_notes(void)
599 GtkWidget
*scrolledwin
;
601 GtkTextBuffer
*buffer
;
603 gchar
*path
, buf
[1024];
606 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
607 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
608 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
609 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
611 text
= gtk_text_view_new();
612 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
613 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
614 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
615 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
616 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
617 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
619 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
620 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
622 path
= g_strconcat(DOCDIR
, G_DIR_SEPARATOR_S
, RELEASE_NOTES_FILE
, NULL
);
623 if ((fp
= g_fopen(path
, "rb")) == NULL
) {
624 if (ENOENT
!= errno
) FILE_OP_ERROR(path
, "fopen");
630 while (fgets(buf
, sizeof(buf
), fp
) != NULL
) {
631 const gchar
*src_codeset
= conv_get_locale_charset_str();
632 const gchar
*dest_codeset
= CS_UTF_8
;
635 tmp
= conv_codeset_strdup(buf
, src_codeset
, dest_codeset
);
637 g_warning("Failed to convert character set of action configuration\n");
641 gtk_text_buffer_insert(buffer
, &iter
, tmp
, -1);
649 static GtkWidget
*about_create_child_page_session_stats(void)
651 GtkWidget
*scrolledwin
;
655 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
656 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
657 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
658 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
660 text
= gtk_text_view_new();
661 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
662 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
663 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
664 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
665 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
666 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
668 stats_text_buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
670 gtk_text_buffer_get_iter_at_offset(stats_text_buffer
, &iter
, 0);
671 gtk_text_buffer_create_tag(stats_text_buffer
, "indented-list-item",
674 gtk_text_buffer_create_tag(stats_text_buffer
, "underlined-list-title",
675 "underline", PANGO_UNDERLINE_SINGLE
,
677 gtk_text_buffer_create_tag(stats_text_buffer
, "bold", "weight", PANGO_WEIGHT_BOLD
,
680 about_update_stats();
685 static void about_update_stats(void)
687 if (stats_text_buffer
!= NULL
)
689 GtkTextIter start
, end
, iter
;
692 gtk_text_buffer_get_start_iter(stats_text_buffer
, &start
);
693 gtk_text_buffer_get_end_iter(stats_text_buffer
, &end
);
694 gtk_text_buffer_delete(stats_text_buffer
, &start
, &end
);
696 gtk_text_buffer_get_iter_at_offset(stats_text_buffer
, &iter
, 0);
698 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
,
699 (_("Session statistics\n")), -1,
700 "underlined-list-title", NULL
);
702 if (prefs_common
.date_format
) {
707 lt
= localtime(&session_stats
.time_started
);
708 fast_strftime(date
, len
, prefs_common
.date_format
, lt
);
709 g_snprintf(buf
, sizeof(buf
), _("Started: %s\n"),
710 lt
? date
: ctime(&session_stats
.time_started
));
712 g_snprintf(buf
, sizeof(buf
), _("Started: %s\n"),
713 ctime(&session_stats
.time_started
));
714 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
715 "indented-list-item", NULL
);
717 gtk_text_buffer_insert(stats_text_buffer
, &iter
, "\n", 1);
718 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
,
719 (_("Incoming traffic\n")), -1,
720 "underlined-list-title", NULL
);
722 g_snprintf(buf
, sizeof(buf
), _("Received messages: %d\n"),
723 session_stats
.received
);
724 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
725 "indented-list-item", "bold", NULL
);
727 gtk_text_buffer_insert(stats_text_buffer
, &iter
, "\n", 1);
728 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
,
729 (_("Outgoing traffic\n")), -1,
730 "underlined-list-title", NULL
);
732 g_snprintf(buf
, sizeof(buf
), _("New/redirected messages: %d\n"),
734 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
735 "indented-list-item", NULL
);
737 g_snprintf(buf
, sizeof(buf
), _("Replied messages: %d\n"),
738 session_stats
.replied
);
739 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
740 "indented-list-item", NULL
);
742 g_snprintf(buf
, sizeof(buf
), _("Forwarded messages: %d\n"),
743 session_stats
.forwarded
);
744 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
745 "indented-list-item", NULL
);
747 g_snprintf(buf
, sizeof(buf
), _("Total outgoing messages: %d\n"),
748 (session_stats
.sent
+ session_stats
.replied
+
749 session_stats
.forwarded
));
750 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
751 "indented-list-item", "bold", NULL
);
755 static void about_create(void)
762 GtkWidget
*scrolledwin
;
766 GtkWidget
*confirm_area
;
767 GtkWidget
*close_button
;
768 static GdkGeometry geometry
;
770 stats_text_buffer
= NULL
;
772 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "about");
773 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER_ALWAYS
);
774 gtk_window_set_title(GTK_WINDOW(window
), _("About Claws Mail"));
775 gtk_container_set_border_width(GTK_CONTAINER(window
), 8);
776 gtk_widget_set_size_request(window
, -1, -1);
777 g_signal_connect(G_OBJECT(window
), "size_allocate",
778 G_CALLBACK(about_size_allocate_cb
), NULL
);
779 g_signal_connect(G_OBJECT(window
), "size_allocate",
780 G_CALLBACK(about_size_allocate_cb
), NULL
);
781 g_signal_connect(G_OBJECT(window
), "delete_event",
782 G_CALLBACK(gtk_widget_hide_on_delete
), NULL
);
783 g_signal_connect(G_OBJECT(window
), "key_press_event",
784 G_CALLBACK(key_pressed
), NULL
);
786 if (!geometry
.min_width
) {
787 geometry
.min_width
= 450;
788 geometry
.min_height
= 500;
791 gtk_window_set_geometry_hints(GTK_WINDOW(window
), NULL
, &geometry
,
793 gtk_window_set_default_size(GTK_WINDOW(window
), prefs_common
.aboutwin_width
,
794 prefs_common
.aboutwin_height
);
796 gtk_widget_realize(window
);
798 vbox1
= gtk_vbox_new(FALSE
, 8);
799 gtk_container_add(GTK_CONTAINER(window
), vbox1
);
801 table
= gtk_table_new (2, 1, FALSE
);
802 gtk_box_pack_start(GTK_BOX(vbox1
), table
,
804 gtk_container_set_border_width (GTK_CONTAINER (table
), 8);
805 gtk_table_set_row_spacings (GTK_TABLE (table
), 8);
806 gtk_table_set_col_spacings (GTK_TABLE (table
), 8);
808 image
= stock_pixmap_widget(window
, STOCK_PIXMAP_CLAWS_MAIL_LOGO
);
809 gtk_table_attach (GTK_TABLE (table
), image
, 0, 1, 0, 1,
810 (GtkAttachOptions
) (GTK_EXPAND
),
811 (GtkAttachOptions
) (0), 0, 0);
813 vbox2
= gtk_vbox_new (FALSE
, 4);
814 gtk_table_attach (GTK_TABLE (table
), vbox2
, 1, 2, 0, 1,
815 (GtkAttachOptions
) (GTK_EXPAND
),
816 (GtkAttachOptions
) (0), 0, 0);
818 label
= gtk_label_new("");
819 gtk_label_set_selectable(GTK_LABEL(label
), TRUE
);
820 gtk_label_set_justify(GTK_LABEL(label
), GTK_JUSTIFY_CENTER
);
821 gtk_box_pack_start(GTK_BOX(vbox2
), label
, FALSE
, FALSE
, 0);
822 markup
= g_markup_printf_escaped
823 ("<span weight=\"bold\" size=\"xx-large\">Claws Mail</span>\nversion %s",
825 gtk_label_set_markup(GTK_LABEL(label
), markup
);
828 button
= gtkut_get_link_btn(window
, HOMEPAGE_URI
, " "HOMEPAGE_URI
" ");
829 gtk_box_pack_start(GTK_BOX(vbox2
), button
, FALSE
, FALSE
, 0);
831 label
= gtk_label_new
832 (_("Copyright (C) 1999-2013\nThe Claws Mail Team\n"
833 "and Hiroyuki Yamamoto"));
834 gtk_label_set_selectable(GTK_LABEL(label
), TRUE
);
835 gtk_label_set_justify(GTK_LABEL(label
), GTK_JUSTIFY_CENTER
);
836 gtk_label_set_line_wrap(GTK_LABEL(label
), TRUE
);
837 gtk_box_pack_start(GTK_BOX(vbox2
), label
, FALSE
, FALSE
, 0);
839 notebook
= gtk_notebook_new();
840 gtk_widget_set_size_request(notebook
, -1, 220);
841 gtk_widget_show(notebook
);
843 if ((scrolledwin
= about_create_child_page_info()) != NULL
) {
844 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
846 gtk_label_new_with_mnemonic(_("_Info")));
849 if ((scrolledwin
= about_create_child_page_authors()) != NULL
) {
850 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
852 gtk_label_new_with_mnemonic(_("_Authors")));
855 if ((scrolledwin
= about_create_child_page_features()) != NULL
) {
856 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
858 gtk_label_new_with_mnemonic(_("_Features")));
861 if ((scrolledwin
= about_create_child_page_license()) != NULL
) {
862 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
864 gtk_label_new_with_mnemonic(_("_License")));
867 if (release_notes_available() &&
868 (scrolledwin
= about_create_child_page_release_notes()) != NULL
) {
870 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
872 gtk_label_new_with_mnemonic(_("_Release Notes")));
875 if ((scrolledwin
= about_create_child_page_session_stats()) != NULL
) {
876 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
878 gtk_label_new_with_mnemonic(_("_Statistics")));
881 gtk_box_pack_start(GTK_BOX(vbox1
), notebook
, TRUE
, TRUE
, 0);
883 gtkut_stock_button_set_create(&confirm_area
, &close_button
, GTK_STOCK_CLOSE
,
884 NULL
, NULL
, NULL
, NULL
);
885 gtk_box_pack_end(GTK_BOX(vbox1
), confirm_area
, FALSE
, FALSE
, 4);
886 gtk_widget_grab_default(close_button
);
887 gtk_widget_grab_focus(close_button
);
888 g_signal_connect_closure
889 (G_OBJECT(close_button
), "clicked",
890 g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete
),
891 window
, NULL
), FALSE
);
893 gtk_widget_show_all(window
);
896 static gboolean
key_pressed(GtkWidget
*widget
, GdkEventKey
*event
)
898 if (event
&& event
->keyval
== GDK_KEY_Escape
)
899 gtk_widget_hide(window
);
903 static void about_size_allocate_cb(GtkWidget
*widget
,
904 GtkAllocation
*allocation
)
906 cm_return_if_fail(allocation
!= NULL
);
908 prefs_common
.aboutwin_width
= allocation
->width
;
909 prefs_common
.aboutwin_height
= allocation
->height
;
913 static gboolean
about_textview_uri_clicked(GtkTextTag
*tag
, GObject
*obj
,
914 GdkEvent
*event
, GtkTextIter
*iter
,
917 GtkTextIter start_iter
, end_iter
;
918 GdkEventButton
*bevent
;
921 if (!event
|| !tag
) {
925 if (event
->type
!= GDK_BUTTON_PRESS
&& event
->type
!= GDK_2BUTTON_PRESS
926 && event
->type
!= GDK_BUTTON_RELEASE
) {
930 /* get link text from tag */
931 if (get_tag_range(iter
, tag
, &start_iter
,
932 &end_iter
) == FALSE
) {
935 link
= gtk_text_iter_get_text(&start_iter
, &end_iter
);
940 bevent
= (GdkEventButton
*) event
;
941 if (bevent
->button
== 1 && event
->type
== GDK_BUTTON_RELEASE
) {
942 GtkTextBuffer
*buffer
;
944 /* we shouldn't follow a link if the user has selected something */
945 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview
));
946 gtk_text_buffer_get_selection_bounds(buffer
, &start_iter
, &end_iter
);
947 if (gtk_text_iter_get_offset(&start_iter
) != gtk_text_iter_get_offset(&end_iter
)) {
950 /* open link and do *not* return TRUE so that
951 further gtk processing of the signal is done */
952 open_uri(link
, prefs_common_get_uri_cmd());
955 if (bevent
->button
== 3 && event
->type
== GDK_BUTTON_PRESS
) {
956 link_popupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
957 gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupLink")));
960 G_OBJECT(link_popupmenu
),
962 gtk_menu_popup(GTK_MENU(link_popupmenu
),
963 NULL
, NULL
, NULL
, NULL
,
964 bevent
->button
, bevent
->time
);
972 static gboolean
about_textview_motion_notify(GtkWidget
*widget
,
973 GdkEventMotion
*event
,
976 about_textview_uri_update(textview
, event
->x
, event
->y
);
977 gdk_window_get_pointer(gtk_widget_get_window(widget
), NULL
, NULL
, NULL
);
982 static gboolean
about_textview_leave_notify(GtkWidget
*widget
,
983 GdkEventCrossing
*event
,
986 about_textview_uri_update(textview
, -1, -1);
991 static void about_textview_uri_update(GtkWidget
*textview
, gint x
, gint y
)
993 GtkTextBuffer
*buffer
;
994 GtkTextIter start_iter
, end_iter
;
998 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview
));
1000 if (x
!= -1 && y
!= -1) {
1006 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(textview
),
1007 GTK_TEXT_WINDOW_WIDGET
,
1009 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(textview
),
1012 tags
= gtk_text_iter_get_tags(&iter
);
1013 for (cur
= tags
; cur
!= NULL
; cur
= cur
->next
) {
1014 GtkTextTag
*tag
= cur
->data
;
1017 g_object_get(G_OBJECT(tag
), "name", &name
, NULL
);
1018 if (strcmp(name
, "link") == 0
1019 && get_tag_range(&iter
, tag
, &start_iter
, &end_iter
)) {
1020 uri
= gtk_text_iter_get_text(&start_iter
, &end_iter
);
1031 /* compare previous hovered link and this one
1032 (here links must be unique in text buffer otherwise ClickableText structures should be
1033 used as in textview.c) */
1034 same
= (uri
!= NULL
&& uri_hover
!= NULL
1035 && strcmp((char*)uri
, (char*)uri_hover
) == 0);
1037 if (same
== FALSE
) {
1041 gtk_text_buffer_remove_tag_by_name(buffer
,
1043 &uri_hover_start_iter
,
1044 &uri_hover_end_iter
);
1049 uri_hover_start_iter
= start_iter
;
1050 uri_hover_end_iter
= end_iter
;
1052 gtk_text_buffer_apply_tag_by_name(buffer
,
1058 window
= gtk_text_view_get_window(GTK_TEXT_VIEW(textview
),
1059 GTK_TEXT_WINDOW_TEXT
);
1061 hand_cursor
= gdk_cursor_new(GDK_HAND2
);
1063 text_cursor
= gdk_cursor_new(GDK_XTERM
);
1064 gdk_window_set_cursor(window
, uri
? hand_cursor
: text_cursor
);