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