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