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