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