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