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