make the creation and updating of .mh_sequences optional and disabled by default
[claws.git] / src / prefs_other.c
blob26e5b36793e5f62f83d1a6963f96a166a5620aeb
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2025 the Claws Mail team and Colin Leroy
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/>.
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #include "claws-features.h"
22 #endif
24 #include "defs.h"
26 #include <stdio.h>
27 #include <stdlib.h>
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 #include <gtk/gtk.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"
39 #include "combobox.h"
40 #ifndef PASSWORD_CRYPTO_OLD
41 #include "password.h"
42 #include "password_gtk.h"
43 #endif
45 #include "manage_window.h"
46 #ifdef HAVE_LIBETPAN
47 #include "imap-thread.h"
48 #endif
50 #include "file-utils.h"
52 typedef struct _OtherPage
54 PrefsPage page;
56 GtkWidget *window;
58 GtkWidget *keys_preset_combo;
59 GtkWidget *keys_preset_hbox;
60 GtkWidget *checkbtn_addaddrbyclick;
61 GtkWidget *checkbtn_confonexit;
62 GtkWidget *checkbtn_cleanonexit;
63 GtkWidget *checkbtn_askonclean;
64 GtkWidget *checkbtn_warnqueued;
65 GtkWidget *spinbtn_iotimeout;
66 GtkWidget *checkbtn_gtk_enable_accels;
67 GtkWidget *checkbtn_askonfilter;
68 GtkWidget *checkbtn_use_shred;
69 GtkWidget *checkbtn_real_time_sync;
70 GtkWidget *entry_attach_save_chmod;
71 GtkWidget *flush_metadata_faster_radiobtn;
72 GtkWidget *flush_metadata_safer_radiobtn;
73 GtkWidget *checkbtn_transhdr;
74 #ifndef PASSWORD_CRYPTO_OLD
75 GtkWidget *checkbtn_use_passphrase;
76 #endif
77 } OtherPage;
79 #ifndef PASSWORD_CRYPTO_OLD
80 static void prefs_change_primary_passphrase(GtkButton *button, gpointer data);
81 #endif
83 struct KeyBind {
84 const gchar *accel_path;
85 const gchar *accel_key;
88 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
90 gint i;
91 guint key;
92 GdkModifierType mods;
94 for (i = 0; i < num; i++) {
95 const gchar *accel_key
96 = keybind[i].accel_key ? keybind[i].accel_key : "";
97 gtk_accelerator_parse(accel_key, &key, &mods);
98 if (key == 0 && mods == 0) {
99 g_message("Failed parsing accelerator '%s' for path '%s'\n",
100 accel_key, keybind[i].accel_path);
102 gtk_accel_map_change_entry(keybind[i].accel_path,
103 key, mods, TRUE);
107 static void prefs_keybind_preset_changed(GtkComboBox *widget)
109 gchar *text;
110 struct KeyBind *menurc;
111 gint n_menurc;
113 /* make sure to keep the table below in sync with the ones in mainwindow.c, messageview.c */
114 static struct KeyBind default_menurc[] = {
115 /* main */
116 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
117 {"<Actions>/Menu/File/SaveAs", "<control>S"},
118 {"<Actions>/Menu/File/SavePartAs", "Y"},
119 {"<Actions>/Menu/File/Print", "<control>P"},
120 {"<Actions>/Menu/File/SynchroniseFolders", "<shift><control>S"},
121 {"<Actions>/Menu/File/Exit", "<control>Q"},
122 {"<Actions>/Menu/File/OfflineMode", "<control>W"},
124 {"<Actions>/Menu/Edit/Copy", "<control>C"},
125 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
126 {"<Actions>/Menu/Edit/Find", "<control>F"},
127 {"<Actions>/Menu/Edit/SearchFolder", "<shift><control>F"},
128 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
130 {"<Actions>/Menu/View/ShowHide/MenuBar", "<control>F12"},
131 {"<Actions>/Menu/View/ShowHide/MessageView", "V"},
132 {"<Actions>/Menu/View/ThreadView", "<control>T"},
133 {"<Actions>/Menu/View/FullScreen", "F11"},
134 {"<Actions>/Menu/View/AllHeaders", "<control>H"},
135 {"<Actions>/Menu/View/Quotes/CollapseAll", "<shift><control>Q"},
137 {"<Actions>/Menu/View/Goto/Prev", "P"},
138 {"<Actions>/Menu/View/Goto/Next", "N"},
139 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
140 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
141 {"<Actions>/Menu/View/Goto/PrevHistory", "<alt>Left"},
142 {"<Actions>/Menu/View/Goto/NextHistory", "<alt>Right"},
143 {"<Actions>/Menu/View/Goto/ParentMessage", "<control>Up"},
144 {"<Actions>/Menu/View/Goto/NextUnreadFolder", "<shift>G"},
145 {"<Actions>/Menu/View/Goto/Folder", "G"},
146 {"<Actions>/Menu/View/Goto/NextPart", "A"},
147 {"<Actions>/Menu/View/Goto/PrevPart", "Z"},
148 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
149 {"<Actions>/Menu/View/MessageSource", "<control>U"},
150 {"<Actions>/Menu/View/Part/AsText", "T"},
151 {"<Actions>/Menu/View/Part/Open", "L"},
152 {"<Actions>/Menu/View/Part/OpenWith", "O"},
153 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"},
155 {"<Actions>/Menu/Message/Receive/CurrentAccount", "<control>I"},
156 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
157 {"<Actions>/Menu/Message/ComposeEmail", "<control>M"},
158 {"<Actions>/Menu/Message/Reply", "<control>R"},
159 {"<Actions>/Menu/Message/ReplyTo/All", "<shift><control>R"},
160 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
161 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
162 {"<Actions>/Menu/Message/Forward", "<control><alt>F"},
163 {"<Actions>/Menu/Message/Move", "<control>O"},
164 {"<Actions>/Menu/Message/Copy", "<shift><control>O"},
165 {"<Actions>/Menu/Message/Trash", "<control>D"},
166 {"<Actions>/Menu/Message/Marks/Mark", "<shift>asterisk"},
167 {"<Actions>/Menu/Message/Marks/Unmark", "U"},
168 {"<Actions>/Menu/Message/Marks/MarkUnread", "<shift>exclam"},
169 {"<Actions>/Menu/Message/Marks/MarkRead", ""},
171 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
172 {"<Actions>/Menu/Tools/ListUrls", "<shift><control>U"},
173 {"<Actions>/Menu/Tools/Execute", "X"},
174 {"<Actions>/Menu/Tools/Expunge", "<control>E"},
175 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
177 /* compose */
178 {"<Actions>/Menu/Message/Send", "<control>Return"},
179 {"<Actions>/Menu/Message/SendLater", "<shift><control>S"},
180 {"<Actions>/Menu/Message/AttachFile", "<control>M"},
181 {"<Actions>/Menu/Message/InsertFile", "<control>I"},
182 {"<Actions>/Menu/Message/InsertSig", "<control>G"},
183 {"<Actions>/Menu/Message/Save", "<control>S"},
184 {"<Actions>/Menu/Message/Close", "<control>W"},
185 {"<Actions>/Menu/Edit/Undo", "<control>Z"},
186 {"<Actions>/Menu/Edit/Redo", "<control>Y"},
187 {"<Actions>/Menu/Edit/Cut", "<control>X"},
188 {"<Actions>/Menu/Edit/Copy", "<control>C"},
189 {"<Actions>/Menu/Edit/Paste", "<control>V"},
190 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
191 {"<Actions>/Menu/Edit/Advanced/BackChar", "<control>B"},
192 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<control>F"},
193 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
194 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
195 {"<Actions>/Menu/Edit/Advanced/BegLine", ""},
196 {"<Actions>/Menu/Edit/Advanced/EndLine", "<control>E"},
197 {"<Actions>/Menu/Edit/Advanced/PrevLine", "<control>P"},
198 {"<Actions>/Menu/Edit/Advanced/NextLine", "<control>N"},
199 {"<Actions>/Menu/Edit/Advanced/DelBackChar", "<control>H"},
200 {"<Actions>/Menu/Edit/Advanced/DelForwChar", "<control>D"},
201 {"<Actions>/Menu/Edit/Advanced/DelBackWord", ""},
202 {"<Actions>/Menu/Edit/Advanced/DelForwWord", ""},
203 {"<Actions>/Menu/Edit/Advanced/DelLine", "<control>U"},
204 {"<Actions>/Menu/Edit/Advanced/DelEndLine", "<control>K"},
205 {"<Actions>/Menu/Edit/WrapPara", "<control>L"},
206 {"<Actions>/Menu/Edit/WrapAllLines", "<control><alt>L"},
207 {"<Actions>/Menu/Edit/AutoWrap", "<shift><control>L"},
208 {"<Actions>/Menu/Edit/ExtEditor", "<shift><control>X"},
211 static struct KeyBind mew_wl_menurc[] = {
212 /* main */
213 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
214 {"<Actions>/Menu/File/SaveAs", "Y"},
215 {"<Actions>/Menu/File/Print", "<control>numbersign"},
216 {"<Actions>/Menu/File/Exit", "<shift>Q"},
218 {"<Actions>/Menu/Edit/Copy", "<control>C"},
219 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
220 {"<Actions>/Menu/Edit/Find", "<control>F"},
221 {"<Actions>/Menu/Edit/SearchFolder", "<control>S"},
222 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
224 {"<Actions>/Menu/View/ShowHide/MessageView", ""},
225 {"<Actions>/Menu/View/ThreadView", "<shift>T"},
226 {"<Actions>/Menu/View/Goto/Prev", "P"},
227 {"<Actions>/Menu/View/Goto/Next", "N"},
228 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
229 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
230 {"<Actions>/Menu/View/Goto/Folder", "G"},
231 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
232 {"<Actions>/Menu/View/MessageSource", "<control>U"},
233 {"<Actions>/Menu/View/AllHeaders", "<shift>H"},
234 {"<Actions>/Menu/View/UpdateSummary", "<shift>S"},
236 {"<Actions>/Menu/Message/Receive/CurrentAccount",
237 "<control>I"},
238 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
239 {"<Actions>/Menu/Message/ComposeEmail", "W"},
240 {"<Actions>/Menu/Message/Reply", "<control>R"},
241 {"<Actions>/Menu/Message/ReplyTo/All", "<shift>A"},
242 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
243 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
244 {"<Actions>/Menu/Message/Forward", "F"},
245 {"<Actions>/Menu/Message/Move", "O"},
246 {"<Actions>/Menu/Message/Copy", "<shift>O"},
247 {"<Actions>/Menu/Message/Trash", "D"},
248 {"<Actions>/Menu/Message/Marks/Mark", "<shift>asterisk"},
249 {"<Actions>/Menu/Message/Marks/Unmark", "U"},
250 {"<Actions>/Menu/Message/Marks/MarkUnread", "<shift>exclam"},
251 {"<Actions>/Menu/Message/Marks/MarkRead", "<shift>R"},
253 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
254 {"<Actions>/Menu/Tools/Execute", "X"},
255 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
257 /* compose */
258 {"<Actions>/Menu/Message/Close", "<alt>W"},
259 {"<Actions>/Menu/Edit/SelectAll", ""},
260 {"<Actions>/Menu/Edit/Advanced/BackChar", "<alt>B"},
261 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<alt>F"},
262 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
263 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
264 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"},
265 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"},
266 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"},
269 static struct KeyBind mutt_menurc[] = {
270 /* main */
271 {"<Actions>/Menu/File/SaveAs", "S"}, /* save-message */
272 {"<Actions>/Menu/File/Print", "P"}, /* print-message */
273 {"<Actions>/Menu/File/Exit", "Q"}, /* quit */
275 {"<Actions>/Menu/Edit/Copy", "<control>C"}, /* - */
276 {"<Actions>/Menu/Edit/SelectAll", "<control>A"}, /* - */
277 {"<Actions>/Menu/Edit/Find", "<alt>B"}, /* <esc>B: search in message bodies */
278 {"<Actions>/Menu/Edit/SearchFolder", "slash"}, /* search */
279 {"<Actions>/Menu/Edit/QuickSearch", "L"}, /* limit */
281 {"<Actions>/Menu/View/ShowHide/MessageView", "V"}, /* - */
282 {"<Actions>/Menu/View/ThreadView", "<control>T"}, /* - */
283 {"<Actions>/Menu/View/Goto/Prev", "K"}, /* previous-entry */
284 {"<Actions>/Menu/View/Goto/Next", "J"}, /* next-entry */
285 {"<Actions>/Menu/View/Goto/PrevUnread", "<alt>U"}, /* <esc>Tab: previous-new-then-unread */
286 {"<Actions>/Menu/View/Goto/NextUnread", "U"}, /* Tab: next-new-then-unread */
287 {"<Actions>/Menu/View/Goto/Folder", "C"}, /* change-folder */
288 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"}, /* - */
289 {"<Actions>/Menu/View/MessageSource", "E"}, /* edit the raw message */
290 {"<Actions>/Menu/View/AllHeaders", "H"}, /* display-toggle-weed */
291 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"}, /* - */
293 {"<Actions>/Menu/Message/Receive/CurrentAccount", "<control>I"}, /* - */
294 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift>G"}, /* fetch-mail */
295 {"<Actions>/Menu/Message/ComposeEmail", "M"}, /* mail */
296 {"<Actions>/Menu/Message/Reply", "R"}, /* reply */
297 {"<Actions>/Menu/Message/ReplyTo/All", "G"}, /* group-reply */
298 {"<Actions>/Menu/Message/ReplyTo/List", "<shift>L"}, /* list-reply */
299 {"<Actions>/Menu/Message/Forward", "F"}, /* forward-message */
300 {"<Actions>/Menu/Message/Move", "<control>O"}, /* - */
301 {"<Actions>/Menu/Message/Copy", "<shift>C"}, /* copy-message */
302 {"<Actions>/Menu/Message/Trash", "D"}, /* delete-message */
303 {"<Actions>/Menu/Message/Marks/Mark", "<shift>F"}, /* flag-message */
304 {"<Actions>/Menu/Message/Marks/Unmark", "<shift><control>F"}, /* - */
305 {"<Actions>/Menu/Message/Marks/MarkUnread", "<shift>N"}, /* toggle-new */
306 {"<Actions>/Menu/Message/Marks/MarkRead", "<control>R"}, /* read-thread */
308 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"}, /* - */
309 {"<Actions>/Menu/Tools/Execute", "dollar"}, /* sync-mailbox */
310 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"}, /* - */
312 /* compose */
313 {"<Actions>/Menu/Message/Close", "<alt>W"}, /* - */
314 {"<Actions>/Menu/Edit/Advanced/BackWord", "<alt>B"}, /* - */
315 {"<Actions>/Menu/Edit/Advanced/ForwWord", "<alt>F"}, /* - */
316 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"}, /* - */
317 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"}, /* - */
318 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"}, /* - */
321 text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget));
323 if (!strcmp(text, _("Default"))) {
324 menurc = default_menurc;
325 n_menurc = G_N_ELEMENTS(default_menurc);
326 } else if (!strcmp(text, "Mew / Wanderlust")) {
327 menurc = mew_wl_menurc;
328 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
329 } else if (!strcmp(text, "Mutt")) {
330 menurc = mutt_menurc;
331 n_menurc = G_N_ELEMENTS(mutt_menurc);
332 } else {
333 g_free(text);
334 return;
336 g_free(text);
338 prefs_keybind_apply(menurc, n_menurc);
341 static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
342 gpointer data)
344 OtherPage *prefs_other = (OtherPage *) _page;
346 GtkWidget *vbox1;
347 GtkWidget *hbox1;
349 GtkWidget *frame_addr;
350 GtkWidget *vbox_addr;
351 GtkWidget *checkbtn_addaddrbyclick;
353 GtkWidget *frame_exit;
354 GtkWidget *vbox_exit;
355 GtkWidget *checkbtn_confonexit;
356 GtkWidget *checkbtn_cleanonexit;
357 GtkWidget *checkbtn_warnqueued;
359 GtkWidget *frame_keys;
360 GtkWidget *vbox_keys;
361 GtkWidget *checkbtn_gtk_enable_accels;
362 GtkWidget *keys_preset_hbox;
363 GtkWidget *keys_preset_label;
364 GtkWidget *keys_preset_combo;
366 GtkWidget *label_iotimeout;
367 GtkWidget *spinbtn_iotimeout;
368 GtkAdjustment *spinbtn_iotimeout_adj;
370 GtkWidget *vbox2;
371 GtkWidget *checkbtn_transhdr;
372 GtkWidget *checkbtn_askonclean;
373 GtkWidget *checkbtn_askonfilter;
374 GtkWidget *checkbtn_use_shred;
375 GtkWidget *checkbtn_real_time_sync;
376 GtkWidget *label_attach_save_chmod;
377 GtkWidget *entry_attach_save_chmod;
379 GtkWidget *frame_metadata;
380 GtkWidget *vbox_metadata;
381 GtkWidget *metadata_label;
382 GtkWidget *flush_metadata_faster_radiobtn;
383 GtkWidget *flush_metadata_safer_radiobtn;
385 #ifndef PASSWORD_CRYPTO_OLD
386 GtkWidget *vbox_passphrase;
387 GtkWidget *frame_passphrase;
388 GtkWidget *checkbtn_use_passphrase;
389 GtkWidget *button_change_passphrase;
390 #endif
392 gchar *shred_binary = NULL;
394 vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
395 gtk_widget_show (vbox1);
396 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
398 vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
400 PACK_CHECK_BUTTON
401 (vbox_addr, checkbtn_addaddrbyclick,
402 _("Add address to destination when double-clicked"));
404 /* On Exit */
405 vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
407 PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
408 _("Confirm on exit"));
410 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 32);
411 gtk_widget_show (hbox1);
412 gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
414 PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
415 _("Empty trash on exit"));
417 PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
418 _("Warn if there are queued messages"));
420 vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
422 PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_enable_accels,
423 _("Enable keyboard shortcuts"));
425 keys_preset_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
426 gtk_widget_show (keys_preset_hbox);
427 gtk_box_pack_start (GTK_BOX (vbox_keys), keys_preset_hbox, FALSE, FALSE, 0);
429 keys_preset_label = gtk_label_new
430 (_("Select preset keyboard shortcuts:"));
431 gtk_box_pack_start (GTK_BOX (keys_preset_hbox), keys_preset_label, FALSE, FALSE, 0);
432 gtk_label_set_justify (GTK_LABEL (keys_preset_label), GTK_JUSTIFY_LEFT);
434 keys_preset_combo = combobox_text_new(FALSE,
435 _("Current"),
436 _("Default"),
437 "Mew / Wanderlust",
438 "Mutt",
439 NULL);
440 gtk_box_pack_start (GTK_BOX (keys_preset_hbox), keys_preset_combo, FALSE, FALSE, 0);
441 gtk_widget_show_all(frame_keys);
442 SET_TOGGLE_SENSITIVITY (checkbtn_gtk_enable_accels, keys_preset_hbox);
444 vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
445 metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
446 "it avoids data loss after crashes but can take some time."));
447 gtk_label_set_xalign(GTK_LABEL(metadata_label), 0.0);
448 gtk_label_set_yalign(GTK_LABEL(metadata_label), 0.0);
449 gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
450 flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
451 flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
452 GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
453 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
454 gtk_widget_show (hbox1);
455 gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
456 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
457 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
459 if (prefs_common.flush_metadata)
460 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
461 else
462 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
464 gtk_widget_show_all(frame_metadata);
466 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
467 gtk_widget_show (hbox1);
468 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
470 label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
471 gtk_widget_show (label_iotimeout);
472 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
474 spinbtn_iotimeout_adj = GTK_ADJUSTMENT(gtk_adjustment_new (60, 0, 1000, 1, 10, 0));
475 spinbtn_iotimeout = gtk_spin_button_new
476 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
477 gtk_widget_show (spinbtn_iotimeout);
478 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
479 FALSE, FALSE, 0);
480 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
482 label_iotimeout = gtk_label_new (_("seconds"));
483 gtk_widget_show (label_iotimeout);
484 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
486 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
487 gtk_widget_show (vbox2);
488 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
490 PACK_CHECK_BUTTON(vbox2, checkbtn_transhdr,
491 _("Translate header names"));
492 CLAWS_SET_TIP(checkbtn_transhdr,
493 _("The display of standard headers (such as 'From:', 'Subject:') "
494 "will be translated into your language."));
495 PACK_CHECK_BUTTON (vbox2, checkbtn_askonclean,
496 _("Ask before emptying trash"));
497 PACK_CHECK_BUTTON (vbox2, checkbtn_askonfilter,
498 _("Ask about account specific filtering rules when "
499 "filtering manually"));
500 shred_binary = g_find_program_in_path("shred");
501 if (shred_binary) {
502 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
503 _("Use secure file deletion if possible"));
504 g_free(shred_binary);
505 } else {
506 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
507 _("Use secure file deletion if possible\n"
508 "(the 'shred' program is not available)"));
509 gtk_widget_set_sensitive(checkbtn_use_shred, FALSE);
511 CLAWS_SET_TIP(checkbtn_use_shred,
512 _("Use the 'shred' program to overwrite files with random data before "
513 "deleting them. This slows down deletion. Be sure to "
514 "read shred's man page for caveats."));
515 PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
516 _("Synchronise offline folders as soon as possible"));
519 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
520 gtk_widget_show(hbox1);
521 gtk_box_pack_start(GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
523 label_attach_save_chmod = gtk_label_new (_("Save attachments with chmod"));
524 gtk_widget_show(label_attach_save_chmod);
525 gtk_box_pack_start(GTK_BOX (hbox1), label_attach_save_chmod, FALSE, FALSE, 0);
527 entry_attach_save_chmod = gtk_entry_new();
528 gtk_entry_set_width_chars(GTK_ENTRY(entry_attach_save_chmod), 5);
529 gtk_widget_set_tooltip_text(entry_attach_save_chmod,
530 _("By default attachments are saved with chmod value 600: "
531 "readable and writeable by the user only. If this is too "
532 "restrictive for you, set a chmod value here, otherwise leave "
533 "blank to use the default."));
534 gtk_widget_show(entry_attach_save_chmod);
535 gtk_box_pack_start(GTK_BOX(hbox1), entry_attach_save_chmod, FALSE, FALSE, 0);
536 if (prefs_common.attach_save_chmod) {
537 gchar *buf;
539 buf = g_strdup_printf("%o", prefs_common.attach_save_chmod);
540 gtk_entry_set_text(GTK_ENTRY(entry_attach_save_chmod), buf);
541 g_free(buf);
544 #ifndef PASSWORD_CRYPTO_OLD
545 vbox_passphrase = gtkut_get_options_frame(vbox1, &frame_passphrase, _("Primary passphrase"));
547 PACK_CHECK_BUTTON(vbox_passphrase, checkbtn_use_passphrase,
548 _("Use a primary passphrase"));
550 CLAWS_SET_TIP(checkbtn_use_passphrase,
551 _("If checked, your saved account passwords will be protected "
552 "by a primary passphrase. If no primary passphrase is set, "
553 "you will be prompted to set one."));
555 button_change_passphrase = gtk_button_new_with_label(
556 _("Change primary passphrase"));
557 gtk_widget_show (button_change_passphrase);
558 hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
559 gtk_widget_show (hbox1);
560 gtk_box_pack_start (GTK_BOX (vbox_passphrase), hbox1, FALSE, FALSE, 0);
561 gtk_box_pack_start (GTK_BOX (hbox1), button_change_passphrase,
562 FALSE, FALSE, 0);
563 SET_TOGGLE_SENSITIVITY (checkbtn_use_passphrase, button_change_passphrase);
564 g_signal_connect (G_OBJECT (button_change_passphrase), "clicked",
565 G_CALLBACK (prefs_change_primary_passphrase), NULL);
566 #endif
568 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick),
569 prefs_common.add_address_by_click);
570 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit),
571 prefs_common.confirm_on_exit);
572 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit),
573 prefs_common.clean_on_exit);
574 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean),
575 prefs_common.ask_on_clean);
576 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued),
577 prefs_common.warn_queued_on_exit);
578 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_enable_accels),
579 prefs_common.gtk_enable_accels);
580 gtk_widget_set_sensitive(keys_preset_hbox, prefs_common.gtk_enable_accels);
582 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
583 prefs_common.io_timeout_secs);
585 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_transhdr),
586 prefs_common.trans_hdr);
587 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter),
588 prefs_common.ask_apply_per_account_filtering_rules);
589 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_shred),
590 prefs_common.use_shred);
591 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync),
592 prefs_common.real_time_sync);
594 #ifndef PASSWORD_CRYPTO_OLD
595 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_passphrase),
596 prefs_common.use_primary_passphrase);
597 gtk_widget_set_sensitive(button_change_passphrase,
598 prefs_common.use_primary_passphrase);
599 #endif
601 prefs_other->keys_preset_hbox = keys_preset_hbox;
602 prefs_other->keys_preset_combo = keys_preset_combo;
603 prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
604 prefs_other->checkbtn_confonexit = checkbtn_confonexit;
605 prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
606 prefs_other->checkbtn_askonclean = checkbtn_askonclean;
607 prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
608 prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
609 prefs_other->checkbtn_transhdr = checkbtn_transhdr;
610 prefs_other->checkbtn_gtk_enable_accels = checkbtn_gtk_enable_accels;
611 prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
612 prefs_other->checkbtn_use_shred = checkbtn_use_shred;
613 prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
614 prefs_other->entry_attach_save_chmod = entry_attach_save_chmod;
615 prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
616 prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
617 #ifndef PASSWORD_CRYPTO_OLD
618 prefs_other->checkbtn_use_passphrase = checkbtn_use_passphrase;
619 #endif
620 prefs_other->page.widget = vbox1;
623 static void prefs_other_save(PrefsPage *_page)
625 OtherPage *page = (OtherPage *) _page;
626 GtkSettings *settings = gtk_settings_get_default();
627 gboolean gtk_enable_accels;
628 gchar *buf;
630 prefs_common.add_address_by_click = gtk_toggle_button_get_active(
631 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
632 prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
633 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
634 prefs_common.clean_on_exit = gtk_toggle_button_get_active(
635 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit));
636 prefs_common.ask_on_clean = gtk_toggle_button_get_active(
637 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
638 prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
639 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued));
640 prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
641 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
642 prefs_common.flush_metadata = gtk_toggle_button_get_active(
643 GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
644 sock_set_io_timeout(prefs_common.io_timeout_secs);
645 #ifdef HAVE_LIBETPAN
646 imap_main_set_timeout(prefs_common.io_timeout_secs);
647 #endif
648 prefs_common.trans_hdr = gtk_toggle_button_get_active(
649 GTK_TOGGLE_BUTTON(page->checkbtn_transhdr));
650 prefs_common.ask_apply_per_account_filtering_rules =
651 gtk_toggle_button_get_active(
652 GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter));
653 prefs_common.use_shred =
654 gtk_toggle_button_get_active(
655 GTK_TOGGLE_BUTTON(page->checkbtn_use_shred));
656 prefs_common.real_time_sync =
657 gtk_toggle_button_get_active(
658 GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync));
660 buf = gtk_editable_get_chars(GTK_EDITABLE(page->entry_attach_save_chmod), 0, -1);
661 prefs_common.attach_save_chmod = prefs_chmod_mode(buf);
662 g_free(buf);
664 prefs_keybind_preset_changed(GTK_COMBO_BOX(page->keys_preset_combo));
666 #ifndef PASSWORD_CRYPTO_OLD
667 /* If we're disabling use of primary passphrase, we need to reencrypt
668 * all account passwords with hardcoded key. */
669 if (!gtk_toggle_button_get_active(
670 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
671 && primary_passphrase_is_set()) {
672 primary_passphrase_change(NULL, NULL);
674 /* In case user did not finish the passphrase change process
675 * (e.g. did not enter a correct current primary passphrase),
676 * we need to enable the "use primary passphrase" checkbox again,
677 * since the old primary passphrase is still valid. */
678 if (primary_passphrase_is_set()) {
679 gtk_toggle_button_set_active(
680 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), TRUE);
684 if (gtk_toggle_button_get_active(
685 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase))
686 && !primary_passphrase_is_set()) {
687 primary_passphrase_change_dialog();
689 /* In case user cancelled the passphrase change dialog, we need
690 * to disable the "use primary passphrase" checkbox. */
691 if (!primary_passphrase_is_set()) {
692 gtk_toggle_button_set_active(
693 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase), FALSE);
697 prefs_common.use_primary_passphrase =
698 gtk_toggle_button_get_active(
699 GTK_TOGGLE_BUTTON(page->checkbtn_use_passphrase));
700 #endif
702 gtk_enable_accels = gtk_toggle_button_get_active(
703 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_enable_accels));
705 if (prefs_common.gtk_enable_accels != gtk_enable_accels) {
706 prefs_common.gtk_enable_accels = gtk_enable_accels;
708 g_object_set(G_OBJECT(settings), "gtk-enable-accels",
709 (glong)prefs_common.gtk_enable_accels,
710 NULL);
711 g_object_set(G_OBJECT(settings), "gtk-enable-mnemonics",
712 (glong)prefs_common.gtk_enable_accels,
713 NULL);
716 if (prefs_common.gtk_enable_accels != gtk_enable_accels) {
717 /* gtk_can_change_accels value changed : we have (only if changed)
718 * to apply the gtk property to all widgets : */
719 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
723 static void prefs_other_destroy_widget(PrefsPage *_page)
727 OtherPage *prefs_other;
729 void prefs_other_init(void)
731 OtherPage *page;
732 GtkSettings *settings = gtk_settings_get_default();
733 static gchar *path[3];
735 path[0] = _("Other");
736 path[1] = _("Miscellaneous");
737 path[2] = NULL;
739 page = g_new0(OtherPage, 1);
740 page->page.path = path;
741 page->page.create_widget = prefs_other_create_widget;
742 page->page.destroy_widget = prefs_other_destroy_widget;
743 page->page.save_page = prefs_other_save;
744 page->page.weight = 5.0;
745 prefs_gtk_register_page((PrefsPage *) page);
746 prefs_other = page;
748 g_object_set(G_OBJECT(settings), "gtk-enable-accels",
749 (glong)prefs_common.gtk_enable_accels,
750 NULL);
751 g_object_set(G_OBJECT(settings), "gtk-enable-mnemonics",
752 (glong)prefs_common.gtk_enable_accels,
753 NULL);
756 void prefs_other_done(void)
758 prefs_gtk_unregister_page((PrefsPage *) prefs_other);
759 g_free(prefs_other);
762 #ifndef PASSWORD_CRYPTO_OLD
763 void prefs_change_primary_passphrase(GtkButton *button, gpointer data)
765 /* Call the passphrase change dialog */
766 primary_passphrase_change_dialog();
768 #endif