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