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