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