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