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