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"
41 #include "manage_window.h"
43 #include "imap-thread.h"
46 typedef struct _OtherPage
52 GtkWidget *checkbtn_addaddrbyclick;
53 GtkWidget *checkbtn_confonexit;
54 GtkWidget *checkbtn_cleanonexit;
55 GtkWidget *checkbtn_askonclean;
56 GtkWidget *checkbtn_warnqueued;
57 GtkWidget *spinbtn_iotimeout;
58 GtkWidget *checkbtn_gtk_can_change_accels;
59 GtkWidget *checkbtn_askonfilter;
60 GtkWidget *checkbtn_use_shred;
61 GtkWidget *checkbtn_real_time_sync;
62 GtkWidget *flush_metadata_faster_radiobtn;
63 GtkWidget *flush_metadata_safer_radiobtn;
66 static struct KeybindDialog {
71 static void prefs_keybind_select (void);
72 static gint prefs_keybind_deleted (GtkWidget *widget,
75 static gboolean prefs_keybind_key_pressed (GtkWidget *widget,
78 static void prefs_keybind_cancel (void);
79 static void prefs_keybind_apply_clicked (GtkWidget *widget);
82 static void prefs_keybind_select(void)
89 GtkWidget *confirm_area;
91 GtkWidget *cancel_btn;
93 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_other");
94 gtk_container_set_border_width (GTK_CONTAINER (window), 8);
95 gtk_window_set_title (GTK_WINDOW (window),
96 _("Choose preset keyboard shortcuts"));
97 gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
98 gtk_window_set_modal (GTK_WINDOW (window), TRUE);
99 gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
100 manage_window_set_transient (GTK_WINDOW (window));
102 vbox1 = gtk_vbox_new (FALSE, VSPACING);
103 gtk_container_add (GTK_CONTAINER (window), vbox1);
104 gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
106 hbox1 = gtk_hbox_new (FALSE, 8);
107 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
109 label = gtk_label_new
110 (_("Select preset:"));
111 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
112 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
114 combo = combobox_text_new(FALSE,
119 gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
121 hbox1 = gtk_hbox_new (FALSE, 8);
122 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
124 label = gtk_label_new
125 (_("You can also modify each menu shortcut by pressing\n"
126 "any key(s) when focusing the mouse pointer on the item."));
127 gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
128 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
129 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
130 gtkut_widget_set_small_font_size (label);
132 hbox1 = gtk_hbox_new (FALSE, 8);
133 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
135 gtkut_stock_button_set_create (&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
136 &ok_btn, GTK_STOCK_OK,
138 gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
139 gtk_widget_grab_focus (ok_btn);
141 MANAGE_WINDOW_SIGNALS_CONNECT(window);
142 g_signal_connect (G_OBJECT (window), "delete_event",
143 G_CALLBACK (prefs_keybind_deleted), NULL);
144 g_signal_connect (G_OBJECT (window), "key_press_event",
145 G_CALLBACK (prefs_keybind_key_pressed), NULL);
146 g_signal_connect (G_OBJECT (ok_btn), "clicked",
147 G_CALLBACK (prefs_keybind_apply_clicked),
149 g_signal_connect (G_OBJECT (cancel_btn), "clicked",
150 G_CALLBACK (prefs_keybind_cancel),
153 gtk_widget_show_all(window);
155 keybind.window = window;
156 keybind.combo = combo;
159 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
162 if (event && event->keyval == GDK_KEY_Escape)
163 prefs_keybind_cancel();
167 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
170 prefs_keybind_cancel();
174 static void prefs_keybind_cancel(void)
176 gtk_widget_destroy(keybind.window);
177 keybind.window = NULL;
178 keybind.combo = NULL;
182 const gchar *accel_path;
183 const gchar *accel_key;
186 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
190 GdkModifierType mods;
192 for (i = 0; i < num; i++) {
193 const gchar *accel_key
194 = keybind[i].accel_key ? keybind[i].accel_key : "";
195 gtk_accelerator_parse(accel_key, &key, &mods);
196 if (key == 0 && mods == 0) {
197 g_message("Failed parsing accelerator '%s' for path '%s'\n",
198 accel_key, keybind[i].accel_path);
200 gtk_accel_map_change_entry(keybind[i].accel_path,
205 static void prefs_keybind_apply_clicked(GtkWidget *widget)
208 struct KeyBind *menurc;
211 static struct KeyBind default_menurc[] = {
213 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
214 {"<Actions>/Menu/File/SaveAs", "<control>S"},
215 {"<Actions>/Menu/File/Print", "<control>P"},
216 {"<Actions>/Menu/File/OfflineMode", "<control>W"},
217 {"<Actions>/Menu/File/SynchroniseFolders", "<control><shift>S"},
218 {"<Actions>/Menu/File/Exit", "<control>Q"},
220 {"<Actions>/Menu/Edit/Copy", "<control>C"},
221 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
222 {"<Actions>/Menu/Edit/Find", "<control>F"},
223 {"<Actions>/Menu/Edit/SearchFolder", "<shift><control>F"},
224 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
226 {"<Actions>/Menu/View/ShowHide/MessageView", "V"},
227 {"<Actions>/Menu/View/ThreadView", "<control>T"},
228 {"<Actions>/Menu/View/Goto/Prev", "P"},
229 {"<Actions>/Menu/View/Goto/Next", "N"},
230 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
231 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
232 {"<Actions>/Menu/View/Goto/OtherFolder", "G"},
233 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
234 {"<Actions>/Menu/View/MessageSource", "<control>U"},
235 {"<Actions>/Menu/View/AllHeaders", "<control>H"},
236 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"},
238 {"<Actions>/Menu/Message/Receive/CurrentAccount",
240 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
241 {"<Actions>/Menu/Message/ComposeEmail", "<control>M"},
242 {"<Actions>/Menu/Message/Reply", "<control>R"},
243 {"<Actions>/Menu/Message/ReplyTo/All", "<shift><control>R"},
244 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
245 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
246 {"<Actions>/Menu/Message/Forward", "<control><alt>F"},
247 {"<Actions>/Menu/Message/Move", "<control>O"},
248 {"<Actions>/Menu/Message/Copy", "<shift><control>O"},
249 {"<Actions>/Menu/Message/Trash", "<control>D"},
250 {"<Actions>/Menu/Message/Mark/Mark", "<shift>asterisk"},
251 {"<Actions>/Menu/Message/Mark/Unmark", "U"},
252 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>exclam"},
253 {"<Actions>/Menu/Message/Mark/MarkRead", ""},
255 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
256 {"<Actions>/Menu/Tools/Execute", "X"},
257 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
259 {"<Actions>/Menu/Message/Send", "<control>Return"},
260 {"<Actions>/Menu/Message/SendLater", "<shift><control>S"},
261 {"<Actions>/Menu/Message/AttachFile", "<control>M"},
262 {"<Actions>/Menu/Message/InsertFile", "<control>I"},
263 {"<Actions>/Menu/Message/InsertSig", "<control>G"},
264 {"<Actions>/Menu/Message/Save", "<control>S"},
265 {"<Actions>/Menu/Message/Close", "<control>W"},
266 {"<Actions>/Menu/Edit/Undo", "<control>Z"},
267 {"<Actions>/Menu/Edit/Redo", "<control>Y"},
268 {"<Actions>/Menu/Edit/Cut", "<control>X"},
269 {"<Actions>/Menu/Edit/Copy", "<control>C"},
270 {"<Actions>/Menu/Edit/Paste", "<control>V"},
271 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
272 {"<Actions>/Menu/Edit/Advanced/BackChar", "<control>B"},
273 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<control>F"},
274 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
275 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
276 {"<Actions>/Menu/Edit/Advanced/BegLine", ""},
277 {"<Actions>/Menu/Edit/Advanced/EndLine", "<control>E"},
278 {"<Actions>/Menu/Edit/Advanced/PrevLine", "<control>P"},
279 {"<Actions>/Menu/Edit/Advanced/NextLine", "<control>N"},
280 {"<Actions>/Menu/Edit/Advanced/DelBackChar", "<control>H"},
281 {"<Actions>/Menu/Edit/Advanced/DelForwChar", "<control>D"},
282 {"<Actions>/Menu/Edit/Advanced/DelBackWord", ""},
283 {"<Actions>/Menu/Edit/Advanced/DelForwWord", ""},
284 {"<Actions>/Menu/Edit/Advanced/DelLine", "<control>U"},
285 {"<Actions>/Menu/Edit/Advanced/DelEndLine", "<control>K"},
286 {"<Actions>/Menu/Edit/WrapPara", "<control>L"},
287 {"<Actions>/Menu/Edit/WrapAllLines", "<control><alt>L"},
288 {"<Actions>/Menu/Edit/AutoWrap", "<shift><control>L"},
289 {"<Actions>/Menu/Edit/ExtEditor", "<shift><control>X"},
290 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
293 static struct KeyBind mew_wl_menurc[] = {
295 {"<Actions>/Menu/File/EmptyTrashes", "<shift>D"},
296 {"<Actions>/Menu/File/SaveAs", "Y"},
297 {"<Actions>/Menu/File/Print", "<control>numbersign"},
298 {"<Actions>/Menu/File/Exit", "<shift>Q"},
300 {"<Actions>/Menu/Edit/Copy", "<control>C"},
301 {"<Actions>/Menu/Edit/SelectAll", "<control>A"},
302 {"<Actions>/Menu/Edit/Find", "<control>F"},
303 {"<Actions>/Menu/Edit/SearchFolder", "<control>S"},
304 {"<Actions>/Menu/Edit/QuickSearch", "slash"},
306 {"<Actions>/Menu/View/ShowHide/MessageView", ""},
307 {"<Actions>/Menu/View/ThreadView", "<shift>T"},
308 {"<Actions>/Menu/View/Goto/Prev", "P"},
309 {"<Actions>/Menu/View/Goto/Next", "N"},
310 {"<Actions>/Menu/View/Goto/PrevUnread", "<shift>P"},
311 {"<Actions>/Menu/View/Goto/NextUnread", "<shift>N"},
312 {"<Actions>/Menu/View/Goto/OtherFolder", "G"},
313 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"},
314 {"<Actions>/Menu/View/MessageSource", "<control>U"},
315 {"<Actions>/Menu/View/AllHeaders", "<shift>H"},
316 {"<Actions>/Menu/View/UpdateSummary", "<shift>S"},
318 {"<Actions>/Menu/Message/Receive/CurrentAccount",
320 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift><control>I"},
321 {"<Actions>/Menu/Message/ComposeEmail", "W"},
322 {"<Actions>/Menu/Message/Reply", "<control>R"},
323 {"<Actions>/Menu/Message/ReplyTo/All", "<shift>A"},
324 {"<Actions>/Menu/Message/ReplyTo/Sender", ""},
325 {"<Actions>/Menu/Message/ReplyTo/List", "<control>L"},
326 {"<Actions>/Menu/Message/Forward", "F"},
327 {"<Actions>/Menu/Message/Move", "O"},
328 {"<Actions>/Menu/Message/Copy", "<shift>O"},
329 {"<Actions>/Menu/Message/Trash", "D"},
330 {"<Actions>/Menu/Message/Mark/Mark", "<shift>asterisk"},
331 {"<Actions>/Menu/Message/Mark/Unmark", "U"},
332 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>exclam"},
333 {"<Actions>/Menu/Message/Mark/MarkRead", "<shift>R"},
335 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"},
336 {"<Actions>/Menu/Tools/Execute", "X"},
337 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"},
339 {"<Actions>/Menu/Message/Close", "<alt>W"},
340 {"<Actions>/Menu/Edit/SelectAll", ""},
341 {"<Actions>/Menu/Edit/Advanced/BackChar", "<alt>B"},
342 {"<Actions>/Menu/Edit/Advanced/ForwChar", "<alt>F"},
343 {"<Actions>/Menu/Edit/Advanced/BackWord", ""},
344 {"<Actions>/Menu/Edit/Advanced/ForwWord", ""},
345 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"},
346 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"},
347 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"},
350 static struct KeyBind mutt_menurc[] = {
352 {"<Actions>/Menu/File/SaveAs", "S"}, /* save-message */
353 {"<Actions>/Menu/File/Print", "P"}, /* print-message */
354 {"<Actions>/Menu/File/Exit", "Q"}, /* quit */
356 {"<Actions>/Menu/Edit/Copy", "<control>C"}, /* - */
357 {"<Actions>/Menu/Edit/SelectAll", "<control>A"}, /* - */
358 {"<Actions>/Menu/Edit/Find", "<alt>B"}, /* <esc>B: search in message bodies */
359 {"<Actions>/Menu/Edit/SearchFolder", "slash"}, /* search */
360 {"<Actions>/Menu/Edit/QuickSearch", "L"}, /* limit */
362 {"<Actions>/Menu/View/ShowHide/MessageView", "V"}, /* - */
363 {"<Actions>/Menu/View/ThreadView", "<control>T"}, /* - */
364 {"<Actions>/Menu/View/Goto/Prev", "K"}, /* previous-entry */
365 {"<Actions>/Menu/View/Goto/Next", "J"}, /* next-entry */
366 {"<Actions>/Menu/View/Goto/PrevUnread", "<alt>U"}, /* <esc>Tab: previous-new-then-unread */
367 {"<Actions>/Menu/View/Goto/NextUnread", "U"}, /* Tab: next-new-then-unread */
368 {"<Actions>/Menu/View/Goto/OtherFolder", "C"}, /* change-folder */
369 {"<Actions>/Menu/View/OpenNewWindow", "<control><alt>N"}, /* - */
370 {"<Actions>/Menu/View/MessageSource", "E"}, /* edit the raw message */
371 {"<Actions>/Menu/View/AllHeaders", "H"}, /* display-toggle-weed */
372 {"<Actions>/Menu/View/UpdateSummary", "<control><alt>U"}, /* - */
374 {"<Actions>/Menu/Message/Receive/CurrentAccount", "<control>I"}, /* - */
375 {"<Actions>/Menu/Message/Receive/AllAccounts", "<shift>G"}, /* fetch-mail */
376 {"<Actions>/Menu/Message/ComposeEmail", "M"}, /* mail */
377 {"<Actions>/Menu/Message/Reply", "R"}, /* reply */
378 {"<Actions>/Menu/Message/ReplyTo/All", "G"}, /* group-reply */
379 {"<Actions>/Menu/Message/ReplyTo/List", "<shift>L"}, /* list-reply */
380 {"<Actions>/Menu/Message/Forward", "F"}, /* forward-message */
381 {"<Actions>/Menu/Message/Move", "<control>O"}, /* - */
382 {"<Actions>/Menu/Message/Copy", "<shift>C"}, /* copy-message */
383 {"<Actions>/Menu/Message/Trash", "D"}, /* delete-message */
384 {"<Actions>/Menu/Message/Mark/Mark", "<shift>F"}, /* flag-message */
385 {"<Actions>/Menu/Message/Mark/Unmark", "<control><shift>F"}, /* - */
386 {"<Actions>/Menu/Message/Mark/MarkUnread", "<shift>N"}, /* toggle-new */
387 {"<Actions>/Menu/Message/Mark/MarkRead", "<control>R"}, /* read-thread */
389 {"<Actions>/Menu/Tools/AddressBook", "<shift><control>A"}, /* - */
390 {"<Actions>/Menu/Tools/Execute", "dollar"}, /* sync-mailbox */
391 {"<Actions>/Menu/Tools/NetworkLog", "<shift><control>L"}, /* - */
393 {"<Actions>/Menu/Message/Close", "<alt>W"}, /* - */
394 {"<Actions>/Menu/Edit/Advanced/BackWord", "<alt>B"}, /* - */
395 {"<Actions>/Menu/Edit/Advanced/ForwWord", "<alt>F"}, /* - */
396 {"<Actions>/Menu/Edit/Advanced/BegLine", "<control>A"}, /* - */
397 {"<Actions>/Menu/Edit/Advanced/DelBackWord", "<control>W"}, /* - */
398 {"<Actions>/Menu/Edit/Advanced/DelForwWord", "<alt>D"}, /* - */
401 #if !GTK_CHECK_VERSION(2, 24, 0)
402 text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(keybind.combo));
404 text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keybind.combo));
407 if (!strcmp(text, _("Default"))) {
408 menurc = default_menurc;
409 n_menurc = G_N_ELEMENTS(default_menurc);
410 } else if (!strcmp(text, "Mew / Wanderlust")) {
411 menurc = mew_wl_menurc;
412 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
413 } else if (!strcmp(text, "Mutt")) {
414 menurc = mutt_menurc;
415 n_menurc = G_N_ELEMENTS(mutt_menurc);
422 prefs_keybind_apply(menurc, n_menurc);
424 gtk_widget_destroy(keybind.window);
425 keybind.window = NULL;
426 keybind.combo = NULL;
429 static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
432 OtherPage *prefs_other = (OtherPage *) _page;
437 GtkWidget *frame_addr;
438 GtkWidget *vbox_addr;
439 GtkWidget *checkbtn_addaddrbyclick;
441 GtkWidget *frame_exit;
442 GtkWidget *vbox_exit;
443 GtkWidget *checkbtn_confonexit;
444 GtkWidget *checkbtn_cleanonexit;
445 GtkWidget *checkbtn_warnqueued;
447 GtkWidget *frame_keys;
448 GtkWidget *vbox_keys;
449 GtkWidget *checkbtn_gtk_can_change_accels;
450 GtkWidget *button_keybind;
452 GtkWidget *label_iotimeout;
453 GtkWidget *spinbtn_iotimeout;
454 GtkAdjustment *spinbtn_iotimeout_adj;
457 GtkWidget *checkbtn_askonclean;
458 GtkWidget *checkbtn_askonfilter;
459 GtkWidget *checkbtn_use_shred;
460 GtkWidget *checkbtn_real_time_sync;
462 GtkWidget *frame_metadata;
463 GtkWidget *vbox_metadata;
464 GtkWidget *metadata_label;
465 GtkWidget *flush_metadata_faster_radiobtn;
466 GtkWidget *flush_metadata_safer_radiobtn;
468 gchar *shred_binary = NULL;
470 vbox1 = gtk_vbox_new (FALSE, VSPACING);
471 gtk_widget_show (vbox1);
472 gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
474 vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
477 (vbox_addr, checkbtn_addaddrbyclick,
478 _("Add address to destination when double-clicked"));
481 vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
483 PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
484 _("Confirm on exit"));
486 hbox1 = gtk_hbox_new (FALSE, 32);
487 gtk_widget_show (hbox1);
488 gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
490 PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
491 _("Empty trash on exit"));
493 PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
494 _("Warn if there are queued messages"));
496 vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
498 PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels,
499 _("Enable customisable keyboard shortcuts"));
501 CLAWS_SET_TIP(checkbtn_gtk_can_change_accels,
502 _("If checked, you can change the keyboard shortcuts of "
503 "most of the menu items by focusing on the menu "
504 "item and pressing a key combination.\n"
505 "Uncheck this option if you want to lock all "
506 "existing keyboard shortcuts."));
508 button_keybind = gtk_button_new_with_label(
509 _(" Choose preset keyboard shortcuts... "));
510 gtk_widget_show (button_keybind);
511 hbox1 = gtk_hbox_new (FALSE, 8);
512 gtk_widget_show (hbox1);
513 gtk_box_pack_start (GTK_BOX (vbox_keys), hbox1, FALSE, FALSE, 0);
514 gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
515 g_signal_connect (G_OBJECT (button_keybind), "clicked",
516 G_CALLBACK (prefs_keybind_select), NULL);
519 vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
520 metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
521 "it avoids data loss after crashes but can take some time."));
522 gtk_misc_set_alignment(GTK_MISC(metadata_label), 0, 0);
523 gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
524 flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
525 flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
526 GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
527 hbox1 = gtk_hbox_new (FALSE, 8);
528 gtk_widget_show (hbox1);
529 gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
530 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
531 gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
533 if (prefs_common.flush_metadata)
534 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
536 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
538 gtk_widget_show_all(frame_metadata);
540 hbox1 = gtk_hbox_new (FALSE, 8);
541 gtk_widget_show (hbox1);
542 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
544 label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
545 gtk_widget_show (label_iotimeout);
546 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
548 spinbtn_iotimeout_adj = GTK_ADJUSTMENT(gtk_adjustment_new (60, 0, 1000, 1, 10, 0));
549 spinbtn_iotimeout = gtk_spin_button_new
550 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
551 gtk_widget_show (spinbtn_iotimeout);
552 gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
554 gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
555 gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
557 label_iotimeout = gtk_label_new (_("second(s)"));
558 gtk_widget_show (label_iotimeout);
559 gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
561 vbox2 = gtk_vbox_new (FALSE, 8);
562 gtk_widget_show (vbox2);
563 gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
565 PACK_CHECK_BUTTON (vbox2, checkbtn_askonclean,
566 _("Ask before emptying trash"));
567 PACK_CHECK_BUTTON (vbox2, checkbtn_askonfilter,
568 _("Ask about account specific filtering rules when "
569 "filtering manually"));
570 shred_binary = g_find_program_in_path("shred");
572 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
573 _("Use secure file deletion if possible"));
574 g_free(shred_binary);
576 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
577 _("Use secure file deletion if possible\n"
578 "(the 'shred' program is not available)"));
579 gtk_widget_set_sensitive(checkbtn_use_shred, FALSE);
581 CLAWS_SET_TIP(checkbtn_use_shred,
582 _("Use the 'shred' program to overwrite files with random data before "
583 "deleting them. This slows down deletion. Be sure to "
584 "read shred's man page for caveats."));
585 PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
586 _("Synchronise offline folders as soon as possible"));
588 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick),
589 prefs_common.add_address_by_click);
590 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit),
591 prefs_common.confirm_on_exit);
592 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit),
593 prefs_common.clean_on_exit);
594 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean),
595 prefs_common.ask_on_clean);
596 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued),
597 prefs_common.warn_queued_on_exit);
598 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
599 prefs_common.gtk_can_change_accels);
601 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
602 prefs_common.io_timeout_secs);
604 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter),
605 prefs_common.ask_apply_per_account_filtering_rules);
606 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_shred),
607 prefs_common.use_shred);
608 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync),
609 prefs_common.real_time_sync);
611 prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
612 prefs_other->checkbtn_confonexit = checkbtn_confonexit;
613 prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
614 prefs_other->checkbtn_askonclean = checkbtn_askonclean;
615 prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
616 prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
617 prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
618 prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
619 prefs_other->checkbtn_use_shred = checkbtn_use_shred;
620 prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
621 prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
622 prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
623 prefs_other->page.widget = vbox1;
626 static void prefs_other_save(PrefsPage *_page)
628 OtherPage *page = (OtherPage *) _page;
629 gboolean gtk_can_change_accels;
631 prefs_common.add_address_by_click = gtk_toggle_button_get_active(
632 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
633 prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
634 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
635 prefs_common.clean_on_exit = gtk_toggle_button_get_active(
636 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit));
637 prefs_common.ask_on_clean = gtk_toggle_button_get_active(
638 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
639 prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
640 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued));
641 prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
642 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
643 prefs_common.flush_metadata = gtk_toggle_button_get_active(
644 GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
645 sock_set_io_timeout(prefs_common.io_timeout_secs);
647 imap_main_set_timeout(prefs_common.io_timeout_secs);
649 prefs_common.ask_apply_per_account_filtering_rules =
650 gtk_toggle_button_get_active(
651 GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter));
652 prefs_common.use_shred =
653 gtk_toggle_button_get_active(
654 GTK_TOGGLE_BUTTON(page->checkbtn_use_shred));
655 prefs_common.real_time_sync =
656 gtk_toggle_button_get_active(
657 GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync));
659 gtk_can_change_accels = gtk_toggle_button_get_active(
660 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
662 if (prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
664 prefs_common.gtk_can_change_accels = gtk_can_change_accels;
666 gtk_settings_set_long_property(gtk_settings_get_default(),
667 "gtk-can-change-accels",
668 (glong)prefs_common.gtk_can_change_accels,
671 /* gtk_can_change_accels value changed : we have (only if changed)
672 * to apply the gtk property to all widgets : */
673 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
677 static void prefs_other_destroy_widget(PrefsPage *_page)
681 OtherPage *prefs_other;
683 void prefs_other_init(void)
686 static gchar *path[3];
688 path[0] = _("Other");
689 path[1] = _("Miscellaneous");
692 page = g_new0(OtherPage, 1);
693 page->page.path = path;
694 page->page.create_widget = prefs_other_create_widget;
695 page->page.destroy_widget = prefs_other_destroy_widget;
696 page->page.save_page = prefs_other_save;
697 page->page.weight = 5.0;
698 prefs_gtk_register_page((PrefsPage *) page);
701 gtk_settings_set_long_property(gtk_settings_get_default(),
702 "gtk-can-change-accels",
703 (glong)prefs_common.gtk_can_change_accels,
707 void prefs_other_done(void)
709 prefs_gtk_unregister_page((PrefsPage *) prefs_other);