2007-11-07 [paul] 3.0.2cvs122
[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), _("Select key bindings"));
93         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
94         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
95         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
96         manage_window_set_transient (GTK_WINDOW (window));
97
98         vbox1 = gtk_vbox_new (FALSE, VSPACING);
99         gtk_container_add (GTK_CONTAINER (window), vbox1);
100         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
101
102         hbox1 = gtk_hbox_new (FALSE, 8);
103         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
104
105         label = gtk_label_new
106                 (_("Select preset:"));
107         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
108         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
109
110         combo = combobox_text_new(FALSE,
111                                _("Default"),
112                                "Mew / Wanderlust",
113                                "Mutt",
114                                _("Old Sylpheed"),
115                                NULL);
116         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
117
118         hbox1 = gtk_hbox_new (FALSE, 8);
119         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
120
121         label = gtk_label_new
122                 (_("You can also modify each menu shortcut by pressing\n"
123                    "any key(s) when focusing the mouse pointer on the item."));
124         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
125         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
126         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
127         gtkut_widget_set_small_font_size (label);
128
129         hbox1 = gtk_hbox_new (FALSE, 8);
130         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
131
132         gtkut_stock_button_set_create (&confirm_area, &cancel_btn, GTK_STOCK_CANCEL,
133                                        &ok_btn, GTK_STOCK_OK,
134                                        NULL, NULL);
135         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
136         gtk_widget_grab_focus (ok_btn);
137
138         MANAGE_WINDOW_SIGNALS_CONNECT(window);
139         g_signal_connect (G_OBJECT (window), "delete_event",
140                           G_CALLBACK (prefs_keybind_deleted), NULL);
141         g_signal_connect (G_OBJECT (window), "key_press_event",
142                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
143         g_signal_connect (G_OBJECT (ok_btn), "clicked",
144                           G_CALLBACK (prefs_keybind_apply_clicked),
145                           NULL);
146         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
147                           G_CALLBACK (prefs_keybind_cancel),
148                           NULL);
149
150         gtk_widget_show_all(window);
151
152         keybind.window = window;
153         keybind.combo = combo;
154 }
155
156 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
157                                           gpointer data)
158 {
159         if (event && event->keyval == GDK_Escape)
160                 prefs_keybind_cancel();
161         return FALSE;
162 }
163
164 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
165                                   gpointer data)
166 {
167         prefs_keybind_cancel();
168         return TRUE;
169 }
170
171 static void prefs_keybind_cancel(void)
172 {
173         gtk_widget_destroy(keybind.window);
174         keybind.window = NULL;
175         keybind.combo = NULL;
176 }
177   
178 struct KeyBind {
179         const gchar *accel_path;
180         const gchar *accel_key;
181 };
182
183 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
184 {
185         gint i;
186         guint key;
187         GdkModifierType mods;
188
189         for (i = 0; i < num; i++) {
190                 const gchar *accel_key
191                         = keybind[i].accel_key ? keybind[i].accel_key : "";
192                 gtk_accelerator_parse(accel_key, &key, &mods);
193                 gtk_accel_map_change_entry(keybind[i].accel_path,
194                                            key, mods, TRUE);
195         }
196 }
197
198 static void prefs_keybind_apply_clicked(GtkWidget *widget)
199 {
200         GtkEntry *entry = GTK_ENTRY(GTK_BIN(keybind.combo)->child);
201         const 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_entry_get_text(entry);
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                 return;
466         }
467
468         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
469         prefs_keybind_apply(menurc, n_menurc);
470
471         gtk_widget_destroy(keybind.window);
472         keybind.window = NULL;
473         keybind.combo = NULL;
474 }
475
476 static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, 
477                                   gpointer data)
478 {
479         OtherPage *prefs_other = (OtherPage *) _page;
480         
481         GtkWidget *vbox1;
482         GtkWidget *hbox1;
483
484         GtkWidget *frame_addr;
485         GtkWidget *vbox_addr;
486         GtkWidget *checkbtn_addaddrbyclick;
487         
488         GtkWidget *frame_exit;
489         GtkWidget *vbox_exit;
490         GtkWidget *checkbtn_confonexit;
491         GtkWidget *checkbtn_cleanonexit;
492         GtkWidget *checkbtn_warnqueued;
493
494         GtkWidget *frame_keys;
495         GtkWidget *vbox_keys;
496         GtkWidget *checkbtn_gtk_can_change_accels;
497         GtkTooltips *gtk_can_change_accels_tooltip;
498         GtkWidget *button_keybind;
499
500         GtkWidget *label_iotimeout;
501         GtkWidget *spinbtn_iotimeout;
502         GtkObject *spinbtn_iotimeout_adj;
503
504         GtkWidget *vbox2;
505         GtkWidget *checkbtn_askonclean;
506         GtkWidget *checkbtn_askonfilter;
507         GtkWidget *checkbtn_real_time_sync;
508         vbox1 = gtk_vbox_new (FALSE, VSPACING);
509         gtk_widget_show (vbox1);
510         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
511
512         vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
513
514         PACK_CHECK_BUTTON
515                 (vbox_addr, checkbtn_addaddrbyclick,
516                  _("Add address to destination when double-clicked"));
517
518         /* On Exit */
519         vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
520
521         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
522                            _("Confirm on exit"));
523
524         hbox1 = gtk_hbox_new (FALSE, 32);
525         gtk_widget_show (hbox1);
526         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
527
528         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
529                            _("Empty trash on exit"));
530
531         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
532                            _("Warn if there are queued messages"));
533
534         vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
535
536         PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels,
537                         _("Enable customisable menu shortcuts"));
538         gtk_can_change_accels_tooltip = gtk_tooltips_new();
539         gtk_tooltips_set_tip(GTK_TOOLTIPS(gtk_can_change_accels_tooltip),
540                         checkbtn_gtk_can_change_accels,
541                         _("If checked, you can change the keyboard shortcuts of "
542                                 "most of the menu items by focusing on the menu "
543                                 "item and pressing a key combination.\n"
544                                 "Uncheck this option if you want to lock all "
545                                 "existing menu shortcuts."),
546                         NULL);
547
548         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
549         gtk_widget_show (button_keybind);
550         hbox1 = gtk_hbox_new (FALSE, 8);
551         gtk_widget_show (hbox1);
552         gtk_box_pack_start (GTK_BOX (vbox_keys), hbox1, FALSE, FALSE, 0);
553         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
554         g_signal_connect (G_OBJECT (button_keybind), "clicked",
555                           G_CALLBACK (prefs_keybind_select), NULL);
556
557         hbox1 = gtk_hbox_new (FALSE, 8);
558         gtk_widget_show (hbox1);
559         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
560
561         label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
562         gtk_widget_show (label_iotimeout);
563         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
564
565         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
566         spinbtn_iotimeout = gtk_spin_button_new
567                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
568         gtk_widget_show (spinbtn_iotimeout);
569         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
570                             FALSE, FALSE, 0);
571         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
572         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
573
574         label_iotimeout = gtk_label_new (_("seconds"));
575         gtk_widget_show (label_iotimeout);
576         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
577
578         vbox2 = gtk_vbox_new (FALSE, 8);
579         gtk_widget_show (vbox2);
580         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
581
582         PACK_CHECK_BUTTON (vbox2, checkbtn_askonclean, 
583                            _("Ask before emptying trash"));
584         PACK_CHECK_BUTTON (vbox2, checkbtn_askonfilter,
585                            _("Ask about account specific filtering rules when "
586                              "filtering manually"));
587         PACK_CHECK_BUTTON (vbox2, checkbtn_real_time_sync,
588                            _("Synchronise offline folders as soon as possible"));
589
590         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick), 
591                 prefs_common.add_address_by_click);
592         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit), 
593                 prefs_common.confirm_on_exit);
594         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit), 
595                 prefs_common.clean_on_exit);
596         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean), 
597                 prefs_common.ask_on_clean);
598         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued), 
599                 prefs_common.warn_queued_on_exit);
600         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
601                 prefs_common.gtk_can_change_accels);
602
603         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
604                 prefs_common.io_timeout_secs);
605
606         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter), 
607                 prefs_common.ask_apply_per_account_filtering_rules);
608         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_real_time_sync), 
609                 prefs_common.real_time_sync);
610
611         prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
612         prefs_other->checkbtn_confonexit = checkbtn_confonexit;
613         prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
614         prefs_other->checkbtn_askonclean = checkbtn_askonclean;
615         prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
616         prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
617         prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
618         prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
619         prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
620
621         prefs_other->page.widget = vbox1;
622 }
623
624 static void prefs_other_save(PrefsPage *_page)
625 {
626         OtherPage *page = (OtherPage *) _page;
627         gboolean gtk_can_change_accels;
628
629         prefs_common.add_address_by_click = gtk_toggle_button_get_active(
630                 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
631         prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
632                 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
633         prefs_common.clean_on_exit = gtk_toggle_button_get_active(
634                 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit)); 
635         prefs_common.ask_on_clean = gtk_toggle_button_get_active(
636                 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
637         prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
638                 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued)); 
639         prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
640                 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
641         sock_set_io_timeout(prefs_common.io_timeout_secs);
642 #ifdef HAVE_LIBETPAN
643         imap_main_set_timeout(prefs_common.io_timeout_secs);
644 #endif
645         prefs_common.ask_apply_per_account_filtering_rules = 
646                 gtk_toggle_button_get_active(
647                         GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter)); 
648         prefs_common.real_time_sync = 
649                 gtk_toggle_button_get_active(
650                         GTK_TOGGLE_BUTTON(page->checkbtn_real_time_sync)); 
651
652         gtk_can_change_accels = gtk_toggle_button_get_active(
653                 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
654
655         if (prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
656
657                 prefs_common.gtk_can_change_accels = gtk_can_change_accels;
658
659                 gtk_settings_set_long_property(gtk_settings_get_default(),
660                                 "gtk-can-change-accels",
661                                 (glong)prefs_common.gtk_can_change_accels,
662                                 "XProperty");
663
664                 /* gtk_can_change_accels value changed : we have (only if changed)
665                  * to apply the gtk property to all widgets : */
666                 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
667         }
668 }
669
670 static void prefs_other_destroy_widget(PrefsPage *_page)
671 {
672 }
673
674 OtherPage *prefs_other;
675
676 void prefs_other_init(void)
677 {
678         OtherPage *page;
679         static gchar *path[2];
680
681         path[0] = _("Other");
682         path[1] = NULL;
683
684         page = g_new0(OtherPage, 1);
685         page->page.path = path;
686         page->page.create_widget = prefs_other_create_widget;
687         page->page.destroy_widget = prefs_other_destroy_widget;
688         page->page.save_page = prefs_other_save;
689         page->page.weight = 5.0;
690         prefs_gtk_register_page((PrefsPage *) page);
691         prefs_other = page;
692
693         gtk_settings_set_long_property(gtk_settings_get_default(),
694                         "gtk-can-change-accels",
695                         (glong)prefs_common.gtk_can_change_accels,
696                         "XProperty");
697 }
698
699 void prefs_other_done(void)
700 {
701         prefs_gtk_unregister_page((PrefsPage *) prefs_other);
702         g_free(prefs_other);
703 }