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