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