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