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