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