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