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