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