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