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