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