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