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