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