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