2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2019 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_enable_accels;
63 GtkWidget *checkbtn_gtk_can_change_accels;
64 GtkWidget *checkbtn_askonfilter;
65 GtkWidget *checkbtn_use_shred;
66 GtkWidget *checkbtn_real_time_sync;
67 GtkWidget *flush_metadata_faster_radiobtn;
68 GtkWidget *flush_metadata_safer_radiobtn;
69 GtkWidget *checkbtn_transhdr;
70 #ifndef PASSWORD_CRYPTO_OLD
71 GtkWidget *checkbtn_use_passphrase;
75 static struct KeybindDialog {
80 static void prefs_keybind_select (void);
81 static gint prefs_keybind_deleted (GtkWidget *widget,
84 static gboolean prefs_keybind_key_pressed (GtkWidget *widget,
87 static void prefs_keybind_cancel (void);
88 static void prefs_keybind_apply_clicked (GtkWidget *widget);
89 #ifndef PASSWORD_CRYPTO_OLD
90 static void prefs_change_master_passphrase(GtkButton *button, gpointer data);
91 static void prefs_use_passphrase_toggled(GtkToggleButton *button, gpointer data);
95 static void prefs_keybind_select(void)
102 GtkWidget *confirm_area;
104 GtkWidget *cancel_btn;
106 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_other");
107 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
108 gtk_window_set_title (GTK_WINDOW (window),
109 _("Choose preset keyboard shortcuts"));
110 gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
111 gtk_window_set_modal (GTK_WINDOW (window), TRUE);
112 gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
113 manage_window_set_transient (GTK_WINDOW (window));
115 vbox1 = gtk_vbox_new (FALSE, VSPACING);
116 gtk_container_add (GTK_CONTAINER (window), vbox1);
117 gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
119 hbox1 = gtk_hbox_new (FALSE, 8);
120 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
122 label = gtk_label_new
123 (_("Select preset:"));
124 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
125 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
127 combo = combobox_text_new(FALSE,
132 gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
134 hbox1 = gtk_hbox_new (FALSE, 8);
135 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
137 label = gtk_label_new
138 (_("You can also modify each menu shortcut by pressing\n"
139 "any key(s) when focusing the mouse pointer on the item."));
140 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
141 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
142 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
143 gtkut_widget_set_small_font_size (label);
145 hbox1 = gtk_hbox_new (FALSE, 8);
146 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
148 gtkut_stock_button_set_create (&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
149 &ok_btn, GTK_STOCK_OK,
151 gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
152 gtk_widget_grab_focus (ok_btn);
154 MANAGE_WINDOW_SIGNALS_CONNECT(window);
155 g_signal_connect (G_OBJECT (window), "delete_event",
156 G_CALLBACK (prefs_keybind_deleted), NULL);
157 g_signal_connect (G_OBJECT (window), "key_press_event",
158 G_CALLBACK (prefs_keybind_key_pressed), NULL);
159 g_signal_connect (G_OBJECT (ok_btn), "clicked",
160 G_CALLBACK (prefs_keybind_apply_clicked),
162 g_signal_connect (G_OBJECT (cancel_btn), "clicked",
163 G_CALLBACK (prefs_keybind_cancel),
166 gtk_widget_show_all(window);
168 keybind.window = window;
169 keybind.combo = combo;
172 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
175 if (event && event->keyval == GDK_KEY_Escape)
176 prefs_keybind_cancel();
180 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
183 prefs_keybind_cancel();
187 static void prefs_keybind_cancel(void)
189 gtk_widget_destroy(keybind.window);
190 keybind.window = NULL;
191 keybind.combo = NULL;
195 const gchar *accel_path;
196 const gchar *accel_key;
199 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
203 GdkModifierType mods;
205 for (i = 0; i < num; i++) {
206 const gchar *accel_key
207 = keybind[i].accel_key ? keybind[i].accel_key : "";
208 gtk_accelerator_parse(accel_key, &key, &mods);
209 if (key == 0 && mods == 0) {
210 g_message("Failed parsing accelerator '%s' for path '%s'\n",
211 accel_key, keybind[i].accel_path);
213 gtk_accel_map_change_entry(keybind[i].accel_path,
218 static void prefs_keybind_apply_clicked(GtkWidget *widget)
221 struct KeyBind *menurc;
224 static struct KeyBind default_menurc[] = {
226 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
227 {"<Actions>/Menu/File/SaveAs", "<control>S"},
228 {"<Actions>/Menu/File/Print", "<control>P"},
229 {"<Actions>/Menu/File/OfflineMode", "<control>W"},
230 {"<Actions>/Menu/File/SynchroniseFolders", "<control><shift>S"},
231 {"<Actions>/Menu/File/Exit", "<control>Q"},
233 {"<Actions>/Menu/Edit/Copy", "<control>C"},
234 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
235 {"<Actions>/Menu/Edit/Find", "<control>F"},
236 {"<Actions>/Menu/Edit/SearchFolder", "<shift><control>F"},
237 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
239 {"<Actions>/Menu/View/ShowHide/MessageView", "V"},
240 {"<Actions>/Menu/View/ThreadView", "<control>T"},
241 {"<Actions>/Menu/View/Goto/Prev", "P"},
242 {"<Actions>/Menu/View/Goto/Next", "N"},
243 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
244 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
245 {"<Actions>/Menu/View/Goto/Folder", "G"},
246 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
247 {"<Actions>/Menu/View/MessageSource", "<control>U"},
248 {"<Actions>/Menu/View/AllHeaders", "<control>H"},
249 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"},
251 {"<Actions>/Menu/Message/Receive/CurrentAccount",
253 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
254 {"<Actions>/Menu/Message/ComposeEmail", "<control>M"},
255 {"<Actions>/Menu/Message/Reply", "<control>R"},
256 {"<Actions>/Menu/Message/ReplyTo/All", "<shift><control>R"},
257 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
258 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
259 {"<Actions>/Menu/Message/Forward", "<control><alt>F"},
260 {"<Actions>/Menu/Message/Move", "<control>O"},
261 {"<Actions>/Menu/Message/Copy", "<shift><control>O"},
262 {"<Actions>/Menu/Message/Trash", "<control>D"},
263 {"<Actions>/Menu/Message/Mark/Mark", "<shift>asterisk"},
264 {"<Actions>/Menu/Message/Mark/Unmark", "U"},
265 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>exclam"},
266 {"<Actions>/Menu/Message/Mark/MarkRead", ""},
268 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
269 {"<Actions>/Menu/Tools/Execute", "X"},
270 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
272 {"<Actions>/Menu/Message/Send", "<control>Return"},
273 {"<Actions>/Menu/Message/SendLater", "<shift><control>S"},
274 {"<Actions>/Menu/Message/AttachFile", "<control>M"},
275 {"<Actions>/Menu/Message/InsertFile", "<control>I"},
276 {"<Actions>/Menu/Message/InsertSig", "<control>G"},
277 {"<Actions>/Menu/Message/Save", "<control>S"},
278 {"<Actions>/Menu/Message/Close", "<control>W"},
279 {"<Actions>/Menu/Edit/Undo", "<control>Z"},
280 {"<Actions>/Menu/Edit/Redo", "<control>Y"},
281 {"<Actions>/Menu/Edit/Cut", "<control>X"},
282 {"<Actions>/Menu/Edit/Copy", "<control>C"},
283 {"<Actions>/Menu/Edit/Paste", "<control>V"},
284 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
285 {"<Actions>/Menu/Edit/Advanced/BackChar", "<control>B"},
286 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<control>F"},
287 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
288 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
289 {"<Actions>/Menu/Edit/Advanced/BegLine", ""},
290 {"<Actions>/Menu/Edit/Advanced/EndLine", "<control>E"},
291 {"<Actions>/Menu/Edit/Advanced/PrevLine", "<control>P"},
292 {"<Actions>/Menu/Edit/Advanced/NextLine", "<control>N"},
293 {"<Actions>/Menu/Edit/Advanced/DelBackChar", "<control>H"},
294 {"<Actions>/Menu/Edit/Advanced/DelForwChar", "<control>D"},
295 {"<Actions>/Menu/Edit/Advanced/DelBackWord", ""},
296 {"<Actions>/Menu/Edit/Advanced/DelForwWord", ""},
297 {"<Actions>/Menu/Edit/Advanced/DelLine", "<control>U"},
298 {"<Actions>/Menu/Edit/Advanced/DelEndLine", "<control>K"},
299 {"<Actions>/Menu/Edit/WrapPara", "<control>L"},
300 {"<Actions>/Menu/Edit/WrapAllLines", "<control><alt>L"},
301 {"<Actions>/Menu/Edit/AutoWrap", "<shift><control>L"},
302 {"<Actions>/Menu/Edit/ExtEditor", "<shift><control>X"},
303 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
306 static struct KeyBind mew_wl_menurc[] = {
308 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
309 {"<Actions>/Menu/File/SaveAs", "Y"},
310 {"<Actions>/Menu/File/Print", "<control>numbersign"},
311 {"<Actions>/Menu/File/Exit", "<shift>Q"},
313 {"<Actions>/Menu/Edit/Copy", "<control>C"},
314 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
315 {"<Actions>/Menu/Edit/Find", "<control>F"},
316 {"<Actions>/Menu/Edit/SearchFolder", "<control>S"},
317 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
319 {"<Actions>/Menu/View/ShowHide/MessageView", ""},
320 {"<Actions>/Menu/View/ThreadView", "<shift>T"},
321 {"<Actions>/Menu/View/Goto/Prev", "P"},
322 {"<Actions>/Menu/View/Goto/Next", "N"},
323 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
324 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
325 {"<Actions>/Menu/View/Goto/Folder", "G"},
326 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
327 {"<Actions>/Menu/View/MessageSource", "<control>U"},
328 {"<Actions>/Menu/View/AllHeaders", "<shift>H"},
329 {"<Actions>/Menu/View/UpdateSummary", "<shift>S"},
331 {"<Actions>/Menu/Message/Receive/CurrentAccount",
333 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
334 {"<Actions>/Menu/Message/ComposeEmail", "W"},
335 {"<Actions>/Menu/Message/Reply", "<control>R"},
336 {"<Actions>/Menu/Message/ReplyTo/All", "<shift>A"},
337 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
338 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
339 {"<Actions>/Menu/Message/Forward", "F"},
340 {"<Actions>/Menu/Message/Move", "O"},
341 {"<Actions>/Menu/Message/Copy", "<shift>O"},
342 {"<Actions>/Menu/Message/Trash", "D"},
343 {"<Actions>/Menu/Message/Mark/Mark", "<shift>asterisk"},
344 {"<Actions>/Menu/Message/Mark/Unmark", "U"},
345 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>exclam"},
346 {"<Actions>/Menu/Message/Mark/MarkRead", "<shift>R"},
348 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
349 {"<Actions>/Menu/Tools/Execute", "X"},
350 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
352 {"<Actions>/Menu/Message/Close", "<alt>W"},
353 {"<Actions>/Menu/Edit/SelectAll", ""},
354 {"<Actions>/Menu/Edit/Advanced/BackChar", "<alt>B"},
355 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<alt>F"},
356 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
357 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
358 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"},
359 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"},
360 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"},
363 static struct KeyBind mutt_menurc[] = {
365 {"<Actions>/Menu/File/SaveAs", "S"}, /* save-message */
366 {"<Actions>/Menu/File/Print", "P"}, /* print-message */
367 {"<Actions>/Menu/File/Exit", "Q"}, /* quit */
369 {"<Actions>/Menu/Edit/Copy", "<control>C"}, /* - */
370 {"<Actions>/Menu/Edit/SelectAll", "<control>A"}, /* - */
371 {"<Actions>/Menu/Edit/Find", "<alt>B"}, /* <esc>B: search in message bodies */
372 {"<Actions>/Menu/Edit/SearchFolder", "slash"}, /* search */
373 {"<Actions>/Menu/Edit/QuickSearch", "L"}, /* limit */
375 {"<Actions>/Menu/View/ShowHide/MessageView", "V"}, /* - */
376 {"<Actions>/Menu/View/ThreadView", "<control>T"}, /* - */
377 {"<Actions>/Menu/View/Goto/Prev", "K"}, /* previous-entry */
378 {"<Actions>/Menu/View/Goto/Next", "J"}, /* next-entry */
379 {"<Actions>/Menu/View/Goto/PrevUnread", "<alt>U"}, /* <esc>Tab: previous-new-then-unread */
380 {"<Actions>/Menu/View/Goto/NextUnread", "U"}, /* Tab: next-new-then-unread */
381 {"<Actions>/Menu/View/Goto/Folder", "C"}, /* change-folder */
382 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"}, /* - */
383 {"<Actions>/Menu/View/MessageSource", "E"}, /* edit the raw message */
384 {"<Actions>/Menu/View/AllHeaders", "H"}, /* display-toggle-weed */
385 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"}, /* - */
387 {"<Actions>/Menu/Message/Receive/CurrentAccount", "<control>I"}, /* - */
388 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift>G"}, /* fetch-mail */
389 {"<Actions>/Menu/Message/ComposeEmail", "M"}, /* mail */
390 {"<Actions>/Menu/Message/Reply", "R"}, /* reply */
391 {"<Actions>/Menu/Message/ReplyTo/All", "G"}, /* group-reply */
392 {"<Actions>/Menu/Message/ReplyTo/List", "<shift>L"}, /* list-reply */
393 {"<Actions>/Menu/Message/Forward", "F"}, /* forward-message */
394 {"<Actions>/Menu/Message/Move", "<control>O"}, /* - */
395 {"<Actions>/Menu/Message/Copy", "<shift>C"}, /* copy-message */
396 {"<Actions>/Menu/Message/Trash", "D"}, /* delete-message */
397 {"<Actions>/Menu/Message/Mark/Mark", "<shift>F"}, /* flag-message */
398 {"<Actions>/Menu/Message/Mark/Unmark", "<control><shift>F"}, /* - */
399 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>N"}, /* toggle-new */
400 {"<Actions>/Menu/Message/Mark/MarkRead", "<control>R"}, /* read-thread */
402 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"}, /* - */
403 {"<Actions>/Menu/Tools/Execute", "dollar"}, /* sync-mailbox */
404 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"}, /* - */
406 {"<Actions>/Menu/Message/Close", "<alt>W"}, /* - */
407 {"<Actions>/Menu/Edit/Advanced/BackWord", "<alt>B"}, /* - */
408 {"<Actions>/Menu/Edit/Advanced/ForwWord", "<alt>F"}, /* - */
409 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"}, /* - */
410 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"}, /* - */
411 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"}, /* - */
414 text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keybind.combo));
416 if (!strcmp(text, _("Default"))) {
417 menurc = default_menurc;
418 n_menurc = G_N_ELEMENTS(default_menurc);
419 } else if (!strcmp(text, "Mew / Wanderlust")) {
420 menurc = mew_wl_menurc;
421 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
422 } else if (!strcmp(text, "Mutt")) {
423 menurc = mutt_menurc;
424 n_menurc = G_N_ELEMENTS(mutt_menurc);
431 prefs_keybind_apply(menurc, n_menurc);
433 gtk_widget_destroy(keybind.window);
434 keybind.window = NULL;
435 keybind.combo = NULL;
438 static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
441 OtherPage *prefs_other = (OtherPage *) _page;
446 GtkWidget *frame_addr;
447 GtkWidget *vbox_addr;
448 GtkWidget *checkbtn_addaddrbyclick;
450 GtkWidget *frame_exit;
451 GtkWidget *vbox_exit;
452 GtkWidget *checkbtn_confonexit;
453 GtkWidget *checkbtn_cleanonexit;
454 GtkWidget *checkbtn_warnqueued;
456 GtkWidget *frame_keys;
457 GtkWidget *vbox_keys;
458 GtkWidget *checkbtn_gtk_enable_accels;
459 GtkWidget *checkbtn_gtk_can_change_accels;
460 GtkWidget *button_keybind;
462 GtkWidget *label_iotimeout;
463 GtkWidget *spinbtn_iotimeout;
464 GtkAdjustment *spinbtn_iotimeout_adj;
467 GtkWidget *checkbtn_transhdr;
468 GtkWidget *checkbtn_askonclean;
469 GtkWidget *checkbtn_askonfilter;
470 GtkWidget *checkbtn_use_shred;
471 GtkWidget *checkbtn_real_time_sync;
473 GtkWidget *frame_metadata;
474 GtkWidget *vbox_metadata;
475 GtkWidget *metadata_label;
476 GtkWidget *flush_metadata_faster_radiobtn;
477 GtkWidget *flush_metadata_safer_radiobtn;
479 #ifndef PASSWORD_CRYPTO_OLD
480 GtkWidget *vbox_passphrase;
481 GtkWidget *frame_passphrase;
482 GtkWidget *checkbtn_use_passphrase;
483 GtkWidget *button_change_passphrase;
486 gchar *shred_binary = NULL;
488 vbox1 = gtk_vbox_new (FALSE, VSPACING);
489 gtk_widget_show (vbox1);
490 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
492 vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
495 (vbox_addr, checkbtn_addaddrbyclick,
496 _("Add address to destination when double-clicked"));
499 vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
501 PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
502 _("Confirm on exit"));
504 hbox1 = gtk_hbox_new (FALSE, 32);
505 gtk_widget_show (hbox1);
506 gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
508 PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
509 _("Empty trash on exit"));
511 PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
512 _("Warn if there are queued messages"));
514 vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
516 PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_enable_accels,
517 _("Enable keyboard shortcuts"));
519 PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels,
520 _("Enable customisable keyboard shortcuts"));
522 CLAWS_SET_TIP(checkbtn_gtk_can_change_accels,
523 _("If checked, you can change the keyboard shortcuts of "
524 "most of the menu items by focusing on the menu "
525 "item and pressing a key combination.\n"
526 "Uncheck this option if you want to lock all "
527 "existing keyboard shortcuts."));
529 button_keybind = gtk_button_new_with_label(
530 _(" Choose preset keyboard shortcuts... "));
531 gtk_widget_show (button_keybind);
532 hbox1 = gtk_hbox_new (FALSE, 8);
533 gtk_widget_show (hbox1);
534 gtk_box_pack_start (GTK_BOX (vbox_keys), hbox1, FALSE, FALSE, 0);
535 gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
536 g_signal_connect (G_OBJECT (button_keybind), "clicked",
537 G_CALLBACK (prefs_keybind_select), NULL);
540 vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
541 metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
542 "it avoids data loss after crashes but can take some time."));
543 gtk_misc_set_alignment(GTK_MISC(metadata_label), 0, 0);
544 gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
545 flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
546 flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
547 GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
548 hbox1 = gtk_hbox_new (FALSE, 8);
549 gtk_widget_show (hbox1);
550 gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
551 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
552 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
554 if (prefs_common.flush_metadata)
555 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
557 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
559 gtk_widget_show_all(frame_metadata);
561 hbox1 = gtk_hbox_new (FALSE, 8);
562 gtk_widget_show (hbox1);
563 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
565 label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
566 gtk_widget_show (label_iotimeout);
567 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
569 spinbtn_iotimeout_adj = GTK_ADJUSTMENT(gtk_adjustment_new (60, 0, 1000, 1, 10, 0));
570 spinbtn_iotimeout = gtk_spin_button_new
571 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
572 gtk_widget_show (spinbtn_iotimeout);
573 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
575 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
577 label_iotimeout = gtk_label_new (_("seconds"));
578 gtk_widget_show (label_iotimeout);
579 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
581 vbox2 = gtk_vbox_new (FALSE, 8);
582 gtk_widget_show (vbox2);
583 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
585 PACK_CHECK_BUTTON(vbox2, checkbtn_transhdr,
586 _("Translate header names"));
587 CLAWS_SET_TIP(checkbtn_transhdr,
588 _("The display of standard headers (such as 'From:', 'Subject:') "
589 "will be translated into your language."));
590 PACK_CHECK_BUTTON (vbox2, checkbtn_askonclean,
591 _("Ask before emptying trash"));
592 PACK_CHECK_BUTTON (vbox2, checkbtn_askonfilter,
593 _("Ask about account specific filtering rules when "
594 "filtering manually"));
595 shred_binary = g_find_program_in_path("shred");
597 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
598 _("Use secure file deletion if possible"));
599 g_free(shred_binary);
601 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
602 _("Use secure file deletion if possible\n"
603 "(the 'shred' program is not available)"));
604 gtk_widget_set_sensitive(checkbtn_use_shred, FALSE);
606 CLAWS_SET_TIP(checkbtn_use_shred,
607 _("Use the 'shred' program to overwrite files with random data before "
608 "deleting them. This slows down deletion. Be sure to "
609 "read shred's man page for caveats."));
610 PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
611 _("Synchronise offline folders as soon as possible"));
613 #ifndef PASSWORD_CRYPTO_OLD
614 vbox_passphrase = gtkut_get_options_frame(vbox1, &frame_passphrase, _("Master passphrase"));
616 PACK_CHECK_BUTTON(vbox_passphrase, checkbtn_use_passphrase,
617 _("Use a master passphrase"));
619 CLAWS_SET_TIP(checkbtn_use_passphrase,
620 _("If checked, your saved account passwords will be protected "
621 "by a master passphrase. If no master passphrase is set, "
622 "you will be prompted to set one."));
624 button_change_passphrase = gtk_button_new_with_label(
625 _("Change master passphrase"));
626 gtk_widget_show (button_change_passphrase);
627 hbox1 = gtk_hbox_new (FALSE, 8);
628 gtk_widget_show (hbox1);
629 gtk_box_pack_start (GTK_BOX (vbox_passphrase), hbox1, FALSE, FALSE, 0);
630 gtk_box_pack_start (GTK_BOX (hbox1), button_change_passphrase,
632 g_signal_connect (G_OBJECT (checkbtn_use_passphrase), "toggled",
633 G_CALLBACK (prefs_use_passphrase_toggled), button_change_passphrase);
634 g_signal_connect (G_OBJECT (button_change_passphrase), "clicked",
635 G_CALLBACK (prefs_change_master_passphrase), NULL);
637 SET_TOGGLE_SENSITIVITY(checkbtn_gtk_enable_accels, checkbtn_gtk_can_change_accels);
638 SET_TOGGLE_SENSITIVITY(checkbtn_gtk_enable_accels, button_keybind);
640 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick),
641 prefs_common.add_address_by_click);
642 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit),
643 prefs_common.confirm_on_exit);
644 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit),
645 prefs_common.clean_on_exit);
646 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean),
647 prefs_common.ask_on_clean);
648 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued),
649 prefs_common.warn_queued_on_exit);
650 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_enable_accels),
651 prefs_common.gtk_enable_accels);
652 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
653 prefs_common.gtk_can_change_accels);
655 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
656 prefs_common.io_timeout_secs);
658 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_transhdr),
659 prefs_common.trans_hdr);
660 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter),
661 prefs_common.ask_apply_per_account_filtering_rules);
662 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_shred),
663 prefs_common.use_shred);
664 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync),
665 prefs_common.real_time_sync);
667 #ifndef PASSWORD_CRYPTO_OLD
668 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_passphrase),
669 prefs_common.use_master_passphrase);
670 gtk_widget_set_sensitive(button_change_passphrase,
671 prefs_common.use_master_passphrase);
674 prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
675 prefs_other->checkbtn_confonexit = checkbtn_confonexit;
676 prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
677 prefs_other->checkbtn_askonclean = checkbtn_askonclean;
678 prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
679 prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
680 prefs_other->checkbtn_transhdr = checkbtn_transhdr;
681 prefs_other->checkbtn_gtk_enable_accels = checkbtn_gtk_enable_accels;
682 prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
683 prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
684 prefs_other->checkbtn_use_shred = checkbtn_use_shred;
685 prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
686 prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
687 prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
688 #ifndef PASSWORD_CRYPTO_OLD
689 prefs_other->checkbtn_use_passphrase = checkbtn_use_passphrase;
691 prefs_other->page.widget = vbox1;
694 static void prefs_other_save(PrefsPage *_page)
696 OtherPage *page = (OtherPage *) _page;
697 gboolean gtk_enable_accels;
698 gboolean gtk_can_change_accels;
700 prefs_common.add_address_by_click = gtk_toggle_button_get_active(
701 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
702 prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
703 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
704 prefs_common.clean_on_exit = gtk_toggle_button_get_active(
705 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit));
706 prefs_common.ask_on_clean = gtk_toggle_button_get_active(
707 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
708 prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
709 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued));
710 prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
711 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
712 prefs_common.flush_metadata = gtk_toggle_button_get_active(
713 GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
714 sock_set_io_timeout(prefs_common.io_timeout_secs);
716 imap_main_set_timeout(prefs_common.io_timeout_secs);
718 prefs_common.trans_hdr = gtk_toggle_button_get_active(
719 GTK_TOGGLE_BUTTON(page->checkbtn_transhdr));
720 prefs_common.ask_apply_per_account_filtering_rules =
721 gtk_toggle_button_get_active(
722 GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter));
723 prefs_common.use_shred =
724 gtk_toggle_button_get_active(
725 GTK_TOGGLE_BUTTON(page->checkbtn_use_shred));
726 prefs_common.real_time_sync =
727 gtk_toggle_button_get_active(
728 GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync));
730 #ifndef PASSWORD_CRYPTO_OLD
731 /* If we're disabling use of master passphrase, we need to reencrypt
732 * all account passwords with hardcoded key. */
733 if (!gtk_toggle_button_get_active(
734 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
735 && master_passphrase_is_set()) {
736 master_passphrase_change(NULL, NULL);
738 /* In case user did not finish the passphrase change process
739 * (e.g. did not enter a correct current master passphrase),
740 * we need to enable the "use master passphrase" checkbox again,
741 * since the old master passphrase is still valid. */
742 if (master_passphrase_is_set()) {
743 gtk_toggle_button_set_active(
744 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), TRUE);
748 if (gtk_toggle_button_get_active(
749 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
750 && !master_passphrase_is_set()) {
751 master_passphrase_change_dialog();
753 /* In case user cancelled the passphrase change dialog, we need
754 * to disable the "use master passphrase" checkbox. */
755 if (!master_passphrase_is_set()) {
756 gtk_toggle_button_set_active(
757 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), FALSE);
761 prefs_common.use_master_passphrase =
762 gtk_toggle_button_get_active(
763 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase));
766 gtk_can_change_accels = gtk_toggle_button_get_active(
767 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
769 if (prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
771 prefs_common.gtk_can_change_accels = gtk_can_change_accels;
773 gtk_settings_set_long_property(gtk_settings_get_default(),
774 "gtk-can-change-accels",
775 (glong)prefs_common.gtk_can_change_accels,
778 gtk_enable_accels = gtk_toggle_button_get_active(
779 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_enable_accels));
781 if (prefs_common.gtk_enable_accels != gtk_enable_accels) {
782 prefs_common.gtk_enable_accels = gtk_enable_accels;
784 gtk_settings_set_long_property(gtk_settings_get_default(),
786 (glong)prefs_common.gtk_enable_accels,
789 gtk_settings_set_long_property(gtk_settings_get_default(),
790 "gtk-enable-mnemonics",
791 (glong)prefs_common.gtk_enable_accels,
795 if (prefs_common.gtk_enable_accels != gtk_enable_accels ||
796 prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
797 /* gtk_can_change_accels value changed : we have (only if changed)
798 * to apply the gtk property to all widgets : */
799 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
803 static void prefs_other_destroy_widget(PrefsPage *_page)
807 OtherPage *prefs_other;
809 void prefs_other_init(void)
812 static gchar *path[3];
814 path[0] = _("Other");
815 path[1] = _("Miscellaneous");
818 page = g_new0(OtherPage, 1);
819 page->page.path = path;
820 page->page.create_widget = prefs_other_create_widget;
821 page->page.destroy_widget = prefs_other_destroy_widget;
822 page->page.save_page = prefs_other_save;
823 page->page.weight = 5.0;
824 prefs_gtk_register_page((PrefsPage *) page);
827 gtk_settings_set_long_property(gtk_settings_get_default(),
828 "gtk-can-change-accels",
829 (glong)prefs_common.gtk_can_change_accels,
831 gtk_settings_set_long_property(gtk_settings_get_default(),
833 (glong)prefs_common.gtk_enable_accels,
835 gtk_settings_set_long_property(gtk_settings_get_default(),
836 "gtk-enable-mnemonics",
837 (glong)prefs_common.gtk_enable_accels,
841 void prefs_other_done(void)
843 prefs_gtk_unregister_page((PrefsPage *) prefs_other);
847 #ifndef PASSWORD_CRYPTO_OLD
848 void prefs_change_master_passphrase(GtkButton *button, gpointer data)
850 /* Call the passphrase change dialog */
851 master_passphrase_change_dialog();
854 void prefs_use_passphrase_toggled(GtkToggleButton *chkbtn, gpointer data)
856 GtkWidget *button = GTK_WIDGET(data);
857 gboolean active = gtk_toggle_button_get_active(chkbtn);
860 gtk_widget_set_sensitive(button, active);