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