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