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