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