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