a58e826049b7f725daacdb032f885dc13c835125
[claws.git] / src / prefs_common.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2004 Hiroyuki Yamamoto
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include <gdk/gdkkeysyms.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <errno.h>
36
37 #include "intl.h"
38 #include "main.h"
39 #include "prefs_gtk.h"
40 #include "prefs_common.h"
41 #include "prefs_display_header.h"
42 #include "prefs_summary_column.h"
43 #include "mainwindow.h"
44 #include "summaryview.h"
45 #include "messageview.h"
46 #include "manage_window.h"
47 #include "inc.h"
48 #include "menu.h"
49 #include "codeconv.h"
50 #include "utils.h"
51 #include "gtkutils.h"
52 #include "alertpanel.h"
53 #include "folder.h"
54 #include "socket.h"
55 #include "filesel.h"
56 #include "folderview.h"
57 #include "stock_pixmap.h"
58 #include "quote_fmt.h"
59
60 PrefsCommon prefs_common;
61
62 static PrefsDialog dialog;
63
64 static struct Receive {
65         GtkWidget *checkbtn_incext;
66         GtkWidget *entry_incext;
67         GtkWidget *button_incext;
68
69         GtkWidget *checkbtn_autochk;
70         GtkWidget *spinbtn_autochk;
71         GtkObject *spinbtn_autochk_adj;
72
73         GtkWidget *checkbtn_chkonstartup;
74         GtkWidget *checkbtn_scan_after_inc;
75
76
77         GtkWidget *checkbtn_newmail_auto;
78         GtkWidget *checkbtn_newmail_manu;
79         GtkWidget *entry_newmail_notify_cmd;
80         GtkWidget *hbox_newmail_notify;
81         GtkWidget *optmenu_recvdialog;
82         GtkWidget *checkbtn_no_recv_err_panel;
83         GtkWidget *checkbtn_close_recv_dialog;
84 } receive;
85
86 static struct Send {
87         GtkWidget *checkbtn_savemsg;
88         GtkWidget *optmenu_senddialog;
89
90         GtkWidget *optmenu_charset;
91         GtkWidget *optmenu_encoding_method;
92 } p_send;
93
94 static struct Compose {
95         GtkWidget *entry_fw_quotemark;
96         GtkWidget *text_fw_quotefmt;
97
98         GtkWidget *checkbtn_autoextedit;
99         GtkWidget *spinbtn_undolevel;
100         GtkObject *spinbtn_undolevel_adj;
101
102         GtkWidget *checkbtn_reply_account_autosel;
103         GtkWidget *checkbtn_forward_account_autosel;
104         GtkWidget *checkbtn_reedit_account_autosel;
105         GtkWidget *checkbtn_quote;
106         GtkWidget *checkbtn_default_reply_list;
107         GtkWidget *checkbtn_forward_as_attachment;
108         GtkWidget *checkbtn_redirect_keep_from;
109         GtkWidget *checkbtn_reply_with_quote;
110         
111         GtkWidget *checkbtn_autosave;
112         GtkWidget *entry_autosave_length;
113 } compose;
114
115 static struct Quote {
116         GtkWidget *entry_quotemark;
117         GtkWidget *text_quotefmt;
118
119         GtkWidget *entry_fw_quotemark;
120         GtkWidget *text_fw_quotefmt;
121         
122         GtkWidget *entry_quote_chars;
123 } quote;
124
125 static struct Display {
126         GtkWidget *chkbtn_folder_unread;
127         GtkWidget *entry_ng_abbrev_len;
128         GtkWidget *spinbtn_ng_abbrev_len;
129         GtkObject *spinbtn_ng_abbrev_len_adj;
130
131         GtkWidget *chkbtn_transhdr;
132
133         GtkWidget *chkbtn_swapfrom;
134         GtkWidget *chkbtn_useaddrbook;
135         GtkWidget *chkbtn_threadsubj;
136         GtkWidget *entry_datefmt;
137 } display;
138
139 static struct Message {
140         GtkWidget *chkbtn_mbalnum;
141         GtkWidget *chkbtn_disphdrpane;
142         GtkWidget *chkbtn_disphdr;
143         GtkWidget *spinbtn_linespc;
144         GtkObject *spinbtn_linespc_adj;
145         GtkWidget *chkbtn_headspc;
146
147         GtkWidget *chkbtn_smoothscroll;
148         GtkWidget *spinbtn_scrollstep;
149         GtkObject *spinbtn_scrollstep_adj;
150         GtkWidget *chkbtn_halfpage;
151
152         GtkWidget *chkbtn_attach_desc;
153 } message;
154
155 #if USE_GPGME
156 static struct Privacy {
157         GtkWidget *checkbtn_auto_check_signatures;
158         GtkWidget *checkbtn_store_passphrase;
159         GtkWidget *spinbtn_store_passphrase;
160         GtkObject *spinbtn_store_passphrase_adj;
161         GtkWidget *checkbtn_passphrase_grab;
162         GtkWidget *checkbtn_gpg_warning;
163 } privacy;
164 #endif
165
166 static struct Interface {
167         /* GtkWidget *checkbtn_emacs; */
168         GtkWidget *checkbtn_always_show_msg;
169         GtkWidget *checkbtn_openunread;
170         GtkWidget *checkbtn_mark_as_read_on_newwin;
171         GtkWidget *checkbtn_openinbox;
172         GtkWidget *checkbtn_immedexec;
173         GtkWidget *optmenu_nextunreadmsgdialog;
174 } interface;
175
176 static struct Other {
177         GtkWidget *checkbtn_addaddrbyclick;
178         GtkWidget *checkbtn_confonexit;
179         GtkWidget *checkbtn_cleanonexit;
180         GtkWidget *checkbtn_askonclean;
181         GtkWidget *checkbtn_warnqueued;
182         GtkWidget *checkbtn_cliplog;
183         GtkWidget *loglength_entry;
184 #if 0
185 #ifdef USE_OPENSSL
186         GtkWidget *checkbtn_ssl_ask_unknown_valid;
187 #endif
188 #endif
189
190         GtkWidget *spinbtn_iotimeout;
191         GtkObject *spinbtn_iotimeout_adj;
192 } other;
193
194 static struct KeybindDialog {
195         GtkWidget *window;
196         GtkWidget *combo;
197 } keybind;
198
199 static void prefs_common_charset_set_data_from_optmenu     (PrefParam *pparam);
200 static void prefs_common_charset_set_optmenu               (PrefParam *pparam);
201 static void prefs_common_encoding_set_data_from_optmenu    (PrefParam *pparam);
202 static void prefs_common_encoding_set_optmenu              (PrefParam *pparam);
203 static void prefs_common_recv_dialog_set_data_from_optmenu (PrefParam *pparam);
204 static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
205 static void prefs_common_recv_dialog_newmail_notify_toggle_cb   (GtkWidget *w,
206                                                                  gpointer data);
207 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
208 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
209 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam);
210 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam);
211 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
212 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
213
214 /*
215    parameter name, default value, pointer to the prefs variable, data type,
216    pointer to the widget pointer,
217    pointer to the function for data setting,
218    pointer to the function for widget setting
219  */
220
221 static PrefParam param[] = {
222         /* Receive */
223         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
224          &receive.checkbtn_incext,
225          prefs_set_data_from_toggle, prefs_set_toggle},
226         {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
227          &receive.entry_incext,
228          prefs_set_data_from_entry, prefs_set_entry},
229
230         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
231          &receive.checkbtn_autochk,
232          prefs_set_data_from_toggle, prefs_set_toggle},
233         {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
234          &receive.spinbtn_autochk,
235          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
236         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
237          &receive.checkbtn_chkonstartup,
238          prefs_set_data_from_toggle, prefs_set_toggle},
239         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
240          P_BOOL, &receive.checkbtn_scan_after_inc,
241          prefs_set_data_from_toggle, prefs_set_toggle},
242         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
243          P_BOOL, &receive.checkbtn_newmail_manu,
244          prefs_set_data_from_toggle, prefs_set_toggle},
245         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
246         P_BOOL, &receive.checkbtn_newmail_auto,
247          prefs_set_data_from_toggle, prefs_set_toggle},
248         {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING,
249          &receive.entry_newmail_notify_cmd,
250          prefs_set_data_from_entry, prefs_set_entry},
251         {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
252          &receive.optmenu_recvdialog,
253          prefs_common_recv_dialog_set_data_from_optmenu,
254          prefs_common_recv_dialog_set_optmenu},
255         {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
256          P_BOOL, &receive.checkbtn_no_recv_err_panel,
257          prefs_set_data_from_toggle, prefs_set_toggle},
258         {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
259          P_BOOL, &receive.checkbtn_close_recv_dialog,
260          prefs_set_data_from_toggle, prefs_set_toggle},
261  
262         /* Send */
263         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
264          &p_send.checkbtn_savemsg,
265          prefs_set_data_from_toggle, prefs_set_toggle},
266         {"send_dialog_mode", "0", &prefs_common.send_dialog_mode, P_ENUM,
267          &p_send.optmenu_senddialog,
268          prefs_common_send_dialog_set_data_from_optmenu,
269          prefs_common_send_dialog_set_optmenu},
270
271         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
272          &p_send.optmenu_charset,
273          prefs_common_charset_set_data_from_optmenu,
274          prefs_common_charset_set_optmenu},
275         {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM,
276          &p_send.optmenu_encoding_method,
277          prefs_common_encoding_set_data_from_optmenu,
278          prefs_common_encoding_set_optmenu},
279
280         {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
281          P_BOOL, NULL, NULL, NULL},
282
283         /* Compose */
284         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
285          &compose.checkbtn_autoextedit,
286          prefs_set_data_from_toggle, prefs_set_toggle},
287         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
288          P_BOOL, &compose.checkbtn_forward_as_attachment,
289          prefs_set_data_from_toggle, prefs_set_toggle},
290         {"redirect_keep_from", "FALSE",
291          &prefs_common.redirect_keep_from, P_BOOL,
292          &compose.checkbtn_redirect_keep_from,
293          prefs_set_data_from_toggle, prefs_set_toggle},
294         {"undo_level", "50", &prefs_common.undolevels, P_INT,
295          &compose.spinbtn_undolevel,
296          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
297
298         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
299          NULL, NULL, NULL},
300         {"linewrap_quotation", "TRUE", &prefs_common.linewrap_quote, P_BOOL,
301          NULL, NULL, NULL},
302         {"linewrap_auto", "TRUE", &prefs_common.autowrap, P_BOOL,
303          NULL, NULL, NULL},
304         {"linewrap_before_sending", "FALSE", &prefs_common.linewrap_at_send, P_BOOL, 
305          NULL, NULL, NULL},
306         {"autosave", "FALSE", &prefs_common.autosave,
307          P_BOOL, &compose.checkbtn_autosave,
308          prefs_set_data_from_toggle, prefs_set_toggle},
309         {"autosave_length", "50", &prefs_common.autosave_length,
310          P_INT, &compose.entry_autosave_length,
311          prefs_set_data_from_entry, prefs_set_entry},
312 #if USE_ASPELL
313         {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL,
314          NULL, NULL, NULL},
315         {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, P_STRING,
316          NULL, NULL, NULL},
317         {"dictionary",  "", &prefs_common.dictionary, P_STRING,
318          NULL, NULL, NULL},
319         {"aspell_sugmode", "1", &prefs_common.aspell_sugmode, P_INT,
320          NULL, NULL, NULL},
321         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL,
322          NULL, NULL, NULL},
323         {"check_while_typing", "TRUE", &prefs_common.check_while_typing, P_BOOL,
324          NULL, NULL, NULL},
325         {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_COLOR,
326          NULL, NULL, NULL},
327 #endif
328         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
329          &compose.checkbtn_reply_with_quote, prefs_set_data_from_toggle, prefs_set_toggle},
330
331         /* Account autoselection */
332         {"reply_account_autoselect", "TRUE",
333          &prefs_common.reply_account_autosel, P_BOOL,
334          &compose.checkbtn_reply_account_autosel,
335          prefs_set_data_from_toggle, prefs_set_toggle},
336         {"forward_account_autoselect", "TRUE",
337          &prefs_common.forward_account_autosel, P_BOOL,
338          &compose.checkbtn_forward_account_autosel,
339          prefs_set_data_from_toggle, prefs_set_toggle},
340         {"reedit_account_autoselect", "TRUE",
341          &prefs_common.reedit_account_autosel, P_BOOL,
342          &compose.checkbtn_reedit_account_autosel,
343          prefs_set_data_from_toggle, prefs_set_toggle},
344
345         {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
346          &compose.checkbtn_default_reply_list,
347          prefs_set_data_from_toggle, prefs_set_toggle},
348
349         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
350          NULL, NULL, NULL},
351
352         /* Quote */
353         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
354          &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
355         {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
356          &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
357          prefs_set_data_from_text, prefs_set_text},
358
359         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
360          &quote.entry_fw_quotemark,
361          prefs_set_data_from_entry, prefs_set_entry},
362         {"forward_quote_format",
363          "\\n\\nBegin forwarded message:\\n\\n"
364          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
365          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
366          &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
367          prefs_set_data_from_text, prefs_set_text},
368         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
369          &quote.entry_quote_chars, prefs_set_data_from_entry, prefs_set_entry},
370
371         /* Display */
372         /* Obsolete fonts. For coexisting with Gtk+-1.2 version */
373         {"widget_font",         NULL,
374           &prefs_common.widgetfont_gtk1,        P_STRING, NULL, NULL, NULL},
375         {"message_font",        "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
376          &prefs_common.textfont_gtk1,           P_STRING, NULL, NULL, NULL},
377         {"small_font",          "-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*",
378           &prefs_common.smallfont_gtk1,         P_STRING, NULL, NULL, NULL},
379         {"bold_font",           "-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*",
380           &prefs_common.boldfont_gtk1,          P_STRING, NULL, NULL, NULL},
381         {"normal_font",         "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*",
382           &prefs_common.normalfont_gtk1,        P_STRING, NULL, NULL, NULL},
383
384         /* new fonts */
385         {"widget_font_gtk2",    NULL,
386           &prefs_common.widgetfont,             P_STRING, NULL, NULL, NULL},
387         {"message_font_gtk2",   "fixed 9",
388          &prefs_common.textfont,                P_STRING, NULL, NULL, NULL},
389         {"small_font_gtk2",     "Sans 9",
390           &prefs_common.smallfont,              P_STRING, NULL, NULL, NULL},
391         {"bold_font_gtk2",      "Sans Bold 9",
392           &prefs_common.boldfont,               P_STRING, NULL, NULL, NULL},
393         {"normal_font_gtk2",    "Sans 9", 
394           &prefs_common.normalfont,             P_STRING, NULL, NULL, NULL},
395
396         {"display_folder_unread_num", "TRUE",
397          &prefs_common.display_folder_unread, P_BOOL,
398          &display.chkbtn_folder_unread,
399          prefs_set_data_from_toggle, prefs_set_toggle},
400         {"newsgroup_abbrev_len", "16",
401          &prefs_common.ng_abbrev_len, P_INT,
402          &display.spinbtn_ng_abbrev_len,
403          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
404
405         {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
406          &display.chkbtn_transhdr,
407          prefs_set_data_from_toggle, prefs_set_toggle},
408
409         /* Display: Summary View */
410         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
411          &display.chkbtn_swapfrom,
412          prefs_set_data_from_toggle, prefs_set_toggle},
413         {"use_address_book", "TRUE", &prefs_common.use_addr_book, P_BOOL,
414          &display.chkbtn_useaddrbook,
415          prefs_set_data_from_toggle, prefs_set_toggle},
416         {"thread_by_subject", "TRUE", &prefs_common.thread_by_subject, P_BOOL,
417          &display.chkbtn_threadsubj,
418          prefs_set_data_from_toggle, prefs_set_toggle},
419         {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
420          P_STRING, &display.entry_datefmt,
421          prefs_set_data_from_entry, prefs_set_entry},
422
423         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
424          NULL, NULL, NULL},
425         {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
426          NULL, NULL, NULL},
427         {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
428         P_INT, NULL, NULL, NULL },
429
430         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
431          NULL, NULL, NULL},
432         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
433          NULL, NULL, NULL},
434         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
435          NULL, NULL, NULL},
436         {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
437          NULL, NULL, NULL},
438
439         {"folderview_vscrollbar_policy", "0",
440          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
441          NULL, NULL, NULL},
442
443         {"summary_col_show_mark", "TRUE",
444          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
445         {"summary_col_show_unread", "TRUE",
446          &prefs_common.summary_col_visible[S_COL_STATUS], P_BOOL, NULL, NULL, NULL},
447         {"summary_col_show_mime", "TRUE",
448          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
449         {"summary_col_show_subject", "TRUE",
450          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
451         {"summary_col_show_from", "TRUE",
452          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
453         {"summary_col_show_date", "TRUE",
454          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
455         {"summary_col_show_size", "TRUE",
456          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
457         {"summary_col_show_number", "FALSE",
458          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
459         {"summary_col_show_score", "FALSE",
460          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
461         {"summary_col_show_locked", "FALSE",
462          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
463
464         {"summary_col_pos_mark", "0",
465           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
466         {"summary_col_pos_unread", "1",
467           &prefs_common.summary_col_pos[S_COL_STATUS], P_INT, NULL, NULL, NULL},
468         {"summary_col_pos_mime", "2",
469           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
470         {"summary_col_pos_subject", "3",
471           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
472         {"summary_col_pos_from", "4",
473           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
474         {"summary_col_pos_date", "5",
475           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
476         {"summary_col_pos_size", "6",
477           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
478         {"summary_col_pos_number", "7",
479           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
480         {"summary_col_pos_score", "8",
481          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
482         {"summary_col_pos_locked", "9",
483          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
484
485         {"summary_col_size_mark", "10",
486          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
487         {"summary_col_size_unread", "13",
488          &prefs_common.summary_col_size[S_COL_STATUS], P_INT, NULL, NULL, NULL},
489         {"summary_col_size_mime", "10",
490          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
491         {"summary_col_size_subject", "200",
492          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
493         {"summary_col_size_from", "120",
494          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
495         {"summary_col_size_date", "118",
496          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
497         {"summary_col_size_size", "45",
498          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
499         {"summary_col_size_number", "40",
500          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
501         {"summary_col_size_score", "40",
502          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
503         {"summary_col_size_locked", "13",
504          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
505
506         /* Widget size */
507         {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT,
508          NULL, NULL, NULL},
509         {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT,
510          NULL, NULL, NULL},
511         {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
512          NULL, NULL, NULL},
513         {"folderview_height", "600", &prefs_common.folderview_height, P_INT,
514          NULL, NULL, NULL},
515         {"folderview_visible", "TRUE", &prefs_common.folderview_visible, P_BOOL,
516          NULL, NULL, NULL},
517
518         {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
519          NULL, NULL, NULL},
520         {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
521          NULL, NULL, NULL},
522         {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
523          NULL, NULL, NULL},
524         {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
525          NULL, NULL, NULL},
526
527         {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
528          NULL, NULL, NULL},
529         {"summaryview_height", "173", &prefs_common.summaryview_height, P_INT,
530          NULL, NULL, NULL},
531
532         {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT,
533          NULL, NULL, NULL},
534         {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT,
535          NULL, NULL, NULL},
536         {"messageview_width", "600", &prefs_common.msgview_width, P_INT,
537          NULL, NULL, NULL},
538         {"messageview_height", "540", &prefs_common.msgview_height, P_INT,
539          NULL, NULL, NULL},
540         {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL,
541          NULL, NULL, NULL},
542
543         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
544          NULL, NULL, NULL},
545         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
546          NULL, NULL, NULL},
547         {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
548          NULL, NULL, NULL},
549         {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
550          NULL, NULL, NULL},
551         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
552          NULL, NULL, NULL},
553         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
554          NULL, NULL, NULL},
555         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
556          NULL, NULL, NULL},
557         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
558          NULL, NULL, NULL},
559         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
560          NULL, NULL, NULL},
561         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
562          NULL, NULL, NULL},
563         {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT,
564          NULL, NULL, NULL},
565         {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT,
566          NULL, NULL, NULL},
567         {"compose_width", "600", &prefs_common.compose_width, P_INT,
568          NULL, NULL, NULL},
569         {"compose_height", "560", &prefs_common.compose_height, P_INT,
570          NULL, NULL, NULL},
571         {"compose_x", "0", &prefs_common.compose_x, P_INT,
572          NULL, NULL, NULL},
573         {"compose_y", "0", &prefs_common.compose_y, P_INT,
574          NULL, NULL, NULL},
575         /* Message */
576         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
577          NULL, NULL, NULL},
578
579         {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_COLOR,
580          NULL, NULL, NULL},
581         {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_COLOR,
582          NULL, NULL, NULL},
583         {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_COLOR,
584          NULL, NULL, NULL},
585         {"uri_color", "32512", &prefs_common.uri_col, P_COLOR,
586          NULL, NULL, NULL},
587         {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_COLOR,
588          NULL, NULL, NULL},
589         {"signature_color", "7960953", &prefs_common.signature_col, P_COLOR,
590          NULL, NULL, NULL},
591         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
592          P_BOOL, NULL, NULL, NULL},
593
594         {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
595          &message.chkbtn_mbalnum,
596          prefs_set_data_from_toggle, prefs_set_toggle},
597         {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
598          P_BOOL, &message.chkbtn_disphdrpane,
599          prefs_set_data_from_toggle, prefs_set_toggle},
600         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
601          &message.chkbtn_disphdr,
602          prefs_set_data_from_toggle, prefs_set_toggle},
603         {"line_space", "2", &prefs_common.line_space, P_INT,
604          &message.spinbtn_linespc,
605          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
606         {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
607          &message.chkbtn_headspc,
608          prefs_set_data_from_toggle, prefs_set_toggle},
609
610         {"enable_smooth_scroll", "FALSE",
611          &prefs_common.enable_smooth_scroll, P_BOOL,
612          &message.chkbtn_smoothscroll,
613          prefs_set_data_from_toggle, prefs_set_toggle},
614         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
615          &message.spinbtn_scrollstep,
616          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
617         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
618          &message.chkbtn_halfpage,
619          prefs_set_data_from_toggle, prefs_set_toggle},
620
621         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
622          NULL, NULL, NULL},
623
624         {"attach_desc", "TRUE", &prefs_common.attach_desc, P_BOOL,
625          &message.chkbtn_attach_desc,
626          prefs_set_data_from_toggle, prefs_set_toggle},
627         {"attach_save_directory", NULL,
628          &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL},
629
630         /* MIME viewer */
631         {"mime_image_viewer", "display '%s'",
632          &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
633         {"mime_audio_player", "play '%s'",
634          &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
635         {"mime_open_command", "gedit '%s'",
636          &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
637
638 #if USE_GPGME
639         /* Privacy */
640         {"auto_check_signatures", "TRUE",
641          &prefs_common.auto_check_signatures, P_BOOL,
642          &privacy.checkbtn_auto_check_signatures,
643          prefs_set_data_from_toggle, prefs_set_toggle},
644         {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL,
645          &privacy.checkbtn_store_passphrase,
646          prefs_set_data_from_toggle, prefs_set_toggle},
647         {"store_passphrase_timeout", "0",
648          &prefs_common.store_passphrase_timeout, P_INT,
649          &privacy.spinbtn_store_passphrase,
650          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
651 #ifndef __MINGW32__
652         {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL,
653          &privacy.checkbtn_passphrase_grab,
654          prefs_set_data_from_toggle, prefs_set_toggle},
655 #endif /* __MINGW32__ */
656         {"gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL,
657          &privacy.checkbtn_gpg_warning,
658          prefs_set_data_from_toggle, prefs_set_toggle},
659 #endif /* USE_GPGME */
660
661         /* Interface */
662         {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
663          NULL, NULL, NULL},
664         {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
665          NULL, NULL, NULL},
666
667         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
668          NULL, NULL, NULL}, */
669         {"always_show_message_when_selected", "FALSE",
670          &prefs_common.always_show_msg,
671          P_BOOL, &interface.checkbtn_always_show_msg,
672          prefs_set_data_from_toggle, prefs_set_toggle},
673         {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
674          P_BOOL, &interface.checkbtn_openunread,
675          prefs_set_data_from_toggle, prefs_set_toggle},
676         {"mark_as_read_on_new_window", "FALSE",
677          &prefs_common.mark_as_read_on_new_window,
678          P_BOOL, &interface.checkbtn_mark_as_read_on_newwin,
679          prefs_set_data_from_toggle, prefs_set_toggle},
680         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
681          P_BOOL, &interface.checkbtn_openinbox,
682          prefs_set_data_from_toggle, prefs_set_toggle},
683         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
684          &interface.checkbtn_immedexec,
685          prefs_set_data_from_toggle, prefs_set_toggle},
686         {"nextunreadmsg_dialog", NULL, &prefs_common.next_unread_msg_dialog, P_ENUM,
687          &interface.optmenu_nextunreadmsgdialog,
688          prefs_nextunreadmsgdialog_set_data_from_optmenu,
689          prefs_nextunreadmsgdialog_set_optmenu},
690
691         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
692          &prefs_common.pixmap_theme_path, P_STRING,
693          NULL, NULL, NULL},
694
695         {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
696          NULL, NULL, NULL},
697         
698         /* Other */
699         {"uri_open_command", DEFAULT_BROWSER_CMD,
700          &prefs_common.uri_cmd, P_STRING, NULL, NULL, NULL},
701         {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING,
702          NULL, NULL, NULL},
703         {"ext_editor_command", "gedit %s",
704          &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
705
706         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
707          P_BOOL, &other.checkbtn_addaddrbyclick,
708          prefs_set_data_from_toggle, prefs_set_toggle},
709
710         {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
711          &other.checkbtn_confonexit,
712          prefs_set_data_from_toggle, prefs_set_toggle},
713         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
714          &other.checkbtn_cleanonexit,
715          prefs_set_data_from_toggle, prefs_set_toggle},
716         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
717          &other.checkbtn_askonclean,
718          prefs_set_data_from_toggle, prefs_set_toggle},
719         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
720          P_BOOL, &other.checkbtn_warnqueued,
721          prefs_set_data_from_toggle, prefs_set_toggle},
722 #if 0
723 #ifdef USE_OPENSSL
724         {"ssl_ask_unknown_valid", "TRUE", &prefs_common.ssl_ask_unknown_valid,
725          P_BOOL, &other.checkbtn_ssl_ask_unknown_valid,
726          prefs_set_data_from_toggle, prefs_set_toggle},
727 #endif
728 #endif
729         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
730          NULL, NULL, NULL},
731         {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
732          NULL, NULL, NULL},
733         {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
734          NULL, NULL, NULL},
735
736         {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
737          P_INT, &other.spinbtn_iotimeout,
738          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
739         {"hide_score", "-9999", &prefs_common.kill_score, P_INT,
740          NULL, NULL, NULL},
741         {"important_score", "1", &prefs_common.important_score, P_INT,
742          NULL, NULL, NULL},
743         {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
744          &other.checkbtn_cliplog,
745          prefs_set_data_from_toggle, prefs_set_toggle},
746         {"log_length", "500", &prefs_common.loglength, P_INT,
747          &other.loglength_entry,
748          prefs_set_data_from_entry, prefs_set_entry},
749
750         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
751          NULL, NULL, NULL},
752         {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
753          NULL, NULL, NULL},
754
755         {"color_new", "179", &prefs_common.color_new, P_COLOR,
756          NULL, NULL, NULL},
757
758         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
759 };
760
761 /* widget creating functions */
762 static void prefs_common_create         (void);
763 static void prefs_receive_create        (void);
764 static void prefs_send_create           (void);
765 static void prefs_compose_create        (void);
766 static void prefs_quote_create          (void);
767 static void prefs_display_create        (void);
768 static void prefs_message_create        (void);
769 #if USE_GPGME
770 static void prefs_privacy_create        (void);
771 #endif
772 static void prefs_interface_create      (void);
773 static void prefs_other_create          (void);
774
775 static void date_format_ok_btn_clicked          (GtkButton      *button,
776                                                  GtkWidget     **widget);
777 static void date_format_cancel_btn_clicked      (GtkButton      *button,
778                                                  GtkWidget     **widget);
779 static gboolean date_format_key_pressed         (GtkWidget      *keywidget,
780                                                  GdkEventKey    *event,
781                                                  GtkWidget     **widget);
782 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
783                                                  GdkEventAny    *event,
784                                                  GtkWidget     **widget);
785 static void date_format_entry_on_change         (GtkEditable    *editable,
786                                                  GtkLabel       *example);
787 static void date_format_select_row              (GtkWidget      *date_format_list,
788                                                  gint            row,
789                                                  gint            column,
790                                                  GdkEventButton *event,
791                                                  GtkWidget      *date_format);
792 static GtkWidget *date_format_create            (GtkButton      *button,
793                                                  void           *data);
794
795 static void prefs_keybind_select                (void);
796 static gint prefs_keybind_deleted               (GtkWidget      *widget,
797                                                  GdkEventAny    *event,
798                                                  gpointer        data);
799 static gboolean prefs_keybind_key_pressed       (GtkWidget      *widget,
800                                                  GdkEventKey    *event,
801                                                  gpointer        data);
802 static void prefs_keybind_cancel                (void);
803 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
804
805 static gint prefs_common_deleted        (GtkWidget      *widget,
806                                          GdkEventAny    *event,
807                                          gpointer        data);
808 static gboolean prefs_common_key_pressed(GtkWidget      *widget,
809                                          GdkEventKey    *event,
810                                          gpointer        data);
811 static void prefs_common_ok             (void);
812 static void prefs_common_apply          (void);
813 static void prefs_common_cancel         (void);
814
815 void prefs_common_init(void) 
816 {
817         prefs_common.disphdr_list = NULL;
818 }
819
820 PrefsCommon *prefs_common_get(void)
821 {
822         return &prefs_common;
823 }
824
825 /*
826  * Read history list from the specified history file
827  */
828 GList *prefs_common_read_history(const gchar *history) 
829 {
830         FILE *fp;
831         gchar *path;
832         gchar buf[PREFSBUFSIZE];
833         GList *tmp = NULL;
834
835         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
836                            NULL);
837         if ((fp = fopen(path, "rb")) == NULL) {
838                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
839                 g_free(path);
840                 return NULL;
841         }
842         g_free(path);
843         while (fgets(buf, sizeof(buf), fp) != NULL) {
844                 g_strstrip(buf);
845                 if (buf[0] == '\0') continue;
846                 tmp = add_history(tmp, buf);
847         }
848         fclose(fp);
849
850         tmp = g_list_reverse(tmp);
851
852         return tmp;
853 }
854
855 void prefs_common_read_config(void)
856 {
857         prefs_read_config(param, "Common", COMMON_RC);
858
859         prefs_common.mime_open_cmd_history =
860                 prefs_common_read_history(COMMAND_HISTORY);
861         prefs_common.summary_quicksearch_history =
862                 prefs_common_read_history(QUICKSEARCH_HISTORY);
863 }
864
865 /*
866  * Save history list to the specified history file
867  */
868 void prefs_common_save_history(const gchar *history, GList *list)
869 {
870         GList *cur;
871         FILE *fp;
872         gchar *path;
873
874         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
875                            NULL);
876         if ((fp = fopen(path, "wb")) == NULL) {
877                 FILE_OP_ERROR(path, "fopen");
878                 g_free(path);
879                 return;
880         }
881
882         for (cur = list; cur != NULL; cur = cur->next) {
883                 fputs((gchar *)cur->data, fp);
884                 fputc('\n', fp);
885         }
886
887         fclose(fp);
888         g_free(path);
889 }
890
891 void prefs_common_write_config(void)
892 {
893         prefs_write_config(param, "Common", COMMON_RC);
894
895         prefs_common_save_history(COMMAND_HISTORY, 
896                 prefs_common.mime_open_cmd_history);
897         prefs_common_save_history(QUICKSEARCH_HISTORY, 
898                 prefs_common.summary_quicksearch_history);
899 }
900
901 void prefs_common_open(void)
902 {
903         if (prefs_rc_is_readonly(COMMON_RC))
904                 return;
905
906         inc_lock();
907
908         if (!dialog.window) {
909                 prefs_common_create();
910         }
911
912         manage_window_set_transient(GTK_WINDOW(dialog.window));
913         gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
914         gtk_widget_grab_focus(dialog.ok_btn);
915
916         prefs_set_dialog(param);
917
918         gtk_widget_show(dialog.window);
919 }
920
921 static void prefs_common_create(void)
922 {
923         gint page = 0;
924
925         debug_print("Creating common preferences window...\n");
926
927         prefs_dialog_create(&dialog);
928         gtk_window_set_title (GTK_WINDOW(dialog.window),
929                               _("Common Preferences"));
930         g_signal_connect (G_OBJECT(dialog.window), "delete_event",
931                           G_CALLBACK(prefs_common_deleted), NULL);
932         g_signal_connect (G_OBJECT(dialog.window), "key_press_event",
933                           G_CALLBACK(prefs_common_key_pressed), NULL);
934         MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
935
936         g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
937                           G_CALLBACK(prefs_common_ok), NULL);
938         g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
939                           G_CALLBACK(prefs_common_apply), NULL);
940         g_signal_connect_swapped(G_OBJECT(dialog.cancel_btn), "clicked",
941                                  G_CALLBACK(prefs_common_cancel),
942                                  G_OBJECT(dialog.window));
943
944         /* create all widgets on notebook */
945         prefs_receive_create();
946         SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
947         prefs_send_create();
948         SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
949         prefs_compose_create();
950         SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
951         prefs_quote_create();
952         SET_NOTEBOOK_LABEL(dialog.notebook, _("Quote"),   page++);
953         prefs_display_create();
954         SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
955         prefs_message_create();
956         SET_NOTEBOOK_LABEL(dialog.notebook, _("Message"),   page++);
957 #if USE_GPGME
958         prefs_privacy_create();
959         SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"),   page++);
960 #endif
961         prefs_interface_create();
962         SET_NOTEBOOK_LABEL(dialog.notebook, _("Interface"), page++);
963         prefs_other_create();
964         SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"),     page++);
965
966         gtk_widget_show_all(dialog.window);
967 }
968
969 static void prefs_receive_create(void)
970 {
971         GtkWidget *vbox1;
972         GtkWidget *vbox2;
973         GtkWidget *frame_incext;
974         GtkWidget *checkbtn_incext;
975         GtkWidget *hbox;
976         GtkWidget *label_incext;
977         GtkWidget *entry_incext;
978         /* GtkWidget *button_incext; */
979
980         GtkWidget *hbox_autochk;
981         GtkWidget *checkbtn_autochk;
982         GtkWidget *label_autochk1;
983         GtkObject *spinbtn_autochk_adj;
984         GtkWidget *spinbtn_autochk;
985         GtkWidget *label_autochk2;
986         GtkWidget *checkbtn_chkonstartup;
987         GtkWidget *checkbtn_scan_after_inc;
988
989
990         GtkWidget *frame_newmail;
991         GtkWidget *hbox_newmail_notify;
992         GtkWidget *checkbtn_newmail_auto;
993         GtkWidget *checkbtn_newmail_manu;
994         GtkWidget *entry_newmail_notify_cmd;
995         GtkWidget *label_newmail_notify_cmd;
996
997         GtkWidget *hbox_recvdialog;
998         GtkWidget *label_recvdialog;
999         GtkWidget *menu;
1000         GtkWidget *menuitem;
1001         GtkWidget *optmenu_recvdialog;
1002         GtkWidget *checkbtn_no_recv_err_panel;
1003         GtkWidget *checkbtn_close_recv_dialog;
1004
1005         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1006         gtk_widget_show (vbox1);
1007         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1008         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1009
1010         PACK_FRAME(vbox1, frame_incext, _("External program"));
1011
1012         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1013         gtk_widget_show (vbox2);
1014         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
1015         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1016
1017         /* Use of external incorporation program */
1018         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
1019                            _("Use external program for incorporation"));
1020
1021         hbox = gtk_hbox_new (FALSE, 8);
1022         gtk_widget_show (hbox);
1023         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1024         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
1025
1026         label_incext = gtk_label_new (_("Command"));
1027         gtk_widget_show (label_incext);
1028         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
1029
1030         entry_incext = gtk_entry_new ();
1031         gtk_widget_show (entry_incext);
1032         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
1033
1034 #if 0
1035         button_incext = gtk_button_new_with_label ("... ");
1036         gtk_widget_show (button_incext);
1037         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1038 #endif
1039
1040         vbox2 = gtk_vbox_new (FALSE, 0);
1041         gtk_widget_show (vbox2);
1042         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1043
1044         /* Auto-checking */
1045         hbox_autochk = gtk_hbox_new (FALSE, 8);
1046         gtk_widget_show (hbox_autochk);
1047         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1048
1049         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1050                            _("Auto-check new mail"));
1051
1052         label_autochk1 = gtk_label_new (_("every"));
1053         gtk_widget_show (label_autochk1);
1054         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1055
1056         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1057         spinbtn_autochk = gtk_spin_button_new
1058                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1059         gtk_widget_show (spinbtn_autochk);
1060         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1061         gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
1062         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1063
1064         label_autochk2 = gtk_label_new (_("minute(s)"));
1065         gtk_widget_show (label_autochk2);
1066         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1067
1068         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1069         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1070         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1071
1072         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1073                            _("Check new mail on startup"));
1074         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1075                            _("Update all local folders after incorporation"));
1076
1077
1078         /* receive dialog */
1079         hbox_recvdialog = gtk_hbox_new (FALSE, 8);
1080         gtk_widget_show (hbox_recvdialog);
1081         gtk_box_pack_start (GTK_BOX (vbox2), hbox_recvdialog, FALSE, FALSE, 0);
1082
1083         label_recvdialog = gtk_label_new (_("Show receive dialog"));
1084         gtk_misc_set_alignment(GTK_MISC(label_recvdialog), 0, 0.5);
1085         gtk_widget_show (label_recvdialog);
1086         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), label_recvdialog, FALSE, FALSE, 0);
1087
1088         optmenu_recvdialog = gtk_option_menu_new ();
1089         gtk_widget_show (optmenu_recvdialog);
1090         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), optmenu_recvdialog, FALSE, FALSE, 0);
1091
1092         menu = gtk_menu_new ();
1093         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
1094         MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
1095                       RECV_DIALOG_MANUAL);
1096         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
1097
1098         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
1099
1100         PACK_CHECK_BUTTON (vbox2, checkbtn_no_recv_err_panel,
1101                            _("Don't popup error dialog on receive error"));
1102
1103         PACK_CHECK_BUTTON (vbox2, checkbtn_close_recv_dialog,
1104                            _("Close receive dialog when finished"));
1105         
1106         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1107                                            "arrives"));
1108         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1109         gtk_widget_show (vbox2);
1110         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1111         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1112
1113         hbox = gtk_hbox_new (TRUE, 8);
1114         gtk_widget_show (hbox);
1115         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1116                            _("after autochecking"));
1117         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1118                            _("after manual checking"));
1119         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1120         g_signal_connect(G_OBJECT(checkbtn_newmail_auto), "toggled",
1121                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1122                          NULL);
1123         g_signal_connect(G_OBJECT(checkbtn_newmail_manu), "toggled",
1124                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1125                          NULL);
1126
1127         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1128         gtk_widget_show (hbox);
1129         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1130                             FALSE, 0);
1131
1132         label_newmail_notify_cmd = gtk_label_new (_("Command to execute:\n"
1133                                                     "(use %d as number of new "
1134                                                     "mails)"));
1135         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1136                               GTK_JUSTIFY_RIGHT);
1137         gtk_widget_show (label_newmail_notify_cmd);
1138         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1139                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1140
1141         entry_newmail_notify_cmd = gtk_entry_new ();
1142         gtk_widget_show (entry_newmail_notify_cmd);
1143         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1144                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1145
1146         gtk_widget_set_sensitive(hbox_newmail_notify, 
1147                                  prefs_common.newmail_notify_auto || 
1148                                  prefs_common.newmail_notify_manu);
1149
1150         receive.checkbtn_incext = checkbtn_incext;
1151         receive.entry_incext    = entry_incext;
1152         /* receive.button_incext   = button_incext; */
1153
1154         receive.checkbtn_autochk    = checkbtn_autochk;
1155         receive.spinbtn_autochk     = spinbtn_autochk;
1156         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1157
1158         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1159         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1160
1161
1162         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1163         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1164         receive.hbox_newmail_notify    = hbox_newmail_notify;
1165         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1166         receive.optmenu_recvdialog          = optmenu_recvdialog;
1167         receive.checkbtn_no_recv_err_panel  = checkbtn_no_recv_err_panel;
1168         receive.checkbtn_close_recv_dialog  = checkbtn_close_recv_dialog;
1169 }
1170
1171 static void prefs_send_create(void)
1172 {
1173         GtkWidget *vbox1;
1174         GtkWidget *vbox2;
1175         GtkWidget *hbox1;
1176         GtkWidget *checkbtn_savemsg;
1177         GtkWidget *label_outcharset;
1178         GtkWidget *optmenu_charset;
1179         GtkWidget *optmenu_menu;
1180         GtkWidget *menuitem;
1181         GtkTooltips *charset_tooltip;
1182         GtkWidget *optmenu_encoding;
1183         GtkWidget *label_encoding;
1184         GtkTooltips *encoding_tooltip;
1185         GtkWidget *label_senddialog;
1186         GtkWidget *menu;
1187         GtkWidget *optmenu_senddialog;
1188         GtkWidget *hbox_senddialog;
1189
1190         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1191         gtk_widget_show (vbox1);
1192         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1193         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1194
1195         vbox2 = gtk_vbox_new (FALSE, 0);
1196         gtk_widget_show (vbox2);
1197         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1198
1199         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1200                            _("Save sent messages to Sent folder"));
1201
1202         hbox_senddialog = gtk_hbox_new (FALSE, 8);
1203         gtk_box_pack_start (GTK_BOX (vbox1), hbox_senddialog, FALSE, FALSE, 0);
1204
1205         label_senddialog = gtk_label_new (_("Show send dialog"));
1206         gtk_widget_show (label_senddialog);
1207         gtk_box_pack_start (GTK_BOX (hbox_senddialog), label_senddialog, FALSE, FALSE, 0);
1208
1209         optmenu_senddialog = gtk_option_menu_new ();
1210         gtk_widget_show (optmenu_senddialog);
1211         gtk_box_pack_start (GTK_BOX (hbox_senddialog), optmenu_senddialog, FALSE, FALSE, 0);
1212         
1213         menu = gtk_menu_new ();
1214         MENUITEM_ADD (menu, menuitem, _("Always"), SEND_DIALOG_ALWAYS);
1215         MENUITEM_ADD (menu, menuitem, _("Never"), SEND_DIALOG_NEVER);
1216
1217         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_senddialog), menu);
1218
1219         hbox1 = gtk_hbox_new (FALSE, 8);
1220         gtk_widget_show (hbox1);
1221         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1222
1223         label_outcharset = gtk_label_new (_("Outgoing codeset"));
1224         gtk_widget_show (label_outcharset);
1225         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1226
1227         charset_tooltip = gtk_tooltips_new();
1228
1229         optmenu_charset = gtk_option_menu_new ();
1230         gtk_widget_show (optmenu_charset);
1231         gtk_tooltips_set_tip(GTK_TOOLTIPS(charset_tooltip), optmenu_charset,
1232                              _("If `Automatic' is selected, the optimal encoding"
1233                                " for the current locale will be used"),
1234                              NULL);
1235         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_charset, FALSE, FALSE, 0);
1236
1237         optmenu_menu = gtk_menu_new ();
1238
1239 #define SET_MENUITEM(str, data) \
1240 { \
1241         MENUITEM_ADD(optmenu_menu, menuitem, str, data); \
1242 }
1243
1244         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1245         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1246 #if HAVE_ICONV
1247         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1248 #endif
1249         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1250         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1251         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1252         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1253         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1254         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1255         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1256 #if HAVE_ICONV
1257         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1258 #endif
1259         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1260 #if HAVE_ICONV
1261         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1262         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1263 #endif
1264         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1265 #if 0
1266         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1267         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1268 #endif /* 0 */
1269         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1270         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1271 #if 0
1272         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1273         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1274 #endif /* 0 */
1275         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1276         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1277         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1278
1279         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_charset),
1280                                   optmenu_menu);
1281
1282         hbox1 = gtk_hbox_new (FALSE, 8);
1283         gtk_widget_show (hbox1);
1284         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1285
1286         hbox1 = gtk_hbox_new (FALSE, 8);
1287         gtk_widget_show (hbox1);
1288         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1289
1290         label_encoding = gtk_label_new (_("Transfer encoding"));
1291         gtk_widget_show (label_encoding);
1292         gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1293
1294         encoding_tooltip = gtk_tooltips_new();
1295
1296         optmenu_encoding = gtk_option_menu_new ();
1297         gtk_widget_show (optmenu_encoding);
1298         gtk_tooltips_set_tip(GTK_TOOLTIPS(encoding_tooltip), optmenu_encoding,
1299                              _("Specify Content-Transfer-Encoding used when"
1300                                " message body contains non-ASCII characters"),
1301                              NULL);
1302         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_encoding, FALSE, FALSE, 0);
1303
1304         optmenu_menu = gtk_menu_new ();
1305
1306         SET_MENUITEM(_("Automatic"),     CTE_AUTO);
1307         SET_MENUITEM("base64",           CTE_BASE64);
1308         SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1309         SET_MENUITEM("8bit",             CTE_8BIT);
1310
1311         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_encoding),
1312                                   optmenu_menu);
1313
1314         hbox1 = gtk_hbox_new (FALSE, 8);
1315         gtk_widget_show (hbox1);
1316         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1317
1318         p_send.checkbtn_savemsg  = checkbtn_savemsg;
1319         p_send.optmenu_senddialog = optmenu_senddialog;
1320
1321         p_send.optmenu_charset = optmenu_charset;
1322         p_send.optmenu_encoding_method = optmenu_encoding;
1323 }
1324
1325 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1326 {
1327         gboolean toggled;
1328
1329         toggled = gtk_toggle_button_get_active
1330                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1331                   gtk_toggle_button_get_active
1332                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1333         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1334 }
1335
1336 static void prefs_compose_create(void)
1337 {
1338         GtkWidget *vbox1;
1339         GtkWidget *vbox2;
1340
1341         GtkWidget *checkbtn_autoextedit;
1342
1343         GtkWidget *frame_autosel;
1344         GtkWidget *hbox_autosel;
1345         GtkWidget *checkbtn_reply_account_autosel;
1346         GtkWidget *checkbtn_forward_account_autosel;
1347         GtkWidget *checkbtn_reedit_account_autosel;
1348
1349         GtkWidget *hbox_undolevel;
1350         GtkWidget *label_undolevel;
1351         GtkObject *spinbtn_undolevel_adj;
1352         GtkWidget *spinbtn_undolevel;
1353
1354         GtkWidget *hbox5;
1355
1356         GtkWidget *checkbtn_default_reply_list;
1357
1358         GtkWidget *checkbtn_forward_as_attachment;
1359         GtkWidget *checkbtn_redirect_keep_from;
1360
1361         GtkWidget *hbox_autosave;
1362         GtkWidget *checkbtn_autosave;
1363         GtkWidget *entry_autosave_length;
1364         GtkWidget *label_autosave_length;
1365         
1366         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1367         gtk_widget_show (vbox1);
1368         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1369         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1370
1371         /* Account autoselection */
1372         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1373
1374         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1375         gtk_widget_show (hbox_autosel);
1376         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1377         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1378
1379         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1380                            _("when replying"));
1381         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1382                            _("when forwarding"));
1383         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1384                            _("when re-editing"));
1385
1386         vbox2 = gtk_vbox_new (FALSE, 0);
1387         gtk_widget_show (vbox2);
1388         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1389
1390         PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1391                            _("Reply button invokes mailing list reply"));
1392
1393         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1394                            _("Automatically launch the external editor"));
1395
1396         hbox5 = gtk_hbox_new (FALSE, 8);
1397         gtk_widget_show (hbox5);
1398         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1399
1400         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1401                            _("Forward as attachment"));
1402
1403         PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from,
1404                            _("Keep the original 'From' header when redirecting"));
1405
1406         
1407         hbox_autosave = gtk_hbox_new (FALSE, 8);
1408         gtk_widget_show (hbox_autosave);
1409         gtk_box_pack_start (GTK_BOX (vbox1), hbox_autosave, FALSE, FALSE, 0);
1410         
1411         PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1412                            _("Autosave to Drafts folder every "));
1413
1414         entry_autosave_length = gtk_entry_new();
1415         gtk_widget_set_size_request (entry_autosave_length, 64, -1);    
1416         gtk_widget_show (entry_autosave_length);
1417         gtk_box_pack_start (GTK_BOX (hbox_autosave), entry_autosave_length, FALSE, FALSE, 0);
1418         
1419         label_autosave_length = gtk_label_new(_("characters"));
1420         gtk_widget_show (label_autosave_length);
1421         gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave_length, FALSE, FALSE, 0);
1422         
1423         hbox_undolevel = gtk_hbox_new (FALSE, 8);
1424         gtk_widget_show (hbox_undolevel);
1425         gtk_box_pack_start (GTK_BOX (vbox1), hbox_undolevel, FALSE, FALSE, 0);
1426
1427         label_undolevel = gtk_label_new (_("Undo level"));
1428         gtk_widget_show (label_undolevel);
1429         gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
1430
1431         spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1432         spinbtn_undolevel = gtk_spin_button_new
1433                 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1434         gtk_widget_show (spinbtn_undolevel);
1435         gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
1436         gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1437         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1438
1439        /*
1440         compose.checkbtn_quote   = checkbtn_quote;
1441         compose.entry_quotemark  = entry_quotemark;
1442         compose.text_quotefmt    = text_quotefmt;
1443         */
1444
1445         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1446
1447         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1448         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1449         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1450
1451         compose.spinbtn_undolevel     = spinbtn_undolevel;
1452         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1453
1454         compose.checkbtn_autosave     = checkbtn_autosave;
1455         compose.entry_autosave_length = entry_autosave_length;
1456         
1457         compose.checkbtn_forward_as_attachment =
1458                 checkbtn_forward_as_attachment;
1459         compose.checkbtn_redirect_keep_from =
1460                 checkbtn_redirect_keep_from;
1461         compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1462 }
1463
1464 static void prefs_quote_create(void)
1465 {
1466         GtkWidget *vbox1;
1467         GtkWidget *frame_quote;
1468         GtkWidget *vbox_quote;
1469         GtkWidget *hbox1;
1470         GtkWidget *hbox2;
1471         GtkWidget *label_quotemark;
1472         GtkWidget *entry_quotemark;
1473         GtkWidget *scrolledwin_quotefmt;
1474         GtkWidget *text_quotefmt;
1475
1476         GtkWidget *entry_fw_quotemark;
1477         GtkWidget *text_fw_quotefmt;
1478
1479         GtkWidget *entry_quote_chars;
1480         GtkWidget *label_quote_chars;
1481         
1482         GtkWidget *btn_quotedesc;
1483
1484         GtkWidget *checkbtn_reply_with_quote;
1485
1486         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1487         gtk_widget_show (vbox1);
1488         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1489         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1490
1491         /* reply */
1492
1493         PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
1494
1495         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1496
1497         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1498         gtk_widget_show (vbox_quote);
1499         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1500         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1501
1502         hbox1 = gtk_hbox_new (FALSE, 32);
1503         gtk_widget_show (hbox1);
1504         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1505
1506         hbox2 = gtk_hbox_new (FALSE, 8);
1507         gtk_widget_show (hbox2);
1508         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1509
1510         label_quotemark = gtk_label_new (_("Quotation mark"));
1511         gtk_widget_show (label_quotemark);
1512         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1513
1514         entry_quotemark = gtk_entry_new ();
1515         gtk_widget_show (entry_quotemark);
1516         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1517         gtk_widget_set_size_request (entry_quotemark, 64, -1);
1518
1519         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1520         gtk_widget_show (scrolledwin_quotefmt);
1521         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1522         gtk_scrolled_window_set_policy
1523                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1524                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1525
1526         text_quotefmt = gtk_text_view_new ();
1527         gtk_widget_show (text_quotefmt);
1528         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1529         gtk_text_view_set_editable (GTK_TEXT_VIEW(text_quotefmt), TRUE);
1530         gtk_widget_set_size_request(text_quotefmt, -1, 60);
1531
1532         /* forward */
1533
1534         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1535
1536         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1537         gtk_widget_show (vbox_quote);
1538         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1539         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1540
1541         hbox1 = gtk_hbox_new (FALSE, 32);
1542         gtk_widget_show (hbox1);
1543         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1544
1545         hbox2 = gtk_hbox_new (FALSE, 8);
1546         gtk_widget_show (hbox2);
1547         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1548
1549         label_quotemark = gtk_label_new (_("Quotation mark"));
1550         gtk_widget_show (label_quotemark);
1551         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1552
1553         entry_fw_quotemark = gtk_entry_new ();
1554         gtk_widget_show (entry_fw_quotemark);
1555         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1556                             FALSE, FALSE, 0);
1557         gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1558
1559         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1560         gtk_widget_show (scrolledwin_quotefmt);
1561         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1562         gtk_scrolled_window_set_policy
1563                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1564                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1565
1566         text_fw_quotefmt = gtk_text_view_new ();
1567         gtk_widget_show (text_fw_quotefmt);
1568         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1569                           text_fw_quotefmt);
1570         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1571         gtk_widget_set_size_request(text_fw_quotefmt, -1, 60);
1572
1573         hbox1 = gtk_hbox_new (FALSE, 32);
1574         gtk_widget_show (hbox1);
1575         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1576
1577         btn_quotedesc =
1578                 gtk_button_new_with_label (_(" Description of symbols "));
1579         gtk_widget_show (btn_quotedesc);
1580         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1581         g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1582                          G_CALLBACK(quote_fmt_quote_description), NULL);
1583
1584         /* quote chars */
1585
1586         PACK_FRAME (vbox1, frame_quote, _("Quotation characters"));
1587
1588         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1589         gtk_widget_show (vbox_quote);
1590         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1591         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1592
1593         hbox1 = gtk_hbox_new (FALSE, 32);
1594         gtk_widget_show (hbox1);
1595         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1596
1597         hbox2 = gtk_hbox_new (FALSE, 8);
1598         gtk_widget_show (hbox2);
1599         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1600
1601         label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks: "));
1602         gtk_widget_show (label_quote_chars);
1603         gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
1604
1605         entry_quote_chars = gtk_entry_new ();
1606         gtk_widget_show (entry_quote_chars);
1607         gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
1608                             FALSE, FALSE, 0);
1609         gtk_widget_set_size_request (entry_quote_chars, 64, -1);
1610
1611
1612         compose.checkbtn_reply_with_quote= checkbtn_reply_with_quote;
1613         quote.entry_quotemark    = entry_quotemark;
1614         quote.text_quotefmt      = text_quotefmt;
1615         quote.entry_fw_quotemark = entry_fw_quotemark;
1616         quote.text_fw_quotefmt   = text_fw_quotefmt;
1617         quote.entry_quote_chars  = entry_quote_chars;
1618 }
1619
1620 static void prefs_display_create(void)
1621 {
1622         GtkWidget *vbox1;
1623         GtkWidget *chkbtn_transhdr;
1624         GtkWidget *chkbtn_folder_unread;
1625         GtkWidget *hbox1;
1626         GtkWidget *label_ng_abbrev;
1627         GtkWidget *spinbtn_ng_abbrev_len;
1628         GtkObject *spinbtn_ng_abbrev_len_adj;
1629         GtkWidget *frame_summary;
1630         GtkWidget *vbox2;
1631         GtkWidget *chkbtn_swapfrom;
1632         GtkWidget *chkbtn_useaddrbook;
1633         GtkWidget *chkbtn_threadsubj;
1634         GtkWidget *vbox3;
1635         GtkWidget *label_datefmt;
1636         GtkWidget *button_datefmt;
1637         GtkWidget *entry_datefmt;
1638         GtkWidget *button_dispitem;
1639
1640         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1641         gtk_widget_show (vbox1);
1642         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1643         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1644
1645         vbox2 = gtk_vbox_new (FALSE, 0);
1646         gtk_widget_show (vbox2);
1647         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
1648
1649         PACK_CHECK_BUTTON
1650                 (vbox2, chkbtn_transhdr,
1651                  _("Translate header name (such as `From:', `Subject:')"));
1652
1653         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1654                            _("Display unread number next to folder name"));
1655
1656         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1657
1658         hbox1 = gtk_hbox_new (FALSE, 8);
1659         gtk_widget_show (hbox1);
1660         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1661
1662         label_ng_abbrev = gtk_label_new
1663                 (_("Abbreviate newsgroup names longer than"));
1664         gtk_widget_show (label_ng_abbrev);
1665         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1666
1667         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
1668         spinbtn_ng_abbrev_len = gtk_spin_button_new
1669                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1670         gtk_widget_show (spinbtn_ng_abbrev_len);
1671         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1672                             FALSE, FALSE, 0);
1673         gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1674         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1675                                      TRUE);
1676
1677         label_ng_abbrev = gtk_label_new
1678                 (_("letters"));
1679         gtk_widget_show (label_ng_abbrev);
1680         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1681
1682         /* ---- Summary ---- */
1683
1684         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
1685
1686         vbox2 = gtk_vbox_new (FALSE, 0);
1687         gtk_widget_show (vbox2);
1688         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1689         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1690
1691         PACK_CHECK_BUTTON
1692                 (vbox2, chkbtn_swapfrom,
1693                  _("Display recipient in `From' column if sender is yourself"));
1694         PACK_CHECK_BUTTON
1695                 (vbox2, chkbtn_useaddrbook,
1696                  _("Display sender using address book"));
1697         PACK_CHECK_BUTTON
1698                 (vbox2, chkbtn_threadsubj,
1699                  _("Thread using subject in addition to standard headers"));
1700
1701         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1702
1703         hbox1 = gtk_hbox_new (FALSE, 8);
1704         gtk_widget_show (hbox1);
1705         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1706
1707         label_datefmt = gtk_label_new (_("Date format"));
1708         gtk_widget_show (label_datefmt);
1709         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1710
1711         entry_datefmt = gtk_entry_new ();
1712         gtk_widget_show (entry_datefmt);
1713         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1714
1715         button_datefmt = gtk_button_new_with_label (" ... ");
1716
1717         gtk_widget_show (button_datefmt);
1718         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1719         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1720                           G_CALLBACK (date_format_create), NULL);
1721
1722         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1723
1724         hbox1 = gtk_hbox_new (FALSE, 8);
1725         gtk_widget_show (hbox1);
1726         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1727
1728         button_dispitem = gtk_button_new_with_label
1729                 (_(" Set displayed items in summary... "));
1730         gtk_widget_show (button_dispitem);
1731         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1732         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1733                           G_CALLBACK (prefs_summary_column_open),
1734                           NULL);
1735
1736         display.chkbtn_transhdr           = chkbtn_transhdr;
1737         display.chkbtn_folder_unread      = chkbtn_folder_unread;
1738         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1739         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1740
1741         display.chkbtn_swapfrom      = chkbtn_swapfrom;
1742         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
1743         display.chkbtn_threadsubj    = chkbtn_threadsubj;
1744         display.entry_datefmt        = entry_datefmt;
1745 }
1746
1747 static void prefs_message_create(void)
1748 {
1749         GtkWidget *vbox1;
1750         GtkWidget *vbox2;
1751         GtkWidget *vbox3;
1752         GtkWidget *hbox1;
1753         GtkWidget *chkbtn_mbalnum;
1754         GtkWidget *chkbtn_disphdrpane;
1755         GtkWidget *chkbtn_disphdr;
1756         GtkWidget *button_edit_disphdr;
1757         GtkWidget *hbox_linespc;
1758         GtkWidget *label_linespc;
1759         GtkObject *spinbtn_linespc_adj;
1760         GtkWidget *spinbtn_linespc;
1761         GtkWidget *chkbtn_headspc;
1762
1763         GtkWidget *frame_scr;
1764         GtkWidget *vbox_scr;
1765         GtkWidget *chkbtn_smoothscroll;
1766         GtkWidget *hbox_scr;
1767         GtkWidget *label_scr;
1768         GtkObject *spinbtn_scrollstep_adj;
1769         GtkWidget *spinbtn_scrollstep;
1770         GtkWidget *chkbtn_halfpage;
1771
1772         GtkWidget *chkbtn_attach_desc;
1773
1774         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1775         gtk_widget_show (vbox1);
1776         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1777         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1778
1779         vbox2 = gtk_vbox_new (FALSE, 0);
1780         gtk_widget_show (vbox2);
1781         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1782
1783         PACK_CHECK_BUTTON
1784                 (vbox2, chkbtn_mbalnum,
1785                  _("Display multi-byte alphanumeric as\n"
1786                    "ASCII character (Japanese only)"));
1787         gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1788                                GTK_JUSTIFY_LEFT);
1789
1790         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1791                           _("Display header pane above message view"));
1792
1793         hbox1 = gtk_hbox_new (FALSE, 8);
1794         gtk_widget_show (hbox1);
1795         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1796
1797         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1798                           _("Display short headers on message view"));
1799
1800         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1801         gtk_widget_show (button_edit_disphdr);
1802         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1803                           FALSE, TRUE, 0);
1804         g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1805                           G_CALLBACK (prefs_display_header_open),
1806                           NULL);
1807
1808         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1809
1810         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1811
1812         hbox1 = gtk_hbox_new (FALSE, 32);
1813         gtk_widget_show (hbox1);
1814         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1815
1816         hbox_linespc = gtk_hbox_new (FALSE, 8);
1817         gtk_widget_show (hbox1);
1818         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1819
1820         label_linespc = gtk_label_new (_("Line space"));
1821         gtk_widget_show (label_linespc);
1822         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1823                             FALSE, FALSE, 0);
1824
1825         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
1826         spinbtn_linespc = gtk_spin_button_new
1827                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1828         gtk_widget_show (spinbtn_linespc);
1829         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1830                             FALSE, FALSE, 0);
1831         gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1832         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1833
1834         label_linespc = gtk_label_new (_("pixel(s)"));
1835         gtk_widget_show (label_linespc);
1836         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1837                             FALSE, FALSE, 0);
1838
1839         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Indent text"));
1840
1841         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1842
1843         vbox_scr = gtk_vbox_new (FALSE, 0);
1844         gtk_widget_show (vbox_scr);
1845         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1846         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1847
1848         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1849
1850         hbox1 = gtk_hbox_new (FALSE, 32);
1851         gtk_widget_show (hbox1);
1852         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1853
1854         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1855
1856         hbox_scr = gtk_hbox_new (FALSE, 8);
1857         gtk_widget_show (hbox_scr);
1858         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
1859
1860         label_scr = gtk_label_new (_("Step"));
1861         gtk_widget_show (label_scr);
1862         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1863
1864         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
1865         spinbtn_scrollstep = gtk_spin_button_new
1866                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
1867         gtk_widget_show (spinbtn_scrollstep);
1868         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
1869                             FALSE, FALSE, 0);
1870         gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
1871         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
1872                                      TRUE);
1873
1874         label_scr = gtk_label_new (_("pixel(s)"));
1875         gtk_widget_show (label_scr);
1876         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1877
1878         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
1879
1880         vbox3 = gtk_vbox_new (FALSE, 0);
1881         gtk_widget_show (vbox3);
1882         gtk_box_pack_start (GTK_BOX (vbox1), vbox3, FALSE, FALSE, 0);
1883
1884         PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
1885                           _("Show attachment descriptions (rather than names)"));
1886
1887         message.chkbtn_mbalnum     = chkbtn_mbalnum;
1888         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
1889         message.chkbtn_disphdr     = chkbtn_disphdr;
1890         message.spinbtn_linespc    = spinbtn_linespc;
1891         message.chkbtn_headspc     = chkbtn_headspc;
1892
1893         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
1894         message.spinbtn_scrollstep     = spinbtn_scrollstep;
1895         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
1896         message.chkbtn_halfpage        = chkbtn_halfpage;
1897
1898         message.chkbtn_attach_desc  = chkbtn_attach_desc;
1899 }
1900
1901 #if USE_GPGME
1902 static void prefs_privacy_create(void)
1903 {
1904         GtkWidget *vbox1;
1905         GtkWidget *vbox2;
1906         GtkWidget *vbox3;
1907         GtkWidget *hbox1;
1908         GtkWidget *hbox_spc;
1909         GtkWidget *label;
1910         GtkWidget *checkbtn_auto_check_signatures;
1911         GtkWidget *checkbtn_store_passphrase;
1912         GtkObject *spinbtn_store_passphrase_adj;
1913         GtkWidget *spinbtn_store_passphrase;
1914         GtkTooltips *store_tooltip;
1915         GtkWidget *checkbtn_passphrase_grab;
1916         GtkWidget *checkbtn_gpg_warning;
1917
1918         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1919         gtk_widget_show (vbox1);
1920         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1921         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1922
1923         vbox2 = gtk_vbox_new (FALSE, 0);
1924         gtk_widget_show (vbox2);
1925         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1926
1927         PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
1928                            _("Automatically check signatures"));
1929
1930         PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
1931                            _("Store passphrase in memory temporarily"));
1932
1933         vbox3 = gtk_vbox_new (FALSE, 0);
1934         gtk_widget_show (vbox3);
1935         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
1936
1937         hbox1 = gtk_hbox_new (FALSE, 8);
1938         gtk_widget_show (hbox1);
1939         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1940
1941         hbox_spc = gtk_hbox_new (FALSE, 0);
1942         gtk_widget_show (hbox_spc);
1943         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1944         gtk_widget_set_size_request (hbox_spc, 12, -1);
1945
1946         label = gtk_label_new (_("Expire after"));
1947         gtk_widget_show (label);
1948         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1949
1950         store_tooltip = gtk_tooltips_new();
1951
1952         spinbtn_store_passphrase_adj = gtk_adjustment_new (0, 0, 1440, 1, 5, 5);
1953         spinbtn_store_passphrase = gtk_spin_button_new
1954                 (GTK_ADJUSTMENT (spinbtn_store_passphrase_adj), 1, 0);
1955         gtk_widget_show (spinbtn_store_passphrase);
1956         gtk_tooltips_set_tip(GTK_TOOLTIPS(store_tooltip), spinbtn_store_passphrase,
1957                              _("Setting to '0' will store the passphrase"
1958                                " for the whole session"),
1959                              NULL);
1960         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_store_passphrase, FALSE, FALSE, 0);
1961         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_store_passphrase),
1962                                      TRUE);
1963         gtk_widget_set_size_request (spinbtn_store_passphrase, 64, -1);
1964
1965         label = gtk_label_new (_("minute(s) "));
1966         gtk_widget_show (label);
1967         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1968
1969         hbox1 = gtk_hbox_new (FALSE, 8);
1970         gtk_widget_show (hbox1);
1971         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1972
1973         hbox_spc = gtk_hbox_new (FALSE, 0);
1974         gtk_widget_show (hbox_spc);
1975         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1976         gtk_widget_set_size_request (hbox_spc, 12, -1);
1977
1978         SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
1979
1980 #ifndef __MINGW32__
1981         PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
1982                            _("Grab input while entering a passphrase"));
1983 #endif
1984
1985         PACK_CHECK_BUTTON
1986                 (vbox2, checkbtn_gpg_warning,
1987                  _("Display warning on startup if GnuPG doesn't work"));
1988
1989         hbox1 = gtk_hbox_new (FALSE, 8);
1990         gtk_widget_show (hbox1);
1991         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1992
1993         privacy.checkbtn_auto_check_signatures
1994                                              = checkbtn_auto_check_signatures;
1995         privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
1996         privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
1997         privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
1998         privacy.checkbtn_passphrase_grab     = checkbtn_passphrase_grab;
1999         privacy.checkbtn_gpg_warning         = checkbtn_gpg_warning;
2000 }
2001 #endif /* USE_GPGME */
2002
2003 static void prefs_interface_create(void)
2004 {
2005         GtkWidget *vbox1;
2006         GtkWidget *vbox2;
2007         GtkWidget *vbox3;
2008         /* GtkWidget *checkbtn_emacs; */
2009         GtkWidget *checkbtn_always_show_msg;
2010         GtkWidget *checkbtn_openunread;
2011         GtkWidget *checkbtn_mark_as_read_on_newwin;
2012         GtkWidget *checkbtn_openinbox;
2013         GtkWidget *checkbtn_immedexec;
2014         GtkTooltips *immedexec_tooltip;
2015         GtkWidget *hbox1;
2016         GtkWidget *label;
2017         GtkWidget *menu;
2018         GtkWidget *menuitem;
2019
2020         GtkWidget *button_keybind;
2021
2022         GtkWidget *hbox_nextunreadmsgdialog;
2023         GtkWidget *optmenu_nextunreadmsgdialog;
2024
2025         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2026         gtk_widget_show (vbox1);
2027         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2028         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2029
2030         vbox2 = gtk_vbox_new (FALSE, 0);
2031         gtk_widget_show (vbox2);
2032         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2033
2034         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
2035                            _("Emulate the behavior of mouse operation of\n"
2036                              "Emacs-based mailer"));
2037         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
2038                                GTK_JUSTIFY_LEFT);   */
2039
2040         PACK_CHECK_BUTTON
2041                 (vbox2, checkbtn_always_show_msg,
2042                  _("Always open messages in summary when selected"));
2043
2044         PACK_CHECK_BUTTON
2045                 (vbox2, checkbtn_openunread,
2046                  _("Open first unread message when entering a folder"));
2047
2048         PACK_CHECK_BUTTON
2049                 (vbox2, checkbtn_mark_as_read_on_newwin,
2050                  _("Only mark message as read when opened in new window"));
2051
2052         PACK_CHECK_BUTTON
2053                 (vbox2, checkbtn_openinbox,
2054                  _("Go to inbox after receiving new mail"));
2055
2056         vbox3 = gtk_vbox_new (FALSE, 0);
2057         gtk_widget_show (vbox3);
2058         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2059
2060         immedexec_tooltip = gtk_tooltips_new();
2061
2062         PACK_CHECK_BUTTON
2063                 (vbox3, checkbtn_immedexec,
2064                  _("Execute immediately when moving or deleting messages"));
2065         gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
2066                              _("Messages will be marked until execution"
2067                                " if this is turned off"),
2068                              NULL);
2069
2070         hbox1 = gtk_hbox_new (FALSE, 0);
2071         gtk_widget_show (hbox1);
2072         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2073
2074         /* Next Unread Message Dialog */
2075         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
2076         gtk_widget_show (hbox1);
2077         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
2078
2079         label = gtk_label_new (_("Show no-unread-message dialog"));
2080         gtk_widget_show (label);
2081         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
2082
2083         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
2084         gtk_widget_show (optmenu_nextunreadmsgdialog);
2085         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
2086         
2087         menu = gtk_menu_new ();
2088         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
2089         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
2090                       NEXTUNREADMSGDIALOG_ASSUME_YES);
2091         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
2092                       NEXTUNREADMSGDIALOG_ASSUME_NO);
2093
2094         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
2095
2096         hbox1 = gtk_hbox_new (FALSE, 8);
2097         gtk_widget_show (hbox1);
2098         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2099
2100         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2101         gtk_widget_show (button_keybind);
2102         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2103         g_signal_connect (G_OBJECT (button_keybind), "clicked",
2104                           G_CALLBACK (prefs_keybind_select), NULL);
2105
2106         /* interface.checkbtn_emacs          = checkbtn_emacs; */
2107         interface.checkbtn_always_show_msg    = checkbtn_always_show_msg;
2108         interface.checkbtn_openunread         = checkbtn_openunread;
2109         interface.checkbtn_mark_as_read_on_newwin
2110                                               = checkbtn_mark_as_read_on_newwin;
2111         interface.checkbtn_openinbox          = checkbtn_openinbox;
2112         interface.checkbtn_immedexec          = checkbtn_immedexec;
2113         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
2114 }
2115
2116 static void prefs_other_create(void)
2117 {
2118         GtkWidget *vbox1;
2119         GtkWidget *hbox1;
2120
2121         GtkWidget *frame_addr;
2122         GtkWidget *vbox_addr;
2123         GtkWidget *checkbtn_addaddrbyclick;
2124         
2125         GtkWidget *frame_cliplog;
2126         GtkWidget *vbox_cliplog;
2127         GtkWidget *hbox_cliplog;
2128         GtkWidget *checkbtn_cliplog;
2129         GtkWidget *loglength_label;
2130         GtkWidget *loglength_entry;
2131         GtkTooltips *loglength_tooltip;
2132
2133         GtkWidget *frame_exit;
2134         GtkWidget *vbox_exit;
2135         GtkWidget *checkbtn_confonexit;
2136         GtkWidget *checkbtn_cleanonexit;
2137         GtkWidget *checkbtn_askonclean;
2138         GtkWidget *checkbtn_warnqueued;
2139
2140         GtkWidget *label_iotimeout;
2141         GtkWidget *spinbtn_iotimeout;
2142         GtkObject *spinbtn_iotimeout_adj;
2143
2144 #if 0
2145 #ifdef USE_OPENSSL
2146         GtkWidget *frame_ssl;
2147         GtkWidget *vbox_ssl;
2148         GtkWidget *hbox_ssl;
2149         GtkWidget *checkbtn_ssl_ask_unknown_valid;
2150 #endif
2151 #endif
2152         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2153         gtk_widget_show (vbox1);
2154         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2155         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2156
2157         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2158
2159         vbox_addr = gtk_vbox_new (FALSE, 0);
2160         gtk_widget_show (vbox_addr);
2161         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2162         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2163
2164         PACK_CHECK_BUTTON
2165                 (vbox_addr, checkbtn_addaddrbyclick,
2166                  _("Add address to destination when double-clicked"));
2167
2168         /* Clip Log */
2169         PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
2170
2171         vbox_cliplog = gtk_vbox_new (FALSE, 0);
2172         gtk_widget_show (vbox_cliplog);
2173         gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
2174         gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
2175         PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
2176                            _("Clip the log size"));
2177         hbox_cliplog = gtk_hbox_new (FALSE, 3);
2178         gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
2179         gtk_widget_show (hbox_cliplog);
2180         
2181         loglength_label = gtk_label_new (_("Log window length"));
2182         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
2183                             FALSE, TRUE, 0);
2184         gtk_widget_show (GTK_WIDGET (loglength_label));
2185         
2186         loglength_tooltip = gtk_tooltips_new();
2187         
2188         loglength_entry = gtk_entry_new ();
2189         gtk_widget_set_size_request (GTK_WIDGET (loglength_entry), 64, -1);
2190         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
2191                             FALSE, TRUE, 0);
2192         gtk_widget_show (GTK_WIDGET (loglength_entry));
2193         gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), loglength_entry,
2194                              _("0 to stop logging in the log window"),
2195                              NULL);
2196         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
2197
2198 #if 0
2199 #ifdef USE_OPENSSL
2200         /* SSL */
2201         PACK_FRAME (vbox1, frame_ssl, _("Security"));
2202
2203         vbox_ssl = gtk_vbox_new (FALSE, 0);
2204         gtk_widget_show (vbox_ssl);
2205         gtk_container_add (GTK_CONTAINER (frame_ssl), vbox_ssl);
2206         gtk_container_set_border_width (GTK_CONTAINER (vbox_ssl), 8);
2207         PACK_CHECK_BUTTON (vbox_ssl, checkbtn_ssl_ask_unknown_valid, 
2208                            _("Ask before accepting SSL certificates"));
2209         hbox_ssl = gtk_hbox_new (FALSE, 3);
2210         gtk_container_add (GTK_CONTAINER (vbox_ssl), hbox_ssl);
2211         gtk_widget_show (hbox_ssl);
2212 #endif
2213 #endif
2214         
2215         /* On Exit */
2216         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2217
2218         vbox_exit = gtk_vbox_new (FALSE, 0);
2219         gtk_widget_show (vbox_exit);
2220         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2221         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2222
2223         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2224                            _("Confirm on exit"));
2225
2226         hbox1 = gtk_hbox_new (FALSE, 32);
2227         gtk_widget_show (hbox1);
2228         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2229
2230         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2231                            _("Empty trash on exit"));
2232         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2233                            _("Ask before emptying"));
2234         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2235
2236         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2237                            _("Warn if there are queued messages"));
2238
2239         hbox1 = gtk_hbox_new (FALSE, 8);
2240         gtk_widget_show (hbox1);
2241         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2242
2243         label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
2244         gtk_widget_show (label_iotimeout);
2245         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2246
2247         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
2248         spinbtn_iotimeout = gtk_spin_button_new
2249                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
2250         gtk_widget_show (spinbtn_iotimeout);
2251         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
2252                             FALSE, FALSE, 0);
2253         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
2254         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
2255
2256         label_iotimeout = gtk_label_new (_("seconds"));
2257         gtk_widget_show (label_iotimeout);
2258         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2259
2260         other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
2261         
2262         other.checkbtn_cliplog     = checkbtn_cliplog;
2263         other.loglength_entry      = loglength_entry;
2264
2265         other.checkbtn_confonexit  = checkbtn_confonexit;
2266         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2267         other.checkbtn_askonclean  = checkbtn_askonclean;
2268         other.checkbtn_warnqueued  = checkbtn_warnqueued;
2269
2270         other.spinbtn_iotimeout     = spinbtn_iotimeout;
2271         other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
2272         
2273 #if 0
2274 #ifdef USE_OPENSSL
2275         other.checkbtn_ssl_ask_unknown_valid = checkbtn_ssl_ask_unknown_valid;
2276 #endif
2277 #endif
2278 }
2279
2280 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2281 {
2282         GtkWidget *datefmt_sample = NULL;
2283         gchar *text;
2284
2285         g_return_if_fail(widget != NULL);
2286         g_return_if_fail(*widget != NULL);
2287         g_return_if_fail(display.entry_datefmt != NULL);
2288
2289         datefmt_sample = GTK_WIDGET(g_object_get_data
2290                                     (G_OBJECT(*widget), "datefmt_sample"));
2291         g_return_if_fail(datefmt_sample != NULL);
2292
2293         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2294         g_free(prefs_common.date_format);
2295         prefs_common.date_format = text;
2296         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2297
2298         gtk_widget_destroy(*widget);
2299         *widget = NULL;
2300 }
2301
2302 static void date_format_cancel_btn_clicked(GtkButton *button,
2303                                            GtkWidget **widget)
2304 {
2305         g_return_if_fail(widget != NULL);
2306         g_return_if_fail(*widget != NULL);
2307
2308         gtk_widget_destroy(*widget);
2309         *widget = NULL;
2310 }
2311
2312 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2313                                         GtkWidget **widget)
2314 {
2315         if (event && event->keyval == GDK_Escape)
2316                 date_format_cancel_btn_clicked(NULL, widget);
2317         return FALSE;
2318 }
2319
2320 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2321                                       GdkEventAny *event, GtkWidget **widget)
2322 {
2323         g_return_val_if_fail(widget != NULL, FALSE);
2324         g_return_val_if_fail(*widget != NULL, FALSE);
2325
2326         *widget = NULL;
2327         return FALSE;
2328 }
2329
2330 static void date_format_entry_on_change(GtkEditable *editable,
2331                                         GtkLabel *example)
2332 {
2333         time_t cur_time;
2334         struct tm *cal_time;
2335         gchar buffer[100];
2336         gchar *text;
2337
2338         cur_time = time(NULL);
2339         cal_time = localtime(&cur_time);
2340         buffer[0] = 0;
2341         text = gtk_editable_get_chars(editable, 0, -1);
2342         if (text)
2343                 strftime(buffer, sizeof buffer, text, cal_time); 
2344         g_free(text);
2345
2346         text = conv_codeset_strdup(buffer,
2347                                    conv_get_current_charset_str(),
2348                                    CS_UTF_8);
2349         if (!text)
2350                 text = g_strdup(buffer);
2351
2352         gtk_label_set_text(example, text);
2353
2354         g_free(text);
2355 }
2356
2357 static void date_format_select_row(GtkWidget *date_format_list, gint row,
2358                                    gint column, GdkEventButton *event,
2359                                    GtkWidget *date_format)
2360 {
2361         gint cur_pos;
2362         gchar *format;
2363         const gchar *old_format;
2364         gchar *new_format;
2365         GtkWidget *datefmt_sample;
2366
2367         /* only on double click */
2368         if (!event || event->type != GDK_2BUTTON_PRESS) return;
2369
2370
2371         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
2372                                                       "datefmt_sample"));
2373
2374         g_return_if_fail(date_format_list != NULL);
2375         g_return_if_fail(date_format != NULL);
2376         g_return_if_fail(datefmt_sample != NULL);
2377
2378         /* get format from clist */
2379         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
2380
2381         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2382         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2383
2384         /* insert the format into the text entry */
2385         new_format = g_malloc(strlen(old_format) + 3);
2386
2387         strncpy(new_format, old_format, cur_pos);
2388         new_format[cur_pos] = '\0';
2389         strcat(new_format, format);
2390         strcat(new_format, &old_format[cur_pos]);
2391
2392         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2393         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2394
2395         g_free(new_format);
2396 }
2397
2398 static GtkWidget *date_format_create(GtkButton *button, void *data)
2399 {
2400         static GtkWidget *datefmt_win = NULL;
2401         GtkWidget *vbox1;
2402         GtkWidget *scrolledwindow1;
2403         GtkWidget *datefmt_clist;
2404         GtkWidget *table;
2405         GtkWidget *label1;
2406         GtkWidget *label2;
2407         GtkWidget *label3;
2408         GtkWidget *confirm_area;
2409         GtkWidget *ok_btn;
2410         GtkWidget *cancel_btn;
2411         GtkWidget *datefmt_entry;
2412
2413         struct {
2414                 gchar *fmt;
2415                 gchar *txt;
2416         } time_format[] = {
2417                 { "%a", NULL },
2418                 { "%A", NULL },
2419                 { "%b", NULL },
2420                 { "%B", NULL },
2421                 { "%c", NULL },
2422                 { "%C", NULL },
2423                 { "%d", NULL },
2424                 { "%H", NULL },
2425                 { "%I", NULL },
2426                 { "%j", NULL },
2427                 { "%m", NULL },
2428                 { "%M", NULL },
2429                 { "%p", NULL },
2430                 { "%S", NULL },
2431                 { "%w", NULL },
2432                 { "%x", NULL },
2433                 { "%y", NULL },
2434                 { "%Y", NULL },
2435                 { "%Z", NULL }
2436         };
2437
2438         gchar *titles[2];
2439         gint i;
2440         const gint TIME_FORMAT_ELEMS =
2441                 sizeof time_format / sizeof time_format[0];
2442
2443         time_format[0].txt  = _("the full abbreviated weekday name");
2444         time_format[1].txt  = _("the full weekday name");
2445         time_format[2].txt  = _("the abbreviated month name");
2446         time_format[3].txt  = _("the full month name");
2447         time_format[4].txt  = _("the preferred date and time for the current locale");
2448         time_format[5].txt  = _("the century number (year/100)");
2449         time_format[6].txt  = _("the day of the month as a decimal number");
2450         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
2451         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
2452         time_format[9].txt  = _("the day of the year as a decimal number");
2453         time_format[10].txt = _("the month as a decimal number");
2454         time_format[11].txt = _("the minute as a decimal number");
2455         time_format[12].txt = _("either AM or PM");
2456         time_format[13].txt = _("the second as a decimal number");
2457         time_format[14].txt = _("the day of the week as a decimal number");
2458         time_format[15].txt = _("the preferred date for the current locale");
2459         time_format[16].txt = _("the last two digits of a year");
2460         time_format[17].txt = _("the year as a decimal number");
2461         time_format[18].txt = _("the time zone or name or abbreviation");
2462
2463         if (datefmt_win) return datefmt_win;
2464
2465         datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2466         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2467         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2468         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2469         gtk_widget_set_size_request(datefmt_win, 440, 280);
2470
2471         vbox1 = gtk_vbox_new(FALSE, 10);
2472         gtk_widget_show(vbox1);
2473         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2474
2475         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2476         gtk_scrolled_window_set_policy
2477                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
2478                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2479         gtk_widget_show(scrolledwindow1);
2480         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2481
2482         titles[0] = _("Specifier");
2483         titles[1] = _("Description");
2484         datefmt_clist = gtk_clist_new_with_titles(2, titles);
2485         gtk_widget_show(datefmt_clist);
2486         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
2487         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
2488         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
2489                                      GTK_SELECTION_BROWSE);
2490
2491         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2492                 gchar *text[2];
2493                 /* phoney casting necessary because of gtk... */
2494                 text[0] = (gchar *)time_format[i].fmt;
2495                 text[1] = (gchar *)time_format[i].txt;
2496                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
2497         }
2498
2499         table = gtk_table_new(2, 2, FALSE);
2500         gtk_widget_show(table);
2501         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
2502         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
2503         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2504
2505         label1 = gtk_label_new(_("Date format"));
2506         gtk_widget_show(label1);
2507         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
2508                          GTK_FILL, 0, 0, 0);
2509         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
2510         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
2511
2512         datefmt_entry = gtk_entry_new();
2513         gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
2514         gtk_widget_show(datefmt_entry);
2515         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
2516                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2517
2518         /* we need the "sample" entry box; add it as data so callbacks can
2519          * get the entry box */
2520         g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
2521                           datefmt_entry);
2522
2523         label2 = gtk_label_new(_("Example"));
2524         gtk_widget_show(label2);
2525         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
2526                          GTK_FILL, 0, 0, 0);
2527         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
2528         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
2529
2530         label3 = gtk_label_new("");
2531         gtk_widget_show(label3);
2532         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
2533                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2534         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
2535         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
2536
2537         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
2538                                 &cancel_btn, _("Cancel"), NULL, NULL);
2539         gtk_widget_grab_default(ok_btn);
2540         gtk_widget_show(confirm_area);
2541
2542         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
2543
2544         /* set the current format */
2545         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
2546         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
2547                                     GTK_LABEL(label3));
2548
2549         g_signal_connect(G_OBJECT(ok_btn), "clicked",
2550                          G_CALLBACK(date_format_ok_btn_clicked),
2551                          &datefmt_win);
2552         g_signal_connect(G_OBJECT(cancel_btn), "clicked",
2553                          G_CALLBACK(date_format_cancel_btn_clicked),
2554                          &datefmt_win);
2555         g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
2556                          G_CALLBACK(date_format_key_pressed),
2557                          &datefmt_win);
2558         g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
2559                          G_CALLBACK(date_format_on_delete),
2560                          &datefmt_win);
2561         g_signal_connect(G_OBJECT(datefmt_entry), "changed",
2562                          G_CALLBACK(date_format_entry_on_change),
2563                          label3);
2564
2565         g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
2566                          G_CALLBACK(date_format_select_row),
2567                          datefmt_win);
2568
2569         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2570         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
2571
2572         gtk_widget_show(datefmt_win);
2573         manage_window_set_transient(GTK_WINDOW(datefmt_win));
2574
2575         gtk_widget_grab_focus(ok_btn);
2576
2577         return datefmt_win;
2578 }
2579
2580 static void prefs_keybind_select(void)
2581 {
2582         GtkWidget *window;
2583         GtkWidget *vbox1;
2584         GtkWidget *hbox1;
2585         GtkWidget *label;
2586         GtkWidget *combo;
2587         GtkWidget *confirm_area;
2588         GtkWidget *ok_btn;
2589         GtkWidget *cancel_btn;
2590
2591         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2592         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
2593         gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
2594         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
2595         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
2596         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
2597         manage_window_set_transient (GTK_WINDOW (window));
2598
2599         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2600         gtk_container_add (GTK_CONTAINER (window), vbox1);
2601         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
2602
2603         hbox1 = gtk_hbox_new (FALSE, 8);
2604         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2605
2606         label = gtk_label_new
2607                 (_("Select preset:"));
2608         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2609         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2610
2611         hbox1 = gtk_hbox_new (FALSE, 8);
2612         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2613
2614         combo = gtk_combo_new ();
2615         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
2616         gtkut_combo_set_items (GTK_COMBO (combo),
2617                                _("Default"),
2618                                "Mew / Wanderlust",
2619                                "Mutt",
2620                                _("Old Sylpheed"),
2621                                NULL);
2622         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
2623
2624         hbox1 = gtk_hbox_new (FALSE, 8);
2625         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2626
2627         label = gtk_label_new
2628                 (_("You can also modify each menu shortcut by pressing\n"
2629                    "any key(s) when placing the mouse pointer on the item."));
2630         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2631         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2632
2633         hbox1 = gtk_hbox_new (FALSE, 8);
2634         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2635
2636         gtkut_button_set_create (&confirm_area, &ok_btn, _("OK"),
2637                                  &cancel_btn, _("Cancel"), NULL, NULL);
2638         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
2639         gtk_widget_grab_default (ok_btn);
2640
2641         MANAGE_WINDOW_SIGNALS_CONNECT(window);
2642         g_signal_connect (G_OBJECT (window), "delete_event",
2643                           G_CALLBACK (prefs_keybind_deleted), NULL);
2644         g_signal_connect (G_OBJECT (window), "key_press_event",
2645                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
2646         g_signal_connect (G_OBJECT (ok_btn), "clicked",
2647                           G_CALLBACK (prefs_keybind_apply_clicked),
2648                           NULL);
2649         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
2650                           G_CALLBACK (prefs_keybind_cancel),
2651                           NULL);
2652
2653         gtk_widget_show_all(window);
2654
2655         keybind.window = window;
2656         keybind.combo = combo;
2657 }
2658
2659 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
2660                                           gpointer data)
2661 {
2662         if (event && event->keyval == GDK_Escape)
2663                 prefs_keybind_cancel();
2664         return FALSE;
2665 }
2666
2667 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
2668                                   gpointer data)
2669 {
2670         prefs_keybind_cancel();
2671         return TRUE;
2672 }
2673
2674 static void prefs_keybind_cancel(void)
2675 {
2676         gtk_widget_destroy(keybind.window);
2677         keybind.window = NULL;
2678         keybind.combo = NULL;
2679 }
2680   
2681 struct KeyBind {
2682         const gchar *accel_path;
2683         const gchar *accel_key;
2684 };
2685
2686 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
2687 {
2688         gint i;
2689         guint key;
2690         GdkModifierType mods;
2691
2692         for (i = 0; i < num; i++) {
2693                 const gchar *accel_key
2694                         = keybind[i].accel_key ? keybind[i].accel_key : "";
2695                 gtk_accelerator_parse(accel_key, &key, &mods);
2696                 gtk_accel_map_change_entry(keybind[i].accel_path,
2697                                            key, mods, TRUE);
2698         }
2699 }
2700
2701 static void prefs_keybind_apply_clicked(GtkWidget *widget)
2702 {
2703         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
2704         const gchar *text;
2705         struct KeyBind *menurc;
2706         gint n_menurc;
2707
2708         static struct KeyBind default_menurc[] = {
2709                 {"<Main>/File/Empty trash",                     ""},
2710                 {"<Main>/File/Save as...",                      "<control>S"},
2711                 {"<Main>/File/Print...",                        ""},
2712                 {"<Main>/File/Exit",                            "<control>Q"},
2713
2714                 {"<Main>/Edit/Copy",                            "<control>C"},
2715                 {"<Main>/Edit/Select all",                      "<control>A"},
2716                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2717                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
2718
2719                 {"<Main>/View/Expand Summary View",             "V"},
2720                 {"<Main>/View/Expand Message View",             "<shift>V"},
2721                 {"<Main>/View/Thread view",                     "<control>T"},
2722                 {"<Main>/View/Go to/Prev message",              "P"},
2723                 {"<Main>/View/Go to/Next message",              "N"},
2724                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2725                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2726                 {"<Main>/View/Go to/Other folder...",           "G"},
2727                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2728                 {"<Main>/View/View source",                     "<control>U"},
2729                 {"<Main>/View/Show all headers",                "<control>H"},
2730                 {"<Main>/View/Update",                          "<control><alt>U"},
2731
2732                 {"<Main>/Message/Receive/Get new mail",         "<control>I"},
2733                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2734                 {"<Main>/Message/Compose an email message",     "<control>M"},
2735                 {"<Main>/Message/Reply",                        "<control>R"},
2736                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
2737                 {"<Main>/Message/Reply to/sender",              ""},
2738                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2739                 {"<Main>/Message/Forward",                      "<control><alt>F"},
2740                 /* {"<Main>/Message/Forward as attachment",      ""}, */
2741                 {"<Main>/Message/Move...",                      "<control>O"},
2742                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
2743                 {"<Main>/Message/Delete",                       "<control>D"},
2744                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2745                 {"<Main>/Message/Mark/Unmark",                  "U"},
2746                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2747                 {"<Main>/Message/Mark/Mark as read",            ""},
2748
2749                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2750                 {"<Main>/Tools/Execute",                        "X"},
2751                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2752
2753                 {"<Compose>/File/Close",                                "<control>W"},
2754                 {"<Compose>/Edit/Select all",                           "<control>A"},
2755                 {"<Compose>/Edit/Advanced/Move a word backward",        ""},
2756                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
2757                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
2758                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
2759                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
2760         };
2761
2762         static struct KeyBind mew_wl_menurc[] = {
2763                 {"<Main>/File/Empty trash",                     "<shift>D"},
2764                 {"<Main>/File/Save as...",                      "Y"},
2765                 {"<Main>/File/Print...",                        "<shift>numbersign"},
2766                 {"<Main>/File/Exit",                            "<shift>Q"},
2767
2768                 {"<Main>/Edit/Copy",                            "<control>C"},
2769                 {"<Main>/Edit/Select all",                      "<control>A"},
2770                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2771                 {"<Main>/Edit/Search folder...",                "<control>S"},
2772
2773                 {"<Main>/View/Expand Summary View",             ""},
2774                 {"<Main>/View/Expand Message View",             ""},
2775                 {"<Main>/View/Thread view",                     "<shift>T"},
2776                 {"<Main>/View/Go to/Prev message",              "P"},
2777                 {"<Main>/View/Go to/Next message",              "N"},
2778                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2779                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2780                 {"<Main>/View/Go to/Other folder...",           "G"},
2781                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2782                 {"<Main>/View/View source",                     "<control>U"},
2783                 {"<Main>/View/Show all headers",                "<shift>H"},
2784                 {"<Main>/View/Update",                          "<shift>S"},
2785
2786                 {"<Main>/Message/Receive/Get new mail",         "<control>I"},
2787                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2788                 {"<Main>/Message/Compose an email message",     "W"},
2789                 {"<Main>/Message/Reply",                        "<control>R"},
2790                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
2791                 {"<Main>/Message/Reply to/sender",              ""},
2792                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2793                 {"<Main>/Message/Forward",                      "F"},
2794                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
2795                 {"<Main>/Message/Move...",                      "O"},
2796                 {"<Main>/Message/Copy...",                      "<shift>O"},
2797                 {"<Main>/Message/Delete",                       "D"},
2798                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2799                 {"<Main>/Message/Mark/Unmark",                  "U"},
2800                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2801                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
2802
2803                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2804                 {"<Main>/Tools/Execute",                        "X"},
2805                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2806
2807                 {"<Compose>/File/Close",                                "<alt>W"},
2808                 {"<Compose>/Edit/Select all",                           ""},
2809                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
2810                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2811                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2812                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2813                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2814         };
2815
2816         static struct KeyBind mutt_menurc[] = {
2817                 {"<Main>/File/Empty trash",                     ""},
2818                 {"<Main>/File/Save as...",                      "S"},
2819                 {"<Main>/File/Print...",                        "P"},
2820                 {"<Main>/File/Exit",                            "Q"},
2821
2822                 {"<Main>/Edit/Copy",                            "<control>C"},
2823                 {"<Main>/Edit/Select all",                      "<control>A"},
2824                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2825                 {"<Main>/Edit/Search messages...",              "slash"},
2826
2827                 {"<Main>/View/Toggle summary view",             "V"},
2828                 {"<Main>/View/Thread view",                     "<control>T"},
2829                 {"<Main>/View/Go to/Prev message",              ""},
2830                 {"<Main>/View/Go to/Next message",              ""},
2831                 {"<Main>/View/Go to/Prev unread message",       ""},
2832                 {"<Main>/View/Go to/Next unread message",       ""},
2833                 {"<Main>/View/Go to/Other folder...",           "C"},
2834                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2835                 {"<Main>/View/View source",                     "<control>U"},
2836                 {"<Main>/View/Show all headers",                "<control>H"},
2837                 {"<Main>/View/Update",                          "<control><alt>U"},
2838
2839                 {"<Main>/Message/Receive/Get new mail",                 "<control>I"},
2840                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2841                 {"<Main>/Message/Compose an email message",             "M"},
2842                 {"<Main>/Message/Reply",                        "R"},
2843                 {"<Main>/Message/Reply to/all",                 "G"},
2844                 {"<Main>/Message/Reply to/sender",              ""},
2845                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2846                 {"<Main>/Message/Forward",                      "F"},
2847                 {"<Main>/Message/Forward as attachment",        ""},
2848                 {"<Main>/Message/Move...",                      "<control>O"},
2849                 {"<Main>/Message/Copy...",                      "<shift>C"},
2850                 {"<Main>/Message/Delete",                       "D"},
2851                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
2852                 {"<Main>/Message/Mark/Unmark",                  "U"},
2853                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
2854                 {"<Main>/Message/Mark/Mark as read",            ""},
2855
2856                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2857                 {"<Main>/Tools/Execute",                        "X"},
2858                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2859
2860                 {"<Compose>/File/Close",                                "<alt>W"},
2861                 {"<Compose>/Edit/Select all",                           ""},
2862                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2863                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2864                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2865                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2866                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2867         };
2868
2869         static struct KeyBind old_sylpheed_menurc[] = {
2870                 {"<Main>/File/Empty trash",                     ""},
2871                 {"<Main>/File/Save as...",                      ""},
2872                 {"<Main>/File/Print...",                        "<alt>P"},
2873                 {"<Main>/File/Exit",                            "<alt>Q"},
2874
2875                 {"<Main>/Edit/Copy",                            "<control>C"},
2876                 {"<Main>/Edit/Select all",                      "<control>A"},
2877                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2878                 {"<Main>/Edit/Search folder...",                "<control>S"},
2879
2880                 {"<Main>/View/Expand Summary View",             ""},
2881                 {"<Main>/View/Expand Message View",             ""},
2882                 {"<Main>/View/Thread view",                     "<control>T"},
2883                 {"<Main>/View/Go to/Prev message",              "P"},
2884                 {"<Main>/View/Go to/Next message",              "N"},
2885                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2886                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2887                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
2888                 {"<Main>/View/Open in new window",              "<shift><control>N"},
2889                 {"<Main>/View/View source",                     "<control>U"},
2890                 {"<Main>/View/Show all headers",                "<control>H"},
2891                 {"<Main>/View/Update",                          "<alt>U"},
2892
2893                 {"<Main>/Message/Receive/Get new mail",                 "<alt>I"},
2894                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
2895                 {"<Main>/Message/Compose an email message",     "<alt>N"},
2896                 {"<Main>/Message/Reply",                        "<alt>R"},
2897                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
2898                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
2899                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2900                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
2901                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
2902                 {"<Main>/Message/Move...",                      "<alt>O"},
2903                 {"<Main>/Message/Copy...",                      ""},
2904                 {"<Main>/Message/Delete",                       "<alt>D"},
2905                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2906                 {"<Main>/Message/Mark/Unmark",                  "U"},
2907                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2908                 {"<Main>/Message/Mark/Mark as read",            ""},
2909
2910                 {"<Main>/Tools/Address book",                   "<alt>A"},
2911                 {"<Main>/Tools/Execute",                        "<alt>X"},
2912                 {"<Main>/Tools/Log window",                     "<alt>L"},
2913
2914                 {"<Compose>/File/Close",                                "<alt>W"},
2915                 {"<Compose>/Edit/Select all",                           ""},
2916                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2917                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2918                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2919                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2920                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2921         };
2922   
2923         text = gtk_entry_get_text(entry);
2924   
2925         if (!strcmp(text, _("Default"))) {
2926                 menurc = default_menurc;
2927                 n_menurc = G_N_ELEMENTS(default_menurc);
2928         } else if (!strcmp(text, "Mew / Wanderlust")) {
2929                 menurc = mew_wl_menurc;
2930                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
2931         } else if (!strcmp(text, "Mutt")) {
2932                 menurc = mutt_menurc;
2933                 n_menurc = G_N_ELEMENTS(mutt_menurc);
2934         } else if (!strcmp(text, _("Old Sylpheed"))) {
2935                 menurc = old_sylpheed_menurc;
2936                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
2937         } else {
2938                 return;
2939         }
2940
2941         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
2942         prefs_keybind_apply(menurc, n_menurc);
2943
2944         gtk_widget_destroy(keybind.window);
2945         keybind.window = NULL;
2946         keybind.combo = NULL;
2947 }
2948
2949 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
2950 {
2951         GtkWidget *menu;
2952         GtkWidget *menuitem;
2953         gchar *charset;
2954
2955         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2956         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2957         charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
2958         g_free(*((gchar **)pparam->data));
2959         *((gchar **)pparam->data) = g_strdup(charset);
2960 }
2961
2962 static void prefs_common_charset_set_optmenu(PrefParam *pparam)
2963 {
2964         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2965         gint index;
2966
2967         g_return_if_fail(optmenu != NULL);
2968         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2969
2970         index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
2971                                             (GCompareFunc)strcmp);
2972         if (index >= 0)
2973                 gtk_option_menu_set_history(optmenu, index);
2974         else {
2975                 gtk_option_menu_set_history(optmenu, 0);
2976                 prefs_common_charset_set_data_from_optmenu(pparam);
2977         }
2978 }
2979
2980 static void prefs_common_encoding_set_data_from_optmenu(PrefParam *pparam)
2981 {
2982         GtkWidget *menu;
2983         GtkWidget *menuitem;
2984
2985         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2986         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2987         *((TransferEncodingMethod *)pparam->data) = GPOINTER_TO_INT
2988                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2989 }
2990
2991 static void prefs_common_encoding_set_optmenu(PrefParam *pparam)
2992 {
2993         TransferEncodingMethod method =
2994                 *((TransferEncodingMethod *)pparam->data);
2995         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2996         gint index;
2997
2998         g_return_if_fail(optmenu != NULL);
2999
3000         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(method),
3001                                             NULL);
3002         if (index >= 0)
3003                 gtk_option_menu_set_history(optmenu, index);
3004         else {
3005                 gtk_option_menu_set_history(optmenu, 0);
3006                 prefs_common_encoding_set_data_from_optmenu(pparam);
3007         }
3008 }
3009
3010 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)
3011 {
3012         GtkWidget *menu;
3013         GtkWidget *menuitem;
3014
3015         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3016         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3017         *((RecvDialogMode *)pparam->data) = GPOINTER_TO_INT
3018                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3019 }
3020
3021 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
3022 {
3023         RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
3024         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3025         GtkWidget *menu;
3026         GtkWidget *menuitem;
3027         gint index;
3028
3029         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
3030                                             NULL);
3031         if (index >= 0)
3032                 gtk_option_menu_set_history(optmenu, index);
3033         else {
3034                 gtk_option_menu_set_history(optmenu, 0);
3035                 prefs_common_recv_dialog_set_data_from_optmenu(pparam);
3036         }
3037
3038         menu = gtk_option_menu_get_menu(optmenu);
3039         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3040         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3041 }
3042
3043 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam)
3044 {
3045         GtkWidget *menu;
3046         GtkWidget *menuitem;
3047
3048         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3049         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3050         *((SendDialogMode *)pparam->data) = GPOINTER_TO_INT
3051                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3052 }
3053
3054 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam)
3055 {
3056         SendDialogMode mode = *((SendDialogMode *)pparam->data);
3057         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3058         GtkWidget *menu;
3059         GtkWidget *menuitem;
3060
3061         switch (mode) {
3062         case SEND_DIALOG_ALWAYS:
3063                 gtk_option_menu_set_history(optmenu, 0);
3064                 break;
3065         case SEND_DIALOG_NEVER:
3066                 gtk_option_menu_set_history(optmenu, 1);
3067                 break;
3068         default:
3069                 break;
3070         }
3071
3072         menu = gtk_option_menu_get_menu(optmenu);
3073         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3074         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3075 }
3076
3077 static gint prefs_common_deleted(GtkWidget *widget, GdkEventAny *event,
3078                                  gpointer data)
3079 {
3080         prefs_common_cancel();
3081         return TRUE;
3082 }
3083
3084 static gboolean prefs_common_key_pressed(GtkWidget *widget, GdkEventKey *event,
3085                                          gpointer data)
3086 {
3087         if (event && event->keyval == GDK_Escape)
3088                 prefs_common_cancel();
3089         return FALSE;
3090 }
3091
3092 static void prefs_common_ok(void)
3093 {
3094         prefs_common_apply();
3095         gtk_widget_hide(dialog.window);
3096
3097         inc_unlock();
3098 }
3099
3100 static void prefs_common_apply(void)
3101 {
3102         MainWindow *mainwindow;
3103
3104         prefs_set_data_from_dialog(param);
3105         sock_set_io_timeout(prefs_common.io_timeout_secs);
3106         main_window_reflect_prefs_all_real(FALSE);
3107         prefs_common_write_config();
3108
3109         mainwindow = mainwindow_get_mainwindow();
3110         log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
3111                                 prefs_common.loglength);
3112         
3113         inc_autocheck_timer_remove();
3114         inc_autocheck_timer_set();
3115 }
3116
3117 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam)
3118 {
3119         GtkWidget *menu;
3120         GtkWidget *menuitem;
3121
3122         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3123         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3124         *((NextUnreadMsgDialogShow *)pparam->data) = GPOINTER_TO_INT
3125                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3126 }
3127
3128 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam)
3129 {
3130         NextUnreadMsgDialogShow dialog_show;
3131         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3132         GtkWidget *menu;
3133         GtkWidget *menuitem;
3134
3135         dialog_show = *((NextUnreadMsgDialogShow *)pparam->data);
3136
3137         switch (dialog_show) {
3138         case NEXTUNREADMSGDIALOG_ALWAYS:
3139                 gtk_option_menu_set_history(optmenu, 0);
3140                 break;
3141         case NEXTUNREADMSGDIALOG_ASSUME_YES:
3142                 gtk_option_menu_set_history(optmenu, 1);
3143                 break;
3144         case NEXTUNREADMSGDIALOG_ASSUME_NO:
3145                 gtk_option_menu_set_history(optmenu, 2);
3146                 break;
3147         }
3148
3149         menu = gtk_option_menu_get_menu(optmenu);
3150         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3151         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3152 }
3153
3154 static void prefs_common_cancel(void)
3155 {
3156         gtk_widget_hide(dialog.window);
3157         inc_unlock();
3158 }
3159
3160
3161 /* static void prefs_recvdialog_set_data_from_optmenu(PrefParam *pparam)
3162 {
3163         GtkWidget *menu;
3164         GtkWidget *menuitem;
3165
3166         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3167         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3168         *((RecvDialogShow *)pparam->data) = GPOINTER_TO_INT
3169                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3170 }  */
3171
3172 /* static void prefs_recvdialog_set_optmenu(PrefParam *pparam)
3173 {
3174         RecvDialogShow dialog_show;
3175         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3176         GtkWidget *menu;
3177         GtkWidget *menuitem;
3178
3179         dialog_show = *((RecvDialogShow *)pparam->data);
3180
3181         switch (dialog_show) {
3182         case RECVDIALOG_ALWAYS:
3183                 gtk_option_menu_set_history(optmenu, 0);
3184                 break;
3185         case RECVDIALOG_WINDOW_ACTIVE:
3186                 gtk_option_menu_set_history(optmenu, 1);
3187                 break;
3188         case RECVDIALOG_NEVER:
3189                 gtk_option_menu_set_history(optmenu, 2);
3190                 break;
3191         default:
3192         }
3193
3194         menu = gtk_option_menu_get_menu(optmenu);
3195         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3196         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3197 }     */