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