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