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