2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2015 Colin Leroy 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"
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
34 #include "prefs_common.h"
35 #include "prefs_gtk.h"
37 #include "gtk/gtkutils.h"
38 #include "gtk/prefswindow.h"
40 #ifndef PASSWORD_CRYPTO_OLD
42 #include "password_gtk.h"
45 #include "manage_window.h"
47 #include "imap-thread.h"
50 typedef struct _OtherPage
56 GtkWidget *checkbtn_addaddrbyclick;
57 GtkWidget *checkbtn_confonexit;
58 GtkWidget *checkbtn_cleanonexit;
59 GtkWidget *checkbtn_askonclean;
60 GtkWidget *checkbtn_warnqueued;
61 GtkWidget *spinbtn_iotimeout;
62 GtkWidget *checkbtn_gtk_can_change_accels;
63 GtkWidget *checkbtn_askonfilter;
64 GtkWidget *checkbtn_use_shred;
65 GtkWidget *checkbtn_real_time_sync;
66 GtkWidget *flush_metadata_faster_radiobtn;
67 GtkWidget *flush_metadata_safer_radiobtn;
68 GtkWidget *checkbtn_transhdr;
69 #ifndef PASSWORD_CRYPTO_OLD
70 GtkWidget *checkbtn_use_passphrase;
74 static struct KeybindDialog {
79 static void prefs_keybind_select (void);
80 static gint prefs_keybind_deleted (GtkWidget *widget,
83 static gboolean prefs_keybind_key_pressed (GtkWidget *widget,
86 static void prefs_keybind_cancel (void);
87 static void prefs_keybind_apply_clicked (GtkWidget *widget);
88 #ifndef PASSWORD_CRYPTO_OLD
89 static void prefs_change_master_passphrase(GtkButton *button, gpointer data);
90 static void prefs_use_passphrase_toggled(GtkToggleButton *button, gpointer data);
94 static void prefs_keybind_select(void)
101 GtkWidget *confirm_area;
103 GtkWidget *cancel_btn;
105 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_other");
106 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
107 gtk_window_set_title (GTK_WINDOW (window),
108 _("Choose preset keyboard shortcuts"));
109 gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
110 gtk_window_set_modal (GTK_WINDOW (window), TRUE);
111 gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
112 manage_window_set_transient (GTK_WINDOW (window));
114 vbox1 = gtk_vbox_new (FALSE, VSPACING);
115 gtk_container_add (GTK_CONTAINER (window), vbox1);
116 gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
118 hbox1 = gtk_hbox_new (FALSE, 8);
119 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
121 label = gtk_label_new
122 (_("Select preset:"));
123 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
124 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
126 combo = combobox_text_new(FALSE,
131 gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
133 hbox1 = gtk_hbox_new (FALSE, 8);
134 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
136 label = gtk_label_new
137 (_("You can also modify each menu shortcut by pressing\n"
138 "any key(s) when focusing the mouse pointer on the item."));
139 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
140 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
141 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
142 gtkut_widget_set_small_font_size (label);
144 hbox1 = gtk_hbox_new (FALSE, 8);
145 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
147 gtkut_stock_button_set_create (&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
148 &ok_btn, GTK_STOCK_OK,
150 gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
151 gtk_widget_grab_focus (ok_btn);
153 MANAGE_WINDOW_SIGNALS_CONNECT(window);
154 g_signal_connect (G_OBJECT (window), "delete_event",
155 G_CALLBACK (prefs_keybind_deleted), NULL);
156 g_signal_connect (G_OBJECT (window), "key_press_event",
157 G_CALLBACK (prefs_keybind_key_pressed), NULL);
158 g_signal_connect (G_OBJECT (ok_btn), "clicked",
159 G_CALLBACK (prefs_keybind_apply_clicked),
161 g_signal_connect (G_OBJECT (cancel_btn), "clicked",
162 G_CALLBACK (prefs_keybind_cancel),
165 gtk_widget_show_all(window);
167 keybind.window = window;
168 keybind.combo = combo;
171 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
174 if (event && event->keyval == GDK_KEY_Escape)
175 prefs_keybind_cancel();
179 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
182 prefs_keybind_cancel();
186 static void prefs_keybind_cancel(void)
188 gtk_widget_destroy(keybind.window);
189 keybind.window = NULL;
190 keybind.combo = NULL;
194 const gchar *accel_path;
195 const gchar *accel_key;
198 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
202 GdkModifierType mods;
204 for (i = 0; i < num; i++) {
205 const gchar *accel_key
206 = keybind[i].accel_key ? keybind[i].accel_key : "";
207 gtk_accelerator_parse(accel_key, &key, &mods);
208 if (key == 0 && mods == 0) {
209 g_message("Failed parsing accelerator '%s' for path '%s'\n",
210 accel_key, keybind[i].accel_path);
212 gtk_accel_map_change_entry(keybind[i].accel_path,
217 static void prefs_keybind_apply_clicked(GtkWidget *widget)
220 struct KeyBind *menurc;
223 static struct KeyBind default_menurc[] = {
225 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
226 {"<Actions>/Menu/File/SaveAs", "<control>S"},
227 {"<Actions>/Menu/File/Print", "<control>P"},
228 {"<Actions>/Menu/File/OfflineMode", "<control>W"},
229 {"<Actions>/Menu/File/SynchroniseFolders", "<control><shift>S"},
230 {"<Actions>/Menu/File/Exit", "<control>Q"},
232 {"<Actions>/Menu/Edit/Copy", "<control>C"},
233 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
234 {"<Actions>/Menu/Edit/Find", "<control>F"},
235 {"<Actions>/Menu/Edit/SearchFolder", "<shift><control>F"},
236 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
238 {"<Actions>/Menu/View/ShowHide/MessageView", "V"},
239 {"<Actions>/Menu/View/ThreadView", "<control>T"},
240 {"<Actions>/Menu/View/Goto/Prev", "P"},
241 {"<Actions>/Menu/View/Goto/Next", "N"},
242 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
243 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
244 {"<Actions>/Menu/View/Goto/Folder", "G"},
245 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
246 {"<Actions>/Menu/View/MessageSource", "<control>U"},
247 {"<Actions>/Menu/View/AllHeaders", "<control>H"},
248 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"},
250 {"<Actions>/Menu/Message/Receive/CurrentAccount",
252 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
253 {"<Actions>/Menu/Message/ComposeEmail", "<control>M"},
254 {"<Actions>/Menu/Message/Reply", "<control>R"},
255 {"<Actions>/Menu/Message/ReplyTo/All", "<shift><control>R"},
256 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
257 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
258 {"<Actions>/Menu/Message/Forward", "<control><alt>F"},
259 {"<Actions>/Menu/Message/Move", "<control>O"},
260 {"<Actions>/Menu/Message/Copy", "<shift><control>O"},
261 {"<Actions>/Menu/Message/Trash", "<control>D"},
262 {"<Actions>/Menu/Message/Mark/Mark", "<shift>asterisk"},
263 {"<Actions>/Menu/Message/Mark/Unmark", "U"},
264 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>exclam"},
265 {"<Actions>/Menu/Message/Mark/MarkRead", ""},
267 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
268 {"<Actions>/Menu/Tools/Execute", "X"},
269 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
271 {"<Actions>/Menu/Message/Send", "<control>Return"},
272 {"<Actions>/Menu/Message/SendLater", "<shift><control>S"},
273 {"<Actions>/Menu/Message/AttachFile", "<control>M"},
274 {"<Actions>/Menu/Message/InsertFile", "<control>I"},
275 {"<Actions>/Menu/Message/InsertSig", "<control>G"},
276 {"<Actions>/Menu/Message/Save", "<control>S"},
277 {"<Actions>/Menu/Message/Close", "<control>W"},
278 {"<Actions>/Menu/Edit/Undo", "<control>Z"},
279 {"<Actions>/Menu/Edit/Redo", "<control>Y"},
280 {"<Actions>/Menu/Edit/Cut", "<control>X"},
281 {"<Actions>/Menu/Edit/Copy", "<control>C"},
282 {"<Actions>/Menu/Edit/Paste", "<control>V"},
283 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
284 {"<Actions>/Menu/Edit/Advanced/BackChar", "<control>B"},
285 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<control>F"},
286 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
287 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
288 {"<Actions>/Menu/Edit/Advanced/BegLine", ""},
289 {"<Actions>/Menu/Edit/Advanced/EndLine", "<control>E"},
290 {"<Actions>/Menu/Edit/Advanced/PrevLine", "<control>P"},
291 {"<Actions>/Menu/Edit/Advanced/NextLine", "<control>N"},
292 {"<Actions>/Menu/Edit/Advanced/DelBackChar", "<control>H"},
293 {"<Actions>/Menu/Edit/Advanced/DelForwChar", "<control>D"},
294 {"<Actions>/Menu/Edit/Advanced/DelBackWord", ""},
295 {"<Actions>/Menu/Edit/Advanced/DelForwWord", ""},
296 {"<Actions>/Menu/Edit/Advanced/DelLine", "<control>U"},
297 {"<Actions>/Menu/Edit/Advanced/DelEndLine", "<control>K"},
298 {"<Actions>/Menu/Edit/WrapPara", "<control>L"},
299 {"<Actions>/Menu/Edit/WrapAllLines", "<control><alt>L"},
300 {"<Actions>/Menu/Edit/AutoWrap", "<shift><control>L"},
301 {"<Actions>/Menu/Edit/ExtEditor", "<shift><control>X"},
302 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
305 static struct KeyBind mew_wl_menurc[] = {
307 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
308 {"<Actions>/Menu/File/SaveAs", "Y"},
309 {"<Actions>/Menu/File/Print", "<control>numbersign"},
310 {"<Actions>/Menu/File/Exit", "<shift>Q"},
312 {"<Actions>/Menu/Edit/Copy", "<control>C"},
313 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
314 {"<Actions>/Menu/Edit/Find", "<control>F"},
315 {"<Actions>/Menu/Edit/SearchFolder", "<control>S"},
316 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
318 {"<Actions>/Menu/View/ShowHide/MessageView", ""},
319 {"<Actions>/Menu/View/ThreadView", "<shift>T"},
320 {"<Actions>/Menu/View/Goto/Prev", "P"},
321 {"<Actions>/Menu/View/Goto/Next", "N"},
322 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
323 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
324 {"<Actions>/Menu/View/Goto/Folder", "G"},
325 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
326 {"<Actions>/Menu/View/MessageSource", "<control>U"},
327 {"<Actions>/Menu/View/AllHeaders", "<shift>H"},
328 {"<Actions>/Menu/View/UpdateSummary", "<shift>S"},
330 {"<Actions>/Menu/Message/Receive/CurrentAccount",
332 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
333 {"<Actions>/Menu/Message/ComposeEmail", "W"},
334 {"<Actions>/Menu/Message/Reply", "<control>R"},
335 {"<Actions>/Menu/Message/ReplyTo/All", "<shift>A"},
336 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
337 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
338 {"<Actions>/Menu/Message/Forward", "F"},
339 {"<Actions>/Menu/Message/Move", "O"},
340 {"<Actions>/Menu/Message/Copy", "<shift>O"},
341 {"<Actions>/Menu/Message/Trash", "D"},
342 {"<Actions>/Menu/Message/Mark/Mark", "<shift>asterisk"},
343 {"<Actions>/Menu/Message/Mark/Unmark", "U"},
344 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>exclam"},
345 {"<Actions>/Menu/Message/Mark/MarkRead", "<shift>R"},
347 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
348 {"<Actions>/Menu/Tools/Execute", "X"},
349 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
351 {"<Actions>/Menu/Message/Close", "<alt>W"},
352 {"<Actions>/Menu/Edit/SelectAll", ""},
353 {"<Actions>/Menu/Edit/Advanced/BackChar", "<alt>B"},
354 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<alt>F"},
355 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
356 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
357 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"},
358 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"},
359 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"},
362 static struct KeyBind mutt_menurc[] = {
364 {"<Actions>/Menu/File/SaveAs", "S"}, /* save-message */
365 {"<Actions>/Menu/File/Print", "P"}, /* print-message */
366 {"<Actions>/Menu/File/Exit", "Q"}, /* quit */
368 {"<Actions>/Menu/Edit/Copy", "<control>C"}, /* - */
369 {"<Actions>/Menu/Edit/SelectAll", "<control>A"}, /* - */
370 {"<Actions>/Menu/Edit/Find", "<alt>B"}, /* <esc>B: search in message bodies */
371 {"<Actions>/Menu/Edit/SearchFolder", "slash"}, /* search */
372 {"<Actions>/Menu/Edit/QuickSearch", "L"}, /* limit */
374 {"<Actions>/Menu/View/ShowHide/MessageView", "V"}, /* - */
375 {"<Actions>/Menu/View/ThreadView", "<control>T"}, /* - */
376 {"<Actions>/Menu/View/Goto/Prev", "K"}, /* previous-entry */
377 {"<Actions>/Menu/View/Goto/Next", "J"}, /* next-entry */
378 {"<Actions>/Menu/View/Goto/PrevUnread", "<alt>U"}, /* <esc>Tab: previous-new-then-unread */
379 {"<Actions>/Menu/View/Goto/NextUnread", "U"}, /* Tab: next-new-then-unread */
380 {"<Actions>/Menu/View/Goto/Folder", "C"}, /* change-folder */
381 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"}, /* - */
382 {"<Actions>/Menu/View/MessageSource", "E"}, /* edit the raw message */
383 {"<Actions>/Menu/View/AllHeaders", "H"}, /* display-toggle-weed */
384 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"}, /* - */
386 {"<Actions>/Menu/Message/Receive/CurrentAccount", "<control>I"}, /* - */
387 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift>G"}, /* fetch-mail */
388 {"<Actions>/Menu/Message/ComposeEmail", "M"}, /* mail */
389 {"<Actions>/Menu/Message/Reply", "R"}, /* reply */
390 {"<Actions>/Menu/Message/ReplyTo/All", "G"}, /* group-reply */
391 {"<Actions>/Menu/Message/ReplyTo/List", "<shift>L"}, /* list-reply */
392 {"<Actions>/Menu/Message/Forward", "F"}, /* forward-message */
393 {"<Actions>/Menu/Message/Move", "<control>O"}, /* - */
394 {"<Actions>/Menu/Message/Copy", "<shift>C"}, /* copy-message */
395 {"<Actions>/Menu/Message/Trash", "D"}, /* delete-message */
396 {"<Actions>/Menu/Message/Mark/Mark", "<shift>F"}, /* flag-message */
397 {"<Actions>/Menu/Message/Mark/Unmark", "<control><shift>F"}, /* - */
398 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>N"}, /* toggle-new */
399 {"<Actions>/Menu/Message/Mark/MarkRead", "<control>R"}, /* read-thread */
401 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"}, /* - */
402 {"<Actions>/Menu/Tools/Execute", "dollar"}, /* sync-mailbox */
403 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"}, /* - */
405 {"<Actions>/Menu/Message/Close", "<alt>W"}, /* - */
406 {"<Actions>/Menu/Edit/Advanced/BackWord", "<alt>B"}, /* - */
407 {"<Actions>/Menu/Edit/Advanced/ForwWord", "<alt>F"}, /* - */
408 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"}, /* - */
409 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"}, /* - */
410 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"}, /* - */
413 text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keybind.combo));
415 if (!strcmp(text, _("Default"))) {
416 menurc = default_menurc;
417 n_menurc = G_N_ELEMENTS(default_menurc);
418 } else if (!strcmp(text, "Mew / Wanderlust")) {
419 menurc = mew_wl_menurc;
420 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
421 } else if (!strcmp(text, "Mutt")) {
422 menurc = mutt_menurc;
423 n_menurc = G_N_ELEMENTS(mutt_menurc);
430 prefs_keybind_apply(menurc, n_menurc);
432 gtk_widget_destroy(keybind.window);
433 keybind.window = NULL;
434 keybind.combo = NULL;
437 static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
440 OtherPage *prefs_other = (OtherPage *) _page;
445 GtkWidget *frame_addr;
446 GtkWidget *vbox_addr;
447 GtkWidget *checkbtn_addaddrbyclick;
449 GtkWidget *frame_exit;
450 GtkWidget *vbox_exit;
451 GtkWidget *checkbtn_confonexit;
452 GtkWidget *checkbtn_cleanonexit;
453 GtkWidget *checkbtn_warnqueued;
455 GtkWidget *frame_keys;
456 GtkWidget *vbox_keys;
457 GtkWidget *checkbtn_gtk_can_change_accels;
458 GtkWidget *button_keybind;
460 GtkWidget *label_iotimeout;
461 GtkWidget *spinbtn_iotimeout;
462 GtkAdjustment *spinbtn_iotimeout_adj;
465 GtkWidget *checkbtn_transhdr;
466 GtkWidget *checkbtn_askonclean;
467 GtkWidget *checkbtn_askonfilter;
468 GtkWidget *checkbtn_use_shred;
469 GtkWidget *checkbtn_real_time_sync;
471 GtkWidget *frame_metadata;
472 GtkWidget *vbox_metadata;
473 GtkWidget *metadata_label;
474 GtkWidget *flush_metadata_faster_radiobtn;
475 GtkWidget *flush_metadata_safer_radiobtn;
477 #ifndef PASSWORD_CRYPTO_OLD
478 GtkWidget *vbox_passphrase;
479 GtkWidget *frame_passphrase;
480 GtkWidget *checkbtn_use_passphrase;
481 GtkWidget *button_change_passphrase;
484 gchar *shred_binary = NULL;
486 vbox1 = gtk_vbox_new (FALSE, VSPACING);
487 gtk_widget_show (vbox1);
488 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
490 vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
493 (vbox_addr, checkbtn_addaddrbyclick,
494 _("Add address to destination when double-clicked"));
497 vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
499 PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
500 _("Confirm on exit"));
502 hbox1 = gtk_hbox_new (FALSE, 32);
503 gtk_widget_show (hbox1);
504 gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
506 PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
507 _("Empty trash on exit"));
509 PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
510 _("Warn if there are queued messages"));
512 vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
514 PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels,
515 _("Enable customisable keyboard shortcuts"));
517 CLAWS_SET_TIP(checkbtn_gtk_can_change_accels,
518 _("If checked, you can change the keyboard shortcuts of "
519 "most of the menu items by focusing on the menu "
520 "item and pressing a key combination.\n"
521 "Uncheck this option if you want to lock all "
522 "existing keyboard shortcuts."));
524 button_keybind = gtk_button_new_with_label(
525 _(" Choose preset keyboard shortcuts... "));
526 gtk_widget_show (button_keybind);
527 hbox1 = gtk_hbox_new (FALSE, 8);
528 gtk_widget_show (hbox1);
529 gtk_box_pack_start (GTK_BOX (vbox_keys), hbox1, FALSE, FALSE, 0);
530 gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
531 g_signal_connect (G_OBJECT (button_keybind), "clicked",
532 G_CALLBACK (prefs_keybind_select), NULL);
535 vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
536 metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
537 "it avoids data loss after crashes but can take some time."));
538 gtk_misc_set_alignment(GTK_MISC(metadata_label), 0, 0);
539 gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
540 flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
541 flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
542 GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
543 hbox1 = gtk_hbox_new (FALSE, 8);
544 gtk_widget_show (hbox1);
545 gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
546 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
547 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
549 if (prefs_common.flush_metadata)
550 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
552 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
554 gtk_widget_show_all(frame_metadata);
556 hbox1 = gtk_hbox_new (FALSE, 8);
557 gtk_widget_show (hbox1);
558 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
560 label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
561 gtk_widget_show (label_iotimeout);
562 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
564 spinbtn_iotimeout_adj = GTK_ADJUSTMENT(gtk_adjustment_new (60, 0, 1000, 1, 10, 0));
565 spinbtn_iotimeout = gtk_spin_button_new
566 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
567 gtk_widget_show (spinbtn_iotimeout);
568 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
570 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
572 label_iotimeout = gtk_label_new (_("seconds"));
573 gtk_widget_show (label_iotimeout);
574 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
576 vbox2 = gtk_vbox_new (FALSE, 8);
577 gtk_widget_show (vbox2);
578 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
580 PACK_CHECK_BUTTON(vbox2, checkbtn_transhdr,
581 _("Translate header names"));
582 CLAWS_SET_TIP(checkbtn_transhdr,
583 _("The display of standard headers (such as 'From:', 'Subject:') "
584 "will be translated into your language."));
585 PACK_CHECK_BUTTON (vbox2, checkbtn_askonclean,
586 _("Ask before emptying trash"));
587 PACK_CHECK_BUTTON (vbox2, checkbtn_askonfilter,
588 _("Ask about account specific filtering rules when "
589 "filtering manually"));
590 shred_binary = g_find_program_in_path("shred");
592 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
593 _("Use secure file deletion if possible"));
594 g_free(shred_binary);
596 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
597 _("Use secure file deletion if possible\n"
598 "(the 'shred' program is not available)"));
599 gtk_widget_set_sensitive(checkbtn_use_shred, FALSE);
601 CLAWS_SET_TIP(checkbtn_use_shred,
602 _("Use the 'shred' program to overwrite files with random data before "
603 "deleting them. This slows down deletion. Be sure to "
604 "read shred's man page for caveats."));
605 PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
606 _("Synchronise offline folders as soon as possible"));
608 #ifndef PASSWORD_CRYPTO_OLD
609 vbox_passphrase = gtkut_get_options_frame(vbox1, &frame_passphrase, _("Master passphrase"));
611 PACK_CHECK_BUTTON(vbox_passphrase, checkbtn_use_passphrase,
612 _("Use a master passphrase"));
614 CLAWS_SET_TIP(checkbtn_use_passphrase,
615 _("If checked, your saved account passwords will be protected "
616 "by a master passphrase. If no master passphrase is set, "
617 "you will be prompted to set one."));
619 button_change_passphrase = gtk_button_new_with_label(
620 _("Change master passphrase"));
621 gtk_widget_show (button_change_passphrase);
622 hbox1 = gtk_hbox_new (FALSE, 8);
623 gtk_widget_show (hbox1);
624 gtk_box_pack_start (GTK_BOX (vbox_passphrase), hbox1, FALSE, FALSE, 0);
625 gtk_box_pack_start (GTK_BOX (hbox1), button_change_passphrase,
627 g_signal_connect (G_OBJECT (checkbtn_use_passphrase), "toggled",
628 G_CALLBACK (prefs_use_passphrase_toggled), button_change_passphrase);
629 g_signal_connect (G_OBJECT (button_change_passphrase), "clicked",
630 G_CALLBACK (prefs_change_master_passphrase), NULL);
633 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick),
634 prefs_common.add_address_by_click);
635 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit),
636 prefs_common.confirm_on_exit);
637 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit),
638 prefs_common.clean_on_exit);
639 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean),
640 prefs_common.ask_on_clean);
641 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued),
642 prefs_common.warn_queued_on_exit);
643 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
644 prefs_common.gtk_can_change_accels);
646 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
647 prefs_common.io_timeout_secs);
649 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_transhdr),
650 prefs_common.trans_hdr);
651 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter),
652 prefs_common.ask_apply_per_account_filtering_rules);
653 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_shred),
654 prefs_common.use_shred);
655 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync),
656 prefs_common.real_time_sync);
658 #ifndef PASSWORD_CRYPTO_OLD
659 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_passphrase),
660 prefs_common.use_master_passphrase);
661 gtk_widget_set_sensitive(button_change_passphrase,
662 prefs_common.use_master_passphrase);
665 prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
666 prefs_other->checkbtn_confonexit = checkbtn_confonexit;
667 prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
668 prefs_other->checkbtn_askonclean = checkbtn_askonclean;
669 prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
670 prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
671 prefs_other->checkbtn_transhdr = checkbtn_transhdr;
672 prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
673 prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
674 prefs_other->checkbtn_use_shred = checkbtn_use_shred;
675 prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
676 prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
677 prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
678 #ifndef PASSWORD_CRYPTO_OLD
679 prefs_other->checkbtn_use_passphrase = checkbtn_use_passphrase;
681 prefs_other->page.widget = vbox1;
684 static void prefs_other_save(PrefsPage *_page)
686 OtherPage *page = (OtherPage *) _page;
687 gboolean gtk_can_change_accels;
689 prefs_common.add_address_by_click = gtk_toggle_button_get_active(
690 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
691 prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
692 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
693 prefs_common.clean_on_exit = gtk_toggle_button_get_active(
694 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit));
695 prefs_common.ask_on_clean = gtk_toggle_button_get_active(
696 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
697 prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
698 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued));
699 prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
700 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
701 prefs_common.flush_metadata = gtk_toggle_button_get_active(
702 GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
703 sock_set_io_timeout(prefs_common.io_timeout_secs);
705 imap_main_set_timeout(prefs_common.io_timeout_secs);
707 prefs_common.trans_hdr = gtk_toggle_button_get_active(
708 GTK_TOGGLE_BUTTON(page->checkbtn_transhdr));
709 prefs_common.ask_apply_per_account_filtering_rules =
710 gtk_toggle_button_get_active(
711 GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter));
712 prefs_common.use_shred =
713 gtk_toggle_button_get_active(
714 GTK_TOGGLE_BUTTON(page->checkbtn_use_shred));
715 prefs_common.real_time_sync =
716 gtk_toggle_button_get_active(
717 GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync));
719 #ifndef PASSWORD_CRYPTO_OLD
720 /* If we're disabling use of master passphrase, we need to reencrypt
721 * all account passwords with hardcoded key. */
722 if (!gtk_toggle_button_get_active(
723 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
724 && master_passphrase_is_set()) {
725 master_passphrase_change(NULL, NULL);
727 /* In case user did not finish the passphrase change process
728 * (e.g. did not enter a correct current master passphrase),
729 * we need to enable the "use master passphrase" checkbox again,
730 * since the old master passphrase is still valid. */
731 if (master_passphrase_is_set()) {
732 gtk_toggle_button_set_active(
733 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), TRUE);
737 if (gtk_toggle_button_get_active(
738 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
739 && !master_passphrase_is_set()) {
740 master_passphrase_change_dialog();
742 /* In case user cancelled the passphrase change dialog, we need
743 * to disable the "use master passphrase" checkbox. */
744 if (!master_passphrase_is_set()) {
745 gtk_toggle_button_set_active(
746 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), FALSE);
750 prefs_common.use_master_passphrase =
751 gtk_toggle_button_get_active(
752 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase));
755 gtk_can_change_accels = gtk_toggle_button_get_active(
756 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
758 if (prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
760 prefs_common.gtk_can_change_accels = gtk_can_change_accels;
762 gtk_settings_set_long_property(gtk_settings_get_default(),
763 "gtk-can-change-accels",
764 (glong)prefs_common.gtk_can_change_accels,
767 /* gtk_can_change_accels value changed : we have (only if changed)
768 * to apply the gtk property to all widgets : */
769 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
773 static void prefs_other_destroy_widget(PrefsPage *_page)
777 OtherPage *prefs_other;
779 void prefs_other_init(void)
782 static gchar *path[3];
784 path[0] = _("Other");
785 path[1] = _("Miscellaneous");
788 page = g_new0(OtherPage, 1);
789 page->page.path = path;
790 page->page.create_widget = prefs_other_create_widget;
791 page->page.destroy_widget = prefs_other_destroy_widget;
792 page->page.save_page = prefs_other_save;
793 page->page.weight = 5.0;
794 prefs_gtk_register_page((PrefsPage *) page);
797 gtk_settings_set_long_property(gtk_settings_get_default(),
798 "gtk-can-change-accels",
799 (glong)prefs_common.gtk_can_change_accels,
803 void prefs_other_done(void)
805 prefs_gtk_unregister_page((PrefsPage *) prefs_other);
809 #ifndef PASSWORD_CRYPTO_OLD
810 void prefs_change_master_passphrase(GtkButton *button, gpointer data)
812 /* Call the passphrase change dialog */
813 master_passphrase_change_dialog();
816 void prefs_use_passphrase_toggled(GtkToggleButton *chkbtn, gpointer data)
818 GtkWidget *button = GTK_WIDGET(data);
819 gboolean active = gtk_toggle_button_get_active(chkbtn);
822 gtk_widget_set_sensitive(button, active);