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