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