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