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