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