2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2017 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/>.
21 #include "claws-features.h"
27 #include <glib/gi18n.h>
28 #include <gdk/gdkkeysyms.h>
30 #if HAVE_SYS_UTSNAME_H
31 # include <sys/utsname.h>
37 #include "stock_pixmap.h"
38 #include "prefs_common.h"
47 extern SessionStats session_stats
;
48 static GtkTextBuffer
*stats_text_buffer
;
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
;
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
,
62 static gboolean
about_textview_motion_notify(GtkWidget
*widget
,
63 GdkEventMotion
*event
,
65 static gboolean
about_textview_leave_notify(GtkWidget
*widget
,
66 GdkEventCrossing
*event
,
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);
73 static GtkWidget
*link_popupmenu
;
82 gtk_window_present(GTK_WINDOW(window
));
87 #define ADD_TEXT(text) gtk_text_buffer_insert(buffer, &iter, text, -1)
89 static GtkWidget
*about_create_child_page_info(void)
91 GtkWidget
*scrolledwin
;
93 GtkTextBuffer
*buffer
;
98 #if HAVE_SYS_UTSNAME_H
99 struct utsname utsbuf
;
102 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
103 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
104 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
105 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
108 text
= gtk_text_view_new();
109 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
110 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
111 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
112 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
113 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
114 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
115 gtk_widget_add_events(text
, GDK_LEAVE_NOTIFY_MASK
);
117 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
118 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
120 /* textview link style (based upon main prefs) */
121 gtkut_convert_int_to_gdk_color(prefs_common
.uri_col
,
122 (GdkColor
*)&uri_color
);
123 tag
= gtk_text_buffer_create_tag(buffer
, "link",
124 "foreground-gdk", &uri_color
,
125 "wrap-mode", GTK_WRAP_NONE
,
127 gtk_text_buffer_create_tag(buffer
, "link-hover",
128 "foreground-gdk", &uri_color
,
129 "underline", PANGO_UNDERLINE_SINGLE
,
132 ADD_TEXT(_("Claws Mail is a lightweight, fast and highly-configurable "
135 ADD_TEXT(_("For further information visit the Claws Mail website:"));
137 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, HOMEPAGE_URI
, -1,
140 ADD_TEXT(_("For support and discussion subscribe to the Claws Mail "
141 "users' mailing list:"));
143 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, USERS_ML_URI
, -1,
146 ADD_TEXT(_("Claws Mail is free software released "
147 "under the GPL. If you wish to donate "
148 "to the Claws Mail project you can do "
151 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, DONATE_URI
, -1,
154 gtk_text_buffer_create_tag(buffer
, "indented-list-item",
157 gtk_text_buffer_create_tag(buffer
, "underlined-list-title",
158 "underline", PANGO_UNDERLINE_SINGLE
,
162 ADD_TEXT(_("Copyright (C) 1999-2017\nThe Claws Mail Team\n"
163 " and Hiroyuki Yamamoto"));
166 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
167 (_("System Information\n")), -1, "underlined-list-title", NULL
);
169 #if HAVE_SYS_UTSNAME_H
171 g_snprintf(buf
, sizeof(buf
),g_strconcat(
172 "GTK+ %d.%d.%d / GLib %d.%d.%d\n",
173 _("Locale: %s (charset: %s)\n"
174 "Operating System: %s %s (%s)"), NULL
),
175 gtk_major_version
, gtk_minor_version
, gtk_micro_version
,
176 glib_major_version
, glib_minor_version
, glib_micro_version
,
177 conv_get_current_locale(), conv_get_locale_charset_str(),
178 utsbuf
.sysname
, utsbuf
.release
, utsbuf
.machine
);
179 #elif defined(G_OS_WIN32)
180 g_snprintf(buf
, sizeof(buf
),g_strconcat(
181 "GTK+ %d.%d.%d / GLib %d.%d.%d\n",
182 _("Locale: %s (charset: %s)\n"
183 "Operating System: %s"), NULL
),
184 gtk_major_version
, gtk_minor_version
, gtk_micro_version
,
185 glib_major_version
, glib_minor_version
, glib_micro_version
,
186 conv_get_current_locale(), conv_get_locale_charset_str(),
189 g_snprintf(buf
, sizeof(buf
),g_strconcat(
190 "GTK+ %d.%d.%d / GLib %d.%d.%d\n",
191 _("Locale: %s (charset: %s)\n"
192 "Operating System: unknown"), NULL
),
193 gtk_major_version
, gtk_minor_version
, gtk_micro_version
,
194 glib_major_version
, glib_minor_version
, glib_micro_version
,
195 conv_get_current_locale(), conv_get_locale_charset_str());
198 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, buf
, -1,
199 "indented-list-item", NULL
);
202 g_signal_connect(G_OBJECT(tag
), "event",
203 G_CALLBACK(about_textview_uri_clicked
), text
);
204 g_signal_connect(G_OBJECT(text
), "motion-notify-event",
205 G_CALLBACK(about_textview_motion_notify
), text
);
206 g_signal_connect(G_OBJECT(text
), "leave-notify-event",
207 G_CALLBACK(about_textview_leave_notify
), text
);
212 static GtkWidget
*about_create_child_page_authors(void)
214 GtkWidget
*scrolledwin
;
216 GtkTextBuffer
*buffer
;
220 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
221 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
222 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
223 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
226 text
= gtk_text_view_new();
227 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
228 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
229 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
230 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
231 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
232 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
233 gtk_widget_add_events(text
, GDK_LEAVE_NOTIFY_MASK
);
235 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
236 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
238 /* init formatting tag: indentation for list items */
239 gtk_text_buffer_create_tag(buffer
, "indented-list-item",
242 gtk_text_buffer_create_tag(buffer
, "underlined-list-title",
243 "underline", PANGO_UNDERLINE_SINGLE
,
246 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
247 (_("The Claws Mail Team")), -1, "underlined-list-title", NULL
);
248 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
250 for (i
= 0; TEAM_LIST
[i
] != NULL
; i
++) {
251 if (g_utf8_validate(TEAM_LIST
[i
], -1, NULL
))
252 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, TEAM_LIST
[i
], -1,
253 "indented-list-item", NULL
);
255 gchar
*conv
= conv_codeset_strdup(TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
257 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
258 "indented-list-item", NULL
);
261 gtk_text_buffer_insert(buffer
, &iter
, "\n", 1);
265 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
266 (_("Previous team members")), -1, "underlined-list-title", NULL
);
269 for (i
= 0; EX_TEAM_LIST
[i
] != NULL
; i
++) {
270 if (g_utf8_validate(EX_TEAM_LIST
[i
], -1, NULL
))
271 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, EX_TEAM_LIST
[i
], -1,
272 "indented-list-item", NULL
);
274 gchar
*conv
= conv_codeset_strdup(EX_TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
276 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
277 "indented-list-item", NULL
);
284 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
285 (_("The translation team")), -1, "underlined-list-title", NULL
);
288 for (i
= 0; TRANS_TEAM_LIST
[i
] != NULL
; i
++) {
289 if (g_utf8_validate(TRANS_TEAM_LIST
[i
], -1, NULL
))
290 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, TRANS_TEAM_LIST
[i
], -1,
291 "indented-list-item", NULL
);
293 gchar
*conv
= conv_codeset_strdup(TRANS_TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
295 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
296 "indented-list-item", NULL
);
303 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
304 (_("Documentation team")), -1, "underlined-list-title", NULL
);
307 for (i
= 0; DOC_TEAM_LIST
[i
] != NULL
; i
++) {
308 if (g_utf8_validate(DOC_TEAM_LIST
[i
], -1, NULL
))
309 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, DOC_TEAM_LIST
[i
], -1,
310 "indented-list-item", NULL
);
312 gchar
*conv
= conv_codeset_strdup(DOC_TEAM_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
314 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
315 "indented-list-item", NULL
);
322 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Logo")), -1,
323 "underlined-list-title", NULL
);
326 for (i
= 0; LOGO_LIST
[i
] != NULL
; i
++) {
327 if (g_utf8_validate(LOGO_LIST
[i
], -1, NULL
))
328 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, LOGO_LIST
[i
], -1,
329 "indented-list-item", NULL
);
331 gchar
*conv
= conv_codeset_strdup(LOGO_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
333 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
334 "indented-list-item", NULL
);
341 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Icons")), -1,
342 "underlined-list-title", NULL
);
345 for (i
= 0; ICONS_LIST
[i
] != NULL
; i
++) {
346 if (g_utf8_validate(ICONS_LIST
[i
], -1, NULL
))
347 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, ICONS_LIST
[i
], -1,
348 "indented-list-item", NULL
);
350 gchar
*conv
= conv_codeset_strdup(ICONS_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
352 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
353 "indented-list-item", NULL
);
360 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (_("Contributors")), -1,
361 "underlined-list-title", NULL
);
364 for (i
= 0; CONTRIBS_LIST
[i
] != NULL
; i
++) {
365 if (g_utf8_validate(CONTRIBS_LIST
[i
], -1, NULL
))
366 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, CONTRIBS_LIST
[i
], -1,
367 "indented-list-item", NULL
);
369 gchar
*conv
= conv_codeset_strdup(CONTRIBS_LIST
[i
], CS_ISO_8859_1
, CS_UTF_8
);
371 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, conv
, -1,
372 "indented-list-item", NULL
);
381 static GtkWidget
*about_create_child_page_features(void)
383 GtkWidget
*scrolledwin
;
385 GtkTextBuffer
*buffer
;
387 GdkPixbuf
*active_pixbuf
;
388 GdkPixbuf
*inactive_pixbuf
;
390 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
391 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
392 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
393 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
396 text
= gtk_text_view_new();
397 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
398 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
399 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
400 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
401 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
402 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
403 gtk_widget_add_events(text
, GDK_LEAVE_NOTIFY_MASK
);
405 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
406 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
408 ADD_TEXT(_("Compiled-in Features"));
411 gtk_text_buffer_create_tag(buffer
, "bold", "weight", PANGO_WEIGHT_BOLD
,
414 stock_pixbuf_gdk(STOCK_PIXMAP_CHECKBOX_ON
, &active_pixbuf
);
415 stock_pixbuf_gdk(STOCK_PIXMAP_CHECKBOX_OFF
, &inactive_pixbuf
);
418 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
420 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
422 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" compface "), -1,
424 gtk_text_buffer_insert(buffer
, &iter
,
425 (gchar
*)C_("compface", "adds support for the X-Face header\n"), -1);
428 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
430 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
432 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" Enchant "), -1,
434 gtk_text_buffer_insert(buffer
, &iter
,
435 (gchar
*)C_("Enchant", "adds support for spell checking\n"), -1);
438 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
440 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
442 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" GnuTLS "), -1,
444 gtk_text_buffer_insert(buffer
, &iter
,
445 (gchar
*)C_("GnuTLS", "adds support for encrypted connections to servers\n"), -1);
448 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
450 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
452 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" IPv6 "), -1,
454 gtk_text_buffer_insert(buffer
, &iter
,
455 (gchar
*)C_("IPv6", "adds support for IPv6 addresses, the new Internet "
456 "addressing protocol\n"), -1);
459 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
461 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
463 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" iconv "), -1,
465 gtk_text_buffer_insert(buffer
, &iter
,
466 (gchar
*)C_("iconv", "allows converting to and from different character sets\n"), -1);
469 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
471 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
473 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" JPilot "), -1,
475 gtk_text_buffer_insert(buffer
, &iter
,
476 (gchar
*)C_("JPilot", "adds support for PalmOS addressbooks\n"), -1);
479 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
481 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
483 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" LDAP "), -1,
485 gtk_text_buffer_insert(buffer
, &iter
,
486 (gchar
*)C_("LDAP", "adds support for LDAP shared addressbooks\n"), -1);
489 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
491 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
493 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" libetpan "), -1,
495 gtk_text_buffer_insert(buffer
, &iter
,
496 (gchar
*)C_("libetpan", "adds support for IMAP and NNTP servers\n"), -1);
499 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
501 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
503 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" libSM "), -1,
505 gtk_text_buffer_insert(buffer
, &iter
,
506 (gchar
*)C_("libSM", "adds support for session handling\n"), -1);
508 #if HAVE_NETWORKMANAGER_SUPPORT
509 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
511 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
513 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" NetworkManager "), -1,
515 gtk_text_buffer_insert(buffer
, &iter
,
516 (gchar
*)C_("NetworkManager", "adds support for detection of network connection changes\n"), -1);
519 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, active_pixbuf
);
521 gtk_text_buffer_insert_pixbuf(buffer
, &iter
, inactive_pixbuf
);
523 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
, (" librSVG "), -1,
525 gtk_text_buffer_insert(buffer
, &iter
,
526 (gchar
*)C_("librSVG", "adds support for SVG themes\n"), -1);
531 static GtkWidget
*about_create_child_page_license(void)
533 GtkWidget
*scrolledwin
;
535 GtkTextBuffer
*buffer
;
540 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
541 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
542 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
543 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
546 text
= gtk_text_view_new();
547 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
548 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
549 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
550 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
551 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
552 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
554 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
555 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
558 _("This program is free software; you can redistribute it and/or modify "
559 "it under the terms of the GNU General Public License as published by "
560 "the Free Software Foundation; either version 3, or (at your option) "
561 "any later version."));
565 _("This program is distributed in the hope that it will be useful, "
566 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
567 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
568 "See the GNU General Public License for more details."));
571 /* textview link style (based upon main prefs) */
572 gtkut_convert_int_to_gdk_color(prefs_common
.uri_col
,
573 (GdkColor
*)&uri_color
);
575 tag
= gtk_text_buffer_create_tag(buffer
, "link",
576 "foreground-gdk", &uri_color
,
578 gtk_text_buffer_create_tag(buffer
, "link-hover",
579 "foreground-gdk", &uri_color
,
580 "underline", PANGO_UNDERLINE_SINGLE
,
583 gtk_text_buffer_insert(buffer
, &iter
, g_strconcat(
584 _("You should have received a copy of the GNU General Public License "
585 "along with this program. If not, see "), "<", NULL
), -1);
586 gtk_text_buffer_insert_with_tags_by_name(buffer
, &iter
,
587 "http://www.gnu.org/licenses/", -1,
589 gtk_text_buffer_insert(buffer
, &iter
, ">. \n\n", -1);
591 g_signal_connect(G_OBJECT(tag
), "event",
592 G_CALLBACK(about_textview_uri_clicked
), text
);
593 g_signal_connect(G_OBJECT(text
), "motion-notify-event",
594 G_CALLBACK(about_textview_motion_notify
), text
);
595 g_signal_connect(G_OBJECT(text
), "leave-notify-event",
596 G_CALLBACK(about_textview_leave_notify
), text
);
603 static gboolean
release_notes_available(void)
605 gboolean ret
= FALSE
;
608 path
= g_strconcat(DOCDIR
, G_DIR_SEPARATOR_S
, RELEASE_NOTES_FILE
, NULL
);
609 ret
= (is_file_exist(path
));
615 static GtkWidget
*about_create_child_page_release_notes(void)
617 GtkWidget
*scrolledwin
;
619 GtkTextBuffer
*buffer
;
621 gchar
*path
, buf
[1024];
624 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
625 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
626 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
627 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
629 text
= gtk_text_view_new();
630 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
631 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
632 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
633 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
634 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
635 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
637 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
638 gtk_text_buffer_get_iter_at_offset(buffer
, &iter
, 0);
640 path
= g_strconcat(DOCDIR
, G_DIR_SEPARATOR_S
, RELEASE_NOTES_FILE
, NULL
);
641 if ((fp
= g_fopen(path
, "rb")) == NULL
) {
642 if (ENOENT
!= errno
) FILE_OP_ERROR(path
, "fopen");
648 while (fgets(buf
, sizeof(buf
), fp
) != NULL
) {
649 const gchar
*src_codeset
= conv_get_locale_charset_str();
650 const gchar
*dest_codeset
= CS_UTF_8
;
653 tmp
= conv_codeset_strdup(buf
, src_codeset
, dest_codeset
);
655 g_warning("Failed to convert character set of action configuration");
659 gtk_text_buffer_insert(buffer
, &iter
, tmp
, -1);
667 static GtkWidget
*about_create_child_page_session_stats(void)
669 GtkWidget
*scrolledwin
;
673 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
674 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
675 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
676 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin
),
678 text
= gtk_text_view_new();
679 gtk_text_view_set_editable(GTK_TEXT_VIEW(text
), FALSE
);
680 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text
), GTK_WRAP_WORD
);
681 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text
), 6);
682 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text
), 6);
683 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text
), FALSE
);
684 gtk_container_add(GTK_CONTAINER(scrolledwin
), text
);
686 stats_text_buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text
));
688 gtk_text_buffer_get_iter_at_offset(stats_text_buffer
, &iter
, 0);
689 gtk_text_buffer_create_tag(stats_text_buffer
, "indented-list-item",
692 gtk_text_buffer_create_tag(stats_text_buffer
, "underlined-list-title",
693 "underline", PANGO_UNDERLINE_SINGLE
,
695 gtk_text_buffer_create_tag(stats_text_buffer
, "bold", "weight", PANGO_WEIGHT_BOLD
,
698 about_update_stats();
703 static void about_update_stats(void)
705 if (stats_text_buffer
!= NULL
)
707 GtkTextIter start
, end
, iter
;
710 gtk_text_buffer_get_start_iter(stats_text_buffer
, &start
);
711 gtk_text_buffer_get_end_iter(stats_text_buffer
, &end
);
712 gtk_text_buffer_delete(stats_text_buffer
, &start
, &end
);
714 gtk_text_buffer_get_iter_at_offset(stats_text_buffer
, &iter
, 0);
716 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
,
717 (_("Session statistics\n")), -1,
718 "underlined-list-title", NULL
);
720 if (prefs_common
.date_format
) {
725 lt
= localtime(&session_stats
.time_started
);
726 fast_strftime(date
, len
, prefs_common
.date_format
, lt
);
727 g_snprintf(buf
, sizeof(buf
), _("Started: %s\n"),
728 lt
? date
: ctime(&session_stats
.time_started
));
730 g_snprintf(buf
, sizeof(buf
), _("Started: %s\n"),
731 ctime(&session_stats
.time_started
));
732 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
733 "indented-list-item", NULL
);
735 gtk_text_buffer_insert(stats_text_buffer
, &iter
, "\n", 1);
736 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
,
737 (_("Incoming traffic\n")), -1,
738 "underlined-list-title", NULL
);
740 g_snprintf(buf
, sizeof(buf
), _("Received messages: %d\n"),
741 session_stats
.received
);
742 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
743 "indented-list-item", "bold", NULL
);
745 gtk_text_buffer_insert(stats_text_buffer
, &iter
, "\n", 1);
746 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
,
747 (_("Outgoing traffic\n")), -1,
748 "underlined-list-title", NULL
);
750 g_snprintf(buf
, sizeof(buf
), _("New/redirected messages: %d\n"),
752 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
753 "indented-list-item", NULL
);
755 g_snprintf(buf
, sizeof(buf
), _("Replied messages: %d\n"),
756 session_stats
.replied
);
757 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
758 "indented-list-item", NULL
);
760 g_snprintf(buf
, sizeof(buf
), _("Forwarded messages: %d\n"),
761 session_stats
.forwarded
);
762 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
763 "indented-list-item", NULL
);
765 g_snprintf(buf
, sizeof(buf
), _("Total outgoing messages: %d\n"),
766 (session_stats
.sent
+ session_stats
.replied
+
767 session_stats
.forwarded
));
768 gtk_text_buffer_insert_with_tags_by_name(stats_text_buffer
, &iter
, buf
, -1,
769 "indented-list-item", "bold", NULL
);
773 static void about_create(void)
780 GtkWidget
*scrolledwin
;
784 GtkWidget
*confirm_area
;
785 GtkWidget
*close_button
;
786 static GdkGeometry geometry
;
788 stats_text_buffer
= NULL
;
790 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "about");
791 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER_ALWAYS
);
792 gtk_window_set_title(GTK_WINDOW(window
), _("About Claws Mail"));
793 gtk_container_set_border_width(GTK_CONTAINER(window
), 8);
794 gtk_widget_set_size_request(window
, -1, -1);
795 g_signal_connect(G_OBJECT(window
), "size_allocate",
796 G_CALLBACK(about_size_allocate_cb
), NULL
);
797 g_signal_connect(G_OBJECT(window
), "size_allocate",
798 G_CALLBACK(about_size_allocate_cb
), NULL
);
799 g_signal_connect(G_OBJECT(window
), "delete_event",
800 G_CALLBACK(gtk_widget_hide_on_delete
), NULL
);
801 g_signal_connect(G_OBJECT(window
), "key_press_event",
802 G_CALLBACK(key_pressed
), NULL
);
804 if (!geometry
.min_width
) {
805 geometry
.min_width
= 450;
806 geometry
.min_height
= 500;
809 gtk_window_set_geometry_hints(GTK_WINDOW(window
), NULL
, &geometry
,
811 gtk_window_set_default_size(GTK_WINDOW(window
), prefs_common
.aboutwin_width
,
812 prefs_common
.aboutwin_height
);
814 gtk_widget_realize(window
);
816 vbox1
= gtk_vbox_new(FALSE
, 8);
817 gtk_container_add(GTK_CONTAINER(window
), vbox1
);
819 table
= gtk_table_new (2, 1, FALSE
);
820 gtk_box_pack_start(GTK_BOX(vbox1
), table
,
822 gtk_container_set_border_width (GTK_CONTAINER (table
), 8);
823 gtk_table_set_row_spacings (GTK_TABLE (table
), 8);
824 gtk_table_set_col_spacings (GTK_TABLE (table
), 8);
826 image
= stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_LOGO
);
827 gtk_table_attach (GTK_TABLE (table
), image
, 0, 1, 0, 1,
828 (GtkAttachOptions
) (GTK_EXPAND
),
829 (GtkAttachOptions
) (0), 0, 0);
831 vbox2
= gtk_vbox_new (FALSE
, 4);
832 gtk_table_attach (GTK_TABLE (table
), vbox2
, 1, 2, 0, 1,
833 (GtkAttachOptions
) (GTK_EXPAND
),
834 (GtkAttachOptions
) (0), 0, 0);
836 label
= gtk_label_new("");
837 gtk_label_set_selectable(GTK_LABEL(label
), TRUE
);
838 gtk_label_set_justify(GTK_LABEL(label
), GTK_JUSTIFY_CENTER
);
839 gtk_box_pack_start(GTK_BOX(vbox2
), label
, FALSE
, FALSE
, 0);
840 markup
= g_markup_printf_escaped
841 ("<span weight=\"bold\" size=\"xx-large\">Claws Mail</span>\nversion %s",
843 gtk_label_set_markup(GTK_LABEL(label
), markup
);
846 button
= gtkut_get_link_btn(window
, HOMEPAGE_URI
, " "HOMEPAGE_URI
" ");
847 gtk_box_pack_start(GTK_BOX(vbox2
), button
, FALSE
, FALSE
, 0);
849 label
= gtk_label_new
850 (_("Copyright (C) 1999-2017\nThe Claws Mail Team\n"
851 "and Hiroyuki Yamamoto"));
852 gtk_label_set_selectable(GTK_LABEL(label
), TRUE
);
853 gtk_label_set_justify(GTK_LABEL(label
), GTK_JUSTIFY_CENTER
);
854 gtk_label_set_line_wrap(GTK_LABEL(label
), TRUE
);
855 gtk_box_pack_start(GTK_BOX(vbox2
), label
, FALSE
, FALSE
, 0);
857 notebook
= gtk_notebook_new();
858 gtk_widget_set_size_request(notebook
, -1, 220);
859 gtk_widget_show(notebook
);
861 if ((scrolledwin
= about_create_child_page_info()) != NULL
) {
862 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
864 gtk_label_new_with_mnemonic(_("_Info")));
867 if ((scrolledwin
= about_create_child_page_authors()) != NULL
) {
868 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
870 gtk_label_new_with_mnemonic(_("_Authors")));
873 if ((scrolledwin
= about_create_child_page_features()) != NULL
) {
874 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
876 gtk_label_new_with_mnemonic(_("_Features")));
879 if ((scrolledwin
= about_create_child_page_license()) != NULL
) {
880 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
882 gtk_label_new_with_mnemonic(_("_License")));
885 if (release_notes_available() &&
886 (scrolledwin
= about_create_child_page_release_notes()) != NULL
) {
888 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
890 gtk_label_new_with_mnemonic(_("_Release Notes")));
893 if ((scrolledwin
= about_create_child_page_session_stats()) != NULL
) {
894 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
),
896 gtk_label_new_with_mnemonic(_("_Statistics")));
899 gtk_box_pack_start(GTK_BOX(vbox1
), notebook
, TRUE
, TRUE
, 0);
901 gtkut_stock_button_set_create(&confirm_area
, &close_button
, GTK_STOCK_CLOSE
,
902 NULL
, NULL
, NULL
, NULL
);
903 gtk_box_pack_end(GTK_BOX(vbox1
), confirm_area
, FALSE
, FALSE
, 4);
904 gtk_widget_grab_default(close_button
);
905 gtk_widget_grab_focus(close_button
);
906 g_signal_connect_closure
907 (G_OBJECT(close_button
), "clicked",
908 g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete
),
909 window
, NULL
), FALSE
);
911 gtk_widget_show_all(window
);
914 static gboolean
key_pressed(GtkWidget
*widget
, GdkEventKey
*event
)
916 if (event
&& event
->keyval
== GDK_KEY_Escape
)
917 gtk_widget_hide(window
);
921 static void about_size_allocate_cb(GtkWidget
*widget
,
922 GtkAllocation
*allocation
)
924 cm_return_if_fail(allocation
!= NULL
);
926 prefs_common
.aboutwin_width
= allocation
->width
;
927 prefs_common
.aboutwin_height
= allocation
->height
;
931 static gboolean
about_textview_uri_clicked(GtkTextTag
*tag
, GObject
*obj
,
932 GdkEvent
*event
, GtkTextIter
*iter
,
935 GtkTextIter start_iter
, end_iter
;
936 GdkEventButton
*bevent
;
939 if (!event
|| !tag
) {
943 if (event
->type
!= GDK_BUTTON_PRESS
&& event
->type
!= GDK_2BUTTON_PRESS
944 && event
->type
!= GDK_BUTTON_RELEASE
) {
948 /* get link text from tag */
949 if (get_tag_range(iter
, tag
, &start_iter
,
950 &end_iter
) == FALSE
) {
953 link
= gtk_text_iter_get_text(&start_iter
, &end_iter
);
958 bevent
= (GdkEventButton
*) event
;
959 if (bevent
->button
== 1 && event
->type
== GDK_BUTTON_RELEASE
) {
960 GtkTextBuffer
*buffer
;
962 /* we shouldn't follow a link if the user has selected something */
963 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview
));
964 gtk_text_buffer_get_selection_bounds(buffer
, &start_iter
, &end_iter
);
965 if (gtk_text_iter_get_offset(&start_iter
) != gtk_text_iter_get_offset(&end_iter
)) {
968 /* open link and do *not* return TRUE so that
969 further gtk processing of the signal is done */
970 open_uri(link
, prefs_common_get_uri_cmd());
973 if (bevent
->button
== 3 && event
->type
== GDK_BUTTON_PRESS
) {
974 link_popupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
975 gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupLink")));
978 G_OBJECT(link_popupmenu
),
980 gtk_menu_popup(GTK_MENU(link_popupmenu
),
981 NULL
, NULL
, NULL
, NULL
,
982 bevent
->button
, bevent
->time
);
990 static gboolean
about_textview_motion_notify(GtkWidget
*widget
,
991 GdkEventMotion
*event
,
994 about_textview_uri_update(textview
, event
->x
, event
->y
);
995 gdk_window_get_pointer(gtk_widget_get_window(widget
), NULL
, NULL
, NULL
);
1000 static gboolean
about_textview_leave_notify(GtkWidget
*widget
,
1001 GdkEventCrossing
*event
,
1002 GtkWidget
*textview
)
1004 about_textview_uri_update(textview
, -1, -1);
1009 static void about_textview_uri_update(GtkWidget
*textview
, gint x
, gint y
)
1011 GtkTextBuffer
*buffer
;
1012 GtkTextIter start_iter
, end_iter
;
1016 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview
));
1018 if (x
!= -1 && y
!= -1) {
1024 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(textview
),
1025 GTK_TEXT_WINDOW_WIDGET
,
1027 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(textview
),
1030 tags
= gtk_text_iter_get_tags(&iter
);
1031 for (cur
= tags
; cur
!= NULL
; cur
= cur
->next
) {
1032 GtkTextTag
*tag
= cur
->data
;
1035 g_object_get(G_OBJECT(tag
), "name", &name
, NULL
);
1036 if (strcmp(name
, "link") == 0
1037 && get_tag_range(&iter
, tag
, &start_iter
, &end_iter
)) {
1038 uri
= gtk_text_iter_get_text(&start_iter
, &end_iter
);
1049 /* compare previous hovered link and this one
1050 (here links must be unique in text buffer otherwise ClickableText structures should be
1051 used as in textview.c) */
1052 same
= (uri
!= NULL
&& uri_hover
!= NULL
1053 && strcmp((char*)uri
, (char*)uri_hover
) == 0);
1055 if (same
== FALSE
) {
1059 gtk_text_buffer_remove_tag_by_name(buffer
,
1061 &uri_hover_start_iter
,
1062 &uri_hover_end_iter
);
1067 uri_hover_start_iter
= start_iter
;
1068 uri_hover_end_iter
= end_iter
;
1070 gtk_text_buffer_apply_tag_by_name(buffer
,
1076 window
= gtk_text_view_get_window(GTK_TEXT_VIEW(textview
),
1077 GTK_TEXT_WINDOW_TEXT
);
1079 hand_cursor
= gdk_cursor_new(GDK_HAND2
);
1081 text_cursor
= gdk_cursor_new(GDK_XTERM
);
1082 gdk_window_set_cursor(window
, uri
? hand_cursor
: text_cursor
);