8bdbff66b4d4ea1e30e5d88463825aa1a8e6db49
[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         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
745 };
746
747 /* widget creating functions */
748 static void prefs_common_create         (void);
749 static void prefs_receive_create        (void);
750 static void prefs_send_create           (void);
751 static void prefs_compose_create        (void);
752 static void prefs_quote_create          (void);
753 static void prefs_display_create        (void);
754 static void prefs_message_create        (void);
755 static void prefs_interface_create      (void);
756 static void prefs_other_create          (void);
757
758 static void date_format_ok_btn_clicked          (GtkButton      *button,
759                                                  GtkWidget     **widget);
760 static void date_format_cancel_btn_clicked      (GtkButton      *button,
761                                                  GtkWidget     **widget);
762 static gboolean date_format_key_pressed         (GtkWidget      *keywidget,
763                                                  GdkEventKey    *event,
764                                                  GtkWidget     **widget);
765 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
766                                                  GdkEventAny    *event,
767                                                  GtkWidget     **widget);
768 static void date_format_entry_on_change         (GtkEditable    *editable,
769                                                  GtkLabel       *example);
770 static void date_format_select_row              (GtkTreeView *list_view,
771                                                  GtkTreePath *path,
772                                                  GtkTreeViewColumn *column,
773                                                  GtkWidget *date_format);
774 static GtkWidget *date_format_create            (GtkButton      *button,
775                                                  void           *data);
776
777 static void prefs_keybind_select                (void);
778 static gint prefs_keybind_deleted               (GtkWidget      *widget,
779                                                  GdkEventAny    *event,
780                                                  gpointer        data);
781 static gboolean prefs_keybind_key_pressed       (GtkWidget      *widget,
782                                                  GdkEventKey    *event,
783                                                  gpointer        data);
784 static void prefs_keybind_cancel                (void);
785 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
786
787 static void prefs_common_apply          (void);
788
789 typedef struct CommonPage
790 {
791         PrefsPage page;
792  
793         GtkWidget *vbox;
794 } CommonPage;
795
796 static CommonPage common_page;
797
798 static void create_widget_func(PrefsPage * _page,
799                                            GtkWindow * window,
800                                            gpointer data)
801 {
802         CommonPage *page = (CommonPage *) _page;
803         GtkWidget *vbox;
804
805         vbox = gtk_vbox_new(FALSE, 6);
806         gtk_widget_show(vbox);
807
808         if (notebook == NULL)
809                 prefs_common_create();
810         gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
811         gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
812
813         prefs_set_dialog(param);
814
815         page->vbox = vbox;
816
817         page->page.widget = vbox;
818 }
819
820 static void destroy_widget_func(PrefsPage *_page)
821 {
822         CommonPage *page = (CommonPage *) _page;
823
824         gtk_container_remove(GTK_CONTAINER (page->vbox), notebook);
825 }
826
827 static void save_func(PrefsPage * _page)
828 {
829         prefs_common_apply();
830 }
831
832 void prefs_common_init(void) 
833 {
834         static gchar *path[2];
835
836         prefs_common.disphdr_list = NULL;
837             
838         path[0] = _("Common");
839         path[2] = NULL;
840         
841         common_page.page.path = path;
842         common_page.page.weight = 1000.0;
843         common_page.page.create_widget = create_widget_func;
844         common_page.page.destroy_widget = destroy_widget_func;
845         common_page.page.save_page = save_func;
846
847         prefs_gtk_register_page((PrefsPage *) &common_page);
848 }
849
850 PrefsCommon *prefs_common_get(void)
851 {
852         return &prefs_common;
853 }
854
855 /*
856  * Read history list from the specified history file
857  */
858 GList *prefs_common_read_history(const gchar *history) 
859 {
860         FILE *fp;
861         gchar *path;
862         gchar buf[PREFSBUFSIZE];
863         GList *tmp = NULL;
864
865         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
866                            NULL);
867         if ((fp = fopen(path, "rb")) == NULL) {
868                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
869                 g_free(path);
870                 return NULL;
871         }
872         g_free(path);
873         while (fgets(buf, sizeof(buf), fp) != NULL) {
874                 g_strstrip(buf);
875                 if (buf[0] == '\0') continue;
876                 tmp = add_history(tmp, buf);
877         }
878         fclose(fp);
879
880         tmp = g_list_reverse(tmp);
881
882         return tmp;
883 }
884
885 void prefs_common_read_config(void)
886 {
887         gchar *rcpath;
888         
889         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
890         prefs_read_config(param, "Common", rcpath, NULL);
891         g_free(rcpath);
892         
893         prefs_common.mime_open_cmd_history =
894                 prefs_common_read_history(COMMAND_HISTORY);
895         prefs_common.summary_quicksearch_history =
896                 prefs_common_read_history(QUICKSEARCH_HISTORY);
897 }
898
899 /*
900  * Save history list to the specified history file
901  */
902 void prefs_common_save_history(const gchar *history, GList *list)
903 {
904         GList *cur;
905         FILE *fp;
906         gchar *path;
907
908         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
909                            NULL);
910         if ((fp = fopen(path, "wb")) == NULL) {
911                 FILE_OP_ERROR(path, "fopen");
912                 g_free(path);
913                 return;
914         }
915
916         for (cur = list; cur != NULL; cur = cur->next) {
917                 fputs((gchar *)cur->data, fp);
918                 fputc('\n', fp);
919         }
920
921         fclose(fp);
922         g_free(path);
923 }
924
925 void prefs_common_write_config(void)
926 {
927         prefs_write_config(param, "Common", COMMON_RC);
928
929         prefs_common_save_history(COMMAND_HISTORY, 
930                 prefs_common.mime_open_cmd_history);
931         prefs_common_save_history(QUICKSEARCH_HISTORY, 
932                 prefs_common.summary_quicksearch_history);
933 }
934
935 static void prefs_common_create(void)
936 {
937         gint page = 0;
938
939         debug_print("Creating common preferences window...\n");
940
941         notebook = gtk_notebook_new ();
942         gtk_widget_show(notebook);
943         gtk_container_set_border_width (GTK_CONTAINER (notebook), 2);
944         /* GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS); */
945         gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
946         
947         gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook));
948
949         gtk_widget_ref(notebook);
950
951         /* create all widgets on notebook */
952         prefs_receive_create();
953         SET_NOTEBOOK_LABEL(notebook, _("Receive"),   page++);
954         prefs_send_create();
955         SET_NOTEBOOK_LABEL(notebook, _("Send"),      page++);
956         prefs_compose_create();
957         SET_NOTEBOOK_LABEL(notebook, _("Compose"),   page++);
958         prefs_quote_create();
959         SET_NOTEBOOK_LABEL(notebook, _("Quote"),     page++);
960         prefs_display_create();
961         SET_NOTEBOOK_LABEL(notebook, _("Display"),   page++);
962         prefs_message_create();
963         SET_NOTEBOOK_LABEL(notebook, _("Message"),   page++);
964         prefs_interface_create();
965         SET_NOTEBOOK_LABEL(notebook, _("Interface"), page++);
966         prefs_other_create();
967         SET_NOTEBOOK_LABEL(notebook, _("Other"),     page++);
968
969         gtk_widget_show_all(notebook);
970 }
971
972 static void prefs_receive_create(void)
973 {
974         GtkWidget *vbox1;
975         GtkWidget *vbox2;
976         GtkWidget *frame_incext;
977         GtkWidget *checkbtn_incext;
978         GtkWidget *hbox;
979         GtkWidget *label_incext;
980         GtkWidget *entry_incext;
981         /* GtkWidget *button_incext; */
982
983         GtkWidget *hbox_autochk;
984         GtkWidget *checkbtn_autochk;
985         GtkWidget *label_autochk1;
986         GtkObject *spinbtn_autochk_adj;
987         GtkWidget *spinbtn_autochk;
988         GtkWidget *label_autochk2;
989         GtkWidget *checkbtn_chkonstartup;
990         GtkWidget *checkbtn_scan_after_inc;
991
992
993         GtkWidget *frame_newmail;
994         GtkWidget *hbox_newmail_notify;
995         GtkWidget *checkbtn_newmail_auto;
996         GtkWidget *checkbtn_newmail_manu;
997         GtkWidget *entry_newmail_notify_cmd;
998         GtkWidget *label_newmail_notify_cmd;
999
1000         GtkWidget *hbox_recvdialog;
1001         GtkWidget *label_recvdialog;
1002         GtkWidget *menu;
1003         GtkWidget *menuitem;
1004         GtkWidget *optmenu_recvdialog;
1005         GtkWidget *checkbtn_no_recv_err_panel;
1006         GtkWidget *checkbtn_close_recv_dialog;
1007
1008         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1009         gtk_widget_show (vbox1);
1010         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1011         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1012
1013         PACK_FRAME(vbox1, frame_incext, _("External program"));
1014
1015         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1016         gtk_widget_show (vbox2);
1017         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
1018         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1019
1020         /* Use of external incorporation program */
1021         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
1022                            _("Use external program for incorporation"));
1023
1024         hbox = gtk_hbox_new (FALSE, 8);
1025         gtk_widget_show (hbox);
1026         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1027         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
1028
1029         label_incext = gtk_label_new (_("Command"));
1030         gtk_widget_show (label_incext);
1031         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
1032
1033         entry_incext = gtk_entry_new ();
1034         gtk_widget_show (entry_incext);
1035         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
1036
1037 #if 0
1038         button_incext = gtk_button_new_with_label ("... ");
1039         gtk_widget_show (button_incext);
1040         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1041 #endif
1042
1043         vbox2 = gtk_vbox_new (FALSE, 0);
1044         gtk_widget_show (vbox2);
1045         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1046
1047         /* Auto-checking */
1048         hbox_autochk = gtk_hbox_new (FALSE, 8);
1049         gtk_widget_show (hbox_autochk);
1050         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1051
1052         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1053                            _("Auto-check new mail"));
1054
1055         label_autochk1 = gtk_label_new (_("every"));
1056         gtk_widget_show (label_autochk1);
1057         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1058
1059         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1060         spinbtn_autochk = gtk_spin_button_new
1061                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1062         gtk_widget_show (spinbtn_autochk);
1063         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1064         gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
1065         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1066
1067         label_autochk2 = gtk_label_new (_("minute(s)"));
1068         gtk_widget_show (label_autochk2);
1069         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1070
1071         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1072         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1073         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1074
1075         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1076                            _("Check new mail on startup"));
1077         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1078                            _("Update all local folders after incorporation"));
1079
1080
1081         /* receive dialog */
1082         hbox_recvdialog = gtk_hbox_new (FALSE, 8);
1083         gtk_widget_show (hbox_recvdialog);
1084         gtk_box_pack_start (GTK_BOX (vbox2), hbox_recvdialog, FALSE, FALSE, 0);
1085
1086         label_recvdialog = gtk_label_new (_("Show receive dialog"));
1087         gtk_misc_set_alignment(GTK_MISC(label_recvdialog), 0, 0.5);
1088         gtk_widget_show (label_recvdialog);
1089         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), label_recvdialog, FALSE, FALSE, 0);
1090
1091         optmenu_recvdialog = gtk_option_menu_new ();
1092         gtk_widget_show (optmenu_recvdialog);
1093         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), optmenu_recvdialog, FALSE, FALSE, 0);
1094
1095         menu = gtk_menu_new ();
1096         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
1097         MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
1098                       RECV_DIALOG_MANUAL);
1099         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
1100
1101         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
1102
1103         PACK_CHECK_BUTTON (vbox2, checkbtn_no_recv_err_panel,
1104                            _("Don't popup error dialog on receive error"));
1105
1106         PACK_CHECK_BUTTON (vbox2, checkbtn_close_recv_dialog,
1107                            _("Close receive dialog when finished"));
1108         
1109         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1110                                            "arrives"));
1111         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1112         gtk_widget_show (vbox2);
1113         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1114         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1115
1116         hbox = gtk_hbox_new (TRUE, 8);
1117         gtk_widget_show (hbox);
1118         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1119                            _("after autochecking"));
1120         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1121                            _("after manual checking"));
1122         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1123         g_signal_connect(G_OBJECT(checkbtn_newmail_auto), "toggled",
1124                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1125                          NULL);
1126         g_signal_connect(G_OBJECT(checkbtn_newmail_manu), "toggled",
1127                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1128                          NULL);
1129
1130         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1131         gtk_widget_show (hbox);
1132         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1133                             FALSE, 0);
1134
1135         label_newmail_notify_cmd = gtk_label_new (_("Command to execute:\n"
1136                                                     "(use %d as number of new "
1137                                                     "mails)"));
1138         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1139                               GTK_JUSTIFY_RIGHT);
1140         gtk_widget_show (label_newmail_notify_cmd);
1141         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1142                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1143
1144         entry_newmail_notify_cmd = gtk_entry_new ();
1145         gtk_widget_show (entry_newmail_notify_cmd);
1146         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1147                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1148
1149         gtk_widget_set_sensitive(hbox_newmail_notify, 
1150                                  prefs_common.newmail_notify_auto || 
1151                                  prefs_common.newmail_notify_manu);
1152
1153         receive.checkbtn_incext = checkbtn_incext;
1154         receive.entry_incext    = entry_incext;
1155         /* receive.button_incext   = button_incext; */
1156
1157         receive.checkbtn_autochk    = checkbtn_autochk;
1158         receive.spinbtn_autochk     = spinbtn_autochk;
1159         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1160
1161         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1162         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1163
1164
1165         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1166         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1167         receive.hbox_newmail_notify    = hbox_newmail_notify;
1168         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1169         receive.optmenu_recvdialog          = optmenu_recvdialog;
1170         receive.checkbtn_no_recv_err_panel  = checkbtn_no_recv_err_panel;
1171         receive.checkbtn_close_recv_dialog  = checkbtn_close_recv_dialog;
1172 }
1173
1174 static void prefs_send_create(void)
1175 {
1176         GtkWidget *vbox1;
1177         GtkWidget *vbox2;
1178         GtkWidget *hbox1;
1179         GtkWidget *checkbtn_savemsg;
1180         GtkWidget *label_outcharset;
1181         GtkWidget *optmenu_charset;
1182         GtkWidget *optmenu_menu;
1183         GtkWidget *menuitem;
1184         GtkTooltips *charset_tooltip;
1185         GtkWidget *optmenu_encoding;
1186         GtkWidget *label_encoding;
1187         GtkTooltips *encoding_tooltip;
1188         GtkWidget *label_senddialog;
1189         GtkWidget *menu;
1190         GtkWidget *optmenu_senddialog;
1191         GtkWidget *hbox_senddialog;
1192
1193         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1194         gtk_widget_show (vbox1);
1195         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1196         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1197
1198         vbox2 = gtk_vbox_new (FALSE, 0);
1199         gtk_widget_show (vbox2);
1200         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1201
1202         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1203                            _("Save sent messages to Sent folder"));
1204
1205         hbox_senddialog = gtk_hbox_new (FALSE, 8);
1206         gtk_box_pack_start (GTK_BOX (vbox1), hbox_senddialog, FALSE, FALSE, 0);
1207
1208         label_senddialog = gtk_label_new (_("Show send dialog"));
1209         gtk_widget_show (label_senddialog);
1210         gtk_box_pack_start (GTK_BOX (hbox_senddialog), label_senddialog, FALSE, FALSE, 0);
1211
1212         optmenu_senddialog = gtk_option_menu_new ();
1213         gtk_widget_show (optmenu_senddialog);
1214         gtk_box_pack_start (GTK_BOX (hbox_senddialog), optmenu_senddialog, FALSE, FALSE, 0);
1215         
1216         menu = gtk_menu_new ();
1217         MENUITEM_ADD (menu, menuitem, _("Always"), SEND_DIALOG_ALWAYS);
1218         MENUITEM_ADD (menu, menuitem, _("Never"), SEND_DIALOG_NEVER);
1219
1220         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_senddialog), menu);
1221
1222         hbox1 = gtk_hbox_new (FALSE, 8);
1223         gtk_widget_show (hbox1);
1224         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1225
1226         label_outcharset = gtk_label_new (_("Outgoing encoding"));
1227         gtk_widget_show (label_outcharset);
1228         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1229
1230         charset_tooltip = gtk_tooltips_new();
1231
1232         optmenu_charset = gtk_option_menu_new ();
1233         gtk_widget_show (optmenu_charset);
1234         gtk_tooltips_set_tip(GTK_TOOLTIPS(charset_tooltip), optmenu_charset,
1235                              _("If `Automatic' is selected, the optimal encoding"
1236                                " for the current locale will be used"),
1237                              NULL);
1238         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_charset, FALSE, FALSE, 0);
1239
1240         optmenu_menu = gtk_menu_new ();
1241
1242 #define SET_MENUITEM(str, data) \
1243 { \
1244         MENUITEM_ADD(optmenu_menu, menuitem, str, data); \
1245 }
1246
1247         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1248         SET_MENUITEM(NULL, NULL);
1249         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1250         SET_MENUITEM(NULL, NULL);
1251         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1252         SET_MENUITEM(NULL, NULL);
1253         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1254         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1255         SET_MENUITEM(NULL, NULL);
1256         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1257         SET_MENUITEM(NULL, NULL);
1258         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1259         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1260         SET_MENUITEM(NULL, NULL);
1261         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1262         SET_MENUITEM(NULL, NULL);
1263         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1264         SET_MENUITEM(NULL, NULL);
1265         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1266         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1267         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1268         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1269         SET_MENUITEM(NULL, NULL);
1270         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1271 #if 0
1272         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1273         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1274 #endif /* 0 */
1275         SET_MENUITEM(NULL, NULL);
1276         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1277         SET_MENUITEM(_("Simplified Chinese (GBK)"),      CS_GBK);
1278         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1279 #if 0
1280         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1281         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1282 #endif /* 0 */
1283         SET_MENUITEM(NULL, NULL);
1284         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1285         SET_MENUITEM(NULL, NULL);
1286         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1287         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1288
1289         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_charset),
1290                                   optmenu_menu);
1291
1292         hbox1 = gtk_hbox_new (FALSE, 8);
1293         gtk_widget_show (hbox1);
1294         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1295
1296         hbox1 = gtk_hbox_new (FALSE, 8);
1297         gtk_widget_show (hbox1);
1298         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1299
1300         label_encoding = gtk_label_new (_("Transfer encoding"));
1301         gtk_widget_show (label_encoding);
1302         gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1303
1304         encoding_tooltip = gtk_tooltips_new();
1305
1306         optmenu_encoding = gtk_option_menu_new ();
1307         gtk_widget_show (optmenu_encoding);
1308         gtk_tooltips_set_tip(GTK_TOOLTIPS(encoding_tooltip), optmenu_encoding,
1309                              _("Specify Content-Transfer-Encoding used when"
1310                                " message body contains non-ASCII characters"),
1311                              NULL);
1312         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_encoding, FALSE, FALSE, 0);
1313
1314         optmenu_menu = gtk_menu_new ();
1315
1316         SET_MENUITEM(_("Automatic"),     CTE_AUTO);
1317         SET_MENUITEM("base64",           CTE_BASE64);
1318         SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1319         SET_MENUITEM("8bit",             CTE_8BIT);
1320
1321         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_encoding),
1322                                   optmenu_menu);
1323
1324         hbox1 = gtk_hbox_new (FALSE, 8);
1325         gtk_widget_show (hbox1);
1326         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1327
1328         p_send.checkbtn_savemsg  = checkbtn_savemsg;
1329         p_send.optmenu_senddialog = optmenu_senddialog;
1330
1331         p_send.optmenu_charset = optmenu_charset;
1332         p_send.optmenu_encoding_method = optmenu_encoding;
1333 }
1334
1335 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1336 {
1337         gboolean toggled;
1338
1339         toggled = gtk_toggle_button_get_active
1340                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1341                   gtk_toggle_button_get_active
1342                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1343         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1344 }
1345
1346 static void prefs_compose_create(void)
1347 {
1348         GtkWidget *vbox1;
1349         GtkWidget *vbox2;
1350
1351         GtkWidget *checkbtn_autoextedit;
1352
1353         GtkWidget *frame_autosel;
1354         GtkWidget *hbox_autosel;
1355         GtkWidget *checkbtn_reply_account_autosel;
1356         GtkWidget *checkbtn_forward_account_autosel;
1357         GtkWidget *checkbtn_reedit_account_autosel;
1358
1359         GtkWidget *hbox_undolevel;
1360         GtkWidget *label_undolevel;
1361         GtkObject *spinbtn_undolevel_adj;
1362         GtkWidget *spinbtn_undolevel;
1363
1364         GtkWidget *hbox5;
1365
1366         GtkWidget *checkbtn_default_reply_list;
1367
1368         GtkWidget *checkbtn_forward_as_attachment;
1369         GtkWidget *checkbtn_redirect_keep_from;
1370
1371         GtkWidget *hbox_autosave;
1372         GtkWidget *checkbtn_autosave;
1373         GtkWidget *entry_autosave_length;
1374         GtkWidget *label_autosave_length;
1375         
1376         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1377         gtk_widget_show (vbox1);
1378         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1379         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1380
1381         /* Account autoselection */
1382         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1383
1384         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1385         gtk_widget_show (hbox_autosel);
1386         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1387         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1388
1389         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1390                            _("when replying"));
1391         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1392                            _("when forwarding"));
1393         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1394                            _("when re-editing"));
1395
1396         vbox2 = gtk_vbox_new (FALSE, 0);
1397         gtk_widget_show (vbox2);
1398         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1399
1400         PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1401                            _("Reply button invokes mailing list reply"));
1402
1403         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1404                            _("Automatically launch the external editor"));
1405
1406         hbox5 = gtk_hbox_new (FALSE, 8);
1407         gtk_widget_show (hbox5);
1408         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1409
1410         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1411                            _("Forward as attachment"));
1412
1413         PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from,
1414                            _("Keep the original 'From' header when redirecting"));
1415
1416         
1417         hbox_autosave = gtk_hbox_new (FALSE, 8);
1418         gtk_widget_show (hbox_autosave);
1419         gtk_box_pack_start (GTK_BOX (vbox1), hbox_autosave, FALSE, FALSE, 0);
1420         
1421         PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1422                            _("Autosave to Drafts folder every "));
1423
1424         entry_autosave_length = gtk_entry_new();
1425         gtk_widget_set_size_request (entry_autosave_length, 64, -1);    
1426         gtk_widget_show (entry_autosave_length);
1427         gtk_box_pack_start (GTK_BOX (hbox_autosave), entry_autosave_length, FALSE, FALSE, 0);
1428         
1429         label_autosave_length = gtk_label_new(_("characters"));
1430         gtk_widget_show (label_autosave_length);
1431         gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave_length, FALSE, FALSE, 0);
1432         
1433         hbox_undolevel = gtk_hbox_new (FALSE, 8);
1434         gtk_widget_show (hbox_undolevel);
1435         gtk_box_pack_start (GTK_BOX (vbox1), hbox_undolevel, FALSE, FALSE, 0);
1436
1437         label_undolevel = gtk_label_new (_("Undo level"));
1438         gtk_widget_show (label_undolevel);
1439         gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
1440
1441         spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1442         spinbtn_undolevel = gtk_spin_button_new
1443                 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1444         gtk_widget_show (spinbtn_undolevel);
1445         gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
1446         gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1447         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1448
1449        /*
1450         compose.checkbtn_quote   = checkbtn_quote;
1451         compose.entry_quotemark  = entry_quotemark;
1452         compose.text_quotefmt    = text_quotefmt;
1453         */
1454
1455         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1456
1457         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1458         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1459         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1460
1461         compose.spinbtn_undolevel     = spinbtn_undolevel;
1462         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1463
1464         compose.checkbtn_autosave     = checkbtn_autosave;
1465         compose.entry_autosave_length = entry_autosave_length;
1466         
1467         compose.checkbtn_forward_as_attachment =
1468                 checkbtn_forward_as_attachment;
1469         compose.checkbtn_redirect_keep_from =
1470                 checkbtn_redirect_keep_from;
1471         compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1472 }
1473
1474 static void prefs_quote_create(void)
1475 {
1476         GtkWidget *vbox1;
1477         GtkWidget *frame_quote;
1478         GtkWidget *vbox_quote;
1479         GtkWidget *hbox1;
1480         GtkWidget *hbox2;
1481         GtkWidget *label_quotemark;
1482         GtkWidget *entry_quotemark;
1483         GtkWidget *scrolledwin_quotefmt;
1484         GtkWidget *text_quotefmt;
1485
1486         GtkWidget *entry_fw_quotemark;
1487         GtkWidget *text_fw_quotefmt;
1488
1489         GtkWidget *entry_quote_chars;
1490         GtkWidget *label_quote_chars;
1491         
1492         GtkWidget *btn_quotedesc;
1493
1494         GtkWidget *checkbtn_reply_with_quote;
1495
1496         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1497         gtk_widget_show (vbox1);
1498         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1499         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1500
1501         /* reply */
1502
1503         PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
1504
1505         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1506
1507         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1508         gtk_widget_show (vbox_quote);
1509         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1510         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1511
1512         hbox1 = gtk_hbox_new (FALSE, 32);
1513         gtk_widget_show (hbox1);
1514         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1515
1516         hbox2 = gtk_hbox_new (FALSE, 8);
1517         gtk_widget_show (hbox2);
1518         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1519
1520         label_quotemark = gtk_label_new (_("Quotation mark"));
1521         gtk_widget_show (label_quotemark);
1522         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1523
1524         entry_quotemark = gtk_entry_new ();
1525         gtk_widget_show (entry_quotemark);
1526         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1527         gtk_widget_set_size_request (entry_quotemark, 64, -1);
1528
1529         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1530         gtk_widget_show (scrolledwin_quotefmt);
1531         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1532                             TRUE, TRUE, 0);
1533         gtk_scrolled_window_set_policy
1534                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1535                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1536         gtk_scrolled_window_set_shadow_type
1537                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1538
1539         text_quotefmt = gtk_text_view_new ();
1540         gtk_widget_show (text_quotefmt);
1541         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1542         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
1543         gtk_widget_set_size_request(text_quotefmt, -1, 60);
1544
1545         /* forward */
1546
1547         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1548
1549         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1550         gtk_widget_show (vbox_quote);
1551         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1552         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1553
1554         hbox1 = gtk_hbox_new (FALSE, 32);
1555         gtk_widget_show (hbox1);
1556         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1557
1558         hbox2 = gtk_hbox_new (FALSE, 8);
1559         gtk_widget_show (hbox2);
1560         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1561
1562         label_quotemark = gtk_label_new (_("Quotation mark"));
1563         gtk_widget_show (label_quotemark);
1564         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1565
1566         entry_fw_quotemark = gtk_entry_new ();
1567         gtk_widget_show (entry_fw_quotemark);
1568         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1569                             FALSE, FALSE, 0);
1570         gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1571
1572         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1573         gtk_widget_show (scrolledwin_quotefmt);
1574         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
1575                             TRUE, TRUE, 0);
1576         gtk_scrolled_window_set_policy
1577                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1578                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1579         gtk_scrolled_window_set_shadow_type
1580                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
1581
1582         text_fw_quotefmt = gtk_text_view_new ();
1583         gtk_widget_show (text_fw_quotefmt);
1584         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1585                           text_fw_quotefmt);
1586         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1587         gtk_widget_set_size_request (text_fw_quotefmt, -1, 60);
1588
1589         hbox1 = gtk_hbox_new (FALSE, 32);
1590         gtk_widget_show (hbox1);
1591         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1592
1593         btn_quotedesc =
1594                 gtk_button_new_with_label (_(" Description of symbols "));
1595         gtk_widget_show (btn_quotedesc);
1596         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1597         g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1598                          G_CALLBACK(quote_fmt_quote_description), NULL);
1599
1600         /* quote chars */
1601
1602         PACK_FRAME (vbox1, frame_quote, _("Quotation characters"));
1603
1604         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1605         gtk_widget_show (vbox_quote);
1606         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1607         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1608
1609         hbox1 = gtk_hbox_new (FALSE, 32);
1610         gtk_widget_show (hbox1);
1611         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1612
1613         hbox2 = gtk_hbox_new (FALSE, 8);
1614         gtk_widget_show (hbox2);
1615         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1616
1617         label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks: "));
1618         gtk_widget_show (label_quote_chars);
1619         gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
1620
1621         entry_quote_chars = gtk_entry_new ();
1622         gtk_widget_show (entry_quote_chars);
1623         gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
1624                             FALSE, FALSE, 0);
1625         gtk_widget_set_size_request (entry_quote_chars, 64, -1);
1626
1627
1628         compose.checkbtn_reply_with_quote= checkbtn_reply_with_quote;
1629         quote.entry_quotemark    = entry_quotemark;
1630         quote.text_quotefmt      = text_quotefmt;
1631         quote.entry_fw_quotemark = entry_fw_quotemark;
1632         quote.text_fw_quotefmt   = text_fw_quotefmt;
1633         quote.entry_quote_chars  = entry_quote_chars;
1634 }
1635
1636 static void prefs_display_create(void)
1637 {
1638         GtkWidget *vbox1;
1639         GtkWidget *chkbtn_transhdr;
1640         GtkWidget *chkbtn_folder_unread;
1641         GtkWidget *hbox1;
1642         GtkWidget *label_ng_abbrev;
1643         GtkWidget *spinbtn_ng_abbrev_len;
1644         GtkObject *spinbtn_ng_abbrev_len_adj;
1645         GtkWidget *frame_summary;
1646         GtkWidget *vbox2;
1647         GtkWidget *chkbtn_swapfrom;
1648         GtkWidget *chkbtn_useaddrbook;
1649         GtkWidget *chkbtn_threadsubj;
1650         GtkWidget *vbox3;
1651         GtkWidget *label_datefmt;
1652         GtkWidget *button_datefmt;
1653         GtkWidget *entry_datefmt;
1654         GtkWidget *button_dispitem;
1655
1656         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1657         gtk_widget_show (vbox1);
1658         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1659         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1660
1661         vbox2 = gtk_vbox_new (FALSE, 0);
1662         gtk_widget_show (vbox2);
1663         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
1664
1665         PACK_CHECK_BUTTON
1666                 (vbox2, chkbtn_transhdr,
1667                  _("Translate header name (such as `From:', `Subject:')"));
1668
1669         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1670                            _("Display unread number next to folder name"));
1671
1672         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1673
1674         hbox1 = gtk_hbox_new (FALSE, 8);
1675         gtk_widget_show (hbox1);
1676         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1677
1678         label_ng_abbrev = gtk_label_new
1679                 (_("Abbreviate newsgroup names longer than"));
1680         gtk_widget_show (label_ng_abbrev);
1681         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1682
1683         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
1684         spinbtn_ng_abbrev_len = gtk_spin_button_new
1685                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1686         gtk_widget_show (spinbtn_ng_abbrev_len);
1687         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1688                             FALSE, FALSE, 0);
1689         gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1690         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1691                                      TRUE);
1692
1693         label_ng_abbrev = gtk_label_new
1694                 (_("letters"));
1695         gtk_widget_show (label_ng_abbrev);
1696         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1697
1698         /* ---- Summary ---- */
1699
1700         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
1701
1702         vbox2 = gtk_vbox_new (FALSE, 0);
1703         gtk_widget_show (vbox2);
1704         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1705         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1706
1707         PACK_CHECK_BUTTON
1708                 (vbox2, chkbtn_swapfrom,
1709                  _("Display recipient in `From' column if sender is yourself"));
1710         PACK_CHECK_BUTTON
1711                 (vbox2, chkbtn_useaddrbook,
1712                  _("Display sender using address book"));
1713         PACK_CHECK_BUTTON
1714                 (vbox2, chkbtn_threadsubj,
1715                  _("Thread using subject in addition to standard headers"));
1716
1717         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1718
1719         hbox1 = gtk_hbox_new (FALSE, 8);
1720         gtk_widget_show (hbox1);
1721         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1722
1723         label_datefmt = gtk_label_new (_("Date format"));
1724         gtk_widget_show (label_datefmt);
1725         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1726
1727         entry_datefmt = gtk_entry_new ();
1728         gtk_widget_show (entry_datefmt);
1729         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1730
1731         button_datefmt = gtk_button_new_with_label (" ... ");
1732
1733         gtk_widget_show (button_datefmt);
1734         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1735         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1736                           G_CALLBACK (date_format_create), NULL);
1737
1738         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1739
1740         hbox1 = gtk_hbox_new (FALSE, 8);
1741         gtk_widget_show (hbox1);
1742         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1743
1744         button_dispitem = gtk_button_new_with_label
1745                 (_(" Set displayed items in summary... "));
1746         gtk_widget_show (button_dispitem);
1747         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1748         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1749                           G_CALLBACK (prefs_summary_column_open),
1750                           NULL);
1751
1752         display.chkbtn_transhdr           = chkbtn_transhdr;
1753         display.chkbtn_folder_unread      = chkbtn_folder_unread;
1754         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1755         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1756
1757         display.chkbtn_swapfrom      = chkbtn_swapfrom;
1758         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
1759         display.chkbtn_threadsubj    = chkbtn_threadsubj;
1760         display.entry_datefmt        = entry_datefmt;
1761 }
1762
1763 static void prefs_message_create(void)
1764 {
1765         GtkWidget *vbox1;
1766         GtkWidget *vbox2;
1767         GtkWidget *vbox3;
1768         GtkWidget *hbox1;
1769         GtkWidget *chkbtn_mbalnum;
1770         GtkWidget *chkbtn_disphdrpane;
1771         GtkWidget *chkbtn_disphdr;
1772         GtkWidget *button_edit_disphdr;
1773         GtkWidget *chkbtn_html;
1774         GtkWidget *hbox_linespc;
1775         GtkWidget *label_linespc;
1776         GtkObject *spinbtn_linespc_adj;
1777         GtkWidget *spinbtn_linespc;
1778
1779         GtkWidget *frame_scr;
1780         GtkWidget *vbox_scr;
1781         GtkWidget *chkbtn_smoothscroll;
1782         GtkWidget *hbox_scr;
1783         GtkWidget *label_scr;
1784         GtkObject *spinbtn_scrollstep_adj;
1785         GtkWidget *spinbtn_scrollstep;
1786         GtkWidget *chkbtn_halfpage;
1787
1788         GtkWidget *chkbtn_attach_desc;
1789
1790         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1791         gtk_widget_show (vbox1);
1792         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1793         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1794
1795         vbox2 = gtk_vbox_new (FALSE, 0);
1796         gtk_widget_show (vbox2);
1797         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1798
1799         PACK_CHECK_BUTTON
1800                 (vbox2, chkbtn_mbalnum,
1801                  _("Display multi-byte alphanumeric as\n"
1802                    "ASCII character (Japanese only)"));
1803         gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1804                                GTK_JUSTIFY_LEFT);
1805
1806         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1807                           _("Display header pane above message view"));
1808
1809         hbox1 = gtk_hbox_new (FALSE, 8);
1810         gtk_widget_show (hbox1);
1811         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1812
1813         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1814                           _("Display short headers on message view"));
1815
1816         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1817         gtk_widget_show (button_edit_disphdr);
1818         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1819                           FALSE, TRUE, 0);
1820         g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1821                           G_CALLBACK (prefs_display_header_open),
1822                           NULL);
1823
1824         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1825
1826         PACK_CHECK_BUTTON(vbox2, chkbtn_html,
1827                           _("Render HTML messages as text"));
1828
1829         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1830
1831         hbox1 = gtk_hbox_new (FALSE, 32);
1832         gtk_widget_show (hbox1);
1833         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1834
1835         hbox_linespc = gtk_hbox_new (FALSE, 8);
1836         gtk_widget_show (hbox1);
1837         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1838
1839         label_linespc = gtk_label_new (_("Line space"));
1840         gtk_widget_show (label_linespc);
1841         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1842                             FALSE, FALSE, 0);
1843
1844         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
1845         spinbtn_linespc = gtk_spin_button_new
1846                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1847         gtk_widget_show (spinbtn_linespc);
1848         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1849                             FALSE, FALSE, 0);
1850         gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1851         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1852
1853         label_linespc = gtk_label_new (_("pixel(s)"));
1854         gtk_widget_show (label_linespc);
1855         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1856                             FALSE, FALSE, 0);
1857
1858         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1859
1860         vbox_scr = gtk_vbox_new (FALSE, 0);
1861         gtk_widget_show (vbox_scr);
1862         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1863         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1864
1865         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1866
1867         hbox1 = gtk_hbox_new (FALSE, 32);
1868         gtk_widget_show (hbox1);
1869         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1870
1871         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1872
1873         hbox_scr = gtk_hbox_new (FALSE, 8);
1874         gtk_widget_show (hbox_scr);
1875         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
1876
1877         label_scr = gtk_label_new (_("Step"));
1878         gtk_widget_show (label_scr);
1879         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1880
1881         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
1882         spinbtn_scrollstep = gtk_spin_button_new
1883                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
1884         gtk_widget_show (spinbtn_scrollstep);
1885         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
1886                             FALSE, FALSE, 0);
1887         gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
1888         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
1889                                      TRUE);
1890
1891         label_scr = gtk_label_new (_("pixel(s)"));
1892         gtk_widget_show (label_scr);
1893         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1894
1895         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
1896
1897         vbox3 = gtk_vbox_new (FALSE, 0);
1898         gtk_widget_show (vbox3);
1899         gtk_box_pack_start (GTK_BOX (vbox1), vbox3, FALSE, FALSE, 0);
1900
1901         PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
1902                           _("Show attachment descriptions (rather than names)"));
1903
1904         message.chkbtn_mbalnum     = chkbtn_mbalnum;
1905         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
1906         message.chkbtn_disphdr     = chkbtn_disphdr;
1907         message.chkbtn_html        = chkbtn_html;
1908         message.spinbtn_linespc    = spinbtn_linespc;
1909
1910         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
1911         message.spinbtn_scrollstep     = spinbtn_scrollstep;
1912         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
1913         message.chkbtn_halfpage        = chkbtn_halfpage;
1914
1915         message.chkbtn_attach_desc  = chkbtn_attach_desc;
1916 }
1917
1918 static void prefs_interface_create(void)
1919 {
1920         GtkWidget *vbox1;
1921         GtkWidget *vbox2;
1922         GtkWidget *vbox3;
1923         /* GtkWidget *checkbtn_emacs; */
1924         GtkWidget *checkbtn_always_show_msg;
1925         GtkWidget *checkbtn_openunread;
1926         GtkWidget *checkbtn_mark_as_read_on_newwin;
1927         GtkWidget *checkbtn_openinbox;
1928         GtkWidget *checkbtn_immedexec;
1929         GtkTooltips *immedexec_tooltip;
1930         GtkWidget *hbox1;
1931         GtkWidget *label;
1932         GtkWidget *menu;
1933         GtkWidget *menuitem;
1934
1935         GtkWidget *button_keybind;
1936
1937         GtkWidget *hbox_nextunreadmsgdialog;
1938         GtkWidget *optmenu_nextunreadmsgdialog;
1939
1940         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1941         gtk_widget_show (vbox1);
1942         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
1943         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1944
1945         vbox2 = gtk_vbox_new (FALSE, 0);
1946         gtk_widget_show (vbox2);
1947         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1948
1949         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
1950                            _("Emulate the behavior of mouse operation of\n"
1951                              "Emacs-based mailer"));
1952         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
1953                                GTK_JUSTIFY_LEFT);   */
1954
1955         PACK_CHECK_BUTTON
1956                 (vbox2, checkbtn_always_show_msg,
1957                  _("Always open messages in summary when selected"));
1958
1959         PACK_CHECK_BUTTON
1960                 (vbox2, checkbtn_openunread,
1961                  _("Open first unread message when entering a folder"));
1962
1963         PACK_CHECK_BUTTON
1964                 (vbox2, checkbtn_mark_as_read_on_newwin,
1965                  _("Only mark message as read when opened in new window"));
1966
1967         PACK_CHECK_BUTTON
1968                 (vbox2, checkbtn_openinbox,
1969                  _("Go to inbox after receiving new mail"));
1970
1971         vbox3 = gtk_vbox_new (FALSE, 0);
1972         gtk_widget_show (vbox3);
1973         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
1974
1975         immedexec_tooltip = gtk_tooltips_new();
1976
1977         PACK_CHECK_BUTTON
1978                 (vbox3, checkbtn_immedexec,
1979                  _("Execute immediately when moving or deleting messages"));
1980         gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
1981                              _("Messages will be marked until execution"
1982                                " if this is turned off"),
1983                              NULL);
1984
1985         hbox1 = gtk_hbox_new (FALSE, 0);
1986         gtk_widget_show (hbox1);
1987         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1988
1989         /* Next Unread Message Dialog */
1990         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
1991         gtk_widget_show (hbox1);
1992         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
1993
1994         label = gtk_label_new (_("Show no-unread-message dialog"));
1995         gtk_widget_show (label);
1996         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
1997
1998         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
1999         gtk_widget_show (optmenu_nextunreadmsgdialog);
2000         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
2001         
2002         menu = gtk_menu_new ();
2003         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
2004         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
2005                       NEXTUNREADMSGDIALOG_ASSUME_YES);
2006         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
2007                       NEXTUNREADMSGDIALOG_ASSUME_NO);
2008
2009         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
2010
2011         hbox1 = gtk_hbox_new (FALSE, 8);
2012         gtk_widget_show (hbox1);
2013         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2014
2015         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2016         gtk_widget_show (button_keybind);
2017         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2018         g_signal_connect (G_OBJECT (button_keybind), "clicked",
2019                           G_CALLBACK (prefs_keybind_select), NULL);
2020
2021         /* interface.checkbtn_emacs          = checkbtn_emacs; */
2022         interface.checkbtn_always_show_msg    = checkbtn_always_show_msg;
2023         interface.checkbtn_openunread         = checkbtn_openunread;
2024         interface.checkbtn_mark_as_read_on_newwin
2025                                               = checkbtn_mark_as_read_on_newwin;
2026         interface.checkbtn_openinbox          = checkbtn_openinbox;
2027         interface.checkbtn_immedexec          = checkbtn_immedexec;
2028         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
2029 }
2030
2031 static void prefs_other_create(void)
2032 {
2033         GtkWidget *vbox1;
2034         GtkWidget *hbox1;
2035
2036         GtkWidget *frame_addr;
2037         GtkWidget *vbox_addr;
2038         GtkWidget *checkbtn_addaddrbyclick;
2039         
2040         GtkWidget *frame_cliplog;
2041         GtkWidget *vbox_cliplog;
2042         GtkWidget *hbox_cliplog;
2043         GtkWidget *checkbtn_cliplog;
2044         GtkWidget *loglength_label;
2045         GtkWidget *loglength_entry;
2046         GtkTooltips *loglength_tooltip;
2047
2048         GtkWidget *frame_exit;
2049         GtkWidget *vbox_exit;
2050         GtkWidget *checkbtn_confonexit;
2051         GtkWidget *checkbtn_cleanonexit;
2052         GtkWidget *checkbtn_askonclean;
2053         GtkWidget *checkbtn_warnqueued;
2054
2055         GtkWidget *label_iotimeout;
2056         GtkWidget *spinbtn_iotimeout;
2057         GtkObject *spinbtn_iotimeout_adj;
2058
2059 #if 0
2060 #ifdef USE_OPENSSL
2061         GtkWidget *frame_ssl;
2062         GtkWidget *vbox_ssl;
2063         GtkWidget *hbox_ssl;
2064         GtkWidget *checkbtn_ssl_ask_unknown_valid;
2065 #endif
2066 #endif
2067         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2068         gtk_widget_show (vbox1);
2069         gtk_container_add (GTK_CONTAINER (notebook), vbox1);
2070         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2071
2072         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2073
2074         vbox_addr = gtk_vbox_new (FALSE, 0);
2075         gtk_widget_show (vbox_addr);
2076         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2077         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2078
2079         PACK_CHECK_BUTTON
2080                 (vbox_addr, checkbtn_addaddrbyclick,
2081                  _("Add address to destination when double-clicked"));
2082
2083         /* Clip Log */
2084         PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
2085
2086         vbox_cliplog = gtk_vbox_new (FALSE, 0);
2087         gtk_widget_show (vbox_cliplog);
2088         gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
2089         gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
2090         PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
2091                            _("Clip the log size"));
2092         hbox_cliplog = gtk_hbox_new (FALSE, 3);
2093         gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
2094         gtk_widget_show (hbox_cliplog);
2095         
2096         loglength_label = gtk_label_new (_("Log window length"));
2097         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
2098                             FALSE, TRUE, 0);
2099         gtk_widget_show (GTK_WIDGET (loglength_label));
2100         
2101         loglength_tooltip = gtk_tooltips_new();
2102         
2103         loglength_entry = gtk_entry_new ();
2104         gtk_widget_set_size_request (GTK_WIDGET (loglength_entry), 64, -1);
2105         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
2106                             FALSE, TRUE, 0);
2107         gtk_widget_show (GTK_WIDGET (loglength_entry));
2108         gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), loglength_entry,
2109                              _("0 to stop logging in the log window"),
2110                              NULL);
2111         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
2112
2113 #if 0
2114 #ifdef USE_OPENSSL
2115         /* SSL */
2116         PACK_FRAME (vbox1, frame_ssl, _("Security"));
2117
2118         vbox_ssl = gtk_vbox_new (FALSE, 0);
2119         gtk_widget_show (vbox_ssl);
2120         gtk_container_add (GTK_CONTAINER (frame_ssl), vbox_ssl);
2121         gtk_container_set_border_width (GTK_CONTAINER (vbox_ssl), 8);
2122         PACK_CHECK_BUTTON (vbox_ssl, checkbtn_ssl_ask_unknown_valid, 
2123                            _("Ask before accepting SSL certificates"));
2124         hbox_ssl = gtk_hbox_new (FALSE, 3);
2125         gtk_container_add (GTK_CONTAINER (vbox_ssl), hbox_ssl);
2126         gtk_widget_show (hbox_ssl);
2127 #endif
2128 #endif
2129         
2130         /* On Exit */
2131         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2132
2133         vbox_exit = gtk_vbox_new (FALSE, 0);
2134         gtk_widget_show (vbox_exit);
2135         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2136         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2137
2138         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2139                            _("Confirm on exit"));
2140
2141         hbox1 = gtk_hbox_new (FALSE, 32);
2142         gtk_widget_show (hbox1);
2143         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2144
2145         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2146                            _("Empty trash on exit"));
2147         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2148                            _("Ask before emptying"));
2149         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2150
2151         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2152                            _("Warn if there are queued messages"));
2153
2154         hbox1 = gtk_hbox_new (FALSE, 8);
2155         gtk_widget_show (hbox1);
2156         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2157
2158         label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
2159         gtk_widget_show (label_iotimeout);
2160         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2161
2162         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
2163         spinbtn_iotimeout = gtk_spin_button_new
2164                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
2165         gtk_widget_show (spinbtn_iotimeout);
2166         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
2167                             FALSE, FALSE, 0);
2168         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
2169         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
2170
2171         label_iotimeout = gtk_label_new (_("seconds"));
2172         gtk_widget_show (label_iotimeout);
2173         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2174
2175         other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
2176         
2177         other.checkbtn_cliplog     = checkbtn_cliplog;
2178         other.loglength_entry      = loglength_entry;
2179
2180         other.checkbtn_confonexit  = checkbtn_confonexit;
2181         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2182         other.checkbtn_askonclean  = checkbtn_askonclean;
2183         other.checkbtn_warnqueued  = checkbtn_warnqueued;
2184
2185         other.spinbtn_iotimeout     = spinbtn_iotimeout;
2186         other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
2187         
2188 #if 0
2189 #ifdef USE_OPENSSL
2190         other.checkbtn_ssl_ask_unknown_valid = checkbtn_ssl_ask_unknown_valid;
2191 #endif
2192 #endif
2193 }
2194
2195 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2196 {
2197         GtkWidget *datefmt_sample = NULL;
2198         gchar *text;
2199
2200         g_return_if_fail(widget != NULL);
2201         g_return_if_fail(*widget != NULL);
2202         g_return_if_fail(display.entry_datefmt != NULL);
2203
2204         datefmt_sample = GTK_WIDGET(g_object_get_data
2205                                     (G_OBJECT(*widget), "datefmt_sample"));
2206         g_return_if_fail(datefmt_sample != NULL);
2207
2208         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2209         g_free(prefs_common.date_format);
2210         prefs_common.date_format = text;
2211         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2212
2213         gtk_widget_destroy(*widget);
2214         *widget = NULL;
2215 }
2216
2217 static void date_format_cancel_btn_clicked(GtkButton *button,
2218                                            GtkWidget **widget)
2219 {
2220         g_return_if_fail(widget != NULL);
2221         g_return_if_fail(*widget != NULL);
2222
2223         gtk_widget_destroy(*widget);
2224         *widget = NULL;
2225 }
2226
2227 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2228                                         GtkWidget **widget)
2229 {
2230         if (event && event->keyval == GDK_Escape)
2231                 date_format_cancel_btn_clicked(NULL, widget);
2232         return FALSE;
2233 }
2234
2235 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2236                                       GdkEventAny *event, GtkWidget **widget)
2237 {
2238         g_return_val_if_fail(widget != NULL, FALSE);
2239         g_return_val_if_fail(*widget != NULL, FALSE);
2240
2241         *widget = NULL;
2242         return FALSE;
2243 }
2244
2245 static void date_format_entry_on_change(GtkEditable *editable,
2246                                         GtkLabel *example)
2247 {
2248         time_t cur_time;
2249         struct tm *cal_time;
2250         gchar buffer[100];
2251         gchar *text;
2252
2253         cur_time = time(NULL);
2254         cal_time = localtime(&cur_time);
2255         buffer[0] = 0;
2256         text = gtk_editable_get_chars(editable, 0, -1);
2257         if (text)
2258                 strftime(buffer, sizeof buffer, text, cal_time); 
2259         g_free(text);
2260
2261         text = conv_codeset_strdup(buffer,
2262                                    conv_get_locale_charset_str(),
2263                                    CS_UTF_8);
2264         if (!text)
2265                 text = g_strdup(buffer);
2266
2267         gtk_label_set_text(example, text);
2268
2269         g_free(text);
2270 }
2271
2272 static void date_format_select_row(GtkTreeView *list_view,
2273                                    GtkTreePath *path,
2274                                    GtkTreeViewColumn *column,
2275                                    GtkWidget *date_format)
2276 {
2277         gint cur_pos;
2278         gchar *format;
2279         const gchar *old_format;
2280         gchar *new_format;
2281         GtkWidget *datefmt_sample;
2282         GtkTreeIter iter;
2283         GtkTreeModel *model;
2284         
2285         g_return_if_fail(date_format != NULL);
2286
2287         /* only on double click */
2288         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
2289                                                       "datefmt_sample"));
2290
2291         g_return_if_fail(datefmt_sample != NULL);
2292
2293         model = gtk_tree_view_get_model(list_view);
2294
2295         /* get format from list */
2296         if (!gtk_tree_model_get_iter(model, &iter, path))
2297                 return;
2298
2299         gtk_tree_model_get(model, &iter, DATEFMT_FMT, &format, -1);             
2300         
2301         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2302         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2303
2304         /* insert the format into the text entry */
2305         new_format = g_malloc(strlen(old_format) + 3);
2306
2307         strncpy(new_format, old_format, cur_pos);
2308         new_format[cur_pos] = '\0';
2309         strcat(new_format, format);
2310         strcat(new_format, &old_format[cur_pos]);
2311
2312         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2313         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2314
2315         g_free(new_format);
2316 }
2317
2318 static GtkWidget *date_format_create(GtkButton *button, void *data)
2319 {
2320         static GtkWidget *datefmt_win = NULL;
2321
2322         GtkWidget *vbox1;
2323         GtkWidget *scrolledwindow1;
2324         GtkWidget *datefmt_list_view;
2325         GtkWidget *table;
2326         GtkWidget *label1;
2327         GtkWidget *label2;
2328         GtkWidget *label3;
2329         GtkWidget *confirm_area;
2330         GtkWidget *ok_btn;
2331         GtkWidget *cancel_btn;
2332         GtkWidget *datefmt_entry;
2333         GtkListStore *store;
2334
2335         struct {
2336                 gchar *fmt;
2337                 gchar *txt;
2338         } time_format[] = {
2339                 { "%a", NULL },
2340                 { "%A", NULL },
2341                 { "%b", NULL },
2342                 { "%B", NULL },
2343                 { "%c", NULL },
2344                 { "%C", NULL },
2345                 { "%d", NULL },
2346                 { "%H", NULL },
2347                 { "%I", NULL },
2348                 { "%j", NULL },
2349                 { "%m", NULL },
2350                 { "%M", NULL },
2351                 { "%p", NULL },
2352                 { "%S", NULL },
2353                 { "%w", NULL },
2354                 { "%x", NULL },
2355                 { "%y", NULL },
2356                 { "%Y", NULL },
2357                 { "%Z", NULL }
2358         };
2359
2360         gchar *titles[2];
2361         gint i;
2362         const gint TIME_FORMAT_ELEMS =
2363                 sizeof time_format / sizeof time_format[0];
2364
2365         GtkCellRenderer *renderer;
2366         GtkTreeViewColumn *column;
2367         GtkTreeSelection *selection;
2368
2369         time_format[0].txt  = _("the full abbreviated weekday name");
2370         time_format[1].txt  = _("the full weekday name");
2371         time_format[2].txt  = _("the abbreviated month name");
2372         time_format[3].txt  = _("the full month name");
2373         time_format[4].txt  = _("the preferred date and time for the current locale");
2374         time_format[5].txt  = _("the century number (year/100)");
2375         time_format[6].txt  = _("the day of the month as a decimal number");
2376         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
2377         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
2378         time_format[9].txt  = _("the day of the year as a decimal number");
2379         time_format[10].txt = _("the month as a decimal number");
2380         time_format[11].txt = _("the minute as a decimal number");
2381         time_format[12].txt = _("either AM or PM");
2382         time_format[13].txt = _("the second as a decimal number");
2383         time_format[14].txt = _("the day of the week as a decimal number");
2384         time_format[15].txt = _("the preferred date for the current locale");
2385         time_format[16].txt = _("the last two digits of a year");
2386         time_format[17].txt = _("the year as a decimal number");
2387         time_format[18].txt = _("the time zone or name or abbreviation");
2388
2389         if (datefmt_win) return datefmt_win;
2390
2391         store = gtk_list_store_new(N_DATEFMT_COLUMNS,
2392                                    G_TYPE_STRING,
2393                                    G_TYPE_STRING,
2394                                    -1);
2395
2396         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2397                 GtkTreeIter iter;
2398
2399                 gtk_list_store_append(store, &iter);
2400                 gtk_list_store_set(store, &iter,
2401                                    DATEFMT_FMT, time_format[i].fmt,
2402                                    DATEFMT_TXT, time_format[i].txt,
2403                                    -1);
2404         }
2405
2406         datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2407         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2408         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2409         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2410         gtk_widget_set_size_request(datefmt_win, 440, 280);
2411
2412         vbox1 = gtk_vbox_new(FALSE, 10);
2413         gtk_widget_show(vbox1);
2414         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2415
2416         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2417         gtk_scrolled_window_set_policy
2418                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
2419                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2420         gtk_widget_show(scrolledwindow1);
2421         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2422
2423         datefmt_list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2424         g_object_unref(G_OBJECT(store));
2425         gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(datefmt_list_view), TRUE);
2426         gtk_widget_show(datefmt_list_view);
2427         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_list_view);
2428
2429         renderer = gtk_cell_renderer_text_new();
2430         column = gtk_tree_view_column_new_with_attributes
2431                         (_("Specifier"), renderer, "text", DATEFMT_FMT,
2432                          NULL);
2433         gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
2434         
2435         renderer = gtk_cell_renderer_text_new();
2436         column = gtk_tree_view_column_new_with_attributes
2437                         (_("Description"), renderer, "text", DATEFMT_TXT,
2438                          NULL);
2439         gtk_tree_view_append_column(GTK_TREE_VIEW(datefmt_list_view), column);
2440         
2441         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
2442         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(datefmt_list_view));
2443         gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
2444
2445         g_signal_connect(G_OBJECT(datefmt_list_view), "row_activated", 
2446                          G_CALLBACK(date_format_select_row),
2447                          datefmt_win);
2448         
2449         table = gtk_table_new(2, 2, FALSE);
2450         gtk_widget_show(table);
2451         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
2452         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
2453         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2454
2455         label1 = gtk_label_new(_("Date format"));
2456         gtk_widget_show(label1);
2457         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
2458                          GTK_FILL, 0, 0, 0);
2459         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
2460         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
2461
2462         datefmt_entry = gtk_entry_new();
2463         gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
2464         gtk_widget_show(datefmt_entry);
2465         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
2466                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2467
2468         /* we need the "sample" entry box; add it as data so callbacks can
2469          * get the entry box */
2470         g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
2471                           datefmt_entry);
2472
2473         label2 = gtk_label_new(_("Example"));
2474         gtk_widget_show(label2);
2475         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
2476                          GTK_FILL, 0, 0, 0);
2477         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
2478         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
2479
2480         label3 = gtk_label_new("");
2481         gtk_widget_show(label3);
2482         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
2483                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2484         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
2485         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
2486
2487         gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
2488                                 &cancel_btn, GTK_STOCK_CANCEL, NULL, NULL);
2489
2490         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
2491         gtk_widget_show(confirm_area);
2492         gtk_widget_grab_default(ok_btn);
2493
2494         /* set the current format */
2495         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
2496         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
2497                                     GTK_LABEL(label3));
2498
2499         g_signal_connect(G_OBJECT(ok_btn), "clicked",
2500                          G_CALLBACK(date_format_ok_btn_clicked),
2501                          &datefmt_win);
2502         g_signal_connect(G_OBJECT(cancel_btn), "clicked",
2503                          G_CALLBACK(date_format_cancel_btn_clicked),
2504                          &datefmt_win);
2505         g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
2506                          G_CALLBACK(date_format_key_pressed),
2507                          &datefmt_win);
2508         g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
2509                          G_CALLBACK(date_format_on_delete),
2510                          &datefmt_win);
2511         g_signal_connect(G_OBJECT(datefmt_entry), "changed",
2512                          G_CALLBACK(date_format_entry_on_change),
2513                          label3);
2514
2515         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2516         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
2517
2518         gtk_widget_show(datefmt_win);
2519         manage_window_set_transient(GTK_WINDOW(datefmt_win));
2520
2521         gtk_widget_grab_focus(ok_btn);
2522
2523         return datefmt_win;
2524 }
2525
2526 static void prefs_keybind_select(void)
2527 {
2528         GtkWidget *window;
2529         GtkWidget *vbox1;
2530         GtkWidget *hbox1;
2531         GtkWidget *label;
2532         GtkWidget *combo;
2533         GtkWidget *confirm_area;
2534         GtkWidget *ok_btn;
2535         GtkWidget *cancel_btn;
2536
2537         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2538         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
2539         gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
2540         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
2541         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
2542         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
2543         manage_window_set_transient (GTK_WINDOW (window));
2544
2545         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2546         gtk_container_add (GTK_CONTAINER (window), vbox1);
2547         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
2548
2549         hbox1 = gtk_hbox_new (FALSE, 8);
2550         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2551
2552         label = gtk_label_new
2553                 (_("Select preset:"));
2554         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2555         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2556
2557         hbox1 = gtk_hbox_new (FALSE, 8);
2558         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2559
2560         combo = gtk_combo_new ();
2561         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
2562         gtkut_combo_set_items (GTK_COMBO (combo),
2563                                _("Default"),
2564                                "Mew / Wanderlust",
2565                                "Mutt",
2566                                _("Old Sylpheed"),
2567                                NULL);
2568         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
2569
2570         hbox1 = gtk_hbox_new (FALSE, 8);
2571         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2572
2573         label = gtk_label_new
2574                 (_("You can also modify each menu shortcut by pressing\n"
2575                    "any key(s) when placing the mouse pointer on the item."));
2576         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2577         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2578
2579         hbox1 = gtk_hbox_new (FALSE, 8);
2580         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2581
2582         gtkut_stock_button_set_create (&confirm_area, &ok_btn, GTK_STOCK_OK,
2583                                        &cancel_btn, GTK_STOCK_CANCEL,
2584                                        NULL, NULL);
2585         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
2586         gtk_widget_grab_default (ok_btn);
2587
2588         MANAGE_WINDOW_SIGNALS_CONNECT(window);
2589         g_signal_connect (G_OBJECT (window), "delete_event",
2590                           G_CALLBACK (prefs_keybind_deleted), NULL);
2591         g_signal_connect (G_OBJECT (window), "key_press_event",
2592                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
2593         g_signal_connect (G_OBJECT (ok_btn), "clicked",
2594                           G_CALLBACK (prefs_keybind_apply_clicked),
2595                           NULL);
2596         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
2597                           G_CALLBACK (prefs_keybind_cancel),
2598                           NULL);
2599
2600         gtk_widget_show_all(window);
2601
2602         keybind.window = window;
2603         keybind.combo = combo;
2604 }
2605
2606 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
2607                                           gpointer data)
2608 {
2609         if (event && event->keyval == GDK_Escape)
2610                 prefs_keybind_cancel();
2611         return FALSE;
2612 }
2613
2614 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
2615                                   gpointer data)
2616 {
2617         prefs_keybind_cancel();
2618         return TRUE;
2619 }
2620
2621 static void prefs_keybind_cancel(void)
2622 {
2623         gtk_widget_destroy(keybind.window);
2624         keybind.window = NULL;
2625         keybind.combo = NULL;
2626 }
2627   
2628 struct KeyBind {
2629         const gchar *accel_path;
2630         const gchar *accel_key;
2631 };
2632
2633 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
2634 {
2635         gint i;
2636         guint key;
2637         GdkModifierType mods;
2638
2639         for (i = 0; i < num; i++) {
2640                 const gchar *accel_key
2641                         = keybind[i].accel_key ? keybind[i].accel_key : "";
2642                 gtk_accelerator_parse(accel_key, &key, &mods);
2643                 gtk_accel_map_change_entry(keybind[i].accel_path,
2644                                            key, mods, TRUE);
2645         }
2646 }
2647
2648 static void prefs_keybind_apply_clicked(GtkWidget *widget)
2649 {
2650         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
2651         const gchar *text;
2652         struct KeyBind *menurc;
2653         gint n_menurc;
2654
2655         static struct KeyBind default_menurc[] = {
2656                 {"<Main>/File/Empty all Trash folders",         ""},
2657                 {"<Main>/File/Save as...",                      "<control>S"},
2658                 {"<Main>/File/Print...",                        ""},
2659                 {"<Main>/File/Exit",                            "<control>Q"},
2660
2661                 {"<Main>/Edit/Copy",                            "<control>C"},
2662                 {"<Main>/Edit/Select all",                      "<control>A"},
2663                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2664                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
2665
2666                 {"<Main>/View/Show or hide/Message View",       "V"},
2667                 {"<Main>/View/Thread view",                     "<control>T"},
2668                 {"<Main>/View/Go to/Prev message",              "P"},
2669                 {"<Main>/View/Go to/Next message",              "N"},
2670                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2671                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2672                 {"<Main>/View/Go to/Other folder...",           "G"},
2673                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2674                 {"<Main>/View/Message source",                  "<control>U"},
2675                 {"<Main>/View/Show all headers",                "<control>H"},
2676                 {"<Main>/View/Update summary",                  "<control><alt>U"},
2677
2678                 {"<Main>/Message/Receive/Get from current account",
2679                                                                 "<control>I"},
2680                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
2681                 {"<Main>/Message/Compose an email message",     "<control>M"},
2682                 {"<Main>/Message/Reply",                        "<control>R"},
2683                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
2684                 {"<Main>/Message/Reply to/sender",              ""},
2685                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2686                 {"<Main>/Message/Forward",                      "<control><alt>F"},
2687                 /* {"<Main>/Message/Forward as attachment",      ""}, */
2688                 {"<Main>/Message/Move...",                      "<control>O"},
2689                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
2690                 {"<Main>/Message/Delete",                       "<control>D"},
2691                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2692                 {"<Main>/Message/Mark/Unmark",                  "U"},
2693                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2694                 {"<Main>/Message/Mark/Mark as read",            ""},
2695
2696                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2697                 {"<Main>/Tools/Execute",                        "X"},
2698                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2699
2700                 {"<Compose>/Message/Close",                             "<control>W"},
2701                 {"<Compose>/Edit/Select all",                           "<control>A"},
2702                 {"<Compose>/Edit/Advanced/Move a word backward",        ""},
2703                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
2704                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
2705                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
2706                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
2707         };
2708
2709         static struct KeyBind mew_wl_menurc[] = {
2710                 {"<Main>/File/Empty all Trash folders",                 "<shift>D"},
2711                 {"<Main>/File/Save as...",                      "Y"},
2712                 {"<Main>/File/Print...",                        "<shift>numbersign"},
2713                 {"<Main>/File/Exit",                            "<shift>Q"},
2714
2715                 {"<Main>/Edit/Copy",                            "<control>C"},
2716                 {"<Main>/Edit/Select all",                      "<control>A"},
2717                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2718                 {"<Main>/Edit/Search folder...",                "<control>S"},
2719
2720                 {"<Main>/View/Show or hide/Message View",       ""},
2721                 {"<Main>/View/Thread view",                     "<shift>T"},
2722                 {"<Main>/View/Go to/Prev message",              "P"},
2723                 {"<Main>/View/Go to/Next message",              "N"},
2724                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2725                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2726                 {"<Main>/View/Go to/Other folder...",           "G"},
2727                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2728                 {"<Main>/View/Message source",                  "<control>U"},
2729                 {"<Main>/View/Show all headers",                "<shift>H"},
2730                 {"<Main>/View/Update summary",                  "<shift>S"},
2731
2732                 {"<Main>/Message/Receive/Get from current account",
2733                                                                 "<control>I"},
2734                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
2735                 {"<Main>/Message/Compose an email message",     "W"},
2736                 {"<Main>/Message/Reply",                        "<control>R"},
2737                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
2738                 {"<Main>/Message/Reply to/sender",              ""},
2739                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2740                 {"<Main>/Message/Forward",                      "F"},
2741                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
2742                 {"<Main>/Message/Move...",                      "O"},
2743                 {"<Main>/Message/Copy...",                      "<shift>O"},
2744                 {"<Main>/Message/Delete",                       "D"},
2745                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2746                 {"<Main>/Message/Mark/Unmark",                  "U"},
2747                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2748                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
2749
2750                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2751                 {"<Main>/Tools/Execute",                        "X"},
2752                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2753
2754                 {"<Compose>/Message/Close",                             "<alt>W"},
2755                 {"<Compose>/Edit/Select all",                           ""},
2756                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
2757                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2758                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2759                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2760                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2761         };
2762
2763         static struct KeyBind mutt_menurc[] = {
2764                 {"<Main>/File/Empty all Trash folders",         ""},
2765                 {"<Main>/File/Save as...",                      "S"},
2766                 {"<Main>/File/Print...",                        "P"},
2767                 {"<Main>/File/Exit",                            "Q"},
2768
2769                 {"<Main>/Edit/Copy",                            "<control>C"},
2770                 {"<Main>/Edit/Select all",                      "<control>A"},
2771                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2772                 {"<Main>/Edit/Search messages...",              "slash"},
2773
2774                 {"<Main>/View/Show or hide/Message view",       "V"},
2775                 {"<Main>/View/Thread view",                     "<control>T"},
2776                 {"<Main>/View/Go to/Prev message",              ""},
2777                 {"<Main>/View/Go to/Next message",              ""},
2778                 {"<Main>/View/Go to/Prev unread message",       ""},
2779                 {"<Main>/View/Go to/Next unread message",       ""},
2780                 {"<Main>/View/Go to/Other folder...",           "C"},
2781                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2782                 {"<Main>/View/Message source",                  "<control>U"},
2783                 {"<Main>/View/Show all headers",                "<control>H"},
2784                 {"<Main>/View/Update summary",                          "<control><alt>U"},
2785
2786                 {"<Main>/Message/Receive/Get from current account",
2787                                                                 "<control>I"},
2788                 {"<Main>/Message/Receive/Get from all accounts","<shift><control>I"},
2789                 {"<Main>/Message/Compose an email message",             "M"},
2790                 {"<Main>/Message/Reply",                        "R"},
2791                 {"<Main>/Message/Reply to/all",                 "G"},
2792                 {"<Main>/Message/Reply to/sender",              ""},
2793                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2794                 {"<Main>/Message/Forward",                      "F"},
2795                 {"<Main>/Message/Forward as attachment",        ""},
2796                 {"<Main>/Message/Move...",                      "<control>O"},
2797                 {"<Main>/Message/Copy...",                      "<shift>C"},
2798                 {"<Main>/Message/Delete",                       "D"},
2799                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
2800                 {"<Main>/Message/Mark/Unmark",                  "U"},
2801                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
2802                 {"<Main>/Message/Mark/Mark as read",            ""},
2803
2804                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2805                 {"<Main>/Tools/Execute",                        "X"},
2806                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2807
2808                 {"<Compose>/Message/Close",                             "<alt>W"},
2809                 {"<Compose>/Edit/Select all",                           ""},
2810                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2811                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2812                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2813                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2814                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2815         };
2816
2817         static struct KeyBind old_sylpheed_menurc[] = {
2818                 {"<Main>/File/Empty all Trash folders",         ""},
2819                 {"<Main>/File/Save as...",                      ""},
2820                 {"<Main>/File/Print...",                        "<alt>P"},
2821                 {"<Main>/File/Exit",                            "<alt>Q"},
2822
2823                 {"<Main>/Edit/Copy",                            "<control>C"},
2824                 {"<Main>/Edit/Select all",                      "<control>A"},
2825                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2826                 {"<Main>/Edit/Search folder...",                "<control>S"},
2827
2828                 {"<Main>/View/Show or hide/Message View",       ""},
2829                 {"<Main>/View/Thread view",                     "<control>T"},
2830                 {"<Main>/View/Go to/Prev message",              "P"},
2831                 {"<Main>/View/Go to/Next message",              "N"},
2832                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2833                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2834                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
2835                 {"<Main>/View/Open in new window",              "<shift><control>N"},
2836                 {"<Main>/View/Message source",                  "<control>U"},
2837                 {"<Main>/View/Show all headers",                "<control>H"},
2838                 {"<Main>/View/Update summary",                  "<alt>U"},
2839
2840                 {"<Main>/Message/Receive/Get from current account",
2841                                                                 "<alt>I"},
2842                 {"<Main>/Message/Receive/Get from all accounts","<shift><alt>I"},
2843                 {"<Main>/Message/Compose an email message",     "<alt>N"},
2844                 {"<Main>/Message/Reply",                        "<alt>R"},
2845                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
2846                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
2847                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2848                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
2849                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
2850                 {"<Main>/Message/Move...",                      "<alt>O"},
2851                 {"<Main>/Message/Copy...",                      ""},
2852                 {"<Main>/Message/Delete",                       "<alt>D"},
2853                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2854                 {"<Main>/Message/Mark/Unmark",                  "U"},
2855                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2856                 {"<Main>/Message/Mark/Mark as read",            ""},
2857
2858                 {"<Main>/Tools/Address book",                   "<alt>A"},
2859                 {"<Main>/Tools/Execute",                        "<alt>X"},
2860                 {"<Main>/Tools/Log window",                     "<alt>L"},
2861
2862                 {"<Compose>/Message/Close",                             "<alt>W"},
2863                 {"<Compose>/Edit/Select all",                           ""},
2864                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2865                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2866                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2867                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2868                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2869         };
2870   
2871         text = gtk_entry_get_text(entry);
2872   
2873         if (!strcmp(text, _("Default"))) {
2874                 menurc = default_menurc;
2875                 n_menurc = G_N_ELEMENTS(default_menurc);
2876         } else if (!strcmp(text, "Mew / Wanderlust")) {
2877                 menurc = mew_wl_menurc;
2878                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
2879         } else if (!strcmp(text, "Mutt")) {
2880                 menurc = mutt_menurc;
2881                 n_menurc = G_N_ELEMENTS(mutt_menurc);
2882         } else if (!strcmp(text, _("Old Sylpheed"))) {
2883                 menurc = old_sylpheed_menurc;
2884                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
2885         } else {
2886                 return;
2887         }
2888
2889         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
2890         prefs_keybind_apply(menurc, n_menurc);
2891
2892         gtk_widget_destroy(keybind.window);
2893         keybind.window = NULL;
2894         keybind.combo = NULL;
2895 }
2896
2897 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
2898 {
2899         GtkWidget *menu;
2900         GtkWidget *menuitem;
2901         gchar *charset;
2902
2903         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2904         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2905         charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
2906         g_free(*((gchar **)pparam->data));
2907         *((gchar **)pparam->data) = g_strdup(charset);
2908 }
2909
2910 static void prefs_common_charset_set_optmenu(PrefParam *pparam)
2911 {
2912         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2913         gint index;
2914
2915         g_return_if_fail(optmenu != NULL);
2916         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2917
2918         index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
2919                                             (GCompareFunc)strcmp2);
2920         if (index >= 0)
2921                 gtk_option_menu_set_history(optmenu, index);
2922         else {
2923                 gtk_option_menu_set_history(optmenu, 0);
2924                 prefs_common_charset_set_data_from_optmenu(pparam);
2925         }
2926 }
2927
2928 static void prefs_common_encoding_set_data_from_optmenu(PrefParam *pparam)
2929 {
2930         GtkWidget *menu;
2931         GtkWidget *menuitem;
2932
2933         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2934         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2935         *((TransferEncodingMethod *)pparam->data) = GPOINTER_TO_INT
2936                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2937 }
2938
2939 static void prefs_common_encoding_set_optmenu(PrefParam *pparam)
2940 {
2941         TransferEncodingMethod method =
2942                 *((TransferEncodingMethod *)pparam->data);
2943         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2944         gint index;
2945
2946         g_return_if_fail(optmenu != NULL);
2947
2948         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(method),
2949                                             NULL);
2950         if (index >= 0)
2951                 gtk_option_menu_set_history(optmenu, index);
2952         else {
2953                 gtk_option_menu_set_history(optmenu, 0);
2954                 prefs_common_encoding_set_data_from_optmenu(pparam);
2955         }
2956 }
2957
2958 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)
2959 {
2960         GtkWidget *menu;
2961         GtkWidget *menuitem;
2962
2963         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2964         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2965         *((RecvDialogMode *)pparam->data) = GPOINTER_TO_INT
2966                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2967 }
2968
2969 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
2970 {
2971         RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
2972         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2973         GtkWidget *menu;
2974         GtkWidget *menuitem;
2975         gint index;
2976
2977         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
2978                                             NULL);
2979         if (index >= 0)
2980                 gtk_option_menu_set_history(optmenu, index);
2981         else {
2982                 gtk_option_menu_set_history(optmenu, 0);
2983                 prefs_common_recv_dialog_set_data_from_optmenu(pparam);
2984         }
2985
2986         menu = gtk_option_menu_get_menu(optmenu);
2987         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2988         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2989 }
2990
2991 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam)
2992 {
2993         GtkWidget *menu;
2994         GtkWidget *menuitem;
2995
2996         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2997         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2998         *((SendDialogMode *)pparam->data) = GPOINTER_TO_INT
2999                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3000 }
3001
3002 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam)
3003 {
3004         SendDialogMode mode = *((SendDialogMode *)pparam->data);
3005         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3006         GtkWidget *menu;
3007         GtkWidget *menuitem;
3008
3009         switch (mode) {
3010         case SEND_DIALOG_ALWAYS:
3011                 gtk_option_menu_set_history(optmenu, 0);
3012                 break;
3013         case SEND_DIALOG_NEVER:
3014                 gtk_option_menu_set_history(optmenu, 1);
3015                 break;
3016         default:
3017                 break;
3018         }
3019
3020         menu = gtk_option_menu_get_menu(optmenu);
3021         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3022         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3023 }
3024
3025 static void prefs_common_apply(void)
3026 {
3027         MainWindow *mainwindow;
3028
3029         prefs_set_data_from_dialog(param);
3030         sock_set_io_timeout(prefs_common.io_timeout_secs);
3031         main_window_reflect_prefs_all_real(FALSE);
3032         prefs_common_write_config();
3033
3034         mainwindow = mainwindow_get_mainwindow();
3035         log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
3036                                 prefs_common.loglength);
3037         
3038         inc_autocheck_timer_remove();
3039         inc_autocheck_timer_set();
3040 }
3041
3042 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam)
3043 {
3044         GtkWidget *menu;
3045         GtkWidget *menuitem;
3046
3047         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3048         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3049         *((NextUnreadMsgDialogShow *)pparam->data) = GPOINTER_TO_INT
3050                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
3051 }
3052
3053 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam)
3054 {
3055         NextUnreadMsgDialogShow dialog_show;
3056         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3057         GtkWidget *menu;
3058         GtkWidget *menuitem;
3059
3060         dialog_show = *((NextUnreadMsgDialogShow *)pparam->data);
3061
3062         switch (dialog_show) {
3063         case NEXTUNREADMSGDIALOG_ALWAYS:
3064                 gtk_option_menu_set_history(optmenu, 0);
3065                 break;
3066         case NEXTUNREADMSGDIALOG_ASSUME_YES:
3067                 gtk_option_menu_set_history(optmenu, 1);
3068                 break;
3069         case NEXTUNREADMSGDIALOG_ASSUME_NO:
3070                 gtk_option_menu_set_history(optmenu, 2);
3071                 break;
3072         }
3073
3074         menu = gtk_option_menu_get_menu(optmenu);
3075         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3076         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3077 }
3078
3079 /*
3080 static void prefs_common_cancel(void)
3081 {
3082         gtk_widget_hide(dialog.window);
3083         inc_unlock();
3084 }
3085 */
3086
3087 /* static void prefs_recvdialog_set_data_from_optmenu(PrefParam *pparam)
3088 {
3089         GtkWidget *menu;
3090         GtkWidget *menuitem;
3091
3092         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3093         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3094         *((RecvDialogShow *)pparam->data) = GPOINTER_TO_INT
3095                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3096 }  */
3097
3098 /* static void prefs_recvdialog_set_optmenu(PrefParam *pparam)
3099 {
3100         RecvDialogShow dialog_show;
3101         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3102         GtkWidget *menu;
3103         GtkWidget *menuitem;
3104
3105         dialog_show = *((RecvDialogShow *)pparam->data);
3106
3107         switch (dialog_show) {
3108         case RECVDIALOG_ALWAYS:
3109                 gtk_option_menu_set_history(optmenu, 0);
3110                 break;
3111         case RECVDIALOG_WINDOW_ACTIVE:
3112                 gtk_option_menu_set_history(optmenu, 1);
3113                 break;
3114         case RECVDIALOG_NEVER:
3115                 gtk_option_menu_set_history(optmenu, 2);
3116                 break;
3117         default:
3118         }
3119
3120         menu = gtk_option_menu_get_menu(optmenu);
3121         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3122         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3123 }     */