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