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