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