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