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