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