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