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