Add note about Fancy & remote content
[claws.git] / src / prefs_other.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2005-2012 Colin Leroy <colin@colino.net> & The Claws Mail Team
4  *
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.
9  *
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.
14  *
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/>.
17  * 
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #include "claws-features.h"
23 #endif
24
25 #include "defs.h"
26
27 #include <stdio.h>
28 #include <stdlib.h>
29
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include <gtk/gtk.h>
33 #include <gdk/gdkkeysyms.h>
34
35 #include "prefs_common.h"
36 #include "prefs_gtk.h"
37
38 #include "gtk/gtkutils.h"
39 #include "gtk/prefswindow.h"
40 #include "combobox.h"
41
42 #include "manage_window.h"
43 #ifdef HAVE_LIBETPAN
44 #include "imap-thread.h"
45 #endif
46
47 typedef struct _OtherPage
48 {
49         PrefsPage page;
50
51         GtkWidget *window;
52
53         GtkWidget *checkbtn_addaddrbyclick;
54         GtkWidget *checkbtn_confonexit;
55         GtkWidget *checkbtn_cleanonexit;
56         GtkWidget *checkbtn_askonclean;
57         GtkWidget *checkbtn_warnqueued;
58         GtkWidget *spinbtn_iotimeout;
59         GtkWidget *checkbtn_gtk_can_change_accels;
60         GtkWidget *checkbtn_askonfilter;
61         GtkWidget *checkbtn_use_shred;
62         GtkWidget *checkbtn_real_time_sync;
63         GtkWidget *flush_metadata_faster_radiobtn;
64         GtkWidget *flush_metadata_safer_radiobtn;
65 } OtherPage;
66
67 static struct KeybindDialog {
68         GtkWidget *window;
69         GtkWidget *combo;
70 } keybind;
71
72 static void prefs_keybind_select                (void);
73 static gint prefs_keybind_deleted               (GtkWidget      *widget,
74                                                  GdkEventAny    *event,
75                                                  gpointer        data);
76 static gboolean prefs_keybind_key_pressed       (GtkWidget      *widget,
77                                                  GdkEventKey    *event,
78                                                  gpointer        data);
79 static void prefs_keybind_cancel                (void);
80 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
81
82
83 static void prefs_keybind_select(void)
84 {
85         GtkWidget *window;
86         GtkWidget *vbox1;
87         GtkWidget *hbox1;
88         GtkWidget *label;
89         GtkWidget *combo;
90         GtkWidget *confirm_area;
91         GtkWidget *ok_btn;
92         GtkWidget *cancel_btn;
93
94         window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_other");
95         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
96         gtk_window_set_title (GTK_WINDOW (window), 
97                                 _("Choose preset keyboard shortcuts"));
98         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
99         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
100         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
101         manage_window_set_transient (GTK_WINDOW (window));
102
103         vbox1 = gtk_vbox_new (FALSE, VSPACING);
104         gtk_container_add (GTK_CONTAINER (window), vbox1);
105         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
106
107         hbox1 = gtk_hbox_new (FALSE, 8);
108         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
109
110         label = gtk_label_new
111                 (_("Select preset:"));
112         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
113         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
114
115         combo = combobox_text_new(FALSE,
116                                _("Default"),
117                                "Mew / Wanderlust",
118                                "Mutt",
119                                NULL);
120         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
121
122         hbox1 = gtk_hbox_new (FALSE, 8);
123         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
124
125         label = gtk_label_new
126                 (_("You can also modify each menu shortcut by pressing\n"
127                    "any key(s) when focusing the mouse pointer on the item."));
128         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
129         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
130         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
131         gtkut_widget_set_small_font_size (label);
132
133         hbox1 = gtk_hbox_new (FALSE, 8);
134         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
135
136         gtkut_stock_button_set_create (&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
137                                        &ok_btn, GTK_STOCK_OK,
138                                        NULL, NULL);
139         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
140         gtk_widget_grab_focus (ok_btn);
141
142         MANAGE_WINDOW_SIGNALS_CONNECT(window);
143         g_signal_connect (G_OBJECT (window), "delete_event",
144                           G_CALLBACK (prefs_keybind_deleted), NULL);
145         g_signal_connect (G_OBJECT (window), "key_press_event",
146                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
147         g_signal_connect (G_OBJECT (ok_btn), "clicked",
148                           G_CALLBACK (prefs_keybind_apply_clicked),
149                           NULL);
150         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
151                           G_CALLBACK (prefs_keybind_cancel),
152                           NULL);
153
154         gtk_widget_show_all(window);
155
156         keybind.window = window;
157         keybind.combo = combo;
158 }
159
160 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
161                                           gpointer data)
162 {
163         if (event && event->keyval == GDK_KEY_Escape)
164                 prefs_keybind_cancel();
165         return FALSE;
166 }
167
168 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
169                                   gpointer data)
170 {
171         prefs_keybind_cancel();
172         return TRUE;
173 }
174
175 static void prefs_keybind_cancel(void)
176 {
177         gtk_widget_destroy(keybind.window);
178         keybind.window = NULL;
179         keybind.combo = NULL;
180 }
181   
182 struct KeyBind {
183         const gchar *accel_path;
184         const gchar *accel_key;
185 };
186
187 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
188 {
189         gint i;
190         guint key;
191         GdkModifierType mods;
192
193         for (i = 0; i < num; i++) {
194                 const gchar *accel_key
195                         = keybind[i].accel_key ? keybind[i].accel_key : "";
196                 gtk_accelerator_parse(accel_key, &key, &mods);
197                 if (key == 0 && mods == 0) {
198                         g_message("Failed parsing accelerator '%s' for path '%s'\n",
199                                   accel_key, keybind[i].accel_path);
200                 }
201                 gtk_accel_map_change_entry(keybind[i].accel_path,
202                                            key, mods, TRUE);
203         }
204 }
205
206 static void prefs_keybind_apply_clicked(GtkWidget *widget)
207 {
208         gchar *text;
209         struct KeyBind *menurc;
210         gint n_menurc;
211
212         static struct KeyBind default_menurc[] = {
213                 /* main */
214                 {"<Actions>/Menu/File/EmptyTrashes",                    "<shift>D"},
215                 {"<Actions>/Menu/File/SaveAs",                          "<control>S"},
216                 {"<Actions>/Menu/File/Print",                           "<control>P"},
217                 {"<Actions>/Menu/File/OfflineMode",                     "<control>W"},
218                 {"<Actions>/Menu/File/SynchroniseFolders",              "<control><shift>S"},
219                 {"<Actions>/Menu/File/Exit",                            "<control>Q"},
220
221                 {"<Actions>/Menu/Edit/Copy",                            "<control>C"},
222                 {"<Actions>/Menu/Edit/SelectAll",                       "<control>A"},
223                 {"<Actions>/Menu/Edit/Find",                            "<control>F"},
224                 {"<Actions>/Menu/Edit/SearchFolder",                    "<shift><control>F"},
225                 {"<Actions>/Menu/Edit/QuickSearch",                     "slash"},
226
227                 {"<Actions>/Menu/View/ShowHide/MessageView",            "V"},
228                 {"<Actions>/Menu/View/ThreadView",                      "<control>T"},
229                 {"<Actions>/Menu/View/Goto/Prev",                       "P"},
230                 {"<Actions>/Menu/View/Goto/Next",                       "N"},
231                 {"<Actions>/Menu/View/Goto/PrevUnread",                 "<shift>P"},
232                 {"<Actions>/Menu/View/Goto/NextUnread",                 "<shift>N"},
233                 {"<Actions>/Menu/View/Goto/OtherFolder",                "G"},
234                 {"<Actions>/Menu/View/OpenNewWindow",                   "<control><alt>N"},
235                 {"<Actions>/Menu/View/MessageSource",                   "<control>U"},
236                 {"<Actions>/Menu/View/AllHeaders",                      "<control>H"},
237                 {"<Actions>/Menu/View/UpdateSummary",                   "<control><alt>U"},
238
239                 {"<Actions>/Menu/Message/Receive/CurrentAccount",
240                                                                         "<control>I"},
241                 {"<Actions>/Menu/Message/Receive/AllAccounts",          "<shift><control>I"},
242                 {"<Actions>/Menu/Message/ComposeEmail",                 "<control>M"},
243                 {"<Actions>/Menu/Message/Reply",                        "<control>R"},
244                 {"<Actions>/Menu/Message/ReplyTo/All",                  "<shift><control>R"},
245                 {"<Actions>/Menu/Message/ReplyTo/Sender",               ""},
246                 {"<Actions>/Menu/Message/ReplyTo/List",                 "<control>L"},
247                 {"<Actions>/Menu/Message/Forward",                      "<control><alt>F"},
248                 {"<Actions>/Menu/Message/Move",                         "<control>O"},
249                 {"<Actions>/Menu/Message/Copy",                         "<shift><control>O"},
250                 {"<Actions>/Menu/Message/Trash",                        "<control>D"},
251                 {"<Actions>/Menu/Message/Mark/Mark",                    "<shift>asterisk"},
252                 {"<Actions>/Menu/Message/Mark/Unmark",                  "U"},
253                 {"<Actions>/Menu/Message/Mark/MarkUnread",              "<shift>exclam"},
254                 {"<Actions>/Menu/Message/Mark/MarkRead",                ""},
255
256                 {"<Actions>/Menu/Tools/AddressBook",                    "<shift><control>A"},
257                 {"<Actions>/Menu/Tools/Execute",                        "X"},
258                 {"<Actions>/Menu/Tools/NetworkLog",                     "<shift><control>L"},
259                 /* compose */
260                 {"<Actions>/Menu/Message/Send",                         "<control>Return"},
261                 {"<Actions>/Menu/Message/SendLater",                    "<shift><control>S"},
262                 {"<Actions>/Menu/Message/AttachFile",                   "<control>M"},
263                 {"<Actions>/Menu/Message/InsertFile",                   "<control>I"},
264                 {"<Actions>/Menu/Message/InsertSig",                    "<control>G"},
265                 {"<Actions>/Menu/Message/Save",                         "<control>S"},
266                 {"<Actions>/Menu/Message/Close",                        "<control>W"},
267                 {"<Actions>/Menu/Edit/Undo",                            "<control>Z"},
268                 {"<Actions>/Menu/Edit/Redo",                            "<control>Y"},
269                 {"<Actions>/Menu/Edit/Cut",                             "<control>X"},
270                 {"<Actions>/Menu/Edit/Copy",                            "<control>C"},
271                 {"<Actions>/Menu/Edit/Paste",                           "<control>V"},
272                 {"<Actions>/Menu/Edit/SelectAll",                       "<control>A"},
273                 {"<Actions>/Menu/Edit/Advanced/BackChar",               "<control>B"},
274                 {"<Actions>/Menu/Edit/Advanced/ForwChar",               "<control>F"},
275                 {"<Actions>/Menu/Edit/Advanced/BackWord",               ""},
276                 {"<Actions>/Menu/Edit/Advanced/ForwWord",               ""},
277                 {"<Actions>/Menu/Edit/Advanced/BegLine",                ""},
278                 {"<Actions>/Menu/Edit/Advanced/EndLine",                "<control>E"},
279                 {"<Actions>/Menu/Edit/Advanced/PrevLine",               "<control>P"},
280                 {"<Actions>/Menu/Edit/Advanced/NextLine",               "<control>N"},
281                 {"<Actions>/Menu/Edit/Advanced/DelBackChar",            "<control>H"},
282                 {"<Actions>/Menu/Edit/Advanced/DelForwChar",            "<control>D"},
283                 {"<Actions>/Menu/Edit/Advanced/DelBackWord",            ""},
284                 {"<Actions>/Menu/Edit/Advanced/DelForwWord",            ""},
285                 {"<Actions>/Menu/Edit/Advanced/DelLine",                "<control>U"},
286                 {"<Actions>/Menu/Edit/Advanced/DelEndLine",             "<control>K"},
287                 {"<Actions>/Menu/Edit/WrapPara",                        "<control>L"},
288                 {"<Actions>/Menu/Edit/WrapAllLines",                    "<control><alt>L"},
289                 {"<Actions>/Menu/Edit/AutoWrap",                        "<shift><control>L"},
290                 {"<Actions>/Menu/Edit/ExtEditor",                       "<shift><control>X"},
291                 {"<Actions>/Menu/Tools/AddressBook",                    "<shift><control>A"},
292         };
293
294         static struct KeyBind mew_wl_menurc[] = {
295                 /* main */
296                 {"<Actions>/Menu/File/EmptyTrashes",                    "<shift>D"},
297                 {"<Actions>/Menu/File/SaveAs",                          "Y"},
298                 {"<Actions>/Menu/File/Print",                           "<control>numbersign"},
299                 {"<Actions>/Menu/File/Exit",                            "<shift>Q"},
300
301                 {"<Actions>/Menu/Edit/Copy",                            "<control>C"},
302                 {"<Actions>/Menu/Edit/SelectAll",                       "<control>A"},
303                 {"<Actions>/Menu/Edit/Find",                            "<control>F"},
304                 {"<Actions>/Menu/Edit/SearchFolder",                    "<control>S"},
305                 {"<Actions>/Menu/Edit/QuickSearch",                     "slash"},
306
307                 {"<Actions>/Menu/View/ShowHide/MessageView",            ""},
308                 {"<Actions>/Menu/View/ThreadView",                      "<shift>T"},
309                 {"<Actions>/Menu/View/Goto/Prev",                       "P"},
310                 {"<Actions>/Menu/View/Goto/Next",                       "N"},
311                 {"<Actions>/Menu/View/Goto/PrevUnread",                 "<shift>P"},
312                 {"<Actions>/Menu/View/Goto/NextUnread",                 "<shift>N"},
313                 {"<Actions>/Menu/View/Goto/OtherFolder",                "G"},
314                 {"<Actions>/Menu/View/OpenNewWindow",                   "<control><alt>N"},
315                 {"<Actions>/Menu/View/MessageSource",                   "<control>U"},
316                 {"<Actions>/Menu/View/AllHeaders",                      "<shift>H"},
317                 {"<Actions>/Menu/View/UpdateSummary",                   "<shift>S"},
318
319                 {"<Actions>/Menu/Message/Receive/CurrentAccount",
320                                                                         "<control>I"},
321                 {"<Actions>/Menu/Message/Receive/AllAccounts",          "<shift><control>I"},
322                 {"<Actions>/Menu/Message/ComposeEmail",                 "W"},
323                 {"<Actions>/Menu/Message/Reply",                        "<control>R"},
324                 {"<Actions>/Menu/Message/ReplyTo/All",                  "<shift>A"},
325                 {"<Actions>/Menu/Message/ReplyTo/Sender",               ""},
326                 {"<Actions>/Menu/Message/ReplyTo/List",                 "<control>L"},
327                 {"<Actions>/Menu/Message/Forward",                      "F"},
328                 {"<Actions>/Menu/Message/Move",                         "O"},
329                 {"<Actions>/Menu/Message/Copy",                         "<shift>O"},
330                 {"<Actions>/Menu/Message/Trash",                        "D"},
331                 {"<Actions>/Menu/Message/Mark/Mark",                    "<shift>asterisk"},
332                 {"<Actions>/Menu/Message/Mark/Unmark",                  "U"},
333                 {"<Actions>/Menu/Message/Mark/MarkUnread",              "<shift>exclam"},
334                 {"<Actions>/Menu/Message/Mark/MarkRead",                "<shift>R"},
335
336                 {"<Actions>/Menu/Tools/AddressBook",                    "<shift><control>A"},
337                 {"<Actions>/Menu/Tools/Execute",                        "X"},
338                 {"<Actions>/Menu/Tools/NetworkLog",                     "<shift><control>L"},
339                 /* compose */
340                 {"<Actions>/Menu/Message/Close",                        "<alt>W"},
341                 {"<Actions>/Menu/Edit/SelectAll",                       ""},
342                 {"<Actions>/Menu/Edit/Advanced/BackChar",               "<alt>B"},
343                 {"<Actions>/Menu/Edit/Advanced/ForwChar",               "<alt>F"},
344                 {"<Actions>/Menu/Edit/Advanced/BackWord",               ""},
345                 {"<Actions>/Menu/Edit/Advanced/ForwWord",               ""},
346                 {"<Actions>/Menu/Edit/Advanced/BegLine",                "<control>A"},
347                 {"<Actions>/Menu/Edit/Advanced/DelBackWord",            "<control>W"},
348                 {"<Actions>/Menu/Edit/Advanced/DelForwWord",            "<alt>D"},
349         };
350
351         static struct KeyBind mutt_menurc[] = {
352                 /* main */
353                 {"<Actions>/Menu/File/SaveAs",                          "S"}, /* save-message */
354                 {"<Actions>/Menu/File/Print",                           "P"}, /* print-message */
355                 {"<Actions>/Menu/File/Exit",                            "Q"}, /* quit */
356
357                 {"<Actions>/Menu/Edit/Copy",                            "<control>C"}, /* - */
358                 {"<Actions>/Menu/Edit/SelectAll",                       "<control>A"}, /* - */
359                 {"<Actions>/Menu/Edit/Find",                            "<alt>B"}, /* <esc>B: search in message bodies */
360                 {"<Actions>/Menu/Edit/SearchFolder",                    "slash"}, /* search */
361                 {"<Actions>/Menu/Edit/QuickSearch",                     "L"}, /* limit */
362
363                 {"<Actions>/Menu/View/ShowHide/MessageView",            "V"}, /* - */
364                 {"<Actions>/Menu/View/ThreadView",                      "<control>T"}, /* - */
365                 {"<Actions>/Menu/View/Goto/Prev",                       "K"}, /* previous-entry */
366                 {"<Actions>/Menu/View/Goto/Next",                       "J"}, /* next-entry */
367                 {"<Actions>/Menu/View/Goto/PrevUnread",                 "<alt>U"}, /* <esc>Tab: previous-new-then-unread */
368                 {"<Actions>/Menu/View/Goto/NextUnread",                 "U"}, /* Tab: next-new-then-unread */
369                 {"<Actions>/Menu/View/Goto/OtherFolder",                "C"}, /* change-folder */
370                 {"<Actions>/Menu/View/OpenNewWindow",                   "<control><alt>N"}, /* - */
371                 {"<Actions>/Menu/View/MessageSource",                   "E"}, /* edit the raw message */
372                 {"<Actions>/Menu/View/AllHeaders",                      "H"}, /* display-toggle-weed */
373                 {"<Actions>/Menu/View/UpdateSummary",                   "<control><alt>U"}, /* - */
374
375                 {"<Actions>/Menu/Message/Receive/CurrentAccount",       "<control>I"}, /* - */
376                 {"<Actions>/Menu/Message/Receive/AllAccounts",          "<shift>G"}, /* fetch-mail */
377                 {"<Actions>/Menu/Message/ComposeEmail",                 "M"}, /* mail */
378                 {"<Actions>/Menu/Message/Reply",                        "R"}, /* reply */
379                 {"<Actions>/Menu/Message/ReplyTo/All",                  "G"}, /* group-reply */
380                 {"<Actions>/Menu/Message/ReplyTo/List",                 "<shift>L"}, /* list-reply */
381                 {"<Actions>/Menu/Message/Forward",                      "F"}, /* forward-message */
382                 {"<Actions>/Menu/Message/Move",                         "<control>O"}, /* - */
383                 {"<Actions>/Menu/Message/Copy",                         "<shift>C"}, /* copy-message */
384                 {"<Actions>/Menu/Message/Trash",                        "D"}, /* delete-message */
385                 {"<Actions>/Menu/Message/Mark/Mark",                    "<shift>F"}, /* flag-message */
386                 {"<Actions>/Menu/Message/Mark/Unmark",                  "<control><shift>F"}, /* - */
387                 {"<Actions>/Menu/Message/Mark/MarkUnread",              "<shift>N"}, /* toggle-new */
388                 {"<Actions>/Menu/Message/Mark/MarkRead",                "<control>R"}, /* read-thread */
389
390                 {"<Actions>/Menu/Tools/AddressBook",                    "<shift><control>A"}, /* - */
391                 {"<Actions>/Menu/Tools/Execute",                        "dollar"}, /* sync-mailbox */
392                 {"<Actions>/Menu/Tools/NetworkLog",                     "<shift><control>L"}, /* - */
393                 /* compose */
394                 {"<Actions>/Menu/Message/Close",                        "<alt>W"}, /* - */
395                 {"<Actions>/Menu/Edit/Advanced/BackWord",               "<alt>B"}, /* - */
396                 {"<Actions>/Menu/Edit/Advanced/ForwWord",               "<alt>F"}, /* - */
397                 {"<Actions>/Menu/Edit/Advanced/BegLine",                "<control>A"}, /* - */
398                 {"<Actions>/Menu/Edit/Advanced/DelBackWord",            "<control>W"}, /* - */
399                 {"<Actions>/Menu/Edit/Advanced/DelForwWord",            "<alt>D"}, /* - */
400         };
401
402 #if !GTK_CHECK_VERSION(2, 24, 0)
403         text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(keybind.combo));
404 #else
405         text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keybind.combo));
406 #endif
407
408         if (!strcmp(text, _("Default"))) {
409                 menurc = default_menurc;
410                 n_menurc = G_N_ELEMENTS(default_menurc);
411         } else if (!strcmp(text, "Mew / Wanderlust")) {
412                 menurc = mew_wl_menurc;
413                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
414         } else if (!strcmp(text, "Mutt")) {
415                 menurc = mutt_menurc;
416                 n_menurc = G_N_ELEMENTS(mutt_menurc);
417         } else {
418                 g_free(text);
419                 return;
420         }
421         g_free(text);
422
423         prefs_keybind_apply(menurc, n_menurc);
424
425         gtk_widget_destroy(keybind.window);
426         keybind.window = NULL;
427         keybind.combo = NULL;
428 }
429
430 static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, 
431                                   gpointer data)
432 {
433         OtherPage *prefs_other = (OtherPage *) _page;
434         
435         GtkWidget *vbox1;
436         GtkWidget *hbox1;
437
438         GtkWidget *frame_addr;
439         GtkWidget *vbox_addr;
440         GtkWidget *checkbtn_addaddrbyclick;
441         
442         GtkWidget *frame_exit;
443         GtkWidget *vbox_exit;
444         GtkWidget *checkbtn_confonexit;
445         GtkWidget *checkbtn_cleanonexit;
446         GtkWidget *checkbtn_warnqueued;
447
448         GtkWidget *frame_keys;
449         GtkWidget *vbox_keys;
450         GtkWidget *checkbtn_gtk_can_change_accels;
451         GtkWidget *button_keybind;
452
453         GtkWidget *label_iotimeout;
454         GtkWidget *spinbtn_iotimeout;
455         GtkAdjustment *spinbtn_iotimeout_adj;
456
457         GtkWidget *vbox2;
458         GtkWidget *checkbtn_askonclean;
459         GtkWidget *checkbtn_askonfilter;
460         GtkWidget *checkbtn_use_shred;
461         GtkWidget *checkbtn_real_time_sync;
462
463         GtkWidget *frame_metadata;
464         GtkWidget *vbox_metadata;
465         GtkWidget *metadata_label;
466         GtkWidget *flush_metadata_faster_radiobtn;
467         GtkWidget *flush_metadata_safer_radiobtn;
468
469         gchar *shred_binary = NULL;
470
471         vbox1 = gtk_vbox_new (FALSE, VSPACING);
472         gtk_widget_show (vbox1);
473         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
474
475         vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
476
477         PACK_CHECK_BUTTON
478                 (vbox_addr, checkbtn_addaddrbyclick,
479                  _("Add address to destination when double-clicked"));
480
481         /* On Exit */
482         vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
483
484         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
485                            _("Confirm on exit"));
486
487         hbox1 = gtk_hbox_new (FALSE, 32);
488         gtk_widget_show (hbox1);
489         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
490
491         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
492                            _("Empty trash on exit"));
493
494         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
495                            _("Warn if there are queued messages"));
496
497         vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
498
499         PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels,
500                         _("Enable customisable keyboard shortcuts"));
501
502         CLAWS_SET_TIP(checkbtn_gtk_can_change_accels,
503                         _("If checked, you can change the keyboard shortcuts of "
504                                 "most of the menu items by focusing on the menu "
505                                 "item and pressing a key combination.\n"
506                                 "Uncheck this option if you want to lock all "
507                                 "existing keyboard shortcuts."));
508
509         button_keybind = gtk_button_new_with_label(
510                                 _(" Choose preset keyboard shortcuts... "));
511         gtk_widget_show (button_keybind);
512         hbox1 = gtk_hbox_new (FALSE, 8);
513         gtk_widget_show (hbox1);
514         gtk_box_pack_start (GTK_BOX (vbox_keys), hbox1, FALSE, FALSE, 0);
515         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
516         g_signal_connect (G_OBJECT (button_keybind), "clicked",
517                           G_CALLBACK (prefs_keybind_select), NULL);
518
519
520         vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
521         metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
522                                          "it avoids data loss after crashes but can take some time."));
523         gtk_misc_set_alignment(GTK_MISC(metadata_label), 0, 0);
524         gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
525         flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
526         flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
527                                            GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
528         hbox1 = gtk_hbox_new (FALSE, 8);
529         gtk_widget_show (hbox1);
530         gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
531         gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
532         gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
533         
534         if (prefs_common.flush_metadata)
535                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
536         else
537                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
538
539         gtk_widget_show_all(frame_metadata);
540
541         hbox1 = gtk_hbox_new (FALSE, 8);
542         gtk_widget_show (hbox1);
543         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
544
545         label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
546         gtk_widget_show (label_iotimeout);
547         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
548
549         spinbtn_iotimeout_adj = GTK_ADJUSTMENT(gtk_adjustment_new (60, 0, 1000, 1, 10, 0));
550         spinbtn_iotimeout = gtk_spin_button_new
551                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
552         gtk_widget_show (spinbtn_iotimeout);
553         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
554                             FALSE, FALSE, 0);
555         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
556         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
557
558         label_iotimeout = gtk_label_new (_("seconds"));
559         gtk_widget_show (label_iotimeout);
560         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
561
562         vbox2 = gtk_vbox_new (FALSE, 8);
563         gtk_widget_show (vbox2);
564         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
565
566         PACK_CHECK_BUTTON (vbox2, checkbtn_askonclean, 
567                            _("Ask before emptying trash"));
568         PACK_CHECK_BUTTON (vbox2, checkbtn_askonfilter,
569                            _("Ask about account specific filtering rules when "
570                              "filtering manually"));
571         shred_binary = g_find_program_in_path("shred");
572         if (shred_binary) {
573                 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
574                                    _("Use secure file deletion if possible"));
575                 g_free(shred_binary);
576         } else {
577                 PACK_CHECK_BUTTON (vbox2, checkbtn_use_shred,
578                                    _("Use secure file deletion if possible\n"
579                                      "(the 'shred' program is not available)"));
580                 gtk_widget_set_sensitive(checkbtn_use_shred, FALSE);
581         }
582         CLAWS_SET_TIP(checkbtn_use_shred,
583                         _("Use the 'shred' program to overwrite files with random data before "
584                           "deleting them. This slows down deletion. Be sure to "
585                           "read shred's man page for caveats."));
586         PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
587                            _("Synchronise offline folders as soon as possible"));
588
589         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick), 
590                 prefs_common.add_address_by_click);
591         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit), 
592                 prefs_common.confirm_on_exit);
593         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit), 
594                 prefs_common.clean_on_exit);
595         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean), 
596                 prefs_common.ask_on_clean);
597         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued), 
598                 prefs_common.warn_queued_on_exit);
599         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
600                 prefs_common.gtk_can_change_accels);
601
602         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
603                 prefs_common.io_timeout_secs);
604
605         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter), 
606                 prefs_common.ask_apply_per_account_filtering_rules);
607         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_shred), 
608                 prefs_common.use_shred);
609         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync), 
610                 prefs_common.real_time_sync);
611
612         prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
613         prefs_other->checkbtn_confonexit = checkbtn_confonexit;
614         prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
615         prefs_other->checkbtn_askonclean = checkbtn_askonclean;
616         prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
617         prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
618         prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
619         prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
620         prefs_other->checkbtn_use_shred = checkbtn_use_shred;
621         prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
622         prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
623         prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
624         prefs_other->page.widget = vbox1;
625 }
626
627 static void prefs_other_save(PrefsPage *_page)
628 {
629         OtherPage *page = (OtherPage *) _page;
630         gboolean gtk_can_change_accels;
631
632         prefs_common.add_address_by_click = gtk_toggle_button_get_active(
633                 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
634         prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
635                 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
636         prefs_common.clean_on_exit = gtk_toggle_button_get_active(
637                 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit)); 
638         prefs_common.ask_on_clean = gtk_toggle_button_get_active(
639                 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
640         prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
641                 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued)); 
642         prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
643                 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
644         prefs_common.flush_metadata = gtk_toggle_button_get_active(
645                 GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
646         sock_set_io_timeout(prefs_common.io_timeout_secs);
647 #ifdef HAVE_LIBETPAN
648         imap_main_set_timeout(prefs_common.io_timeout_secs);
649 #endif
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)); 
659
660         gtk_can_change_accels = gtk_toggle_button_get_active(
661                 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
662
663         if (prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
664
665                 prefs_common.gtk_can_change_accels = gtk_can_change_accels;
666
667                 gtk_settings_set_long_property(gtk_settings_get_default(),
668                                 "gtk-can-change-accels",
669                                 (glong)prefs_common.gtk_can_change_accels,
670                                 "XProperty");
671
672                 /* gtk_can_change_accels value changed : we have (only if changed)
673                  * to apply the gtk property to all widgets : */
674                 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
675         }
676 }
677
678 static void prefs_other_destroy_widget(PrefsPage *_page)
679 {
680 }
681
682 OtherPage *prefs_other;
683
684 void prefs_other_init(void)
685 {
686         OtherPage *page;
687         static gchar *path[3];
688
689         path[0] = _("Other");
690         path[1] = _("Miscellaneous");
691         path[2] = NULL;
692
693         page = g_new0(OtherPage, 1);
694         page->page.path = path;
695         page->page.create_widget = prefs_other_create_widget;
696         page->page.destroy_widget = prefs_other_destroy_widget;
697         page->page.save_page = prefs_other_save;
698         page->page.weight = 5.0;
699         prefs_gtk_register_page((PrefsPage *) page);
700         prefs_other = page;
701
702         gtk_settings_set_long_property(gtk_settings_get_default(),
703                         "gtk-can-change-accels",
704                         (glong)prefs_common.gtk_can_change_accels,
705                         "XProperty");
706 }
707
708 void prefs_other_done(void)
709 {
710         prefs_gtk_unregister_page((PrefsPage *) prefs_other);
711         g_free(prefs_other);
712 }