sync with 0.7.5cvs16
[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         hbox1 = gtk_hbox_new (FALSE, 8);
2184         gtk_widget_show (hbox1);
2185         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2186
2187         label_ng_abbrev = gtk_label_new
2188                 (_("Abbreviate newsgroups longer than"));
2189         gtk_widget_show (label_ng_abbrev);
2190         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
2191
2192         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
2193         spinbtn_ng_abbrev_len = gtk_spin_button_new
2194                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
2195         gtk_widget_show (spinbtn_ng_abbrev_len);
2196         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
2197                             FALSE, FALSE, 0);
2198         gtk_widget_set_usize (spinbtn_ng_abbrev_len, 56, -1);
2199         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
2200                                      TRUE);
2201
2202         label_ng_abbrev = gtk_label_new
2203                 (_("letters"));
2204         gtk_widget_show (label_ng_abbrev);
2205         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
2206
2207         /* ---- Summary ---- */
2208
2209         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
2210
2211         vbox2 = gtk_vbox_new (FALSE, 0);
2212         gtk_widget_show (vbox2);
2213         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
2214         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
2215
2216         PACK_CHECK_BUTTON
2217                 (vbox2, chkbtn_swapfrom,
2218                  _("Display recipient on `From' column if sender is yourself"));
2219         PACK_CHECK_BUTTON
2220                 (vbox2, chkbtn_useaddrbook,
2221                  _("Display sender using address book"));
2222         PACK_CHECK_BUTTON
2223                 (vbox2, chkbtn_hscrollbar, _("Enable horizontal scroll bar"));
2224         PACK_CHECK_BUTTON
2225                 (vbox2, chkbtn_expand_thread, _("Expand threads"));
2226         PACK_CHECK_BUTTON
2227                 (vbox2, chkbtn_bold_unread,
2228                  _("Display unread messages with bold font"));
2229
2230         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2231
2232         hbox1 = gtk_hbox_new (FALSE, 8);
2233         gtk_widget_show (hbox1);
2234         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2235
2236         label_datefmt = gtk_label_new (_("Date format"));
2237         gtk_widget_show (label_datefmt);
2238         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
2239
2240         entry_datefmt = gtk_entry_new ();
2241         gtk_widget_show (entry_datefmt);
2242         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
2243
2244         button_datefmt = gtk_button_new_with_label (" ... ");
2245
2246         gtk_widget_show (button_datefmt);
2247         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
2248         gtk_signal_connect (GTK_OBJECT (button_datefmt), "clicked",
2249                             GTK_SIGNAL_FUNC (date_format_create), NULL);
2250
2251         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
2252
2253         hbox1 = gtk_hbox_new (FALSE, 8);
2254         gtk_widget_show (hbox1);
2255         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2256
2257         button_dispitem = gtk_button_new_with_label
2258                 (_(" Set display item of summary... "));
2259         gtk_widget_show (button_dispitem);
2260         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
2261         gtk_signal_connect (GTK_OBJECT (button_dispitem), "clicked",
2262                             GTK_SIGNAL_FUNC (prefs_summary_column_open),
2263                             NULL);
2264
2265         display.entry_textfont  = entry_textfont;
2266         display.button_textfont = button_textfont;
2267
2268         display.chkbtn_display_img   = chkbtn_display_img;
2269         display.chkbtn_transhdr           = chkbtn_transhdr;
2270         display.chkbtn_folder_unread      = chkbtn_folder_unread;
2271         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
2272         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
2273
2274         display.chkbtn_swapfrom      = chkbtn_swapfrom;
2275         display.chkbtn_hscrollbar    = chkbtn_hscrollbar;
2276         display.chkbtn_expand_thread = chkbtn_expand_thread;
2277         display.chkbtn_bold_unread   = chkbtn_bold_unread;
2278         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
2279         display.entry_datefmt        = entry_datefmt;
2280 }
2281
2282 static void prefs_message_create(void)
2283 {
2284         GtkWidget *vbox1;
2285         GtkWidget *vbox2;
2286         GtkWidget *vbox3;
2287         GtkWidget *hbox1;
2288         GtkWidget *chkbtn_enablecol;
2289         GtkWidget *button_edit_col;
2290         GtkWidget *chkbtn_mbalnum;
2291         GtkWidget *chkbtn_disphdrpane;
2292         GtkWidget *chkbtn_disphdr;
2293         GtkWidget *button_edit_disphdr;
2294         GtkWidget *hbox_linespc;
2295         GtkWidget *label_linespc;
2296         GtkObject *spinbtn_linespc_adj;
2297         GtkWidget *spinbtn_linespc;
2298         GtkWidget *chkbtn_headspc;
2299
2300         GtkWidget *frame_scr;
2301         GtkWidget *vbox_scr;
2302         GtkWidget *chkbtn_smoothscroll;
2303         GtkWidget *hbox_scr;
2304         GtkWidget *label_scr;
2305         GtkObject *spinbtn_scrollstep_adj;
2306         GtkWidget *spinbtn_scrollstep;
2307         GtkWidget *chkbtn_halfpage;
2308
2309         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2310         gtk_widget_show (vbox1);
2311         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2312         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2313
2314         hbox1 = gtk_hbox_new (FALSE, 8);
2315         gtk_widget_show (hbox1);
2316         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
2317
2318         PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
2319                            _("Enable coloration of message"));
2320         gtk_signal_connect (GTK_OBJECT (chkbtn_enablecol), "toggled",
2321                                                 GTK_SIGNAL_FUNC (prefs_enable_message_color_toggled),
2322                                                 NULL);
2323
2324         button_edit_col = gtk_button_new_with_label (_(" Edit... "));
2325         gtk_widget_show (button_edit_col);
2326         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
2327         gtk_signal_connect (GTK_OBJECT (button_edit_col), "clicked",
2328                             GTK_SIGNAL_FUNC (prefs_quote_colors_dialog), NULL);
2329
2330         SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
2331
2332         vbox2 = gtk_vbox_new (FALSE, 0);
2333         gtk_widget_show (vbox2);
2334         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2335
2336         PACK_CHECK_BUTTON
2337                 (vbox2, chkbtn_mbalnum,
2338                  _("Display 2-byte alphabet and numeric with 1-byte character"));
2339         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
2340                           _("Display header pane above message view"));
2341
2342         hbox1 = gtk_hbox_new (FALSE, 8);
2343         gtk_widget_show (hbox1);
2344         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2345
2346         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
2347                           _("Display short headers on message view"));
2348
2349         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
2350         gtk_widget_show (button_edit_disphdr);
2351         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
2352                           FALSE, TRUE, 0);
2353         gtk_signal_connect (GTK_OBJECT (button_edit_disphdr), "clicked",
2354                             GTK_SIGNAL_FUNC (prefs_display_header_open),
2355                             NULL);
2356
2357         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
2358
2359         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
2360
2361         hbox1 = gtk_hbox_new (FALSE, 32);
2362         gtk_widget_show (hbox1);
2363         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
2364
2365         hbox_linespc = gtk_hbox_new (FALSE, 8);
2366         gtk_widget_show (hbox1);
2367         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
2368
2369         label_linespc = gtk_label_new (_("Line space"));
2370         gtk_widget_show (label_linespc);
2371         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2372                             FALSE, FALSE, 0);
2373
2374         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
2375         spinbtn_linespc = gtk_spin_button_new
2376                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
2377         gtk_widget_show (spinbtn_linespc);
2378         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
2379                             FALSE, FALSE, 0);
2380         gtk_widget_set_usize (spinbtn_linespc, 64, -1);
2381         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
2382
2383         label_linespc = gtk_label_new (_("pixel(s)"));
2384         gtk_widget_show (label_linespc);
2385         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2386                             FALSE, FALSE, 0);
2387
2388         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Leave space on head"));
2389
2390         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
2391
2392         vbox_scr = gtk_vbox_new (FALSE, 0);
2393         gtk_widget_show (vbox_scr);
2394         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
2395         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
2396
2397         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
2398
2399         hbox1 = gtk_hbox_new (FALSE, 32);
2400         gtk_widget_show (hbox1);
2401         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
2402
2403         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
2404
2405         hbox_scr = gtk_hbox_new (FALSE, 8);
2406         gtk_widget_show (hbox_scr);
2407         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
2408
2409         label_scr = gtk_label_new (_("Step"));
2410         gtk_widget_show (label_scr);
2411         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2412
2413         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
2414         spinbtn_scrollstep = gtk_spin_button_new
2415                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
2416         gtk_widget_show (spinbtn_scrollstep);
2417         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
2418                             FALSE, FALSE, 0);
2419         gtk_widget_set_usize (spinbtn_scrollstep, 64, -1);
2420         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
2421                                      TRUE);
2422
2423         label_scr = gtk_label_new (_("pixel(s)"));
2424         gtk_widget_show (label_scr);
2425         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2426
2427         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2428
2429         message.chkbtn_enablecol   = chkbtn_enablecol;
2430         message.button_edit_col    = button_edit_col;
2431         message.chkbtn_mbalnum     = chkbtn_mbalnum;
2432         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2433         message.chkbtn_disphdr     = chkbtn_disphdr;
2434         message.spinbtn_linespc    = spinbtn_linespc;
2435         message.chkbtn_headspc     = chkbtn_headspc;
2436
2437         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2438         message.spinbtn_scrollstep     = spinbtn_scrollstep;
2439         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2440         message.chkbtn_halfpage        = chkbtn_halfpage;
2441 }
2442
2443 #if USE_GPGME
2444 static void prefs_privacy_create(void)
2445 {
2446         GtkWidget *vbox1;
2447         GtkWidget *vbox2;
2448         GtkWidget *hbox1;
2449         GtkWidget *checkbtn_auto_check_signatures;
2450         GtkWidget *checkbtn_gpg_signature_popup;
2451         GtkWidget *hbox_stpass;
2452         GtkWidget *checkbtn_store_passphrase;
2453         GtkWidget *label_stpass1;
2454         GtkObject *spinbtn_store_passphrase_adj;
2455         GtkWidget *spinbtn_store_passphrase;
2456         GtkWidget *label_stpass2;
2457         GtkWidget *hbox_stpassinfo;
2458         GtkWidget *label_stpassinfo;
2459         GtkWidget *checkbtn_passphrase_grab;
2460         GtkWidget *checkbtn_gpg_warning;
2461         GtkWidget *label;
2462         GtkWidget *menuitem;
2463         GtkWidget *optmenu;
2464         GtkWidget *optmenu_menu;
2465
2466         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2467         gtk_widget_show (vbox1);
2468         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2469         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2470
2471         vbox2 = gtk_vbox_new (FALSE, 0);
2472         gtk_widget_show (vbox2);
2473         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2474
2475         PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2476                            _("Automatically check signatures"));
2477
2478         PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2479                            _("Show signature check result in a popup window"));
2480
2481         hbox_stpass = gtk_hbox_new(FALSE, 8);
2482         gtk_box_pack_start(GTK_BOX(vbox2), hbox_stpass, FALSE, FALSE, 0);
2483
2484         PACK_CHECK_BUTTON (hbox_stpass, checkbtn_store_passphrase,
2485                            _("Store passphrase temporarily"));
2486
2487         label_stpass1 = gtk_label_new(_("- remove after"));
2488         gtk_box_pack_start(GTK_BOX(hbox_stpass), label_stpass1, FALSE, FALSE, 0);
2489
2490         spinbtn_store_passphrase_adj = gtk_adjustment_new(0, 0, 1440, 1, 5, 5);
2491         spinbtn_store_passphrase = gtk_spin_button_new(
2492                         GTK_ADJUSTMENT(spinbtn_store_passphrase_adj), 1, 0);
2493         gtk_box_pack_start(GTK_BOX(hbox_stpass), spinbtn_store_passphrase, FALSE, 
2494                            FALSE, 0);
2495         gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbtn_store_passphrase), 
2496                                     TRUE);
2497         gtk_widget_set_usize(spinbtn_store_passphrase, 50, -1);
2498     
2499         label_stpass2 = gtk_label_new(_("minute(s)"));
2500         gtk_box_pack_start(GTK_BOX(hbox_stpass), label_stpass2, FALSE, FALSE, 0);
2501         gtk_widget_show_all(hbox_stpass);
2502
2503         hbox_stpassinfo = gtk_hbox_new(FALSE, 8);
2504         gtk_box_pack_start(GTK_BOX(vbox2), hbox_stpassinfo, FALSE, FALSE, 0);
2505
2506         label_stpassinfo = gtk_label_new
2507                 (_("(A setting of '0' will store the passphrase\n"
2508                    " for the whole session)"));
2509         gtk_box_pack_start (GTK_BOX (hbox_stpassinfo), label_stpassinfo, FALSE, FALSE, 0);
2510         gtk_label_set_justify (GTK_LABEL (label_stpassinfo), GTK_JUSTIFY_LEFT);
2511         gtk_widget_show_all(hbox_stpassinfo);
2512
2513         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, label_stpass1);
2514         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, spinbtn_store_passphrase); 
2515         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, label_stpass2);
2516         SET_TOGGLE_SENSITIVITY(checkbtn_store_passphrase, label_stpassinfo);
2517
2518 #ifndef __MINGW32__
2519         PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2520                            _("Grab input while entering a passphrase"));
2521 #endif
2522
2523         PACK_CHECK_BUTTON
2524                 (vbox2, checkbtn_gpg_warning,
2525                  _("Display warning on startup if GnuPG doesn't work"));
2526
2527         hbox1 = gtk_hbox_new (FALSE, 8);
2528         gtk_widget_show (hbox1);
2529         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2530
2531         /* create default signkey box */
2532         label = gtk_label_new (_("Default Sign Key"));
2533         gtk_widget_show (label);
2534         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2535         optmenu = gtk_option_menu_new ();
2536         gtk_widget_show (optmenu);
2537         gtk_box_pack_start(GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
2538         optmenu_menu = gtk_menu_new ();
2539
2540         MENUITEM_ADD(optmenu_menu, menuitem, "Default Key", "def_key");
2541         MENUITEM_ADD(optmenu_menu, menuitem, "Second Key", "2nd_key");
2542         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
2543         /* FIXME: disabled because not implemented */
2544         gtk_widget_set_sensitive(optmenu, FALSE);
2545
2546         privacy.checkbtn_auto_check_signatures
2547                                          = checkbtn_auto_check_signatures;
2548         privacy.checkbtn_gpg_signature_popup
2549                                          = checkbtn_gpg_signature_popup;
2550         privacy.checkbtn_store_passphrase    = checkbtn_store_passphrase;
2551         privacy.spinbtn_store_passphrase     = spinbtn_store_passphrase;
2552         privacy.spinbtn_store_passphrase_adj = spinbtn_store_passphrase_adj;
2553         privacy.checkbtn_passphrase_grab = checkbtn_passphrase_grab;
2554         privacy.checkbtn_gpg_warning     = checkbtn_gpg_warning;
2555         privacy.optmenu_default_signkey  = optmenu;
2556 }
2557
2558 static void
2559 prefs_common_default_signkey_set_data_from_optmenu(PrefParam *pparam)
2560 {
2561 #if 0
2562         GtkWidget *menu;
2563         GtkWidget *menuitem;
2564         gchar *charset;
2565
2566         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2567         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2568         charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
2569         g_free(*((gchar **)pparam->data));
2570         *((gchar **)pparam->data) = g_strdup(charset);
2571 #endif
2572 }
2573
2574 static void prefs_common_default_signkey_set_optmenu(PrefParam *pparam)
2575 {
2576 #if 0
2577         GList *cur;
2578         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2579         GtkWidget *menu;
2580         GtkWidget *menuitem;
2581         gchar *charset;
2582         gint n = 0;
2583
2584         g_return_if_fail(optmenu != NULL);
2585         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2586
2587         menu = gtk_option_menu_get_menu(optmenu);
2588         for (cur = GTK_MENU_SHELL(menu)->children;
2589              cur != NULL; cur = cur->next) {
2590                 menuitem = GTK_WIDGET(cur->data);
2591                 charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
2592                 if (!strcmp(charset, *((gchar **)pparam->data))) {
2593                         gtk_option_menu_set_history(optmenu, n);
2594                         return;
2595                 }
2596                 n++;
2597         }
2598
2599         gtk_option_menu_set_history(optmenu, 0);
2600         prefs_common_charset_set_data_from_optmenu(pparam);
2601 #endif
2602 }
2603 #endif /* USE_GPGME */
2604
2605 static void prefs_interface_create(void)
2606 {
2607         GtkWidget *vbox1;
2608         GtkWidget *vbox2;
2609         GtkWidget *vbox3;
2610         /* GtkWidget *checkbtn_emacs; */
2611         GtkWidget *checkbtn_openunread;
2612         GtkWidget *checkbtn_openinbox;
2613         GtkWidget *checkbtn_immedexec;
2614         GtkWidget *hbox1;
2615         GtkWidget *label;
2616         GtkWidget *optmenu_recvdialog;
2617         GtkWidget *menu;
2618         GtkWidget *menuitem;
2619
2620         GtkWidget *frame_addr;
2621         GtkWidget *vbox_addr;
2622         GtkWidget *checkbtn_addaddrbyclick;
2623
2624         GtkWidget *button_keybind;
2625
2626         GtkWidget *hbox2;
2627         GtkWidget *optmenu_nextunreadmsgdialog;
2628         GtkWidget *optmenu_nextunreadmsgdialog_menu;
2629         GtkWidget *nextunreadmsgdialog_menuitem;
2630
2631         GtkWidget *frame_pixmap_theme;
2632         GtkWidget *vbox_pixmap_theme;
2633         GtkWidget *entry_pixmap_theme;
2634         GtkWidget *combo_pixmap_theme;
2635         GList *avail_pixmap_themes = NULL;
2636
2637         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2638         gtk_widget_show (vbox1);
2639         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2640         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2641
2642         vbox2 = gtk_vbox_new (FALSE, 0);
2643         gtk_widget_show (vbox2);
2644         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2645
2646         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
2647                            _("Emulate the behavior of mouse operation of\n"
2648                              "Emacs-based mailer"));
2649         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
2650                                GTK_JUSTIFY_LEFT);   */
2651
2652         PACK_CHECK_BUTTON
2653                 (vbox2, checkbtn_openunread,
2654                  _("Open first unread message when entering a folder"));
2655
2656         PACK_CHECK_BUTTON
2657                 (vbox2, checkbtn_openinbox,
2658                  _("Go to inbox after receiving new mail"));
2659
2660         vbox3 = gtk_vbox_new (FALSE, 0);
2661         gtk_widget_show (vbox3);
2662         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2663
2664         PACK_CHECK_BUTTON
2665                 (vbox3, checkbtn_immedexec,
2666                  _("Execute immediately when moving or deleting messages"));
2667
2668         hbox1 = gtk_hbox_new (FALSE, 0);
2669         gtk_widget_show (hbox1);
2670         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2671
2672         label = gtk_label_new
2673                 (_("(Messages will be marked until execution\n"
2674                    " if this is turned off)"));
2675         gtk_widget_show (label);
2676         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8);
2677         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2678
2679         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
2680
2681         hbox1 = gtk_hbox_new (FALSE, 8);
2682         gtk_widget_show (hbox1);
2683         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2684
2685         label = gtk_label_new (_("Show receive dialog"));
2686         gtk_widget_show (label);
2687         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2688
2689         optmenu_recvdialog = gtk_option_menu_new ();
2690         gtk_widget_show (optmenu_recvdialog);
2691         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2692                             FALSE, FALSE, 0);
2693
2694         menu = gtk_menu_new ();
2695         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2696         MENUITEM_ADD (menu, menuitem, _("Only if a window is active"),
2697                       RECV_DIALOG_ACTIVE);
2698         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2699
2700         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2701
2702         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2703
2704         vbox_addr = gtk_vbox_new (FALSE, 0);
2705         gtk_widget_show (vbox_addr);
2706         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2707         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2708
2709         PACK_CHECK_BUTTON
2710                 (vbox_addr, checkbtn_addaddrbyclick,
2711                  _("Add address to destination when double-clicked"));
2712
2713         /* Next Unread Message Dialog */
2714         hbox2 = gtk_hbox_new (FALSE, 8);
2715         gtk_widget_show (hbox2);
2716         gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
2717
2718         label = gtk_label_new (_("Show no-unread-message dialog"));
2719         gtk_widget_show (label);
2720         gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2721
2722         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
2723         gtk_widget_show (optmenu_nextunreadmsgdialog);
2724         gtk_box_pack_start (GTK_BOX (hbox2), optmenu_nextunreadmsgdialog,
2725                             FALSE, FALSE, 0);
2726
2727         optmenu_nextunreadmsgdialog_menu = gtk_menu_new ();
2728         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2729                       _("Always"),  NEXTUNREADMSGDIALOG_ALWAYS);
2730         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2731                       _("Assume 'Yes'"),  NEXTUNREADMSGDIALOG_ASSUME_YES);
2732         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2733                       _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO);
2734
2735         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog),
2736                                   optmenu_nextunreadmsgdialog_menu);
2737
2738
2739         /* Receive Dialog */
2740 /*      hbox = gtk_hbox_new (FALSE, 8);
2741         gtk_widget_show (hbox);
2742         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2743
2744         label = gtk_label_new (_("Show receive Dialog"));
2745         gtk_widget_show (label);
2746         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2747
2748         recvdialog_optmenu = gtk_option_menu_new ();
2749         gtk_widget_show (recvdialog_optmenu);
2750         gtk_box_pack_start (GTK_BOX (hbox), recvdialog_optmenu, FALSE, FALSE, 0);
2751
2752         recvdialog_optmenu_menu = gtk_menu_new ();
2753
2754         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Always"),  RECVDIALOG_ALWAYS);
2755         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Only if a sylpheed window is active"),  RECVDIALOG_WINDOW_ACTIVE);
2756         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Never"), RECVDIALOG_NEVER);
2757
2758         gtk_option_menu_set_menu (GTK_OPTION_MENU (recvdialog_optmenu), recvdialog_optmenu_menu);     */
2759
2760         hbox1 = gtk_hbox_new (FALSE, 8);
2761         gtk_widget_show (hbox1);
2762         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2763
2764         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
2765         gtk_widget_show (button_keybind);
2766         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
2767         gtk_signal_connect (GTK_OBJECT (button_keybind), "clicked",
2768                             GTK_SIGNAL_FUNC (prefs_keybind_select), NULL);
2769
2770         PACK_FRAME(vbox1, frame_pixmap_theme, "Pixmap theme");
2771         
2772         vbox_pixmap_theme = gtk_vbox_new(FALSE, 0);
2773         gtk_widget_show(vbox_pixmap_theme);
2774         gtk_container_add(GTK_CONTAINER(frame_pixmap_theme), vbox_pixmap_theme);
2775         gtk_container_set_border_width(GTK_CONTAINER(vbox_pixmap_theme), 8);
2776  
2777         avail_pixmap_themes = stock_pixmap_themes_list_new(); 
2778  
2779         combo_pixmap_theme = gtk_combo_new ();
2780         gtk_widget_show (combo_pixmap_theme);
2781         gtk_box_pack_start (GTK_BOX (vbox_pixmap_theme), combo_pixmap_theme, TRUE, TRUE, 0);
2782         gtk_combo_set_popdown_strings(GTK_COMBO(combo_pixmap_theme), avail_pixmap_themes);
2783         entry_pixmap_theme = GTK_COMBO (combo_pixmap_theme)->entry;
2784
2785         stock_pixmap_themes_list_free(avail_pixmap_themes);
2786
2787         /* interface.checkbtn_emacs          = checkbtn_emacs; */
2788         interface.checkbtn_openunread         = checkbtn_openunread;
2789         interface.checkbtn_openinbox          = checkbtn_openinbox;
2790         interface.checkbtn_immedexec          = checkbtn_immedexec;
2791         interface.optmenu_recvdialog          = optmenu_recvdialog;
2792         interface.checkbtn_addaddrbyclick     = checkbtn_addaddrbyclick;
2793         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
2794         interface.combo_pixmap_theme            = combo_pixmap_theme;
2795         interface.entry_pixmap_theme            = entry_pixmap_theme;
2796 }
2797
2798 static void prefs_other_create(void)
2799 {
2800         GtkWidget *vbox1;
2801         GtkWidget *ext_frame;
2802         GtkWidget *ext_table;
2803         GtkWidget *hbox1;
2804
2805         GtkWidget *uri_label;
2806         GtkWidget *uri_combo;
2807         GtkWidget *uri_entry;
2808
2809         GtkWidget *printcmd_label;
2810         GtkWidget *printcmd_entry;
2811
2812         GtkWidget *exteditor_label;
2813         GtkWidget *exteditor_combo;
2814         GtkWidget *exteditor_entry;
2815
2816         GtkWidget *frame_exit;
2817         GtkWidget *vbox_exit;
2818         GtkWidget *checkbtn_confonexit;
2819         GtkWidget *checkbtn_cleanonexit;
2820         GtkWidget *checkbtn_askonclean;
2821         GtkWidget *checkbtn_warnqueued;
2822
2823         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2824         gtk_widget_show (vbox1);
2825         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2826         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2827
2828         PACK_FRAME(vbox1, ext_frame,
2829                    _("External commands (%s will be replaced with file name / URI)"));
2830
2831         ext_table = gtk_table_new (3, 2, FALSE);
2832         gtk_widget_show (ext_table);
2833         gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2834         gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2835         gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2836         gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2837
2838         uri_label = gtk_label_new (_("Web browser"));
2839         gtk_widget_show(uri_label);
2840         gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2841                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2842         gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2843
2844         uri_combo = gtk_combo_new ();
2845         gtk_widget_show (uri_combo);
2846         gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2847                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2848         gtkut_combo_set_items (GTK_COMBO (uri_combo),
2849                                "netscape -remote 'openURL(%s,raise)'",
2850                                "netscape '%s'",
2851                                "gnome-moz-remote --raise --newwin '%s'",
2852                                "kfmclient openURL '%s'",
2853                                "opera -newwindow '%s'",        
2854                                "kterm -e w3m '%s'",
2855                                "kterm -e lynx '%s'",
2856                                NULL);
2857         uri_entry = GTK_COMBO (uri_combo)->entry;
2858
2859         printcmd_label = gtk_label_new (_("Print"));
2860         gtk_widget_show (printcmd_label);
2861         gtk_table_attach (GTK_TABLE (ext_table), printcmd_label, 0, 1, 1, 2,
2862                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2863         gtk_misc_set_alignment (GTK_MISC (printcmd_label), 1, 0.5);
2864
2865         printcmd_entry = gtk_entry_new ();
2866         gtk_widget_show (printcmd_entry);
2867         gtk_table_attach (GTK_TABLE (ext_table), printcmd_entry, 1, 2, 1, 2,
2868                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2869
2870         exteditor_label = gtk_label_new (_("Editor"));
2871         gtk_widget_show (exteditor_label);
2872         gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 2, 3,
2873                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2874         gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2875
2876         exteditor_combo = gtk_combo_new ();
2877         gtk_widget_show (exteditor_combo);
2878         gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 2, 3,
2879                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2880         gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2881                                "gedit %s",
2882                                "kedit %s",
2883                                "mgedit --no-fork %s",
2884                                "emacs %s",
2885                                "xemacs %s",
2886                                "kterm -e jed %s",
2887                                "kterm -e vi %s",
2888                                NULL);
2889         exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2890
2891         /* On Exit */
2892         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2893
2894         vbox_exit = gtk_vbox_new (FALSE, 0);
2895         gtk_widget_show (vbox_exit);
2896         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2897         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2898
2899         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2900                            _("Confirm on exit"));
2901
2902         hbox1 = gtk_hbox_new (FALSE, 32);
2903         gtk_widget_show (hbox1);
2904         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2905
2906         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2907                            _("Empty trash on exit"));
2908         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2909                            _("Ask before emptying"));
2910         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2911
2912         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2913                            _("Warn if there are queued messages"));
2914
2915         other.uri_combo = uri_combo;
2916         other.uri_entry = uri_entry;
2917         other.printcmd_entry = printcmd_entry;
2918
2919         other.exteditor_combo = exteditor_combo;
2920         other.exteditor_entry = exteditor_entry;
2921
2922         other.checkbtn_confonexit  = checkbtn_confonexit;
2923         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2924         other.checkbtn_askonclean  = checkbtn_askonclean;
2925         other.checkbtn_warnqueued  = checkbtn_warnqueued;
2926 }
2927
2928 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2929 {
2930         GtkWidget *datefmt_sample = NULL;
2931         gchar *text;
2932
2933         g_return_if_fail(widget != NULL);
2934         g_return_if_fail(*widget != NULL);
2935         g_return_if_fail(display.entry_datefmt != NULL);
2936
2937         datefmt_sample = GTK_WIDGET(gtk_object_get_data
2938                                     (GTK_OBJECT(*widget), "datefmt_sample"));
2939         g_return_if_fail(datefmt_sample != NULL);
2940
2941         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2942         g_free(prefs_common.date_format);
2943         prefs_common.date_format = text;
2944         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2945
2946         gtk_widget_destroy(*widget);
2947         *widget = NULL;
2948 }
2949
2950 static void date_format_cancel_btn_clicked(GtkButton *button,
2951                                            GtkWidget **widget)
2952 {
2953         g_return_if_fail(widget != NULL);
2954         g_return_if_fail(*widget != NULL);
2955
2956         gtk_widget_destroy(*widget);
2957         *widget = NULL;
2958 }
2959
2960 static void date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2961                                     GtkWidget **widget)
2962 {
2963         if (event && event->keyval == GDK_Escape)
2964                 date_format_cancel_btn_clicked(NULL, widget);
2965 }
2966
2967 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2968                                       GdkEventAny *event, GtkWidget **widget)
2969 {
2970         g_return_val_if_fail(widget != NULL, FALSE);
2971         g_return_val_if_fail(*widget != NULL, FALSE);
2972
2973         *widget = NULL;
2974         return FALSE;
2975 }
2976
2977 static void date_format_entry_on_change(GtkEditable *editable,
2978                                         GtkLabel *example)
2979 {
2980         time_t cur_time;
2981         struct tm *cal_time;
2982         gchar buffer[100];
2983         gchar *text;
2984
2985         cur_time = time(NULL);
2986         cal_time = localtime(&cur_time);
2987         buffer[0] = 0;
2988         text = gtk_editable_get_chars(editable, 0, -1);
2989         if (text)
2990                 strftime(buffer, sizeof buffer, text, cal_time); 
2991         gtk_label_set_text(example, buffer);
2992 }
2993
2994 static void date_format_select_row(GtkWidget *date_format_list, gint row,
2995                                    gint column, GdkEventButton *event,
2996                                    GtkWidget *date_format)
2997 {
2998         gint cur_pos;
2999         gchar *format;
3000         gchar *old_format;
3001         gchar *new_format;
3002         GtkWidget *datefmt_sample;
3003
3004         /* only on double click */
3005         if (!event || event->type != GDK_2BUTTON_PRESS) return;
3006
3007
3008         datefmt_sample = GTK_WIDGET(gtk_object_get_data
3009                                     (GTK_OBJECT(date_format), "datefmt_sample"));
3010
3011         g_return_if_fail(date_format_list != NULL);
3012         g_return_if_fail(date_format != NULL);
3013         g_return_if_fail(datefmt_sample != NULL);
3014
3015         /* get format from clist */
3016         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
3017
3018         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
3019         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
3020
3021         /* insert the format into the text entry */
3022         new_format = g_malloc(strlen(old_format) + 3);
3023
3024         strncpy(new_format, old_format, cur_pos);
3025         new_format[cur_pos] = '\0';
3026         strcat(new_format, format);
3027         strcat(new_format, &old_format[cur_pos]);
3028
3029         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
3030         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
3031
3032         g_free(new_format);
3033 }
3034
3035 static GtkWidget *date_format_create(GtkButton *button, void *data)
3036 {
3037         static GtkWidget *datefmt_win = NULL;
3038         GtkWidget *vbox1;
3039         GtkWidget *scrolledwindow1;
3040         GtkWidget *datefmt_clist;
3041         GtkWidget *table;
3042         GtkWidget *label1;
3043         GtkWidget *label2;
3044         GtkWidget *label3;
3045         GtkWidget *confirm_area;
3046         GtkWidget *ok_btn;
3047         GtkWidget *cancel_btn;
3048         GtkWidget *datefmt_entry;
3049
3050         struct {
3051                 gchar *fmt;
3052                 gchar *txt;
3053         } time_format[] = {
3054                 { "%a", NULL },
3055                 { "%A", NULL },
3056                 { "%b", NULL },
3057                 { "%B", NULL },
3058                 { "%c", NULL },
3059                 { "%C", NULL },
3060                 { "%d", NULL },
3061                 { "%H", NULL },
3062                 { "%I", NULL },
3063                 { "%j", NULL },
3064                 { "%m", NULL },
3065                 { "%M", NULL },
3066                 { "%p", NULL },
3067                 { "%S", NULL },
3068                 { "%w", NULL },
3069                 { "%x", NULL },
3070                 { "%y", NULL },
3071                 { "%Y", NULL },
3072                 { "%Z", NULL }
3073         };
3074
3075         gchar *titles[2];
3076         gint i;
3077         const gint TIME_FORMAT_ELEMS =
3078                 sizeof time_format / sizeof time_format[0];
3079
3080         time_format[0].txt  = _("the full abbreviated weekday name");
3081         time_format[1].txt  = _("the full weekday name");
3082         time_format[2].txt  = _("the abbreviated month name");
3083         time_format[3].txt  = _("the full month name");
3084         time_format[4].txt  = _("the preferred date and time for the current locale");
3085         time_format[5].txt  = _("the century number (year/100)");
3086         time_format[6].txt  = _("the day of the month as a decimal number");
3087         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
3088         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
3089         time_format[9].txt  = _("the day of the year as a decimal number");
3090         time_format[10].txt = _("the month as a decimal number");
3091         time_format[11].txt = _("the minute as a decimal number");
3092         time_format[12].txt = _("either AM or PM");
3093         time_format[13].txt = _("the second as a decimal number");
3094         time_format[14].txt = _("the day of the week as a decimal number");
3095         time_format[15].txt = _("the preferred date for the current locale");
3096         time_format[16].txt = _("the last two digits of a year");
3097         time_format[17].txt = _("the year as a decimal number");
3098         time_format[18].txt = _("the time zone or name or abbreviation");
3099
3100         if (datefmt_win) return datefmt_win;
3101
3102         datefmt_win = gtk_window_new(GTK_WINDOW_DIALOG);
3103         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
3104         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
3105         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3106         gtk_widget_set_usize(datefmt_win, 440, 280);
3107
3108         vbox1 = gtk_vbox_new(FALSE, 10);
3109         gtk_widget_show(vbox1);
3110         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
3111
3112         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
3113         gtk_scrolled_window_set_policy
3114                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
3115                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3116         gtk_widget_show(scrolledwindow1);
3117         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
3118
3119         titles[0] = _("Specifier");
3120         titles[1] = _("Description");
3121         datefmt_clist = gtk_clist_new_with_titles(2, titles);
3122         gtk_widget_show(datefmt_clist);
3123         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
3124         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
3125         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
3126                                      GTK_SELECTION_BROWSE);
3127
3128         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
3129                 gchar *text[2];
3130                 /* phoney casting necessary because of gtk... */
3131                 text[0] = (gchar *)time_format[i].fmt;
3132                 text[1] = (gchar *)time_format[i].txt;
3133                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
3134         }
3135
3136         table = gtk_table_new(2, 2, FALSE);
3137         gtk_widget_show(table);
3138         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3139         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3140         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3141
3142         label1 = gtk_label_new(_("Date format"));
3143         gtk_widget_show(label1);
3144         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3145                          GTK_FILL, 0, 0, 0);
3146         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3147         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3148
3149         datefmt_entry = gtk_entry_new_with_max_length(256);
3150         gtk_widget_show(datefmt_entry);
3151         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3152                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3153
3154         /* we need the "sample" entry box; add it as data so callbacks can
3155          * get the entry box */
3156         gtk_object_set_data(GTK_OBJECT(datefmt_win), "datefmt_sample",
3157                             datefmt_entry);
3158
3159         label2 = gtk_label_new(_("Example"));
3160         gtk_widget_show(label2);
3161         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3162                          GTK_FILL, 0, 0, 0);
3163         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3164         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3165
3166         label3 = gtk_label_new("");
3167         gtk_widget_show(label3);
3168         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
3169                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3170         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
3171         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
3172
3173         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
3174                                 &cancel_btn, _("Cancel"), NULL, NULL);
3175         gtk_widget_grab_default(ok_btn);
3176         gtk_widget_show(confirm_area);
3177
3178         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3179
3180         /* set the current format */
3181         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3182         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3183                                     GTK_LABEL(label3));
3184
3185         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
3186                            GTK_SIGNAL_FUNC(date_format_ok_btn_clicked),
3187                            &datefmt_win);
3188         gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
3189                            GTK_SIGNAL_FUNC(date_format_cancel_btn_clicked),
3190                            &datefmt_win);
3191         gtk_signal_connect(GTK_OBJECT(datefmt_win), "key_press_event",
3192                            GTK_SIGNAL_FUNC(date_format_key_pressed),
3193                            &datefmt_win);
3194         gtk_signal_connect(GTK_OBJECT(datefmt_win), "delete_event",
3195                            GTK_SIGNAL_FUNC(date_format_on_delete),
3196                            &datefmt_win);
3197         gtk_signal_connect(GTK_OBJECT(datefmt_entry), "changed",
3198                            GTK_SIGNAL_FUNC(date_format_entry_on_change),
3199                            label3);
3200
3201         gtk_signal_connect(GTK_OBJECT(datefmt_clist), "select_row",
3202                            GTK_SIGNAL_FUNC(date_format_select_row),
3203                            datefmt_win);
3204
3205         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3206         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3207
3208         gtk_widget_show(datefmt_win);
3209         manage_window_set_transient(GTK_WINDOW(datefmt_win));
3210
3211         gtk_widget_grab_focus(ok_btn);
3212
3213         return datefmt_win;
3214 }
3215
3216 void prefs_quote_colors_dialog(void)
3217 {
3218         if (!quote_color_win)
3219                 prefs_quote_colors_dialog_create();
3220         gtk_widget_show(quote_color_win);
3221         manage_window_set_transient(GTK_WINDOW(quote_color_win));
3222
3223         gtk_main();
3224         gtk_widget_hide(quote_color_win);
3225
3226         textview_update_message_colors();
3227         main_window_reflect_prefs_all();
3228 }
3229
3230 static void prefs_quote_colors_dialog_create(void)
3231 {
3232         GtkWidget *window;
3233         GtkWidget *vbox;
3234         GtkWidget *table;
3235         GtkWidget *quotelevel1_label;
3236         GtkWidget *quotelevel2_label;
3237         GtkWidget *quotelevel3_label;
3238         GtkWidget *uri_label;
3239         GtkWidget *tgt_folder_label;
3240         GtkWidget *hbbox;
3241         GtkWidget *ok_btn;
3242         GtkWidget *recycle_colors_btn;
3243         GtkWidget *frame_colors;
3244
3245         window = gtk_window_new(GTK_WINDOW_DIALOG);
3246         gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3247         gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3248         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3249         gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3250         gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3251
3252         vbox = gtk_vbox_new (FALSE, VSPACING);
3253         gtk_container_add (GTK_CONTAINER (window), vbox);
3254         gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3255         PACK_FRAME(vbox, frame_colors, _("Colors"));
3256
3257         table = gtk_table_new (4, 2, FALSE);
3258         gtk_container_add (GTK_CONTAINER (frame_colors), table);
3259         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3260         gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3261         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
3262
3263
3264         color_buttons.quote_level1_btn = gtk_button_new();
3265         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
3266                           0, 1, 0, 1, 0, 0, 0, 0);
3267         gtk_widget_set_usize (color_buttons.quote_level1_btn, 40, 30);
3268         gtk_container_set_border_width
3269                 (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
3270
3271         color_buttons.quote_level2_btn = gtk_button_new();
3272         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
3273                           0, 1, 1, 2, 0, 0, 0, 0);
3274         gtk_widget_set_usize (color_buttons.quote_level2_btn, 40, 30);
3275         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
3276
3277         color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3278         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3279                           0, 1, 2, 3, 0, 0, 0, 0);
3280         gtk_widget_set_usize (color_buttons.quote_level3_btn, 40, 30);
3281         gtk_container_set_border_width
3282                 (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3283
3284         color_buttons.uri_btn = gtk_button_new_with_label ("");
3285         gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
3286                           0, 1, 3, 4, 0, 0, 0, 0);
3287         gtk_widget_set_usize (color_buttons.uri_btn, 40, 30);
3288         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
3289
3290         color_buttons.tgt_folder_btn = gtk_button_new_with_label ("");
3291         gtk_table_attach (GTK_TABLE (table), color_buttons.tgt_folder_btn,
3292                           0, 1, 4, 5, 0, 0, 0, 0);
3293         gtk_widget_set_usize (color_buttons.tgt_folder_btn, 40, 30);
3294         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.tgt_folder_btn), 5);
3295
3296         quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3297         gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3298                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3299         gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3300         gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3301
3302         quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
3303         gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
3304                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3305         gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
3306         gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
3307
3308         quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
3309         gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
3310                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3311         gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
3312         gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
3313
3314         uri_label = gtk_label_new (_("URI link"));
3315         gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3316                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3317         gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3318         gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3319
3320         tgt_folder_label = gtk_label_new (_("Target folder"));
3321         gtk_table_attach (GTK_TABLE (table), tgt_folder_label, 1, 2, 4, 5,
3322                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3323         gtk_label_set_justify (GTK_LABEL (tgt_folder_label), GTK_JUSTIFY_LEFT);
3324         gtk_misc_set_alignment (GTK_MISC (tgt_folder_label), 0, 0.5);
3325
3326         PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3327                            _("Recycle quote colors"));
3328
3329         gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
3330                                 NULL, NULL, NULL, NULL);
3331         gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3332
3333         gtk_widget_grab_default(ok_btn);
3334         MANAGE_WINDOW_SIGNALS_CONNECT(window);
3335         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
3336                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3337         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
3338                            GTK_SIGNAL_FUNC(prefs_quote_colors_key_pressed),
3339                            NULL);
3340
3341         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level1_btn), "clicked",
3342                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL1");
3343         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level2_btn), "clicked",
3344                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL2");
3345         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level3_btn), "clicked",
3346                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL3");
3347         gtk_signal_connect(GTK_OBJECT(color_buttons.uri_btn), "clicked",
3348                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "URI");
3349         gtk_signal_connect(GTK_OBJECT(color_buttons.tgt_folder_btn), "clicked",
3350                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "TGTFLD");
3351         gtk_signal_connect(GTK_OBJECT(recycle_colors_btn), "toggled",
3352                            GTK_SIGNAL_FUNC(prefs_recycle_colors_toggled), NULL);
3353         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
3354                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3355
3356         /* show message button colors and recycle options */
3357         set_button_bg_color(color_buttons.quote_level1_btn,
3358                             prefs_common.quote_level1_col);
3359         set_button_bg_color(color_buttons.quote_level2_btn,
3360                             prefs_common.quote_level2_col);
3361         set_button_bg_color(color_buttons.quote_level3_btn,
3362                             prefs_common.quote_level3_col);
3363         set_button_bg_color(color_buttons.uri_btn,
3364                             prefs_common.uri_col);
3365         set_button_bg_color(color_buttons.tgt_folder_btn,
3366                             prefs_common.tgt_folder_col);
3367         gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
3368                                      prefs_common.recycle_quote_colors);
3369
3370         gtk_widget_show_all(vbox);
3371         quote_color_win = window;
3372 }
3373
3374 static void prefs_quote_colors_key_pressed(GtkWidget *widget,
3375                                            GdkEventKey *event, gpointer data)
3376 {
3377         if (event && event->keyval == GDK_Escape)
3378                 gtk_main_quit();
3379 }
3380
3381 static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
3382 {
3383         gchar *type = (gchar *)data;
3384         gchar *title = NULL;
3385         gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
3386         gint rgbvalue = 0;
3387         GtkColorSelectionDialog *dialog;
3388
3389         if(g_strcasecmp(type, "LEVEL1") == 0) {
3390                 title = _("Pick color for quotation level 1");
3391                 rgbvalue = prefs_common.quote_level1_col;
3392         } else if(g_strcasecmp(type, "LEVEL2") == 0) {
3393                 title = _("Pick color for quotation level 2");
3394                 rgbvalue = prefs_common.quote_level2_col;
3395         } else if(g_strcasecmp(type, "LEVEL3") == 0) {
3396                 title = _("Pick color for quotation level 3");
3397                 rgbvalue = prefs_common.quote_level3_col;
3398         } else if(g_strcasecmp(type, "URI") == 0) {
3399                 title = _("Pick color for URI");
3400                 rgbvalue = prefs_common.uri_col;
3401         } else if(g_strcasecmp(type, "TGTFLD") == 0) {
3402                 title = _("Pick color for target folder");
3403                 rgbvalue = prefs_common.tgt_folder_col;
3404 #if USE_PSPELL          
3405         } else if(g_strcasecmp(type, "Misspelled word") == 0) {
3406                 title = _("Pick color for misspelled word");
3407                 rgbvalue = prefs_common.misspelled_col;
3408 #endif          
3409         } else {   /* Should never be called */
3410                 g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
3411                 return;
3412         }
3413
3414         color_dialog = gtk_color_selection_dialog_new(title);
3415         gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
3416         gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
3417         gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
3418         manage_window_set_transient(GTK_WINDOW(color_dialog));
3419
3420         gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
3421                            "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_ok), data);
3422         gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
3423                            "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_cancel), data);
3424         gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
3425                            GTK_SIGNAL_FUNC(quote_colors_set_dialog_key_pressed),
3426                            data);
3427
3428         /* preselect the previous color in the color selection dialog */
3429         color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
3430         color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
3431         color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
3432         dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
3433         gtk_color_selection_set_color
3434                 (GTK_COLOR_SELECTION(dialog->colorsel), color);
3435
3436         gtk_widget_show(color_dialog);
3437 }
3438
3439 static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
3440 {
3441         GtkColorSelection *colorsel = (GtkColorSelection *)
3442                                                 ((GtkColorSelectionDialog *)color_dialog)->colorsel;
3443         gdouble color[4];
3444         gint red, green, blue, rgbvalue;
3445         gchar *type = (gchar *)data;
3446
3447         gtk_color_selection_get_color(colorsel, color);
3448
3449         red      = (gint) (color[0] * 255.0);
3450         green    = (gint) (color[1] * 255.0);
3451         blue     = (gint) (color[2] * 255.0);
3452         rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3453
3454 #if 0
3455         fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3456         fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3457         fprintf(stderr, "Color is %x\n", rgbvalue);
3458 #endif
3459
3460         if (g_strcasecmp(type, "LEVEL1") == 0) {
3461                 prefs_common.quote_level1_col = rgbvalue;
3462                 set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3463         } else if (g_strcasecmp(type, "LEVEL2") == 0) {
3464                 prefs_common.quote_level2_col = rgbvalue;
3465                 set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3466         } else if (g_strcasecmp(type, "LEVEL3") == 0) {
3467                 prefs_common.quote_level3_col = rgbvalue;
3468                 set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3469         } else if (g_strcasecmp(type, "URI") == 0) {
3470                 prefs_common.uri_col = rgbvalue;
3471                 set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3472         } else if (g_strcasecmp(type, "TGTFLD") == 0) {
3473                 prefs_common.tgt_folder_col = rgbvalue;
3474                 set_button_bg_color(color_buttons.tgt_folder_btn, rgbvalue);
3475                 folderview_set_target_folder_color(prefs_common.tgt_folder_col);
3476 #if USE_PSPELL          
3477         } else if (g_strcasecmp(type, "Misspelled word") == 0) {
3478                 prefs_common.misspelled_col = rgbvalue;
3479                 set_button_bg_color(spelling.misspelled_btn, rgbvalue);
3480 #endif          
3481         } else
3482                 fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3483
3484 &