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