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