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