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