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