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