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