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