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