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