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