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