po/POTFILES.in
[claws.git] / src / prefs_common.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include <gdk/gdkkeysyms.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <errno.h>
36
37 #include "intl.h"
38 #include "main.h"
39 #include "prefs.h"
40 #include "prefs_common.h"
41 #include "prefs_display_header.h"
42 #include "prefs_summary_column.h"
43 #include "mainwindow.h"
44 #include "summaryview.h"
45 #include "messageview.h"
46 #include "manage_window.h"
47 #include "inc.h"
48 #include "menu.h"
49 #include "codeconv.h"
50 #include "utils.h"
51 #include "gtkutils.h"
52 #include "alertpanel.h"
53 #include "folder.h"
54 #include "filesel.h"
55 #include "folderview.h"
56 #include "stock_pixmap.h"
57 #include "quote_fmt.h"
58
59 #if USE_PSPELL
60 #include "gtkspell.h"
61 #endif
62
63 PrefsCommon prefs_common;
64
65 static PrefsDialog dialog;
66
67 static struct Receive {
68         GtkWidget *checkbtn_incext;
69         GtkWidget *entry_incext;
70         GtkWidget *button_incext;
71
72         GtkWidget *checkbtn_local;
73         GtkWidget *checkbtn_filter_on_inc;
74         GtkWidget *entry_spool;
75
76         GtkWidget *checkbtn_autochk;
77         GtkWidget *spinbtn_autochk;
78         GtkObject *spinbtn_autochk_adj;
79
80         GtkWidget *checkbtn_chkonstartup;
81         GtkWidget *checkbtn_noerrorpanel;
82         GtkWidget *checkbtn_scan_after_inc;
83
84
85         GtkWidget *checkbtn_newmail_auto;
86         GtkWidget *checkbtn_newmail_manu;
87         GtkWidget *entry_newmail_notify_cmd;
88         GtkWidget *hbox_newmail_notify;
89
90         GtkWidget *spinbtn_maxarticle;
91         GtkObject *spinbtn_maxarticle_adj;
92 } receive;
93
94 static struct Send {
95         GtkWidget *checkbtn_extsend;
96         GtkWidget *entry_extsend;
97         GtkWidget *button_extsend;
98
99         GtkWidget *checkbtn_savemsg;
100         GtkWidget *checkbtn_queuemsg;
101
102         GtkWidget *optmenu_charset;
103         
104         GtkWidget *checkbtn_returnreceipt;
105 } send;
106
107 static struct Compose {
108         GtkWidget *checkbtn_autosig;
109         GtkWidget *entry_sigsep;
110
111         GtkWidget *entry_fw_quotemark;
112         GtkWidget *text_fw_quotefmt;
113
114         GtkWidget *checkbtn_autoextedit;
115         GtkWidget *spinbtn_undolevel;
116         GtkObject *spinbtn_undolevel_adj;
117         GtkWidget *checkbtn_reply_account_autosel;
118         GtkWidget *checkbtn_forward_account_autosel;
119         GtkWidget *checkbtn_reedit_account_autosel;
120
121         GtkWidget *spinbtn_linewrap;
122         GtkObject *spinbtn_linewrap_adj;
123         GtkWidget *checkbtn_wrapquote;
124         GtkWidget *checkbtn_wrapatsend;
125
126         GtkWidget *checkbtn_quote;
127         GtkWidget *checkbtn_forward_as_attachment;
128         GtkWidget *checkbtn_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 } other;
234
235 static struct MessageColorButtons {
236         GtkWidget *quote_level1_btn;
237         GtkWidget *quote_level2_btn;
238         GtkWidget *quote_level3_btn;
239         GtkWidget *uri_btn;
240         GtkWidget *tgt_folder_btn;
241 } color_buttons;
242
243 static struct KeybindDialog {
244         GtkWidget *window;
245         GtkWidget *combo;
246 } keybind;
247
248 static GtkWidget *font_sel_win;
249 static guint font_sel_conn_id; 
250 static GtkWidget *quote_color_win;
251 static GtkWidget *color_dialog;
252
253 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam);
254 static void prefs_common_charset_set_optmenu          (PrefParam *pparam);
255 #if USE_GPGME
256 static void prefs_common_default_signkey_set_data_from_optmenu
257                                                         (PrefParam *pparam);
258 static void prefs_common_default_signkey_set_optmenu    (PrefParam *pparam);
259 #endif
260 static void prefs_common_recv_dialog_newmail_notify_toggle_cb   (GtkWidget *w,
261                                                                  gpointer data);
262 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
263 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
264 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
265 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
266
267 #if USE_PSPELL
268 static void prefs_dictionary_set_data_from_optmenu      (PrefParam *param);
269 static void prefs_dictionary_set_optmenu                (PrefParam *pparam);
270 static void prefs_speller_sugmode_set_data_from_optmenu (PrefParam *pparam);
271 static void prefs_speller_sugmode_set_optmenu           (PrefParam *pparam);
272 #endif
273
274
275 /*
276    parameter name, default value, pointer to the prefs variable, data type,
277    pointer to the widget pointer,
278    pointer to the function for data setting,
279    pointer to the function for widget setting
280  */
281
282 static PrefParam param[] = {
283         /* Receive */
284         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
285          &receive.checkbtn_incext,
286          prefs_set_data_from_toggle, prefs_set_toggle},
287         {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
288          &receive.entry_incext,
289          prefs_set_data_from_entry, prefs_set_entry},
290
291         {"inc_local", "TRUE", &prefs_common.inc_local, P_BOOL,
292          &receive.checkbtn_local,
293          prefs_set_data_from_toggle, prefs_set_toggle},
294         {"filter_on_inc_local", "FALSE", &prefs_common.filter_on_inc, P_BOOL,
295          &receive.checkbtn_filter_on_inc,
296          prefs_set_data_from_toggle, prefs_set_toggle},
297         {"spool_path", DEFAULT_SPOOL_PATH, &prefs_common.spool_path, P_STRING,
298          &receive.entry_spool,
299          prefs_set_data_from_entry, prefs_set_entry},
300
301         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
302          &receive.checkbtn_autochk,
303          prefs_set_data_from_toggle, prefs_set_toggle},
304         {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
305          &receive.spinbtn_autochk,
306          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
307         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
308          &receive.checkbtn_chkonstartup,
309          prefs_set_data_from_toggle, prefs_set_toggle},
310         {"noerrorpanel", "FALSE", &prefs_common.noerrorpanel, P_BOOL,
311          &receive.checkbtn_noerrorpanel,
312          prefs_set_data_from_toggle, prefs_set_toggle},
313         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
314          P_BOOL, &receive.checkbtn_scan_after_inc,
315          prefs_set_data_from_toggle, prefs_set_toggle},
316         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
317          P_BOOL, &receive.checkbtn_newmail_manu,
318          prefs_set_data_from_toggle, prefs_set_toggle},
319         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
320         P_BOOL, &receive.checkbtn_newmail_auto,
321          prefs_set_data_from_toggle, prefs_set_toggle},
322         {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING,
323          &receive.entry_newmail_notify_cmd,
324          prefs_set_data_from_entry, prefs_set_entry},
325  
326         {"max_news_articles", "300", &prefs_common.max_articles, P_INT,
327          &receive.spinbtn_maxarticle,
328          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
329
330         /* Send */
331         {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL,
332          &send.checkbtn_extsend,
333          prefs_set_data_from_toggle, prefs_set_toggle},
334         {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD,
335          &prefs_common.extsend_cmd, P_STRING,
336          &send.entry_extsend, prefs_set_data_from_entry, prefs_set_entry},
337         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
338          &send.checkbtn_savemsg,
339          prefs_set_data_from_toggle, prefs_set_toggle},
340         {"queue_message", "FALSE", &prefs_common.queue_msg, P_BOOL,
341          &send.checkbtn_queuemsg,
342          prefs_set_data_from_toggle, prefs_set_toggle},
343
344         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
345          &send.optmenu_charset,
346          prefs_common_charset_set_data_from_optmenu,
347          prefs_common_charset_set_optmenu},
348
349         /* Compose */
350         {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL,
351          &compose.checkbtn_autosig,
352          prefs_set_data_from_toggle, prefs_set_toggle},
353         {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING,
354          &compose.entry_sigsep, prefs_set_data_from_entry, prefs_set_entry},
355
356         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
357          &compose.checkbtn_autoextedit,
358          prefs_set_data_from_toggle, prefs_set_toggle},
359         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
360          P_BOOL, &compose.checkbtn_forward_as_attachment,
361          prefs_set_data_from_toggle, prefs_set_toggle},
362         {"redirect_keep_from", "FALSE",
363          &prefs_common.redirect_keep_from, P_BOOL,
364          &compose.checkbtn_redirect_keep_from,
365          prefs_set_data_from_toggle, prefs_set_toggle},
366         {"undo_level", "50", &prefs_common.undolevels, P_INT,
367          &compose.spinbtn_undolevel,
368          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
369         {"block_cursor", "FALSE", &prefs_common.block_cursor,
370          P_BOOL, &compose.checkbtn_block_cursor,
371          prefs_set_data_from_toggle, prefs_set_toggle},
372
373         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
374          &compose.spinbtn_linewrap,
375          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
376         {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL,
377          &compose.checkbtn_wrapquote,
378          prefs_set_data_from_toggle, prefs_set_toggle},
379         {"linewrap_before_sending", "FALSE",
380          &prefs_common.linewrap_at_send, P_BOOL,
381          &compose.checkbtn_wrapatsend,
382          prefs_set_data_from_toggle, prefs_set_toggle},
383         {"smart_wrapping", "TRUE", &prefs_common.smart_wrapping,
384          P_BOOL, &compose.checkbtn_smart_wrapping,
385          prefs_set_data_from_toggle, prefs_set_toggle},
386 #if USE_PSPELL
387         {"enable_pspell", "TRUE", &prefs_common.enable_pspell,
388          P_BOOL, &spelling.checkbtn_enable_pspell,
389          prefs_set_data_from_toggle, prefs_set_toggle},
390         {"pspell_path", PSPELL_PATH, &prefs_common.pspell_path, 
391          P_STRING, &spelling.entry_pspell_path, 
392          prefs_set_data_from_entry, prefs_set_entry},
393         {"dictionary",  "", &prefs_common.dictionary,
394          P_STRING, &spelling.optmenu_dictionary, 
395          prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
396         {"pspell_sugmode",  "1", &prefs_common.pspell_sugmode,
397          P_INT, &spelling.optmenu_sugmode, 
398          prefs_speller_sugmode_set_data_from_optmenu, prefs_speller_sugmode_set_optmenu },
399         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate,
400          P_BOOL, &spelling.checkbtn_use_alternate,
401          prefs_set_data_from_toggle, prefs_set_toggle},
402         {"check_while_typing", "TRUE", &prefs_common.check_while_typing,
403          P_BOOL, &spelling.checkbtn_check_while_typing,
404          prefs_set_data_from_toggle, prefs_set_toggle},
405         {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_INT,
406          NULL, NULL, NULL},
407 #endif
408         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
409          &compose.checkbtn_reply_with_quote, prefs_set_data_from_toggle, prefs_set_toggle},
410
411         /* Account autoselection */
412         {"reply_account_autoselect", "TRUE",
413          &prefs_common.reply_account_autosel, P_BOOL,
414          &compose.checkbtn_reply_account_autosel,
415          prefs_set_data_from_toggle, prefs_set_toggle},
416         {"forward_account_autoselect", "TRUE",
417          &prefs_common.forward_account_autosel, P_BOOL,
418          &compose.checkbtn_forward_account_autosel,
419          prefs_set_data_from_toggle, prefs_set_toggle},
420         {"reedit_account_autoselect", "TRUE",
421          &prefs_common.reedit_account_autosel, P_BOOL,
422          &compose.checkbtn_reedit_account_autosel,
423          prefs_set_data_from_toggle, prefs_set_toggle},
424
425         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
426          NULL, NULL, NULL},
427
428         /* Quote */
429         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
430          &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
431         {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
432          &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
433          prefs_set_data_from_text, prefs_set_text},
434
435         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
436          &quote.entry_fw_quotemark,
437          prefs_set_data_from_entry, prefs_set_entry},
438         {"forward_quote_format",
439          "\\n\\nBegin forwarded message:\\n\\n"
440          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
441          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
442          &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
443          prefs_set_data_from_text, prefs_set_text},
444         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
445          &quote.entry_quote_chars, prefs_set_data_from_entry, prefs_set_entry},
446
447         /* Display */
448         {"widget_font", NULL, &prefs_common.widgetfont, P_STRING,
449          NULL, NULL, NULL},
450         {"message_font", "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
451          &prefs_common.textfont, P_STRING,
452          &display.entry_textfont,
453          prefs_set_data_from_entry, prefs_set_entry},
454         {"small_font",   "-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*",
455          &prefs_common.smallfont,   P_STRING,
456          &display.entry_smallfont,
457          prefs_set_data_from_entry, prefs_set_entry},
458         {"bold_font",    "-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*",
459          &prefs_common.boldfont,    P_STRING,
460          &display.entry_boldfont,
461          prefs_set_data_from_entry, prefs_set_entry},
462         {"normal_font",  "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*",
463          &prefs_common.normalfont,  P_STRING,
464          &display.entry_normalfont, 
465          prefs_set_data_from_entry, prefs_set_entry},
466
467
468         {"display_folder_unread_num", "TRUE",
469          &prefs_common.display_folder_unread, P_BOOL,
470          &display.chkbtn_folder_unread,
471          prefs_set_data_from_toggle, prefs_set_toggle},
472
473         {"display_img", "TRUE",
474          &prefs_common.display_img, P_BOOL,
475          &display.chkbtn_display_img,
476          prefs_set_data_from_toggle, prefs_set_toggle},
477         {"newsgroup_abbrev_len", "16",
478          &prefs_common.ng_abbrev_len, P_INT,
479          &display.spinbtn_ng_abbrev_len,
480          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
481
482         {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
483          &display.chkbtn_transhdr,
484          prefs_set_data_from_toggle, prefs_set_toggle},
485
486         /* Display: Summary View */
487         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
488          &display.chkbtn_swapfrom,
489          prefs_set_data_from_toggle, prefs_set_toggle},
490         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
491          &display.chkbtn_hscrollbar,
492          prefs_set_data_from_toggle, prefs_set_toggle},
493         {"use_address_book", "TRUE", &prefs_common.use_addr_book, P_BOOL,
494          &display.chkbtn_useaddrbook,
495          prefs_set_data_from_toggle, prefs_set_toggle},
496         {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
497          P_STRING, &display.entry_datefmt,
498          prefs_set_data_from_entry, prefs_set_entry},
499         {"expand_thread", "TRUE", &prefs_common.expand_thread, P_BOOL,
500          &display.chkbtn_expand_thread,
501          prefs_set_data_from_toggle, prefs_set_toggle},
502         {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
503          &display.chkbtn_bold_unread,
504          prefs_set_data_from_toggle, prefs_set_toggle},
505
506         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
507          NULL, NULL, NULL},
508         
509         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
510          NULL, NULL, NULL},
511         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
512          NULL, NULL, NULL},
513
514         {"summary_col_show_mark", "TRUE",
515          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
516         {"summary_col_show_unread", "TRUE",
517          &prefs_common.summary_col_visible[S_COL_UNREAD], P_BOOL, NULL, NULL, NULL},
518         {"summary_col_show_mime", "TRUE",
519          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
520         {"summary_col_show_subject", "TRUE",
521          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
522         {"summary_col_show_from", "TRUE",
523          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
524         {"summary_col_show_date", "TRUE",
525          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
526         {"summary_col_show_size", "TRUE",
527          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
528         {"summary_col_show_number", "FALSE",
529          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
530         {"summary_col_show_score", "FALSE",
531          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
532         {"summary_col_show_locked", "FALSE",
533          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
534
535         {"summary_col_pos_mark", "0",
536           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
537         {"summary_col_pos_unread", "1",
538           &prefs_common.summary_col_pos[S_COL_UNREAD], P_INT, NULL, NULL, NULL},
539         {"summary_col_pos_mime", "2",
540           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
541         {"summary_col_pos_subject", "3",
542           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
543         {"summary_col_pos_from", "4",
544           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
545         {"summary_col_pos_date", "5",
546           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
547         {"summary_col_pos_size", "6",
548           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
549         {"summary_col_pos_number", "7",
550           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
551         {"summary_col_pos_score", "8",
552          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
553         {"summary_col_pos_locked", "9",
554          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
555
556         {"summary_col_size_mark", "10",
557          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
558         {"summary_col_size_unread", "13",
559          &prefs_common.summary_col_size[S_COL_UNREAD], P_INT, NULL, NULL, NULL},
560         {"summary_col_size_mime", "10",
561          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
562         {"summary_col_size_subject", "200",
563          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
564         {"summary_col_size_from", "120",
565          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
566         {"summary_col_size_date", "118",
567          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
568         {"summary_col_size_size", "45",
569          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
570         {"summary_col_size_number", "40",
571          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
572         {"summary_col_size_score", "40",
573          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
574         {"summary_col_size_locked", "13",
575          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
576
577         /* Widget size */
578         {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
579          NULL, NULL, NULL},
580         {"folderview_height", "600", &prefs_common.folderview_height, P_INT,
581          NULL, NULL, NULL},
582         {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
583          NULL, NULL, NULL},
584         {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
585          NULL, NULL, NULL},
586         {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
587          NULL, NULL, NULL},
588         {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
589          NULL, NULL, NULL},
590
591         {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
592          NULL, NULL, NULL},
593         {"summaryview_height", "173", &prefs_common.summaryview_height, P_INT,
594          NULL, NULL, NULL},
595
596         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
597          NULL, NULL, NULL},
598         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
599          NULL, NULL, NULL},
600         {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
601          NULL, NULL, NULL},
602         {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
603          NULL, NULL, NULL},
604         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
605          NULL, NULL, NULL},
606         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
607          NULL, NULL, NULL},
608         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
609          NULL, NULL, NULL},
610         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
611          NULL, NULL, NULL},
612         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
613          NULL, NULL, NULL},
614         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
615          NULL, NULL, NULL},
616         {"compose_width", "600", &prefs_common.compose_width, P_INT,
617          NULL, NULL, NULL},
618         {"compose_height", "560", &prefs_common.compose_height, P_INT,
619          NULL, NULL, NULL},
620
621         /* Message */
622         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
623          &message.chkbtn_enablecol,
624          prefs_set_data_from_toggle, prefs_set_toggle},
625
626         {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_INT,
627          NULL, NULL, NULL},
628         {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_INT,
629          NULL, NULL, NULL},
630         {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_INT,
631          NULL, NULL, NULL},
632         {"uri_color", "32512", &prefs_common.uri_col, P_INT,
633          NULL, NULL, NULL},
634         {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_INT,
635          NULL, NULL, NULL},
636         {"signature_color", "0", &prefs_common.sig_col, P_USHORT,
637          NULL, NULL, NULL},
638         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
639          P_BOOL, NULL, NULL, NULL},
640
641         {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
642          &message.chkbtn_mbalnum,
643          prefs_set_data_from_toggle, prefs_set_toggle},
644         {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
645          P_BOOL, &message.chkbtn_disphdrpane,
646          prefs_set_data_from_toggle, prefs_set_toggle},
647         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
648          &message.chkbtn_disphdr,
649          prefs_set_data_from_toggle, prefs_set_toggle},
650         {"line_space", "2", &prefs_common.line_space, P_INT,
651          &message.spinbtn_linespc,
652          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
653         {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
654          &message.chkbtn_headspc,
655          prefs_set_data_from_toggle, prefs_set_toggle},
656
657         {"enable_smooth_scroll", "FALSE",
658          &prefs_common.enable_smooth_scroll, P_BOOL,
659          &message.chkbtn_smoothscroll,
660          prefs_set_data_from_toggle, prefs_set_toggle},
661         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
662          &message.spinbtn_scrollstep,
663          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
664         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
665          &message.chkbtn_halfpage,
666          prefs_set_data_from_toggle, prefs_set_toggle},
667
668         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
669          NULL, NULL, NULL},
670
671         /* MIME viewer */
672         {"mime_image_viewer", "display '%s'",
673          &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
674         {"mime_audio_player", "play '%s'",
675          &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
676         {"mime_open_command", "gedit '%s'",
677          &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
678
679 #if USE_GPGME
680         /* Privacy */
681         {"auto_check_signatures", "TRUE",
682          &prefs_common.auto_check_signatures, P_BOOL,
683          &privacy.checkbtn_auto_check_signatures,
684          prefs_set_data_from_toggle, prefs_set_toggle},
685         {"gpg_signature_popup", "FALSE",
686          &prefs_common.gpg_signature_popup, P_BOOL,
687          &privacy.checkbtn_gpg_signature_popup,
688          prefs_set_data_from_toggle, prefs_set_toggle},
689         {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL,
690          &privacy.checkbtn_store_passphrase,
691          prefs_set_data_from_toggle, prefs_set_toggle},
692         {"store_passphrase_timeout", "0", &prefs_common.store_passphrase_timeout,
693          P_INT, &privacy.spinbtn_store_passphrase, 
694          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
695 #ifndef __MINGW32__
696         {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL,
697          &privacy.checkbtn_passphrase_grab,
698          prefs_set_data_from_toggle, prefs_set_toggle},
699 #endif /* __MINGW32__ */
700         {"gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL,
701          &privacy.checkbtn_gpg_warning,
702          prefs_set_data_from_toggle, prefs_set_toggle},
703         {"default_signkey", CS_AUTO, &prefs_common.default_signkey, P_STRING,
704          &privacy.optmenu_default_signkey,
705          prefs_common_default_signkey_set_data_from_optmenu,
706          prefs_common_default_signkey_set_optmenu},
707 #endif /* USE_GPGME */
708
709         /* Interface */
710         {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
711          NULL, NULL, NULL},
712         {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
713          NULL, NULL, NULL},
714
715         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
716          NULL, NULL, NULL}, */
717
718         {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
719          P_BOOL, &interface.checkbtn_openunread,
720          prefs_set_data_from_toggle, prefs_set_toggle},
721         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
722          P_BOOL, &interface.checkbtn_openinbox,
723          prefs_set_data_from_toggle, prefs_set_toggle},
724         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
725          &interface.checkbtn_immedexec,
726          prefs_set_data_from_toggle, prefs_set_toggle},
727         {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
728          &interface.optmenu_recvdialog,
729          prefs_common_recv_dialog_set_data_from_optmenu,
730          prefs_common_recv_dialog_set_optmenu},
731         {"nextunreadmsg_dialog", NULL, &prefs_common.next_unread_msg_dialog, P_ENUM,
732          &interface.optmenu_nextunreadmsgdialog,
733          prefs_nextunreadmsgdialog_set_data_from_optmenu,
734          prefs_nextunreadmsgdialog_set_optmenu},
735
736         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
737          P_BOOL, &interface.checkbtn_addaddrbyclick,
738          prefs_set_data_from_toggle, prefs_set_toggle},
739         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
740          &prefs_common.pixmap_theme_path, P_STRING,
741          &interface.entry_pixmap_theme, prefs_set_data_from_entry, prefs_set_entry},
742         
743         /* Other */
744         {"uri_open_command", "netscape -remote 'openURL(%s,raise)'",
745          &prefs_common.uri_cmd, P_STRING,
746          &other.uri_entry, prefs_set_data_from_entry, prefs_set_entry},
747         {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING,
748          &other.printcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
749         {"ext_editor_command", "gedit %s",
750          &prefs_common.ext_editor_cmd, P_STRING,
751          &other.exteditor_entry, prefs_set_data_from_entry, prefs_set_entry},
752
753         {"confirm_on_exit", "TRUE", &prefs_common.confirm_on_exit, P_BOOL,
754          &other.checkbtn_confonexit,
755          prefs_set_data_from_toggle, prefs_set_toggle},
756         {"send_return_receipt", "TRUE", &prefs_common.return_receipt, P_BOOL,
757          &send.checkbtn_returnreceipt,
758          prefs_set_data_from_toggle, prefs_set_toggle},
759         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
760          &other.checkbtn_cleanonexit,
761          prefs_set_data_from_toggle, prefs_set_toggle},
762         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
763          &other.checkbtn_askonclean,
764          prefs_set_data_from_toggle, prefs_set_toggle},
765         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
766          P_BOOL, &other.checkbtn_warnqueued,
767          prefs_set_data_from_toggle, prefs_set_toggle},
768         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
769          NULL, NULL, NULL},
770
771         {"kill_score", "-9999", &prefs_common.kill_score, P_INT,
772          NULL, NULL, NULL},
773         {"important_score", "1", &prefs_common.important_score, P_INT,
774          NULL, NULL, NULL},
775
776         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
777 };
778
779 /* widget creating functions */
780 static void prefs_common_create         (void);
781 static void prefs_receive_create        (void);
782 static void prefs_send_create           (void);
783 static void prefs_compose_create        (void);
784 static void prefs_spelling_create       (void);
785 static void prefs_quote_create          (void);
786 static void prefs_display_create        (void);
787 static void prefs_message_create        (void);
788 #if USE_GPGME
789 static void prefs_privacy_create        (void);
790 #endif
791 static void prefs_interface_create      (void);
792 static void prefs_other_create          (void);
793
794 static void date_format_ok_btn_clicked          (GtkButton      *button,
795                                                  GtkWidget     **widget);
796 static void date_format_cancel_btn_clicked      (GtkButton      *button,
797                                                  GtkWidget     **widget);
798 static void date_format_key_pressed             (GtkWidget      *keywidget,
799                                                  GdkEventKey    *event,
800                                                  GtkWidget     **widget);
801 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
802                                                  GdkEventAny    *event,
803                                                  GtkWidget     **widget);
804 static void date_format_entry_on_change         (GtkEditable    *editable,
805                                                  GtkLabel       *example);
806 static void date_format_select_row              (GtkWidget      *date_format_list,
807                                                  gint            row,
808                                                  gint            column,
809                                                  GdkEventButton *event,
810                                                  GtkWidget      *date_format);
811 static GtkWidget *date_format_create            (GtkButton      *button,
812                                                  void           *data);
813
814 static void prefs_quote_colors_dialog           (void);
815 static void prefs_quote_colors_dialog_create    (void);
816 static void prefs_quote_colors_key_pressed      (GtkWidget      *widget,
817                                                  GdkEventKey    *event,
818                                                  gpointer        data);
819 static void quote_color_set_dialog              (GtkWidget      *widget,
820                                                  gpointer        data);
821 static void quote_colors_set_dialog_ok          (GtkWidget      *widget,
822                                                  gpointer        data);
823 static void quote_colors_set_dialog_cancel      (GtkWidget      *widget,
824                                                  gpointer        data);
825 static void quote_colors_set_dialog_key_pressed (GtkWidget      *widget,
826                                                  GdkEventKey    *event,
827                                                  gpointer        data);
828 static void set_button_bg_color                 (GtkWidget      *widget,
829                                                  gint            color);
830 static void prefs_enable_message_color_toggled  (void);
831 static void prefs_recycle_colors_toggled        (GtkWidget      *widget);
832
833 static void prefs_font_select   (GtkButton *button, GtkEntry *entry);
834
835 static void prefs_font_selection_key_pressed    (GtkWidget      *widget,
836                                                  GdkEventKey    *event,
837                                                  gpointer        data);
838 static void prefs_font_selection_ok             (GtkButton      *button, GtkEntry *entry);
839
840 static void prefs_keybind_select                (void);
841 static gint prefs_keybind_deleted               (GtkWidget      *widget,
842                                                  GdkEventAny    *event,
843                                                  gpointer        data);
844 static void prefs_keybind_key_pressed           (GtkWidget      *widget,
845                                                  GdkEventKey    *event,
846                                                  gpointer        data);
847 static void prefs_keybind_cancel                (void);
848 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
849
850 static gint prefs_common_deleted        (GtkWidget      *widget,
851                                          GdkEventAny    *event,
852                                          gpointer        data);
853 static void prefs_common_key_pressed    (GtkWidget      *widget,
854                                          GdkEventKey    *event,
855                                          gpointer        data);
856 static void prefs_common_ok             (void);
857 static void prefs_common_apply          (void);
858 static void prefs_common_cancel         (void);
859
860 void prefs_common_init() {
861         prefs_common.fltlist = NULL;
862         prefs_common.disphdr_list = NULL;
863 }
864
865 void prefs_common_read_config(void)
866 {
867         FILE *fp;
868         gchar *path;
869         gchar buf[PREFSBUFSIZE];
870
871         prefs_read_config(param, "Common", COMMON_RC);
872
873         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
874                            NULL);
875         if ((fp = fopen(path, "rb")) == NULL) {
876                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
877                 g_free(path);
878                 return;
879         }
880         g_free(path);
881         while (fgets(buf, sizeof(buf), fp) != NULL) {
882                 g_strstrip(buf);
883                 if (buf[0] == '\0') continue;
884                 prefs_common.mime_open_cmd_history =
885                         add_history(prefs_common.mime_open_cmd_history, buf);
886         }
887         fclose(fp);
888
889         prefs_common.mime_open_cmd_history =
890                 g_list_reverse(prefs_common.mime_open_cmd_history);
891 }
892
893 void prefs_common_save_config(void)
894 {
895         GList *cur;
896         FILE *fp;
897         gchar *path;
898
899         prefs_save_config(param, "Common", COMMON_RC);
900
901         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
902                            NULL);
903         if ((fp = fopen(path, "wb")) == NULL) {
904                 FILE_OP_ERROR(path, "fopen");
905                 g_free(path);
906                 return;
907         }
908
909         for (cur = prefs_common.mime_open_cmd_history;
910              cur != NULL; cur = cur->next) {
911                 fputs((gchar *)cur->data, fp);
912                 fputc('\n', fp);
913         }
914
915         fclose(fp);
916         g_free(path);
917 }
918
919 void prefs_common_open(void)
920 {
921         if (prefs_rc_is_readonly(COMMON_RC))
922                 return;
923
924         inc_lock();
925
926         if (!dialog.window) {
927                 prefs_common_create();
928         }
929
930         manage_window_set_transient(GTK_WINDOW(dialog.window));
931         gtk_notebook_set_page(GTK_NOTEBOOK(dialog.notebook), 0);
932         gtk_widget_grab_focus(dialog.ok_btn);
933
934         prefs_set_dialog(param);
935
936         gtk_widget_show(dialog.window);
937 }
938
939 static void prefs_common_create(void)
940 {
941         gint page = 0;
942
943         debug_print(_("Creating common preferences window...\n"));
944
945         prefs_dialog_create(&dialog);
946         gtk_window_set_title (GTK_WINDOW(dialog.window),
947                               _("Common Preferences"));
948         gtk_signal_connect (GTK_OBJECT(dialog.window), "delete_event",
949                             GTK_SIGNAL_FUNC(prefs_common_deleted), NULL);
950         gtk_signal_connect (GTK_OBJECT(dialog.window), "key_press_event",
951                             GTK_SIGNAL_FUNC(prefs_common_key_pressed), NULL);
952         MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
953
954         gtk_signal_connect (GTK_OBJECT(dialog.ok_btn), "clicked",
955                             GTK_SIGNAL_FUNC(prefs_common_ok), NULL);
956         gtk_signal_connect (GTK_OBJECT(dialog.apply_btn), "clicked",
957                             GTK_SIGNAL_FUNC(prefs_common_apply), NULL);
958         gtk_signal_connect_object (GTK_OBJECT(dialog.cancel_btn), "clicked",
959                                    GTK_SIGNAL_FUNC(prefs_common_cancel),
960                                    GTK_OBJECT(dialog.window));
961
962         /* create all widgets on notebook */
963         prefs_receive_create();
964         SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
965         prefs_send_create();
966         SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
967         prefs_compose_create();
968         SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
969 #if USE_PSPELL
970         prefs_spelling_create();
971         SET_NOTEBOOK_LABEL(dialog.notebook, _("Spell Checker"),   page++);
972 #endif  
973         prefs_quote_create();
974         SET_NOTEBOOK_LABEL(dialog.notebook, _("Quote"),   page++);
975         prefs_display_create();
976         SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
977         prefs_message_create();
978         SET_NOTEBOOK_LABEL(dialog.notebook, _("Message"),   page++);
979 #if USE_GPGME
980         prefs_privacy_create();
981         SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"),   page++);
982 #endif
983         prefs_interface_create();
984         SET_NOTEBOOK_LABEL(dialog.notebook, _("Interface"), page++);
985         prefs_other_create();
986         SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"),     page++);
987
988         gtk_widget_show_all(dialog.window);
989 }
990
991 static void prefs_receive_create(void)
992 {
993         GtkWidget *vbox1;
994         GtkWidget *vbox2;
995         GtkWidget *frame_incext;
996         GtkWidget *checkbtn_incext;
997         GtkWidget *hbox;
998         GtkWidget *label_incext;
999         GtkWidget *entry_incext;
1000         /* GtkWidget *button_incext; */
1001
1002         GtkWidget *frame_spool;
1003         GtkWidget *checkbtn_local;
1004         GtkWidget *checkbtn_filter_on_inc;
1005         GtkWidget *label_spool;
1006         GtkWidget *entry_spool;
1007
1008         GtkWidget *hbox_autochk;
1009         GtkWidget *checkbtn_autochk;
1010         GtkWidget *label_autochk1;
1011         GtkObject *spinbtn_autochk_adj;
1012         GtkWidget *spinbtn_autochk;
1013         GtkWidget *label_autochk2;
1014         GtkWidget *checkbtn_chkonstartup;
1015         GtkWidget *checkbtn_noerrorpanel;
1016         GtkWidget *checkbtn_scan_after_inc;
1017
1018
1019         GtkWidget *frame_newmail;
1020         GtkWidget *hbox_newmail_notify;
1021         GtkWidget *checkbtn_newmail_auto;
1022         GtkWidget *checkbtn_newmail_manu;
1023         GtkWidget *entry_newmail_notify_cmd;
1024         GtkWidget *label_newmail_notify_cmd;
1025
1026         GtkWidget *frame_news;
1027         GtkWidget *label_maxarticle;
1028         GtkWidget *spinbtn_maxarticle;
1029         GtkObject *spinbtn_maxarticle_adj;
1030
1031         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1032         gtk_widget_show (vbox1);
1033         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1034         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1035
1036         PACK_FRAME(vbox1, frame_incext, _("External program"));
1037
1038         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1039         gtk_widget_show (vbox2);
1040         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
1041         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1042
1043         /* Use of external incorporation program */
1044         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
1045                            _("Use external program for incorporation"));
1046
1047         hbox = gtk_hbox_new (FALSE, 8);
1048         gtk_widget_show (hbox);
1049         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1050         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
1051
1052         label_incext = gtk_label_new (_("Command"));
1053         gtk_widget_show (label_incext);
1054         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
1055
1056         entry_incext = gtk_entry_new ();
1057         gtk_widget_show (entry_incext);
1058         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
1059
1060 #if 0
1061         button_incext = gtk_button_new_with_label ("... ");
1062         gtk_widget_show (button_incext);
1063         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1064 #endif
1065
1066         PACK_FRAME(vbox1, frame_spool, _("Local spool"));
1067
1068         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1069         gtk_widget_show (vbox2);
1070         gtk_container_add (GTK_CONTAINER (frame_spool), vbox2);
1071         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1072
1073         hbox = gtk_hbox_new (FALSE, 32);
1074         gtk_widget_show (hbox);
1075         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1076
1077         PACK_CHECK_BUTTON (hbox, checkbtn_local, _("Incorporate from spool"));
1078         PACK_CHECK_BUTTON (hbox, checkbtn_filter_on_inc,
1079                            _("Filter on incorporation"));
1080         SET_TOGGLE_SENSITIVITY (checkbtn_local, checkbtn_filter_on_inc);
1081
1082         hbox = gtk_hbox_new (FALSE, 8);
1083         gtk_widget_show (hbox);
1084         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1085         SET_TOGGLE_SENSITIVITY (checkbtn_local, hbox);
1086
1087         label_spool = gtk_label_new (_("Spool directory"));
1088         gtk_widget_show (label_spool);
1089         gtk_box_pack_start (GTK_BOX (hbox), label_spool, FALSE, FALSE, 0);
1090
1091         entry_spool = gtk_entry_new ();
1092         gtk_widget_show (entry_spool);
1093         gtk_box_pack_start (GTK_BOX (hbox), entry_spool, TRUE, TRUE, 0);
1094
1095         vbox2 = gtk_vbox_new (FALSE, 0);
1096         gtk_widget_show (vbox2);
1097         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1098
1099         /* Auto-checking */
1100         hbox_autochk = gtk_hbox_new (FALSE, 8);
1101         gtk_widget_show (hbox_autochk);
1102         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1103
1104         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1105                            _("Auto-check new mail"));
1106
1107         label_autochk1 = gtk_label_new (_("every"));
1108         gtk_widget_show (label_autochk1);
1109         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1110
1111         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1112         spinbtn_autochk = gtk_spin_button_new
1113                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1114         gtk_widget_show (spinbtn_autochk);
1115         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1116         gtk_widget_set_usize (spinbtn_autochk, 64, -1);
1117         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1118
1119         label_autochk2 = gtk_label_new (_("minute(s)"));
1120         gtk_widget_show (label_autochk2);
1121         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1122
1123         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1124         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1125         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1126
1127         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1128                            _("Check new mail on startup"));
1129
1130         PACK_CHECK_BUTTON (vbox2, checkbtn_noerrorpanel,
1131                            _("No error popup on receive error"));
1132         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1133                            _("Update all local folders after incorporation"));
1134
1135         
1136         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1137                                            "arrives"));
1138         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1139         gtk_widget_show (vbox2);
1140         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1141         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1142
1143         hbox = gtk_hbox_new (TRUE, 8);
1144         gtk_widget_show (hbox);
1145         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1146                            _("after autochecking"));
1147         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1148                            _("after manual checking"));
1149         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1150         gtk_signal_connect(GTK_OBJECT(checkbtn_newmail_auto), "toggled",
1151                            GTK_SIGNAL_FUNC(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1152                            NULL);
1153         gtk_signal_connect(GTK_OBJECT(checkbtn_newmail_manu), "toggled",
1154                            GTK_SIGNAL_FUNC(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1155                            NULL);
1156
1157         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1158         gtk_widget_show (hbox);
1159         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1160                             FALSE, 0);
1161
1162         label_newmail_notify_cmd = gtk_label_new (_("Command  to execute:\n"
1163                                                     "(use %d as number of new "
1164                                                     "mails)"));
1165         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1166                               GTK_JUSTIFY_RIGHT);
1167         gtk_widget_show (label_newmail_notify_cmd);
1168         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1169                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1170
1171         entry_newmail_notify_cmd = gtk_entry_new ();
1172         gtk_widget_show (entry_newmail_notify_cmd);
1173         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1174                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1175
1176         gtk_widget_set_sensitive(hbox_newmail_notify, 
1177                                  prefs_common.newmail_notify_auto || 
1178                                  prefs_common.newmail_notify_manu);
1179
1180         PACK_FRAME(vbox1, frame_news, _("News"));
1181
1182         hbox = gtk_hbox_new (FALSE, 8);
1183         gtk_widget_show (hbox);
1184         gtk_container_add (GTK_CONTAINER (frame_news), hbox);
1185         gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
1186
1187         label_maxarticle = gtk_label_new
1188                 (_("Maximum number of articles to download\n"
1189                    "(unlimited if 0 is specified)"));
1190         gtk_widget_show (label_maxarticle);
1191         gtk_box_pack_start (GTK_BOX (hbox), label_maxarticle, FALSE, FALSE, 0);
1192         gtk_label_set_justify (GTK_LABEL (label_maxarticle), GTK_JUSTIFY_LEFT);
1193
1194         spinbtn_maxarticle_adj =
1195                 gtk_adjustment_new (300, 0, 10000, 10, 100, 100);
1196         spinbtn_maxarticle = gtk_spin_button_new
1197                 (GTK_ADJUSTMENT (spinbtn_maxarticle_adj), 10, 0);
1198         gtk_widget_show (spinbtn_maxarticle);
1199         gtk_box_pack_start (GTK_BOX (hbox), spinbtn_maxarticle,
1200                             FALSE, FALSE, 0);
1201         gtk_widget_set_usize (spinbtn_maxarticle, 64, -1);
1202         gtk_spin_button_set_numeric
1203                 (GTK_SPIN_BUTTON (spinbtn_maxarticle), TRUE);
1204
1205         receive.checkbtn_incext = checkbtn_incext;
1206         receive.entry_incext    = entry_incext;
1207         /* receive.button_incext   = button_incext; */
1208
1209         receive.checkbtn_local         = checkbtn_local;
1210         receive.checkbtn_filter_on_inc = checkbtn_filter_on_inc;
1211         receive.entry_spool            = entry_spool;
1212
1213         receive.checkbtn_autochk    = checkbtn_autochk;
1214         receive.spinbtn_autochk     = spinbtn_autochk;
1215         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1216
1217         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1218         receive.checkbtn_noerrorpanel = checkbtn_noerrorpanel;
1219         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1220
1221
1222         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1223         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1224         receive.hbox_newmail_notify    = hbox_newmail_notify;
1225         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1226
1227         receive.spinbtn_maxarticle     = spinbtn_maxarticle;
1228         receive.spinbtn_maxarticle_adj = spinbtn_maxarticle_adj;
1229 }
1230
1231 static void prefs_send_create(void)
1232 {
1233         GtkWidget *vbox1;
1234         GtkWidget *vbox2;
1235         GtkWidget *frame_extsend;
1236         GtkWidget *vbox_extsend;
1237         GtkWidget *checkbtn_extsend;
1238         GtkWidget *hbox1;
1239         GtkWidget *label_extsend;
1240         GtkWidget *entry_extsend;
1241         /* GtkWidget *button_extsend; */
1242         GtkWidget *checkbtn_savemsg;
1243         GtkWidget *checkbtn_queuemsg;
1244         GtkWidget *label_outcharset;
1245         GtkWidget *optmenu;
1246         GtkWidget *optmenu_menu;
1247         GtkWidget *menuitem;
1248         GtkWidget *checkbtn_returnreceipt;
1249         GtkWidget *label_charset_desc;
1250
1251         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1252         gtk_widget_show (vbox1);
1253         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1254         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1255
1256         PACK_FRAME(vbox1, frame_extsend, _("External program"));
1257
1258         vbox_extsend = gtk_vbox_new (FALSE, VSPACING_NARROW);
1259         gtk_widget_show (vbox_extsend);
1260         gtk_container_add (GTK_CONTAINER (frame_extsend), vbox_extsend);
1261         gtk_container_set_border_width (GTK_CONTAINER (vbox_extsend), 8);
1262
1263         PACK_CHECK_BUTTON (vbox_extsend, checkbtn_extsend,
1264                            _("Use external program for sending"));
1265
1266         hbox1 = gtk_hbox_new (FALSE, 8);
1267         gtk_widget_show (hbox1);
1268         gtk_box_pack_start (GTK_BOX (vbox_extsend), hbox1, FALSE, FALSE, 0);
1269         SET_TOGGLE_SENSITIVITY(checkbtn_extsend, hbox1);
1270
1271         label_extsend = gtk_label_new (_("Command"));
1272         gtk_widget_show (label_extsend);
1273         gtk_box_pack_start (GTK_BOX (hbox1), label_extsend, FALSE, FALSE, 0);
1274
1275         entry_extsend = gtk_entry_new ();
1276         gtk_widget_show (entry_extsend);
1277         gtk_box_pack_start (GTK_BOX (hbox1), entry_extsend, TRUE, TRUE, 0);
1278
1279 #if 0
1280         button_extsend = gtk_button_new_with_label ("... ");
1281         gtk_widget_show (button_extsend);
1282         gtk_box_pack_start (GTK_BOX (hbox1), button_extsend, FALSE, FALSE, 0);
1283 #endif
1284
1285         vbox2 = gtk_vbox_new (FALSE, 0);
1286         gtk_widget_show (vbox2);
1287         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1288
1289         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1290                            _("Save sent messages to Sent"));
1291         PACK_CHECK_BUTTON (vbox2, checkbtn_queuemsg,
1292                            _("Queue messages that fail to send"));
1293         PACK_CHECK_BUTTON (vbox2, checkbtn_returnreceipt,
1294                            _("Send return receipt on request"));
1295
1296         hbox1 = gtk_hbox_new (FALSE, 8);
1297         gtk_widget_show (hbox1);
1298         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1299
1300         label_outcharset = gtk_label_new (_("Outgoing codeset"));
1301         gtk_widget_show (label_outcharset);
1302         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1303
1304         optmenu = gtk_option_menu_new ();
1305         gtk_widget_show (optmenu);
1306         gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1307
1308         optmenu_menu = gtk_menu_new ();
1309
1310 #define SET_MENUITEM(str, charset) \
1311 { \
1312         MENUITEM_ADD(optmenu_menu, menuitem, str, charset); \
1313 }
1314
1315         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1316         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1317 #if HAVE_LIBJCONV
1318         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1319 #endif
1320         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1321         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1322         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1323         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1324         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1325         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1326         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1327 #if HAVE_LIBJCONV
1328         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1329 #endif
1330         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1331 #if HAVE_LIBJCONV
1332         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1333         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1334 #endif
1335         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1336 #if 0
1337         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1338         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1339 #endif /* 0 */
1340         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1341         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1342 #if 0
1343         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1344         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1345 #endif /* 0 */
1346         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1347         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1348         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1349
1350         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
1351
1352         hbox1 = gtk_hbox_new (FALSE, 8);
1353         gtk_widget_show (hbox1);
1354         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1355
1356         label_charset_desc = gtk_label_new
1357                 (_("If `Automatic' is selected, the optimal encoding\n"
1358                    "for the current locale will be used."));
1359         gtk_widget_show (label_charset_desc);
1360         gtk_box_pack_start (GTK_BOX (hbox1), label_charset_desc,
1361                             FALSE, FALSE, 0);
1362         gtk_label_set_justify(GTK_LABEL (label_charset_desc), GTK_JUSTIFY_LEFT);
1363
1364         send.checkbtn_extsend = checkbtn_extsend;
1365         send.entry_extsend    = entry_extsend;
1366         /* send.button_extsend   = button_extsend; */
1367
1368         send.checkbtn_savemsg  = checkbtn_savemsg;
1369         send.checkbtn_queuemsg = checkbtn_queuemsg;
1370         send.checkbtn_returnreceipt = checkbtn_returnreceipt;
1371
1372         send.optmenu_charset = optmenu;
1373 }
1374
1375 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1376 {
1377         gboolean toggled;
1378
1379         toggled = gtk_toggle_button_get_active
1380                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1381                   gtk_toggle_button_get_active
1382                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1383         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1384 }
1385
1386 #if USE_PSPELL
1387 static void prefs_dictionary_set_data_from_optmenu(PrefParam *param)
1388 {
1389         gchar *str;
1390         gchar *dict_fullname;
1391         
1392         g_return_if_fail(param);
1393         g_return_if_fail(param->data);
1394         g_return_if_fail(param->widget);
1395         g_return_if_fail(*(param->widget));
1396
1397         dict_fullname = gtkpspell_get_dictionary_menu_active_item
1398                 (gtk_option_menu_get_menu(GTK_OPTION_MENU(*(param->widget))));
1399         str = *((gchar **) param->data);
1400         if (str)
1401                 g_free(str);
1402         *((gchar **) param->data) = dict_fullname;
1403 }
1404
1405 static void prefs_dictionary_set_optmenu(PrefParam *pparam)
1406 {
1407         GList *cur;
1408         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
1409         GtkWidget *menu;
1410         GtkWidget *menuitem;
1411         gchar *dict_name;
1412         gint n = 0;
1413
1414         g_return_if_fail(optmenu != NULL);
1415         g_return_if_fail(pparam->data != NULL);
1416
1417         if (*(gchar **) pparam->data) {
1418                 menu = gtk_option_menu_get_menu(optmenu);
1419                 for (cur = GTK_MENU_SHELL(menu)->children;
1420                      cur != NULL; cur = cur->next) {
1421                         menuitem = GTK_WIDGET(cur->data);
1422                         dict_name = gtk_object_get_data(GTK_OBJECT(menuitem), 
1423                                                         "dict_name");
1424                         if (!strcmp2(dict_name, *((gchar **)pparam->data))) {
1425                                 gtk_option_menu_set_history(optmenu, n);
1426                                 return;
1427                         }
1428                         n++;
1429                 }
1430         }               
1431
1432         gtk_option_menu_set_history(optmenu, 0);
1433         prefs_dictionary_set_data_from_optmenu(pparam);
1434 }
1435
1436 static void prefs_speller_sugmode_set_data_from_optmenu(PrefParam *param)
1437 {
1438         gint sugmode;
1439         g_return_if_fail(param);
1440         g_return_if_fail(param->data);
1441         g_return_if_fail(param->widget);
1442         g_return_if_fail(*(param->widget));
1443
1444         sugmode = gtkpspell_get_sugmode_from_option_menu
1445                 (GTK_OPTION_MENU(*(param->widget)));
1446         *((gint *) param->data) = sugmode;
1447 }
1448
1449 static void prefs_speller_sugmode_set_optmenu(PrefParam *pparam)
1450 {
1451         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
1452         gint sugmode;
1453
1454         g_return_if_fail(optmenu != NULL);
1455         g_return_if_fail(pparam->data != NULL);
1456
1457         sugmode = *(gint *) pparam->data;
1458         gtkpspell_sugmode_option_menu_set(optmenu, sugmode);
1459 }
1460         
1461         
1462 static void prefs_spelling_checkbtn_enable_pspell_toggle_cb
1463         (GtkWidget *widget,
1464          gpointer data)
1465 {
1466         gboolean toggled;
1467
1468         toggled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
1469
1470         gtk_widget_set_sensitive(spelling.entry_pspell_path,   toggled);
1471         gtk_widget_set_sensitive(spelling.optmenu_dictionary,  toggled);
1472         gtk_widget_set_sensitive(spelling.optmenu_sugmode,     toggled);
1473         gtk_widget_set_sensitive(spelling.btn_pspell_path,     toggled);
1474         gtk_widget_set_sensitive(spelling.misspelled_btn,      toggled);
1475         gtk_widget_set_sensitive(spelling.checkbtn_use_alternate,      toggled);
1476         gtk_widget_set_sensitive(spelling.checkbtn_check_while_typing, toggled);
1477 }
1478
1479 static void prefs_spelling_btn_pspell_path_clicked_cb(GtkWidget *widget,
1480                                                      gpointer data)
1481 {
1482         gchar *file_path, *tmp;
1483         GtkWidget *new_menu;
1484
1485         file_path = filesel_select_file(_("Select dictionaries location"),
1486                                         prefs_common.pspell_path);
1487         if (file_path == NULL) {
1488                 /* don't change */      
1489         }
1490         else {
1491           tmp=g_dirname(file_path);
1492           
1493                 if (prefs_common.pspell_path)
1494                         g_free(prefs_common.pspell_path);
1495                 prefs_common.pspell_path = g_strdup_printf("%s%s",tmp,
1496                                                            G_DIR_SEPARATOR_S);
1497
1498                 new_menu = gtkpspell_dictionary_option_menu_new(prefs_common.pspell_path);
1499                 gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling.optmenu_dictionary),
1500                                          new_menu);
1501
1502                 gtk_entry_set_text(GTK_ENTRY(spelling.entry_pspell_path), 
1503                                    prefs_common.pspell_path);                                    
1504                 /* select first one */
1505                 gtk_option_menu_set_history(GTK_OPTION_MENU(
1506                                         spelling.optmenu_dictionary), 0);
1507         
1508                 if (prefs_common.dictionary)
1509                         g_free(prefs_common.dictionary);
1510
1511                 prefs_common.dictionary = 
1512                         gtkpspell_get_dictionary_menu_active_item(
1513                                 gtk_option_menu_get_menu(
1514                                         GTK_OPTION_MENU(
1515                                                 spelling.optmenu_dictionary)));
1516                 g_free(tmp);
1517
1518         }
1519 }
1520
1521 static void prefs_spelling_create()
1522 {
1523         GtkWidget *vbox1;
1524         GtkWidget *frame_spell;
1525         GtkWidget *vbox_spell;
1526         GtkWidget *hbox_pspell_path;
1527         GtkWidget *checkbtn_enable_pspell;
1528         GtkWidget *label_pspell_path;
1529         GtkWidget *entry_pspell_path;
1530         GtkWidget *btn_pspell_path;
1531         GtkWidget *spell_table;
1532         GtkWidget *label_dictionary;
1533         GtkWidget *optmenu_dictionary;
1534         GtkWidget *sugmode_label;
1535         GtkWidget *sugmode_optmenu;
1536         GtkWidget *checkbtn_use_alternate;
1537         GtkWidget *help_label;
1538         GtkWidget *checkbtn_check_while_typing;
1539         GtkWidget *color_label;
1540         GtkWidget *col_align;
1541
1542         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1543         gtk_widget_show (vbox1);
1544         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1545         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1546
1547         /* spell checker defaults */                       
1548         PACK_FRAME(vbox1, frame_spell, _("Global spelling checker settings"));
1549         vbox_spell = gtk_vbox_new(FALSE, VSPACING_NARROW);
1550         gtk_widget_show (vbox_spell);
1551         gtk_container_add(GTK_CONTAINER(frame_spell), vbox_spell);
1552         gtk_container_set_border_width(GTK_CONTAINER(vbox_spell), 8);
1553
1554         PACK_CHECK_BUTTON(vbox_spell, checkbtn_enable_pspell, 
1555                           _("Enable spell checker (EXPERIMENTAL)"));
1556
1557         gtk_signal_connect(GTK_OBJECT(checkbtn_enable_pspell), "toggled",
1558                            GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_pspell_toggle_cb),
1559                            NULL);
1560
1561         /* Check while typing */
1562         PACK_CHECK_BUTTON(vbox_spell, checkbtn_check_while_typing, 
1563                           _("Check while typing"));
1564
1565         PACK_CHECK_BUTTON(vbox_spell, checkbtn_use_alternate, 
1566                           _("Enable alternate dictionary"));
1567
1568         help_label = gtk_label_new(_("Enabling alternate dictionary makes switching\nwith the last used dictionary faster."));
1569         gtk_widget_show(help_label);
1570         gtk_box_pack_start(GTK_BOX(vbox_spell), help_label, FALSE, TRUE, 0);
1571         
1572         spell_table = gtk_table_new(4, 3, FALSE);
1573         gtk_container_set_border_width (GTK_CONTAINER (spell_table), VSPACING);
1574         gtk_table_set_row_spacings(GTK_TABLE(spell_table), 8);
1575         gtk_table_set_col_spacings(GTK_TABLE(spell_table), 8);
1576
1577         gtk_box_pack_start(GTK_BOX(vbox_spell), spell_table, TRUE, TRUE, 0);
1578
1579         label_pspell_path = gtk_label_new (_("Dictionaries path:"));
1580         gtk_misc_set_alignment(GTK_MISC(label_pspell_path), 1.0, 0.5);
1581         gtk_widget_show(label_pspell_path);
1582         gtk_table_attach (GTK_TABLE (spell_table), label_pspell_path, 0, 1, 0,
1583                           1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1584         
1585         hbox_pspell_path = gtk_hbox_new (FALSE, 8);
1586         gtk_table_attach (GTK_TABLE (spell_table), hbox_pspell_path, 1, 2, 0,
1587                           1, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1588         gtk_widget_show(hbox_pspell_path);
1589
1590         entry_pspell_path = gtk_entry_new();
1591         gtk_widget_show(entry_pspell_path);
1592         gtk_box_pack_start(GTK_BOX(hbox_pspell_path), entry_pspell_path, TRUE,
1593                            TRUE, 0);    
1594         
1595         gtk_widget_set_sensitive(entry_pspell_path, prefs_common.enable_pspell);
1596
1597         btn_pspell_path = gtk_button_new_with_label(" ... ");
1598         gtk_widget_show(btn_pspell_path);
1599         gtk_box_pack_start(GTK_BOX(hbox_pspell_path), btn_pspell_path, FALSE, FALSE, 0);
1600         gtk_widget_set_sensitive(btn_pspell_path, prefs_common.enable_pspell);
1601
1602         gtk_signal_connect(GTK_OBJECT(btn_pspell_path), "clicked", 
1603                            GTK_SIGNAL_FUNC(prefs_spelling_btn_pspell_path_clicked_cb),
1604                            NULL);
1605
1606         label_dictionary = gtk_label_new(_("Default dictionary:"));
1607         gtk_misc_set_alignment(GTK_MISC(label_dictionary), 1.0, 0.5);
1608         gtk_widget_show(label_dictionary);
1609         gtk_table_attach (GTK_TABLE (spell_table), label_dictionary, 0, 1, 1, 2,
1610                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1611
1612         optmenu_dictionary = gtk_option_menu_new();
1613         gtk_widget_show(optmenu_dictionary);
1614         gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary), 
1615                                  gtkpspell_dictionary_option_menu_new(
1616                                          prefs_common.pspell_path));
1617         gtk_table_attach (GTK_TABLE (spell_table), optmenu_dictionary, 1, 2, 1,
1618                           2, GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1619         gtk_widget_set_sensitive(optmenu_dictionary, prefs_common.enable_pspell);
1620
1621         /* Suggestion mode */
1622         sugmode_label = gtk_label_new(_("Default suggestion mode"));
1623         gtk_misc_set_alignment(GTK_MISC(sugmode_label), 1.0, 0.5);
1624         gtk_widget_show(sugmode_label);
1625         gtk_table_attach(GTK_TABLE (spell_table), sugmode_label, 0, 1, 2, 3,
1626                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1627
1628         sugmode_optmenu = gtk_option_menu_new();
1629         gtk_widget_show(sugmode_optmenu);
1630         gtk_option_menu_set_menu(GTK_OPTION_MENU(sugmode_optmenu),
1631                             gtkpspell_sugmode_option_menu_new(prefs_common.pspell_sugmode));
1632         gtk_table_attach(GTK_TABLE(spell_table), sugmode_optmenu, 1, 2, 2, 3,
1633                          GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1634         gtk_widget_set_sensitive(sugmode_optmenu, prefs_common.enable_pspell);
1635
1636         /* Color */
1637         color_label = gtk_label_new(_("Misspelled word color:"));
1638         gtk_misc_set_alignment(GTK_MISC(color_label), 1.0, 0.5);
1639         gtk_table_attach (GTK_TABLE (spell_table), color_label, 0, 1, 3, 4,
1640                           GTK_FILL, GTK_SHRINK, 0, 0);
1641         gtk_widget_show(color_label);
1642         
1643         col_align = gtk_alignment_new(0.0, 0.5, 0, 0);
1644         gtk_widget_show(col_align);
1645         gtk_table_attach (GTK_TABLE (spell_table), col_align, 1, 2, 3, 4,
1646                           GTK_FILL, GTK_SHRINK, 0, 0);
1647
1648         spelling.misspelled_btn = gtk_button_new_with_label ("");
1649         set_button_bg_color(spelling.misspelled_btn,
1650                             prefs_common.misspelled_col);
1651         gtk_widget_set_usize (spelling.misspelled_btn, 30, 20);
1652         gtk_widget_set_sensitive(spelling.misspelled_btn, prefs_common.enable_pspell);
1653         gtk_signal_connect (GTK_OBJECT (spelling.misspelled_btn), "clicked",
1654                             GTK_SIGNAL_FUNC(quote_color_set_dialog), "Misspelled word");
1655         gtk_container_add(GTK_CONTAINER(col_align), spelling.misspelled_btn);
1656
1657
1658         spelling.checkbtn_enable_pspell = checkbtn_enable_pspell;
1659         spelling.entry_pspell_path      = entry_pspell_path;
1660         spelling.btn_pspell_path        = btn_pspell_path;
1661         spelling.optmenu_dictionary     = optmenu_dictionary;
1662         spelling.optmenu_sugmode        = sugmode_optmenu;
1663         spelling.checkbtn_use_alternate = checkbtn_use_alternate;
1664         spelling.checkbtn_check_while_typing = checkbtn_check_while_typing;
1665 }
1666
1667 #endif
1668
1669
1670 static void prefs_compose_create(void)
1671 {
1672         GtkWidget *vbox1;
1673         GtkWidget *vbox2;
1674         GtkWidget *vbox3;
1675         GtkWidget *hbox1;
1676         GtkWidget *hbox2;
1677         GtkWidget *btn_quotefmt;
1678
1679         GtkWidget *frame_sig;
1680         GtkWidget *vbox_sig;
1681         GtkWidget *checkbtn_autosig;
1682         GtkWidget *label_sigsep;
1683         GtkWidget *entry_sigsep;
1684
1685         GtkWidget *frame_editor;
1686         GtkWidget *hbox_editor;
1687         GtkWidget *checkbtn_autoextedit;
1688
1689         GtkWidget *frame_autosel;
1690         GtkWidget *hbox_autosel;
1691         GtkWidget *vbox_autosel;
1692         GtkWidget *checkbtn_reply_account_autosel;
1693         GtkWidget *checkbtn_forward_account_autosel;
1694         GtkWidget *checkbtn_reedit_account_autosel;
1695
1696         GtkWidget *hbox_undolevel;
1697         GtkWidget *label_undolevel;
1698         GtkObject *spinbtn_undolevel_adj;
1699         GtkWidget *spinbtn_undolevel;
1700
1701         GtkWidget *vbox_linewrap;
1702
1703         GtkWidget *hbox3;
1704         GtkWidget *hbox4;
1705         GtkWidget *hbox5;
1706         GtkWidget *label_linewrap;
1707         GtkObject *spinbtn_linewrap_adj;
1708         GtkWidget *spinbtn_linewrap;
1709         GtkWidget *checkbtn_wrapquote;
1710         GtkWidget *checkbtn_wrapatsend;
1711
1712         GtkWidget *frame_reply;
1713         GtkWidget *checkbtn_quote;
1714         GtkWidget *checkbtn_forward_as_attachment;
1715         GtkWidget *checkbtn_redirect_keep_from;
1716         GtkWidget *checkbtn_smart_wrapping;
1717         GtkWidget *checkbtn_block_cursor;
1718         GtkWidget *frame_msgwrap;
1719
1720         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1721         gtk_widget_show (vbox1);
1722         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1723         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1724
1725
1726
1727         hbox1 = gtk_hbox_new (FALSE, 32);
1728         gtk_widget_show (hbox1);
1729
1730         hbox2 = gtk_hbox_new (FALSE, 8);
1731         gtk_widget_show (hbox2);
1732         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1733
1734
1735         hbox1 = gtk_hbox_new (FALSE, 32);
1736         gtk_widget_show (hbox1);
1737         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1738
1739         PACK_FRAME(vbox1, frame_sig, _("Signature"));
1740
1741         vbox_sig = gtk_vbox_new (FALSE, VSPACING_NARROW);
1742         gtk_widget_show (vbox_sig);
1743         gtk_container_add (GTK_CONTAINER (frame_sig), vbox_sig);
1744         gtk_container_set_border_width (GTK_CONTAINER (vbox_sig), 8);
1745
1746         PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
1747                            _("Insert signature automatically"));
1748
1749         hbox1 = gtk_hbox_new (FALSE, 8);
1750         gtk_widget_show (hbox1);
1751         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
1752         label_sigsep = gtk_label_new (_("Signature separator"));
1753         gtk_widget_show (label_sigsep);
1754         gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
1755
1756         entry_sigsep = gtk_entry_new ();
1757         gtk_widget_show (entry_sigsep);
1758         gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
1759
1760         gtk_widget_set_usize (entry_sigsep, 64, -1);
1761
1762         /* Account autoselection */
1763         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1764
1765         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1766         gtk_widget_show (hbox_autosel);
1767         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1768         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1769
1770         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1771                            _("when replying"));
1772         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1773                            _("when forwarding"));
1774         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1775                            _("when re-editing"));
1776
1777         vbox2 = gtk_vbox_new (FALSE, 0);
1778         gtk_widget_show (vbox2);
1779         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1780
1781         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1782                            _("Automatically launch the external editor"));
1783
1784         PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1785
1786         hbox5 = gtk_hbox_new (FALSE, 32);
1787         gtk_widget_show (hbox5);
1788         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1789
1790         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1791                            _("Forward as attachment"));
1792
1793         PACK_CHECK_BUTTON (hbox5, checkbtn_block_cursor,
1794                           _("Block cursor"));
1795
1796         PACK_CHECK_BUTTON (vbox2, checkbtn_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         PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1816
1817         /* line-wrapping */
1818         PACK_FRAME(vbox1, frame_msgwrap, _("Message wrapping"));
1819
1820         vbox_linewrap = gtk_vbox_new (FALSE, VSPACING_NARROW);
1821         gtk_widget_show (vbox_linewrap);
1822         gtk_container_add (GTK_CONTAINER (frame_msgwrap), vbox_linewrap);
1823         gtk_container_set_border_width (GTK_CONTAINER (vbox_linewrap), 8);
1824
1825         hbox3 = gtk_hbox_new (FALSE, 8);
1826         gtk_widget_show (hbox3);
1827         gtk_box_pack_start (GTK_BOX (vbox_linewrap), hbox3, FALSE, FALSE, 0);
1828
1829
1830         label_linewrap = gtk_label_new (_("Wrap messages at"));
1831         gtk_widget_show (label_linewrap);
1832         gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1833
1834         spinbtn_linewrap_adj = gtk_adjustment_new (72, 20, 1024, 1, 10, 10);
1835         spinbtn_linewrap = gtk_spin_button_new
1836                 (GTK_ADJUSTMENT (spinbtn_linewrap_adj), 1, 0);
1837         gtk_widget_show (spinbtn_linewrap);
1838         gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_linewrap, FALSE, FALSE, 0);
1839         gtk_widget_set_usize (spinbtn_linewrap, 64, -1);
1840         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linewrap), TRUE);
1841
1842         label_linewrap = gtk_label_new (_("characters"));
1843         gtk_widget_show (label_linewrap);
1844         gtk_box_pack_start (GTK_BOX (hbox3), label_linewrap, FALSE, FALSE, 0);
1845
1846         PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
1847
1848         hbox4 = gtk_hbox_new (FALSE, 32);
1849         gtk_widget_show (hbox4);
1850         gtk_box_pack_start (GTK_BOX (vbox_linewrap), hbox4, FALSE, FALSE, 0);
1851
1852         PACK_CHECK_BUTTON (hbox4, checkbtn_wrapquote, _("Wrap quotation"));
1853         PACK_CHECK_BUTTON
1854                 (hbox4, checkbtn_wrapatsend, _("Wrap before sending"));
1855
1856         PACK_CHECK_BUTTON (vbox_linewrap, checkbtn_smart_wrapping,
1857                            _("Smart wrapping (EXPERIMENTAL)"));
1858         
1859        /*
1860         compose.checkbtn_quote   = checkbtn_quote;
1861         compose.entry_quotemark  = entry_quotemark;
1862         compose.text_quotefmt    = text_quotefmt;
1863         */
1864         compose.checkbtn_autosig = checkbtn_autosig;
1865         compose.entry_sigsep     = entry_sigsep;
1866
1867         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1868
1869         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1870         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1871         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1872
1873         compose.spinbtn_undolevel     = spinbtn_undolevel;
1874         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1875
1876         compose.spinbtn_linewrap     = spinbtn_linewrap;
1877         compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
1878         compose.checkbtn_wrapquote   = checkbtn_wrapquote;
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_exit;
2818         GtkWidget *vbox_exit;
2819         GtkWidget *checkbtn_confonexit;
2820         GtkWidget *checkbtn_cleanonexit;
2821         GtkWidget *checkbtn_askonclean;
2822         GtkWidget *checkbtn_warnqueued;
2823
2824         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2825         gtk_widget_show (vbox1);
2826         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2827         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2828
2829         PACK_FRAME(vbox1, ext_frame,
2830                    _("External commands (%s will be replaced with file name / URI)"));
2831
2832         ext_table = gtk_table_new (3, 2, FALSE);
2833         gtk_widget_show (ext_table);
2834         gtk_container_add (GTK_CONTAINER (ext_frame), ext_table);
2835         gtk_container_set_border_width (GTK_CONTAINER (ext_table), 8);
2836         gtk_table_set_row_spacings (GTK_TABLE (ext_table), VSPACING_NARROW);
2837         gtk_table_set_col_spacings (GTK_TABLE (ext_table), 8);
2838
2839         uri_label = gtk_label_new (_("Web browser"));
2840         gtk_widget_show(uri_label);
2841         gtk_table_attach (GTK_TABLE (ext_table), uri_label, 0, 1, 0, 1,
2842                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2843         gtk_misc_set_alignment (GTK_MISC (uri_label), 1, 0.5);
2844
2845         uri_combo = gtk_combo_new ();
2846         gtk_widget_show (uri_combo);
2847         gtk_table_attach (GTK_TABLE (ext_table), uri_combo, 1, 2, 0, 1,
2848                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2849         gtkut_combo_set_items (GTK_COMBO (uri_combo),
2850                                "netscape -remote 'openURL(%s,raise)'",
2851                                "netscape '%s'",
2852                                "gnome-moz-remote --raise --newwin '%s'",
2853                                "kfmclient openURL '%s'",
2854                                "opera -newwindow '%s'",        
2855                                "kterm -e w3m '%s'",
2856                                "kterm -e lynx '%s'",
2857                                NULL);
2858         uri_entry = GTK_COMBO (uri_combo)->entry;
2859
2860         printcmd_label = gtk_label_new (_("Print"));
2861         gtk_widget_show (printcmd_label);
2862         gtk_table_attach (GTK_TABLE (ext_table), printcmd_label, 0, 1, 1, 2,
2863                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2864         gtk_misc_set_alignment (GTK_MISC (printcmd_label), 1, 0.5);
2865
2866         printcmd_entry = gtk_entry_new ();
2867         gtk_widget_show (printcmd_entry);
2868         gtk_table_attach (GTK_TABLE (ext_table), printcmd_entry, 1, 2, 1, 2,
2869                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2870
2871         exteditor_label = gtk_label_new (_("Editor"));
2872         gtk_widget_show (exteditor_label);
2873         gtk_table_attach (GTK_TABLE (ext_table), exteditor_label, 0, 1, 2, 3,
2874                           GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
2875         gtk_misc_set_alignment (GTK_MISC (exteditor_label), 1, 0.5);
2876
2877         exteditor_combo = gtk_combo_new ();
2878         gtk_widget_show (exteditor_combo);
2879         gtk_table_attach (GTK_TABLE (ext_table), exteditor_combo, 1, 2, 2, 3,
2880                           GTK_EXPAND | GTK_FILL, 0, 0, 0);
2881         gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2882                                "gedit %s",
2883                                "kedit %s",
2884                                "mgedit --no-fork %s",
2885                                "emacs %s",
2886                                "xemacs %s",
2887                                "kterm -e jed %s",
2888                                "kterm -e vi %s",
2889                                NULL);
2890         exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2891
2892         /* On Exit */
2893         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2894
2895         vbox_exit = gtk_vbox_new (FALSE, 0);
2896         gtk_widget_show (vbox_exit);
2897         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2898         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2899
2900         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2901                            _("Confirm on exit"));
2902
2903         hbox1 = gtk_hbox_new (FALSE, 32);
2904         gtk_widget_show (hbox1);
2905         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2906
2907         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2908                            _("Empty trash on exit"));
2909         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2910                            _("Ask before emptying"));
2911         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2912
2913         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2914                            _("Warn if there are queued messages"));
2915
2916         other.uri_combo = uri_combo;
2917         other.uri_entry = uri_entry;
2918         other.printcmd_entry = printcmd_entry;
2919
2920         other.exteditor_combo = exteditor_combo;
2921         other.exteditor_entry = exteditor_entry;
2922
2923         other.checkbtn_confonexit  = checkbtn_confonexit;
2924         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2925         other.checkbtn_askonclean  = checkbtn_askonclean;
2926         other.checkbtn_warnqueued  = checkbtn_warnqueued;
2927 }
2928
2929 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2930 {
2931         GtkWidget *datefmt_sample = NULL;
2932         gchar *text;
2933
2934         g_return_if_fail(widget != NULL);
2935         g_return_if_fail(*widget != NULL);
2936         g_return_if_fail(display.entry_datefmt != NULL);
2937
2938         datefmt_sample = GTK_WIDGET(gtk_object_get_data
2939                                     (GTK_OBJECT(*widget), "datefmt_sample"));
2940         g_return_if_fail(datefmt_sample != NULL);
2941
2942         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2943         g_free(prefs_common.date_format);
2944         prefs_common.date_format = text;
2945         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2946
2947         gtk_widget_destroy(*widget);
2948         *widget = NULL;
2949 }
2950
2951 static void date_format_cancel_btn_clicked(GtkButton *button,
2952                                            GtkWidget **widget)
2953 {
2954         g_return_if_fail(widget != NULL);
2955         g_return_if_fail(*widget != NULL);
2956
2957         gtk_widget_destroy(*widget);
2958         *widget = NULL;
2959 }
2960
2961 static void date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2962                                     GtkWidget **widget)
2963 {
2964         if (event && event->keyval == GDK_Escape)
2965                 date_format_cancel_btn_clicked(NULL, widget);
2966 }
2967
2968 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2969                                       GdkEventAny *event, GtkWidget **widget)
2970 {
2971         g_return_val_if_fail(widget != NULL, FALSE);
2972         g_return_val_if_fail(*widget != NULL, FALSE);
2973
2974         *widget = NULL;
2975         return FALSE;
2976 }
2977
2978 static void date_format_entry_on_change(GtkEditable *editable,
2979                                         GtkLabel *example)
2980 {
2981         time_t cur_time;
2982         struct tm *cal_time;
2983         gchar buffer[100];
2984         gchar *text;
2985
2986         cur_time = time(NULL);
2987         cal_time = localtime(&cur_time);
2988         buffer[0] = 0;
2989         text = gtk_editable_get_chars(editable, 0, -1);
2990         if (text)
2991                 strftime(buffer, sizeof buffer, text, cal_time); 
2992         gtk_label_set_text(example, buffer);
2993 }
2994
2995 static void date_format_select_row(GtkWidget *date_format_list, gint row,
2996                                    gint column, GdkEventButton *event,
2997                                    GtkWidget *date_format)
2998 {
2999         gint cur_pos;
3000         gchar *format;
3001         gchar *old_format;
3002         gchar *new_format;
3003         GtkWidget *datefmt_sample;
3004
3005         /* only on double click */
3006         if (!event || event->type != GDK_2BUTTON_PRESS) return;
3007
3008
3009         datefmt_sample = GTK_WIDGET(gtk_object_get_data
3010                                     (GTK_OBJECT(date_format), "datefmt_sample"));
3011
3012         g_return_if_fail(date_format_list != NULL);
3013         g_return_if_fail(date_format != NULL);
3014         g_return_if_fail(datefmt_sample != NULL);
3015
3016         /* get format from clist */
3017         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
3018
3019         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
3020         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
3021
3022         /* insert the format into the text entry */
3023         new_format = g_malloc(strlen(old_format) + 3);
3024
3025         strncpy(new_format, old_format, cur_pos);
3026         new_format[cur_pos] = '\0';
3027         strcat(new_format, format);
3028         strcat(new_format, &old_format[cur_pos]);
3029
3030         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
3031         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
3032
3033         g_free(new_format);
3034 }
3035
3036 static GtkWidget *date_format_create(GtkButton *button, void *data)
3037 {
3038         static GtkWidget *datefmt_win = NULL;
3039         GtkWidget *vbox1;
3040         GtkWidget *scrolledwindow1;
3041         GtkWidget *datefmt_clist;
3042         GtkWidget *table;
3043         GtkWidget *label1;
3044         GtkWidget *label2;
3045         GtkWidget *label3;
3046         GtkWidget *confirm_area;
3047         GtkWidget *ok_btn;
3048         GtkWidget *cancel_btn;
3049         GtkWidget *datefmt_entry;
3050
3051         struct {
3052                 gchar *fmt;
3053                 gchar *txt;
3054         } time_format[] = {
3055                 { "%a", NULL },
3056                 { "%A", NULL },
3057                 { "%b", NULL },
3058                 { "%B", NULL },
3059                 { "%c", NULL },
3060                 { "%C", NULL },
3061                 { "%d", NULL },
3062                 { "%H", NULL },
3063                 { "%I", NULL },
3064                 { "%j", NULL },
3065                 { "%m", NULL },
3066                 { "%M", NULL },
3067                 { "%p", NULL },
3068                 { "%S", NULL },
3069                 { "%w", NULL },
3070                 { "%x", NULL },
3071                 { "%y", NULL },
3072                 { "%Y", NULL },
3073                 { "%Z", NULL }
3074         };
3075
3076         gchar *titles[2];
3077         gint i;
3078         const gint TIME_FORMAT_ELEMS =
3079                 sizeof time_format / sizeof time_format[0];
3080
3081         time_format[0].txt  = _("the full abbreviated weekday name");
3082         time_format[1].txt  = _("the full weekday name");
3083         time_format[2].txt  = _("the abbreviated month name");
3084         time_format[3].txt  = _("the full month name");
3085         time_format[4].txt  = _("the preferred date and time for the current locale");
3086         time_format[5].txt  = _("the century number (year/100)");
3087         time_format[6].txt  = _("the day of the month as a decimal number");
3088         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
3089         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
3090         time_format[9].txt  = _("the day of the year as a decimal number");
3091         time_format[10].txt = _("the month as a decimal number");
3092         time_format[11].txt = _("the minute as a decimal number");
3093         time_format[12].txt = _("either AM or PM");
3094         time_format[13].txt = _("the second as a decimal number");
3095         time_format[14].txt = _("the day of the week as a decimal number");
3096         time_format[15].txt = _("the preferred date for the current locale");
3097         time_format[16].txt = _("the last two digits of a year");
3098         time_format[17].txt = _("the year as a decimal number");
3099         time_format[18].txt = _("the time zone or name or abbreviation");
3100
3101         if (datefmt_win) return datefmt_win;
3102
3103         datefmt_win = gtk_window_new(GTK_WINDOW_DIALOG);
3104         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
3105         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
3106         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3107         gtk_widget_set_usize(datefmt_win, 440, 280);
3108
3109         vbox1 = gtk_vbox_new(FALSE, 10);
3110         gtk_widget_show(vbox1);
3111         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
3112
3113         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
3114         gtk_scrolled_window_set_policy
3115                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
3116                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3117         gtk_widget_show(scrolledwindow1);
3118         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
3119
3120         titles[0] = _("Specifier");
3121         titles[1] = _("Description");
3122         datefmt_clist = gtk_clist_new_with_titles(2, titles);
3123         gtk_widget_show(datefmt_clist);
3124         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
3125         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
3126         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
3127                                      GTK_SELECTION_BROWSE);
3128
3129         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
3130                 gchar *text[2];
3131                 /* phoney casting necessary because of gtk... */
3132                 text[0] = (gchar *)time_format[i].fmt;
3133                 text[1] = (gchar *)time_format[i].txt;
3134                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
3135         }
3136
3137         table = gtk_table_new(2, 2, FALSE);
3138         gtk_widget_show(table);
3139         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
3140         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
3141         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
3142
3143         label1 = gtk_label_new(_("Date format"));
3144         gtk_widget_show(label1);
3145         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
3146                          GTK_FILL, 0, 0, 0);
3147         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
3148         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
3149
3150         datefmt_entry = gtk_entry_new_with_max_length(256);
3151         gtk_widget_show(datefmt_entry);
3152         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
3153                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3154
3155         /* we need the "sample" entry box; add it as data so callbacks can
3156          * get the entry box */
3157         gtk_object_set_data(GTK_OBJECT(datefmt_win), "datefmt_sample",
3158                             datefmt_entry);
3159
3160         label2 = gtk_label_new(_("Example"));
3161         gtk_widget_show(label2);
3162         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
3163                          GTK_FILL, 0, 0, 0);
3164         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
3165         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
3166
3167         label3 = gtk_label_new("");
3168         gtk_widget_show(label3);
3169         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
3170                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3171         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
3172         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
3173
3174         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
3175                                 &cancel_btn, _("Cancel"), NULL, NULL);
3176         gtk_widget_grab_default(ok_btn);
3177         gtk_widget_show(confirm_area);
3178
3179         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
3180
3181         /* set the current format */
3182         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
3183         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
3184                                     GTK_LABEL(label3));
3185
3186         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
3187                            GTK_SIGNAL_FUNC(date_format_ok_btn_clicked),
3188                            &datefmt_win);
3189         gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
3190                            GTK_SIGNAL_FUNC(date_format_cancel_btn_clicked),
3191                            &datefmt_win);
3192         gtk_signal_connect(GTK_OBJECT(datefmt_win), "key_press_event",
3193                            GTK_SIGNAL_FUNC(date_format_key_pressed),
3194                            &datefmt_win);
3195         gtk_signal_connect(GTK_OBJECT(datefmt_win), "delete_event",
3196                            GTK_SIGNAL_FUNC(date_format_on_delete),
3197                            &datefmt_win);
3198         gtk_signal_connect(GTK_OBJECT(datefmt_entry), "changed",
3199                            GTK_SIGNAL_FUNC(date_format_entry_on_change),
3200                            label3);
3201
3202         gtk_signal_connect(GTK_OBJECT(datefmt_clist), "select_row",
3203                            GTK_SIGNAL_FUNC(date_format_select_row),
3204                            datefmt_win);
3205
3206         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
3207         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
3208
3209         gtk_widget_show(datefmt_win);
3210         manage_window_set_transient(GTK_WINDOW(datefmt_win));
3211
3212         gtk_widget_grab_focus(ok_btn);
3213
3214         return datefmt_win;
3215 }
3216
3217 void prefs_quote_colors_dialog(void)
3218 {
3219         if (!quote_color_win)
3220                 prefs_quote_colors_dialog_create();
3221         gtk_widget_show(quote_color_win);
3222         manage_window_set_transient(GTK_WINDOW(quote_color_win));
3223
3224         gtk_main();
3225         gtk_widget_hide(quote_color_win);
3226
3227         textview_update_message_colors();
3228         main_window_reflect_prefs_all();
3229 }
3230
3231 static void prefs_quote_colors_dialog_create(void)
3232 {
3233         GtkWidget *window;
3234         GtkWidget *vbox;
3235         GtkWidget *table;
3236         GtkWidget *quotelevel1_label;
3237         GtkWidget *quotelevel2_label;
3238         GtkWidget *quotelevel3_label;
3239         GtkWidget *uri_label;
3240         GtkWidget *tgt_folder_label;
3241         GtkWidget *hbbox;
3242         GtkWidget *ok_btn;
3243         GtkWidget *recycle_colors_btn;
3244         GtkWidget *frame_colors;
3245
3246         window = gtk_window_new(GTK_WINDOW_DIALOG);
3247         gtk_container_set_border_width(GTK_CONTAINER(window), 2);
3248         gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
3249         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
3250         gtk_window_set_modal(GTK_WINDOW(window), TRUE);
3251         gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
3252
3253         vbox = gtk_vbox_new (FALSE, VSPACING);
3254         gtk_container_add (GTK_CONTAINER (window), vbox);
3255         gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
3256         PACK_FRAME(vbox, frame_colors, _("Colors"));
3257
3258         table = gtk_table_new (4, 2, FALSE);
3259         gtk_container_add (GTK_CONTAINER (frame_colors), table);
3260         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
3261         gtk_table_set_row_spacings (GTK_TABLE (table), 2);
3262         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
3263
3264
3265         color_buttons.quote_level1_btn = gtk_button_new();
3266         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
3267                           0, 1, 0, 1, 0, 0, 0, 0);
3268         gtk_widget_set_usize (color_buttons.quote_level1_btn, 40, 30);
3269         gtk_container_set_border_width
3270                 (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
3271
3272         color_buttons.quote_level2_btn = gtk_button_new();
3273         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
3274                           0, 1, 1, 2, 0, 0, 0, 0);
3275         gtk_widget_set_usize (color_buttons.quote_level2_btn, 40, 30);
3276         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
3277
3278         color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
3279         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
3280                           0, 1, 2, 3, 0, 0, 0, 0);
3281         gtk_widget_set_usize (color_buttons.quote_level3_btn, 40, 30);
3282         gtk_container_set_border_width
3283                 (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
3284
3285         color_buttons.uri_btn = gtk_button_new_with_label ("");
3286         gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
3287                           0, 1, 3, 4, 0, 0, 0, 0);
3288         gtk_widget_set_usize (color_buttons.uri_btn, 40, 30);
3289         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
3290
3291         color_buttons.tgt_folder_btn = gtk_button_new_with_label ("");
3292         gtk_table_attach (GTK_TABLE (table), color_buttons.tgt_folder_btn,
3293                           0, 1, 4, 5, 0, 0, 0, 0);
3294         gtk_widget_set_usize (color_buttons.tgt_folder_btn, 40, 30);
3295         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.tgt_folder_btn), 5);
3296
3297         quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
3298         gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
3299                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3300         gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
3301         gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
3302
3303         quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
3304         gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
3305                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3306         gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
3307         gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
3308
3309         quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
3310         gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
3311                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3312         gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
3313         gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
3314
3315         uri_label = gtk_label_new (_("URI link"));
3316         gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
3317                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3318         gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
3319         gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
3320
3321         tgt_folder_label = gtk_label_new (_("Target folder"));
3322         gtk_table_attach (GTK_TABLE (table), tgt_folder_label, 1, 2, 4, 5,
3323                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
3324         gtk_label_set_justify (GTK_LABEL (tgt_folder_label), GTK_JUSTIFY_LEFT);
3325         gtk_misc_set_alignment (GTK_MISC (tgt_folder_label), 0, 0.5);
3326
3327         PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
3328                            _("Recycle quote colors"));
3329
3330         gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
3331                                 NULL, NULL, NULL, NULL);
3332         gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3333
3334         gtk_widget_grab_default(ok_btn);
3335         MANAGE_WINDOW_SIGNALS_CONNECT(window);
3336         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
3337                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3338         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
3339                            GTK_SIGNAL_FUNC(prefs_quote_colors_key_pressed),
3340                            NULL);
3341
3342         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level1_btn), "clicked",
3343                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL1");
3344         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level2_btn), "clicked",
3345                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL2");
3346         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level3_btn), "clicked",
3347                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL3");
3348         gtk_signal_connect(GTK_OBJECT(color_buttons.uri_btn), "clicked",
3349                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "URI");
3350         gtk_signal_connect(GTK_OBJECT(color_buttons.tgt_folder_btn), "clicked",
3351                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "TGTFLD");
3352         gtk_signal_connect(GTK_OBJECT(recycle_colors_btn), "toggled",
3353                            GTK_SIGNAL_FUNC(prefs_recycle_colors_toggled), NULL);
3354         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
3355                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3356
3357         /* show message button colors and recycle options */
3358         set_button_bg_color(color_buttons.quote_level1_btn,
3359                             prefs_common.quote_level1_col);
3360         set_button_bg_color(color_buttons.quote_level2_btn,
3361                             prefs_common.quote_level2_col);
3362         set_button_bg_color(color_buttons.quote_level3_btn,
3363                             prefs_common.quote_level3_col);
3364         set_button_bg_color(color_buttons.uri_btn,
3365                             prefs_common.uri_col);
3366         set_button_bg_color(color_buttons.tgt_folder_btn,
3367                             prefs_common.tgt_folder_col);
3368         gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
3369                                      prefs_common.recycle_quote_colors);
3370
3371         gtk_widget_show_all(vbox);
3372         quote_color_win = window;
3373 }
3374
3375 static void prefs_quote_colors_key_pressed(GtkWidget *widget,
3376                                            GdkEventKey *event, gpointer data)
3377 {
3378         if (event && event->keyval == GDK_Escape)
3379                 gtk_main_quit();
3380 }
3381
3382 static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
3383 {
3384         gchar *type = (gchar *)data;
3385         gchar *title = NULL;
3386         gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
3387         gint rgbvalue = 0;
3388         GtkColorSelectionDialog *dialog;
3389
3390         if(g_strcasecmp(type, "LEVEL1") == 0) {
3391                 title = _("Pick color for quotation level 1");
3392                 rgbvalue = prefs_common.quote_level1_col;
3393         } else if(g_strcasecmp(type, "LEVEL2") == 0) {
3394                 title = _("Pick color for quotation level 2");
3395                 rgbvalue = prefs_common.quote_level2_col;
3396         } else if(g_strcasecmp(type, "LEVEL3") == 0) {
3397                 title = _("Pick color for quotation level 3");
3398                 rgbvalue = prefs_common.quote_level3_col;
3399         } else if(g_strcasecmp(type, "URI") == 0) {
3400                 title = _("Pick color for URI");
3401                 rgbvalue = prefs_common.uri_col;
3402         } else if(g_strcasecmp(type, "TGTFLD") == 0) {
3403                 title = _("Pick color for target folder");
3404                 rgbvalue = prefs_common.tgt_folder_col;
3405 #if USE_PSPELL          
3406         } else if(g_strcasecmp(type, "Misspelled word") == 0) {
3407                 title = _("Pick color for misspelled word");
3408                 rgbvalue = prefs_common.misspelled_col;
3409 #endif          
3410         } else {   /* Should never be called */
3411                 g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
3412                 return;
3413         }
3414
3415         color_dialog = gtk_color_selection_dialog_new(title);
3416         gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
3417         gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
3418         gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
3419         manage_window_set_transient(GTK_WINDOW(color_dialog));
3420
3421         gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
3422                            "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_ok), data);
3423         gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
3424                            "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_cancel), data);
3425         gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
3426                            GTK_SIGNAL_FUNC(quote_colors_set_dialog_key_pressed),
3427                            data);
3428
3429         /* preselect the previous color in the color selection dialog */
3430         color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
3431         color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
3432         color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
3433         dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
3434         gtk_color_selection_set_color
3435                 (GTK_COLOR_SELECTION(dialog->colorsel), color);
3436
3437         gtk_widget_show(color_dialog);
3438 }
3439
3440 static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
3441 {
3442         GtkColorSelection *colorsel = (GtkColorSelection *)
3443                                                 ((GtkColorSelectionDialog *)color_dialog)->colorsel;
3444         gdouble color[4];
3445         gint red, green, blue, rgbvalue;
3446         gchar *type = (gchar *)data;
3447
3448         gtk_color_selection_get_color(colorsel, color);
3449
3450         red      = (gint) (color[0] * 255.0);
3451         green    = (gint) (color[1] * 255.0);
3452         blue     = (gint) (color[2] * 255.0);
3453         rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3454
3455 #if 0
3456         fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3457         fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3458         fprintf(stderr, "Color is %x\n", rgbvalue);
3459 #endif
3460
3461         if (g_strcasecmp(type, "LEVEL1") == 0) {
3462                 prefs_common.quote_level1_col = rgbvalue;
3463                 set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3464         } else if (g_strcasecmp(type, "LEVEL2") == 0) {
3465                 prefs_common.quote_level2_col = rgbvalue;
3466                 set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3467         } else if (g_strcasecmp(type, "LEVEL3") == 0) {
3468                 prefs_common.quote_level3_col = rgbvalue;
3469                 set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3470         } else if (g_strcasecmp(type, "URI") == 0) {
3471                 prefs_common.uri_col = rgbvalue;
3472                 set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3473         } else if (g_strcasecmp(type, "TGTFLD") == 0) {
3474                 prefs_common.tgt_folder_col = rgbvalue;
3475                 set_button_bg_color(color_buttons.tgt_folder_btn, rgbvalue);
3476                 folderview_set_target_folder_color(prefs_common.tgt_folder_col);
3477 #if USE_PSPELL          
3478         } else if (g_strcasecmp(type, "Misspelled word") == 0) {
3479                 prefs_common.misspelled_col = rgbvalue;
3480                 set_button_bg_color(spelling.misspelled_btn, rgbvalue);
3481 #endif          
3482         } else
3483                 fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3484