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