2007-02-09 [paul] 2.7.2cvs34
[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 2 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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
40 #include "manage_window.h"
41 #ifdef HAVE_LIBETPAN
42 #include "imap-thread.h"
43 #endif
44
45 typedef struct _OtherPage
46 {
47         PrefsPage page;
48
49         GtkWidget *window;
50
51         GtkWidget *checkbtn_addaddrbyclick;
52         GtkWidget *checkbtn_confonexit;
53         GtkWidget *checkbtn_cleanonexit;
54         GtkWidget *checkbtn_askonclean;
55         GtkWidget *checkbtn_warnqueued;
56         GtkWidget *checkbtn_cliplog;
57         GtkWidget *spinbtn_loglength;
58         GtkWidget *spinbtn_iotimeout;
59         GtkWidget *checkbtn_gtk_can_change_accels;
60         GtkWidget *checkbtn_askonfilter;
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 = gtk_combo_new ();
111         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
112         gtkut_combo_set_items (GTK_COMBO (combo),
113                                _("Default"),
114                                "Mew / Wanderlust",
115                                "Mutt",
116                                _("Old Sylpheed"),
117                                NULL);
118         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
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         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
203         const gchar *text;
204         struct KeyBind *menurc;
205         gint n_menurc;
206
207         static struct KeyBind default_menurc[] = {
208                 {"<Main>/File/Empty all Trash folders",         "<shift>D"},
209                 {"<Main>/File/Save as...",                      "<control>S"},
210                 {"<Main>/File/Print...",                        "<control>P"},
211                 {"<Main>/File/Work offline",                    "<control>W"},
212                 {"<Main>/File/Synchronise folders",             "<control><shift>S"},
213                 {"<Main>/File/Exit",                            "<control>Q"},
214
215                 {"<Main>/Edit/Copy",                            "<control>C"},
216                 {"<Main>/Edit/Select all",                      "<control>A"},
217                 {"<Main>/Edit/Find in current message...",      "<control>F"},
218                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
219                 {"<Main>/Edit/Quick search",                    "slash"},
220
221                 {"<Main>/View/Show or hide/Message View",       "V"},
222                 {"<Main>/View/Thread view",                     "<control>T"},
223                 {"<Main>/View/Go to/Previous message",          "P"},
224                 {"<Main>/View/Go to/Next message",              "N"},
225                 {"<Main>/View/Go to/Previous unread message",   "<shift>P"},
226                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
227                 {"<Main>/View/Go to/Other folder...",           "G"},
228                 {"<Main>/View/Open in new window",              "<control><alt>N"},
229                 {"<Main>/View/Message source",                  "<control>U"},
230                 {"<Main>/View/All headers",                     "<control>H"},
231                 {"<Main>/View/Update summary",                  "<control><alt>U"},
232
233                 {"<Main>/Message/Receive/Get from current account",
234                                                                 "<control>I"},
235                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
236                 {"<Main>/Message/Compose an email message",     "<control>M"},
237                 {"<Main>/Message/Reply",                        "<control>R"},
238                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
239                 {"<Main>/Message/Reply to/sender",              ""},
240                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
241                 {"<Main>/Message/Forward",                      "<control><alt>F"},
242                 /* {"<Main>/Message/Forward as attachment",      ""}, */
243                 {"<Main>/Message/Move...",                      "<control>O"},
244                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
245                 {"<Main>/Message/Move to trash",                "<control>D"},
246                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
247                 {"<Main>/Message/Mark/Unmark",                  "U"},
248                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
249                 {"<Main>/Message/Mark/Mark as read",            ""},
250
251                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
252                 {"<Main>/Tools/Execute",                        "X"},
253                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
254
255                 {"<Compose>/Message/Send",                              "<control>Return"},
256                 {"<Compose>/Message/Send later",                        "<shift><control>S"},
257                 {"<Compose>/Message/Attach file",                       "<control>M"},
258                 {"<Compose>/Message/Insert file",                       "<control>I"},
259                 {"<Compose>/Message/Insert signature",                  "<control>G"},
260                 {"<Compose>/Message/Save",                              "<control>S"},
261                 {"<Compose>/Message/Close",                             "<control>W"},
262                 {"<Compose>/Edit/Undo",                                 "<control>Z"},
263                 {"<Compose>/Edit/Redo",                                 "<control>Y"},
264                 {"<Compose>/Edit/Cut",                                  "<control>X"},
265                 {"<Compose>/Edit/Copy",                                 "<control>C"},
266                 {"<Compose>/Edit/Paste",                                "<control>V"},
267                 {"<Compose>/Edit/Select all",                           "<control>A"},
268                 {"<Compose>/Edit/Advanced/Move a character backward",   "<control>B"},
269                 {"<Compose>/Edit/Advanced/Move a character forward",    "<control>F"},
270                 {"<Compose>/Edit/Advanced/Move a word backward,"        ""},
271                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
272                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
273                 {"<Compose>/Edit/Advanced/Move to end of line",         "<control>E"},
274                 {"<Compose>/Edit/Advanced/Move to previous line",       "<control>P"},
275                 {"<Compose>/Edit/Advanced/Move to next line",           "<control>N"},
276                 {"<Compose>/Edit/Advanced/Delete a character backward", "<control>H"},
277                 {"<Compose>/Edit/Advanced/Delete a character forward",  "<control>D"},
278                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
279                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
280                 {"<Compose>/Edit/Advanced/Delete line",                 "<control>U"},
281                 {"<Compose>/Edit/Advanced/Delete entire line",          ""},
282                 {"<Compose>/Edit/Advanced/Delete to end of line",       "<control>K"},
283                 {"<Compose>/Edit/Wrap current paragraph",               "<control>L"},
284                 {"<Compose>/Edit/Wrap all long lines",                  "<control><alt>L"},
285                 {"<Compose>/Edit/Auto wrapping",                        "<shift><control>L"},
286                 {"<Compose>/Edit/Edit with external editor",            "<shift><control>X"},
287                 {"<Compose>/Tools/Address book",                        "<shift><control>A"},
288         };
289
290         static struct KeyBind mew_wl_menurc[] = {
291                 {"<Main>/File/Empty all Trash folders",         "<shift>D"},
292                 {"<Main>/File/Save as...",                      "Y"},
293                 {"<Main>/File/Print...",                        "<shift>numbersign"},
294                 {"<Main>/File/Exit",                            "<shift>Q"},
295
296                 {"<Main>/Edit/Copy",                            "<control>C"},
297                 {"<Main>/Edit/Select all",                      "<control>A"},
298                 {"<Main>/Edit/Find in current message...",      "<control>F"},
299                 {"<Main>/Edit/Search folder...",                "<control>S"},
300
301                 {"<Main>/View/Show or hide/Message View",       ""},
302                 {"<Main>/View/Thread view",                     "<shift>T"},
303                 {"<Main>/View/Go to/Previous message",          "P"},
304                 {"<Main>/View/Go to/Next message",              "N"},
305                 {"<Main>/View/Go to/Previous unread message",   "<shift>P"},
306                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
307                 {"<Main>/View/Go to/Other folder...",           "G"},
308                 {"<Main>/View/Open in new window",              "<control><alt>N"},
309                 {"<Main>/View/Message source",                  "<control>U"},
310                 {"<Main>/View/All headers",                     "<shift>H"},
311                 {"<Main>/View/Update summary",                  "<shift>S"},
312
313                 {"<Main>/Message/Receive/Get from current account",
314                                                                 "<control>I"},
315                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
316                 {"<Main>/Message/Compose an email message",     "W"},
317                 {"<Main>/Message/Reply",                        "<control>R"},
318                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
319                 {"<Main>/Message/Reply to/sender",              ""},
320                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
321                 {"<Main>/Message/Forward",                      "F"},
322                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
323                 {"<Main>/Message/Move...",                      "O"},
324                 {"<Main>/Message/Copy...",                      "<shift>O"},
325                 {"<Main>/Message/Delete",                       "D"},
326                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
327                 {"<Main>/Message/Mark/Unmark",                  "U"},
328                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
329                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
330
331                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
332                 {"<Main>/Tools/Execute",                        "X"},
333                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
334
335                 {"<Compose>/Message/Close",                             "<alt>W"},
336                 {"<Compose>/Edit/Select all",                           ""},
337                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
338                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
339                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
340                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
341                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
342         };
343
344         static struct KeyBind mutt_menurc[] = {
345                 {"<Main>/File/Empty all Trash folders",         ""},
346                 {"<Main>/File/Save as...",                      "S"},
347                 {"<Main>/File/Print...",                        "P"},
348                 {"<Main>/File/Exit",                            "Q"},
349
350                 {"<Main>/Edit/Copy",                            "<control>C"},
351                 {"<Main>/Edit/Select all",                      "<control>A"},
352                 {"<Main>/Edit/Find in current message...",      "<control>F"},
353                 {"<Main>/Edit/Search messages...",              "slash"},
354
355                 {"<Main>/View/Show or hide/Message view",       "V"},
356                 {"<Main>/View/Thread view",                     "<control>T"},
357                 {"<Main>/View/Go to/Previous message",          ""},
358                 {"<Main>/View/Go to/Next message",              ""},
359                 {"<Main>/View/Go to/Previous unread message",   ""},
360                 {"<Main>/View/Go to/Next unread message",       ""},
361                 {"<Main>/View/Go to/Other folder...",           "C"},
362                 {"<Main>/View/Open in new window",              "<control><alt>N"},
363                 {"<Main>/View/Message source",                  "<control>U"},
364                 {"<Main>/View/All headers",                     "<control>H"},
365                 {"<Main>/View/Update summary",                  "<control><alt>U"},
366
367                 {"<Main>/Message/Receive/Get from current account",
368                                                                 "<control>I"},
369                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
370                 {"<Main>/Message/Compose an email message",             "M"},
371                 {"<Main>/Message/Reply",                        "R"},
372                 {"<Main>/Message/Reply to/all",                 "G"},
373                 {"<Main>/Message/Reply to/sender",              ""},
374                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
375                 {"<Main>/Message/Forward",                      "F"},
376                 {"<Main>/Message/Forward as attachment",        ""},
377                 {"<Main>/Message/Move...",                      "<control>O"},
378                 {"<Main>/Message/Copy...",                      "<shift>C"},
379                 {"<Main>/Message/Delete",                       "D"},
380                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
381                 {"<Main>/Message/Mark/Unmark",                  "U"},
382                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
383                 {"<Main>/Message/Mark/Mark as read",            ""},
384
385                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
386                 {"<Main>/Tools/Execute",                        "X"},
387                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
388
389                 {"<Compose>/Message/Close",                             "<alt>W"},
390                 {"<Compose>/Edit/Select all",                           ""},
391                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
392                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
393                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
394                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
395                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
396         };
397
398         static struct KeyBind old_sylpheed_menurc[] = {
399                 {"<Main>/File/Empty all Trash folders",         ""},
400                 {"<Main>/File/Save as...",                      ""},
401                 {"<Main>/File/Print...",                        "<alt>P"},
402                 {"<Main>/File/Exit",                            "<alt>Q"},
403
404                 {"<Main>/Edit/Copy",                            "<control>C"},
405                 {"<Main>/Edit/Select all",                      "<control>A"},
406                 {"<Main>/Edit/Find in current message...",      "<control>F"},
407                 {"<Main>/Edit/Search folder...",                "<control>S"},
408
409                 {"<Main>/View/Show or hide/Message View",       ""},
410                 {"<Main>/View/Thread view",                     "<control>T"},
411                 {"<Main>/View/Go to/Previous message",          "P"},
412                 {"<Main>/View/Go to/Next message",              "N"},
413                 {"<Main>/View/Go to/Previous unread message",   "<shift>P"},
414                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
415                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
416                 {"<Main>/View/Open in new window",              "<shift><control>N"},
417                 {"<Main>/View/Message source",                  "<control>U"},
418                 {"<Main>/View/All headers",                     "<control>H"},
419                 {"<Main>/View/Update summary",                  "<alt>U"},
420
421                 {"<Main>/Message/Receive/Get from current account",
422                                                                 "<alt>I"},
423                 {"<Main>/Message/Receive/Get from all accounts","<shift><alt>I"},
424                 {"<Main>/Message/Compose an email message",     "<alt>N"},
425                 {"<Main>/Message/Reply",                        "<alt>R"},
426                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
427                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
428                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
429                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
430                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
431                 {"<Main>/Message/Move...",                      "<alt>O"},
432                 {"<Main>/Message/Copy...",                      ""},
433                 {"<Main>/Message/Delete",                       "<alt>D"},
434                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
435                 {"<Main>/Message/Mark/Unmark",                  "U"},
436                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
437                 {"<Main>/Message/Mark/Mark as read",            ""},
438
439                 {"<Main>/Tools/Address book",                   "<alt>A"},
440                 {"<Main>/Tools/Execute",                        "<alt>X"},
441                 {"<Main>/Tools/Log window",                     "<alt>L"},
442
443                 {"<Compose>/Message/Close",                             "<alt>W"},
444                 {"<Compose>/Edit/Select all",                           ""},
445                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
446                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
447                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
448                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
449                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
450         };
451   
452         text = gtk_entry_get_text(entry);
453   
454         if (!strcmp(text, _("Default"))) {
455                 menurc = default_menurc;
456                 n_menurc = G_N_ELEMENTS(default_menurc);
457         } else if (!strcmp(text, "Mew / Wanderlust")) {
458                 menurc = mew_wl_menurc;
459                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
460         } else if (!strcmp(text, "Mutt")) {
461                 menurc = mutt_menurc;
462                 n_menurc = G_N_ELEMENTS(mutt_menurc);
463         } else if (!strcmp(text, _("Old Sylpheed"))) {
464                 menurc = old_sylpheed_menurc;
465                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
466         } else {
467                 return;
468         }
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_cliplog;
491         GtkWidget *vbox_cliplog;
492         GtkWidget *hbox_cliplog;
493         GtkWidget *checkbtn_cliplog;
494         GtkWidget *loglength_label;
495         GtkWidget *spinbtn_loglength;
496         GtkObject *spinbtn_loglength_adj;
497         GtkTooltips *loglength_tooltip;
498         GtkWidget *label;
499
500         GtkWidget *frame_exit;
501         GtkWidget *vbox_exit;
502         GtkWidget *checkbtn_confonexit;
503         GtkWidget *checkbtn_cleanonexit;
504         GtkWidget *checkbtn_askonclean;
505         GtkWidget *checkbtn_warnqueued;
506         GtkWidget *checkbtn_askonfilter;
507
508         GtkWidget *frame_keys;
509         GtkWidget *vbox_keys;
510         GtkWidget *checkbtn_gtk_can_change_accels;
511         GtkTooltips *gtk_can_change_accels_tooltip;
512         GtkWidget *button_keybind;
513
514         GtkWidget *label_iotimeout;
515         GtkWidget *spinbtn_iotimeout;
516         GtkObject *spinbtn_iotimeout_adj;
517
518         vbox1 = gtk_vbox_new (FALSE, VSPACING);
519         gtk_widget_show (vbox1);
520         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
521
522         vbox_addr = gtkut_get_options_frame(vbox1, &frame_addr, _("Address book"));
523
524         PACK_CHECK_BUTTON
525                 (vbox_addr, checkbtn_addaddrbyclick,
526                  _("Add address to destination when double-clicked"));
527
528         /* Clip Log */
529         vbox_cliplog = gtkut_get_options_frame(vbox1, &frame_cliplog, _("Log Size"));
530
531         PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
532                            _("Clip the log size"));
533         hbox_cliplog = gtk_hbox_new (FALSE, 8);
534         gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
535         gtk_widget_show (hbox_cliplog);
536         
537         loglength_label = gtk_label_new (_("Log window length"));
538         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
539                             FALSE, TRUE, 0);
540         gtk_widget_show (GTK_WIDGET (loglength_label));
541         
542         loglength_tooltip = gtk_tooltips_new();
543
544         spinbtn_loglength_adj = gtk_adjustment_new (500, 0, G_MAXINT, 1, 10, 10);
545         spinbtn_loglength = gtk_spin_button_new
546                 (GTK_ADJUSTMENT (spinbtn_loglength_adj), 1, 0);
547         gtk_widget_show (spinbtn_loglength);
548         gtk_box_pack_start (GTK_BOX (hbox_cliplog), spinbtn_loglength,
549                             FALSE, FALSE, 0);
550         gtk_widget_set_size_request (GTK_WIDGET (spinbtn_loglength), 64, -1);
551         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_loglength), TRUE);
552
553         gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), spinbtn_loglength,
554                              _("0 to stop logging in the log window"),
555                              NULL);
556
557         label = gtk_label_new(_("lines"));
558         gtk_widget_show (label);
559         gtk_box_pack_start(GTK_BOX(hbox_cliplog), label, FALSE, FALSE, 0);
560
561         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_label);
562         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, spinbtn_loglength);
563         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, label);
564
565         /* On Exit */
566         vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
567
568         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
569                            _("Confirm on exit"));
570
571         hbox1 = gtk_hbox_new (FALSE, 32);
572         gtk_widget_show (hbox1);
573         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
574
575         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
576                            _("Empty trash on exit"));
577         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
578                            _("Ask before emptying"));
579         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
580
581         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
582                            _("Warn if there are queued messages"));
583
584         vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts"));
585
586         PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels,
587                         _("Enable customisable menu shortcuts"));
588         gtk_can_change_accels_tooltip = gtk_tooltips_new();
589         gtk_tooltips_set_tip(GTK_TOOLTIPS(gtk_can_change_accels_tooltip),
590                         checkbtn_gtk_can_change_accels,
591                         _("If checked, you can change the keyboard shortcuts of "
592                                 "most of the menu items by focusing on the menu "
593                                 "item and pressing a key combination.\n"
594                                 "Uncheck this option if you want to lock all "
595                                 "existing menu shortcuts."),
596                         NULL);
597
598         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
599         gtk_widget_show (button_keybind);
600         hbox1 = gtk_hbox_new (FALSE, 8);
601         gtk_widget_show (hbox1);
602         gtk_box_pack_start (GTK_BOX (vbox_keys), hbox1, FALSE, FALSE, 0);
603         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
604         g_signal_connect (G_OBJECT (button_keybind), "clicked",
605                           G_CALLBACK (prefs_keybind_select), NULL);
606
607         hbox1 = gtk_hbox_new (FALSE, 8);
608         gtk_widget_show (hbox1);
609         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
610
611         label_iotimeout = gtk_label_new (_("Socket I/O timeout"));
612         gtk_widget_show (label_iotimeout);
613         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
614
615         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
616         spinbtn_iotimeout = gtk_spin_button_new
617                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
618         gtk_widget_show (spinbtn_iotimeout);
619         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
620                             FALSE, FALSE, 0);
621         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
622         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
623
624         label_iotimeout = gtk_label_new (_("seconds"));
625         gtk_widget_show (label_iotimeout);
626         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
627
628         hbox1 = gtk_hbox_new (FALSE, 8);
629         gtk_widget_show (hbox1);
630         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
631
632         PACK_CHECK_BUTTON (hbox1, checkbtn_askonfilter,
633                            _("Ask about account specific filtering rules when "
634                              "filtering manually"));
635
636         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick), 
637                 prefs_common.add_address_by_click);
638         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_confonexit), 
639                 prefs_common.confirm_on_exit);
640         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cleanonexit), 
641                 prefs_common.clean_on_exit);
642         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonclean), 
643                 prefs_common.ask_on_clean);
644         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued), 
645                 prefs_common.warn_queued_on_exit);
646         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cliplog), 
647                 prefs_common.cliplog);
648         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
649                 prefs_common.gtk_can_change_accels);
650
651         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_loglength),
652                 prefs_common.loglength);
653         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
654                 prefs_common.io_timeout_secs);
655
656         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_askonfilter), 
657                 prefs_common.ask_apply_per_account_filtering_rules);
658
659         prefs_other->checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
660         prefs_other->checkbtn_confonexit = checkbtn_confonexit;
661         prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
662         prefs_other->checkbtn_askonclean = checkbtn_askonclean;
663         prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
664         prefs_other->checkbtn_cliplog = checkbtn_cliplog;
665         prefs_other->spinbtn_loglength = spinbtn_loglength;
666         prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
667         prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
668         prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
669
670         prefs_other->page.widget = vbox1;
671 }
672
673 static void prefs_other_save(PrefsPage *_page)
674 {
675         OtherPage *page = (OtherPage *) _page;
676         MainWindow *mainwindow;
677         gboolean gtk_can_change_accels;
678
679         prefs_common.add_address_by_click = gtk_toggle_button_get_active(
680                 GTK_TOGGLE_BUTTON(page->checkbtn_addaddrbyclick));
681         prefs_common.confirm_on_exit = gtk_toggle_button_get_active(
682                 GTK_TOGGLE_BUTTON(page->checkbtn_confonexit));
683         prefs_common.clean_on_exit = gtk_toggle_button_get_active(
684                 GTK_TOGGLE_BUTTON(page->checkbtn_cleanonexit)); 
685         prefs_common.ask_on_clean = gtk_toggle_button_get_active(
686                 GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
687         prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
688                 GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued)); 
689         prefs_common.cliplog = gtk_toggle_button_get_active(
690                 GTK_TOGGLE_BUTTON(page->checkbtn_cliplog));
691         prefs_common.loglength = gtk_spin_button_get_value_as_int(
692                 GTK_SPIN_BUTTON(page->spinbtn_loglength));
693         prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
694                 GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
695         sock_set_io_timeout(prefs_common.io_timeout_secs);
696 #ifdef HAVE_LIBETPAN
697         imap_main_set_timeout(prefs_common.io_timeout_secs);
698 #endif
699         prefs_common.ask_apply_per_account_filtering_rules = 
700                 gtk_toggle_button_get_active(
701                         GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter)); 
702
703         mainwindow = mainwindow_get_mainwindow();
704         log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
705                                 prefs_common.loglength);
706
707         gtk_can_change_accels = gtk_toggle_button_get_active(
708                 GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
709
710         if (prefs_common.gtk_can_change_accels != gtk_can_change_accels) {
711
712                 prefs_common.gtk_can_change_accels = gtk_can_change_accels;
713
714                 gtk_settings_set_long_property(gtk_settings_get_default(),
715                                 "gtk-can-change-accels",
716                                 (glong)prefs_common.gtk_can_change_accels,
717                                 "XProperty");
718
719                 /* gtk_can_change_accels value changed : we have (only if changed)
720                  * to apply the gtk property to all widgets : */
721                 gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
722         }
723 }
724
725 static void prefs_other_destroy_widget(PrefsPage *_page)
726 {
727 }
728
729 OtherPage *prefs_other;
730
731 void prefs_other_init(void)
732 {
733         OtherPage *page;
734         static gchar *path[2];
735
736         path[0] = _("Other");
737         path[1] = NULL;
738
739         page = g_new0(OtherPage, 1);
740         page->page.path = path;
741         page->page.create_widget = prefs_other_create_widget;
742         page->page.destroy_widget = prefs_other_destroy_widget;
743         page->page.save_page = prefs_other_save;
744         page->page.weight = 5.0;
745         prefs_gtk_register_page((PrefsPage *) page);
746         prefs_other = page;
747
748         gtk_settings_set_long_property(gtk_settings_get_default(),
749                         "gtk-can-change-accels",
750                         (glong)prefs_common.gtk_can_change_accels,
751                         "XProperty");
752 }
753
754 void prefs_other_done(void)
755 {
756         prefs_gtk_unregister_page((PrefsPage *) prefs_other);
757         g_free(prefs_other);
758 }