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