visual indicator locked ("keep"); not yet completed
[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
123         /* spelling */
124 #if USE_PSPELL
125         GtkWidget *checkbtn_enable_pspell;
126         GtkWidget *entry_pspell_path;
127         GtkWidget *btn_pspell_path;
128         GtkWidget *optmenu_dictionary;
129 #endif
130
131 } compose;
132
133 static struct Quote {
134         GtkWidget *entry_quotemark;
135         GtkWidget *text_quotefmt;
136
137         GtkWidget *entry_fw_quotemark;
138         GtkWidget *text_fw_quotefmt;
139 } quote;
140
141 static struct Display {
142         GtkWidget *entry_textfont;
143         GtkWidget *button_textfont;
144
145         GtkWidget *entry_smallfont;
146         GtkWidget *entry_normalfont;
147         GtkWidget *entry_boldfont;
148
149         GtkWidget *chkbtn_folder_unread;
150
151         GtkWidget *chkbtn_transhdr;
152
153         GtkWidget *chkbtn_swapfrom;
154         GtkWidget *chkbtn_hscrollbar;
155         GtkWidget *chkbtn_useaddrbook;
156         GtkWidget *chkbtn_expand_thread;
157         GtkWidget *chkbtn_bold_unread;
158
159         GtkWidget *entry_datefmt;
160 } display;
161
162 static struct Message {
163         GtkWidget *chkbtn_enablecol;
164         GtkWidget *button_edit_col;
165         GtkWidget *chkbtn_mbalnum;
166         GtkWidget *chkbtn_disphdrpane;
167         GtkWidget *chkbtn_disphdr;
168         GtkWidget *spinbtn_linespc;
169         GtkObject *spinbtn_linespc_adj;
170         GtkWidget *chkbtn_headspc;
171
172         GtkWidget *chkbtn_smoothscroll;
173         GtkWidget *spinbtn_scrollstep;
174         GtkObject *spinbtn_scrollstep_adj;
175         GtkWidget *chkbtn_halfpage;
176 } message;
177
178 #if USE_GPGME
179 static struct Privacy {
180         GtkWidget *checkbtn_default_encrypt;
181         GtkWidget *checkbtn_ascii_armored;
182         GtkWidget *checkbtn_default_sign;
183         GtkWidget *checkbtn_auto_check_signatures;
184         GtkWidget *checkbtn_gpg_signature_popup;
185         GtkWidget *checkbtn_passphrase_grab;
186         GtkWidget *checkbtn_gpg_warning;
187         GtkWidget *optmenu_default_signkey;
188 } privacy;
189 #endif
190
191 static struct Interface {
192         /* GtkWidget *checkbtn_emacs; */
193         GtkWidget *checkbtn_openunread;
194         GtkWidget *checkbtn_openinbox;
195         GtkWidget *checkbtn_immedexec;
196         GtkWidget *checkbtn_confonexit;
197         GtkWidget *checkbtn_cleanonexit;
198         GtkWidget *checkbtn_askonclean;
199         GtkWidget *checkbtn_warnqueued;
200         GtkWidget *checkbtn_addaddrbyclick;
201         GtkWidget *optmenu_recvdialog;
202         GtkWidget *optmenu_nextunreadmsgdialog;
203 } interface;
204
205 static struct Other {
206         GtkWidget *uri_combo;
207         GtkWidget *uri_entry;
208         GtkWidget *printcmd_entry;
209         GtkWidget *exteditor_combo;
210         GtkWidget *exteditor_entry;
211 } other;
212
213 static struct MessageColorButtons {
214         GtkWidget *quote_level1_btn;
215         GtkWidget *quote_level2_btn;
216         GtkWidget *quote_level3_btn;
217         GtkWidget *uri_btn;
218         GtkWidget *tgt_folder_btn;
219 } color_buttons;
220
221 static GtkWidget *quote_desc_win;
222 static GtkWidget *font_sel_win;
223 static guint font_sel_conn_id; 
224 static GtkWidget *quote_color_win;
225 static GtkWidget *color_dialog;
226
227 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam);
228 static void prefs_common_charset_set_optmenu          (PrefParam *pparam);
229 #if USE_GPGME
230 static void prefs_common_default_signkey_set_data_from_optmenu
231                                                         (PrefParam *pparam);
232 static void prefs_common_default_signkey_set_optmenu    (PrefParam *pparam);
233 static void prefs_common_ascii_armored_warning(GtkWidget* widget, 
234                                                gpointer unused);
235 #endif
236 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
237 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
238 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
239 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
240
241 #if USE_PSPELL
242 static void prefs_dictionary_set_data_from_optmenu(PrefParam *param);
243 static void prefs_dictionary_set_optmenu(PrefParam *pparam);
244 #endif
245
246
247 /*
248    parameter name, default value, pointer to the prefs variable, data type,
249    pointer to the widget pointer,
250    pointer to the function for data setting,
251    pointer to the function for widget setting
252  */
253
254 static PrefParam param[] = {
255         /* Receive */
256         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
257          &receive.checkbtn_incext,
258          prefs_set_data_from_toggle, prefs_set_toggle},
259         {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
260          &receive.entry_incext,
261          prefs_set_data_from_entry, prefs_set_entry},
262
263         {"inc_local", "TRUE", &prefs_common.inc_local, P_BOOL,
264          &receive.checkbtn_local,
265          prefs_set_data_from_toggle, prefs_set_toggle},
266         {"filter_on_inc_local", "FALSE", &prefs_common.filter_on_inc, P_BOOL,
267          &receive.checkbtn_filter_on_inc,
268          prefs_set_data_from_toggle, prefs_set_toggle},
269         {"spool_path", DEFAULT_SPOOL_PATH, &prefs_common.spool_path, P_STRING,
270          &receive.entry_spool,
271          prefs_set_data_from_entry, prefs_set_entry},
272
273         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
274          &receive.checkbtn_autochk,
275          prefs_set_data_from_toggle, prefs_set_toggle},
276         {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
277          &receive.spinbtn_autochk,
278          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
279         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
280          &receive.checkbtn_chkonstartup,
281          prefs_set_data_from_toggle, prefs_set_toggle},
282         {"noerrorpanel", "FALSE", &prefs_common.noerrorpanel, P_BOOL,
283          &receive.checkbtn_noerrorpanel,
284          prefs_set_data_from_toggle, prefs_set_toggle},
285         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
286          P_BOOL, &receive.checkbtn_scan_after_inc,
287          prefs_set_data_from_toggle, prefs_set_toggle},
288         {"max_news_articles", "300", &prefs_common.max_articles, P_INT,
289          &receive.spinbtn_maxarticle,
290          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
291
292         /* Send */
293         {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL,
294          &send.checkbtn_extsend,
295          prefs_set_data_from_toggle, prefs_set_toggle},
296         {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD,
297          &prefs_common.extsend_cmd, P_STRING,
298          &send.entry_extsend, prefs_set_data_from_entry, prefs_set_entry},
299         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
300          &send.checkbtn_savemsg,
301          prefs_set_data_from_toggle, prefs_set_toggle},
302         {"queue_message", "FALSE", &prefs_common.queue_msg, P_BOOL,
303          &send.checkbtn_queuemsg,
304          prefs_set_data_from_toggle, prefs_set_toggle},
305
306         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
307          &send.optmenu_charset,
308          prefs_common_charset_set_data_from_optmenu,
309          prefs_common_charset_set_optmenu},
310
311         /* Compose */
312         {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL,
313          &compose.checkbtn_autosig,
314          prefs_set_data_from_toggle, prefs_set_toggle},
315         {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING,
316          &compose.entry_sigsep, prefs_set_data_from_entry, prefs_set_entry},
317
318         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
319          &compose.checkbtn_autoextedit,
320          prefs_set_data_from_toggle, prefs_set_toggle},
321
322         {"linewrap_length", "74", &prefs_common.linewrap_len, P_INT,
323          &compose.spinbtn_linewrap,
324          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
325         {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL,
326          &compose.checkbtn_wrapquote,
327          prefs_set_data_from_toggle, prefs_set_toggle},
328         {"linewrap_before_sending", "FALSE",
329          &prefs_common.linewrap_at_send, P_BOOL,
330          &compose.checkbtn_wrapatsend,
331          prefs_set_data_from_toggle, prefs_set_toggle},
332         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
333          P_BOOL, &compose.checkbtn_forward_as_attachment,
334          prefs_set_data_from_toggle, prefs_set_toggle},
335         {"smart_wrapping", "TRUE", &prefs_common.smart_wrapping,
336          P_BOOL, &compose.checkbtn_smart_wrapping,
337          prefs_set_data_from_toggle, prefs_set_toggle},
338         {"block_cursor", "FALSE", &prefs_common.block_cursor,
339          P_BOOL, &compose.checkbtn_block_cursor,
340          prefs_set_data_from_toggle, prefs_set_toggle},
341 #if USE_PSPELL
342         {"enable_pspell", "TRUE", &prefs_common.enable_pspell,
343          P_BOOL, &compose.checkbtn_enable_pspell,
344          prefs_set_data_from_toggle, prefs_set_toggle},
345         {"pspell_path", "/usr/local/share/pspell/", &prefs_common.pspell_path, 
346          P_STRING, &compose.entry_pspell_path, 
347          prefs_set_data_from_entry, prefs_set_entry},
348         {"dictionary",  "", &prefs_common.dictionary,
349          P_STRING, &compose.optmenu_dictionary, 
350          prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
351 #endif
352         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
353          &compose.checkbtn_quote,
354          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         {"fw_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
381          &quote.entry_fw_quotemark,
382          prefs_set_data_from_entry, prefs_set_entry},
383         {"fw_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         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1609         gtk_widget_show (vbox1);
1610         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1611         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1612
1613         /* reply */
1614
1615         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1616
1617         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1618         gtk_widget_show (vbox_quote);
1619         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1620         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1621
1622         hbox1 = gtk_hbox_new (FALSE, 32);
1623         gtk_widget_show (hbox1);
1624         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1625
1626         hbox2 = gtk_hbox_new (FALSE, 8);
1627         gtk_widget_show (hbox2);
1628         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1629
1630         label_quotemark = gtk_label_new (_("Quotation mark"));
1631         gtk_widget_show (label_quotemark);
1632         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1633
1634         entry_quotemark = gtk_entry_new ();
1635         gtk_widget_show (entry_quotemark);
1636         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1637         gtk_widget_set_usize (entry_quotemark, 64, -1);
1638
1639         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1640         gtk_widget_show (scrolledwin_quotefmt);
1641         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1642         gtk_scrolled_window_set_policy
1643                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1644                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1645
1646         text_quotefmt = gtk_text_new (NULL, NULL);
1647         gtk_widget_show (text_quotefmt);
1648         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1649         gtk_text_set_editable (GTK_TEXT (text_quotefmt), TRUE);
1650         gtk_widget_set_usize(text_quotefmt, -1, 60);
1651
1652         /* forward */
1653
1654         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1655
1656         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1657         gtk_widget_show (vbox_quote);
1658         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1659         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1660
1661         hbox1 = gtk_hbox_new (FALSE, 32);
1662         gtk_widget_show (hbox1);
1663         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1664
1665         hbox2 = gtk_hbox_new (FALSE, 8);
1666         gtk_widget_show (hbox2);
1667         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1668
1669         label_quotemark = gtk_label_new (_("Quotation mark"));
1670         gtk_widget_show (label_quotemark);
1671         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1672
1673         entry_fw_quotemark = gtk_entry_new ();
1674         gtk_widget_show (entry_fw_quotemark);
1675         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1676                             FALSE, FALSE, 0);
1677         gtk_widget_set_usize (entry_fw_quotemark, 64, -1);
1678
1679         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1680         gtk_widget_show (scrolledwin_quotefmt);
1681         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1682         gtk_scrolled_window_set_policy
1683                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1684                  GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1685
1686         text_fw_quotefmt = gtk_text_new (NULL, NULL);
1687         gtk_widget_show (text_fw_quotefmt);
1688         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1689                           text_fw_quotefmt);
1690         gtk_text_set_editable (GTK_TEXT (text_fw_quotefmt), TRUE);
1691         gtk_widget_set_usize(text_fw_quotefmt, -1, 60);
1692
1693         hbox1 = gtk_hbox_new (FALSE, 32);
1694         gtk_widget_show (hbox1);
1695         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1696
1697         btn_quotedesc =
1698                 gtk_button_new_with_label (_(" Description of symbols "));
1699         gtk_widget_show (btn_quotedesc);
1700         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1701         gtk_signal_connect(GTK_OBJECT(btn_quotedesc), "clicked",
1702                            GTK_SIGNAL_FUNC(prefs_quote_description), NULL);
1703
1704         quote.entry_quotemark    = entry_quotemark;
1705         quote.text_quotefmt      = text_quotefmt;
1706         quote.entry_fw_quotemark = entry_fw_quotemark;
1707         quote.text_fw_quotefmt   = text_fw_quotefmt;
1708 }
1709
1710 static void prefs_display_create(void)
1711 {
1712         GtkWidget *vbox1;
1713         GtkWidget *frame_font;
1714         GtkWidget *table1;
1715         GtkWidget *label_textfont;
1716         GtkWidget *entry_textfont;
1717         GtkWidget *button_textfont;
1718         GtkWidget *chkbtn_folder_unread;
1719         GtkWidget *chkbtn_transhdr;
1720         GtkWidget *frame_summary;
1721         GtkWidget *vbox2;
1722         GtkWidget *chkbtn_swapfrom;
1723         GtkWidget *chkbtn_hscrollbar;
1724         GtkWidget *chkbtn_useaddrbook;
1725         GtkWidget *chkbtn_expand_thread;
1726         GtkWidget *chkbtn_bold_unread;
1727         GtkWidget *vbox3;
1728         GtkWidget *hbox1;
1729         GtkWidget *label_datefmt;
1730         GtkWidget *button_datefmt;
1731         GtkWidget *entry_datefmt;
1732         GtkWidget *button_dispitem;
1733         GtkWidget *tmplabel, *tmpbutton, *tmpentry;
1734
1735         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1736         gtk_widget_show (vbox1);
1737         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1738         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1739
1740         PACK_FRAME(vbox1, frame_font, _("Font"));
1741
1742         table1 = gtk_table_new (4, 3, FALSE);
1743
1744         gtk_widget_show (table1);
1745         gtk_container_add (GTK_CONTAINER (frame_font), table1);
1746         gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
1747         gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
1748         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1749
1750         label_textfont = gtk_label_new (_("Text"));
1751         gtk_misc_set_alignment(GTK_MISC(label_textfont), 0, 0.5);
1752         gtk_widget_show (label_textfont);
1753         gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
1754                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1755
1756         entry_textfont = gtk_entry_new ();
1757         gtk_widget_show (entry_textfont);
1758         gtk_table_attach (GTK_TABLE (table1), entry_textfont, 1, 2, 0, 1,
1759                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1760
1761         button_textfont = gtk_button_new_with_label ("... ");
1762
1763         gtk_widget_show (button_textfont);
1764         gtk_table_attach (GTK_TABLE (table1), button_textfont, 2, 3, 0, 1,
1765                           0, 0, 0, 0);
1766         gtk_signal_connect (GTK_OBJECT (button_textfont), "clicked",
1767                             GTK_SIGNAL_FUNC (prefs_font_select), entry_textfont);
1768
1769         tmplabel = gtk_label_new (_("Small"));
1770         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
1771         gtk_widget_show (tmplabel);
1772         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 1, 2,
1773                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1774
1775         tmpentry = gtk_entry_new ();
1776         gtk_widget_show (tmpentry);
1777         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 1, 2,
1778                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1779
1780         tmpbutton = gtk_button_new_with_label (" ... ");
1781         gtk_widget_show (tmpbutton);
1782         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 1, 2,
1783                           0, 0, 0, 0);
1784         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
1785                             GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
1786         display.entry_smallfont = tmpentry;                       
1787
1788         tmplabel = gtk_label_new (_("Normal"));
1789         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
1790         gtk_widget_show (tmplabel);
1791         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 2, 3,
1792                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1793
1794         tmpentry = gtk_entry_new ();
1795         gtk_widget_show (tmpentry);
1796         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 2, 3,
1797                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1798
1799         tmpbutton = gtk_button_new_with_label (" ... ");
1800         gtk_widget_show (tmpbutton);
1801         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 2, 3,
1802                           0, 0, 0, 0);
1803         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
1804                                 GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
1805         display.entry_normalfont = tmpentry;                      
1806
1807         tmplabel = gtk_label_new (_("Bold"));
1808         gtk_misc_set_alignment(GTK_MISC(tmplabel), 0, 0.5);
1809         gtk_widget_show (tmplabel);
1810         gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 3, 4,
1811                           GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
1812
1813         tmpentry = gtk_entry_new ();
1814         gtk_widget_show (tmpentry);
1815         gtk_table_attach (GTK_TABLE (table1), tmpentry, 1, 2, 3, 4,
1816                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
1817
1818         tmpbutton = gtk_button_new_with_label (" ... ");
1819         gtk_widget_show (tmpbutton);
1820         gtk_table_attach (GTK_TABLE (table1), tmpbutton, 2, 3, 3, 4,
1821                           0, 0, 0, 0);
1822         gtk_signal_connect (GTK_OBJECT(tmpbutton), "clicked",
1823                                 GTK_SIGNAL_FUNC(prefs_font_select), tmpentry);
1824         display.entry_boldfont = tmpentry;
1825
1826         vbox2 = gtk_vbox_new (FALSE, 0);
1827         gtk_widget_show (vbox2);
1828         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
1829
1830         PACK_CHECK_BUTTON
1831                 (vbox2, chkbtn_transhdr,
1832                  _("Translate header name (such as `From:', `Subject:')"));
1833
1834         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1835                            _("Display unread number next to folder name"));
1836
1837         /* ---- Summary ---- */
1838
1839         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
1840
1841         vbox2 = gtk_vbox_new (FALSE, 0);
1842         gtk_widget_show (vbox2);
1843         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1844         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1845
1846         PACK_CHECK_BUTTON
1847                 (vbox2, chkbtn_swapfrom,
1848                  _("Display recipient on `From' column if sender is yourself"));
1849         PACK_CHECK_BUTTON
1850                 (vbox2, chkbtn_useaddrbook,
1851                  _("Display sender using address book"));
1852         PACK_CHECK_BUTTON
1853                 (vbox2, chkbtn_hscrollbar, _("Enable horizontal scroll bar"));
1854         PACK_CHECK_BUTTON
1855                 (vbox2, chkbtn_expand_thread, _("Expand threads"));
1856         PACK_CHECK_BUTTON
1857                 (vbox2, chkbtn_bold_unread,
1858                  _("Display unread messages with bold font"));
1859
1860         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1861
1862         hbox1 = gtk_hbox_new (FALSE, 8);
1863         gtk_widget_show (hbox1);
1864         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1865
1866         label_datefmt = gtk_label_new (_("Date format"));
1867         gtk_widget_show (label_datefmt);
1868         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1869
1870         entry_datefmt = gtk_entry_new ();
1871         gtk_widget_show (entry_datefmt);
1872         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1873
1874         button_datefmt = gtk_button_new_with_label ("... ");
1875
1876         gtk_widget_show (button_datefmt);
1877         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1878         gtk_signal_connect (GTK_OBJECT (button_datefmt), "clicked",
1879                             GTK_SIGNAL_FUNC (date_format_create), NULL);
1880
1881         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1882
1883         hbox1 = gtk_hbox_new (FALSE, 8);
1884         gtk_widget_show (hbox1);
1885         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1886
1887         button_dispitem = gtk_button_new_with_label
1888                 (_(" Set display item of summary... "));
1889         gtk_widget_show (button_dispitem);
1890         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1891         gtk_signal_connect (GTK_OBJECT (button_dispitem), "clicked",
1892                             GTK_SIGNAL_FUNC (prefs_summary_column_open),
1893                             NULL);
1894
1895         display.entry_textfont  = entry_textfont;
1896         display.button_textfont = button_textfont;
1897
1898         display.chkbtn_folder_unread = chkbtn_folder_unread;
1899         display.chkbtn_transhdr   = chkbtn_transhdr;
1900
1901         display.chkbtn_swapfrom      = chkbtn_swapfrom;
1902         display.chkbtn_hscrollbar    = chkbtn_hscrollbar;
1903         display.chkbtn_expand_thread = chkbtn_expand_thread;
1904         display.chkbtn_bold_unread   = chkbtn_bold_unread;
1905         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
1906         display.entry_datefmt        = entry_datefmt;
1907 }
1908
1909 static void prefs_message_create(void)
1910 {
1911         GtkWidget *vbox1;
1912         GtkWidget *vbox2;
1913         GtkWidget *vbox3;
1914         GtkWidget *hbox1;
1915         GtkWidget *chkbtn_enablecol;
1916         GtkWidget *button_edit_col;
1917         GtkWidget *chkbtn_mbalnum;
1918         GtkWidget *chkbtn_disphdrpane;
1919         GtkWidget *chkbtn_disphdr;
1920         GtkWidget *button_edit_disphdr;
1921         GtkWidget *hbox_linespc;
1922         GtkWidget *label_linespc;
1923         GtkObject *spinbtn_linespc_adj;
1924         GtkWidget *spinbtn_linespc;
1925         GtkWidget *chkbtn_headspc;
1926
1927         GtkWidget *frame_scr;
1928         GtkWidget *vbox_scr;
1929         GtkWidget *chkbtn_smoothscroll;
1930         GtkWidget *hbox_scr;
1931         GtkWidget *label_scr;
1932         GtkObject *spinbtn_scrollstep_adj;
1933         GtkWidget *spinbtn_scrollstep;
1934         GtkWidget *chkbtn_halfpage;
1935
1936         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1937         gtk_widget_show (vbox1);
1938         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1939         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1940
1941         hbox1 = gtk_hbox_new (FALSE, 8);
1942         gtk_widget_show (hbox1);
1943         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
1944
1945         PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
1946                            _("Enable coloration of message"));
1947         gtk_signal_connect (GTK_OBJECT (chkbtn_enablecol), "toggled",
1948                                                 GTK_SIGNAL_FUNC (prefs_enable_message_color_toggled),
1949                                                 NULL);
1950
1951         button_edit_col = gtk_button_new_with_label (_(" Edit... "));
1952         gtk_widget_show (button_edit_col);
1953         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
1954         gtk_signal_connect (GTK_OBJECT (button_edit_col), "clicked",
1955                             GTK_SIGNAL_FUNC (prefs_quote_colors_dialog), NULL);
1956
1957         SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
1958
1959         vbox2 = gtk_vbox_new (FALSE, 0);
1960         gtk_widget_show (vbox2);
1961         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1962
1963         PACK_CHECK_BUTTON
1964                 (vbox2, chkbtn_mbalnum,
1965                  _("Display 2-byte alphabet and numeric with 1-byte character"));
1966         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1967                           _("Display header pane above message view"));
1968
1969         hbox1 = gtk_hbox_new (FALSE, 8);
1970         gtk_widget_show (hbox1);
1971         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1972
1973         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1974                           _("Display short headers on message view"));
1975
1976         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1977         gtk_widget_show (button_edit_disphdr);
1978         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1979                           FALSE, TRUE, 0);
1980         gtk_signal_connect (GTK_OBJECT (button_edit_disphdr), "clicked",
1981                             GTK_SIGNAL_FUNC (prefs_display_header_open),
1982                             NULL);
1983
1984         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1985
1986         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1987
1988         hbox1 = gtk_hbox_new (FALSE, 32);
1989         gtk_widget_show (hbox1);
1990         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1991
1992         hbox_linespc = gtk_hbox_new (FALSE, 8);
1993         gtk_widget_show (hbox1);
1994         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1995
1996         label_linespc = gtk_label_new (_("Line space"));
1997         gtk_widget_show (label_linespc);
1998         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1999                             FALSE, FALSE, 0);
2000
2001         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
2002         spinbtn_linespc = gtk_spin_button_new
2003                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
2004         gtk_widget_show (spinbtn_linespc);
2005         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
2006                             FALSE, FALSE, 0);
2007         gtk_widget_set_usize (spinbtn_linespc, 64, -1);
2008         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
2009
2010         label_linespc = gtk_label_new (_("pixel(s)"));
2011         gtk_widget_show (label_linespc);
2012         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
2013                             FALSE, FALSE, 0);
2014
2015         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Leave space on head"));
2016
2017         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
2018
2019         vbox_scr = gtk_vbox_new (FALSE, 0);
2020         gtk_widget_show (vbox_scr);
2021         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
2022         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
2023
2024         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
2025
2026         hbox1 = gtk_hbox_new (FALSE, 32);
2027         gtk_widget_show (hbox1);
2028         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
2029
2030         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
2031
2032         hbox_scr = gtk_hbox_new (FALSE, 8);
2033         gtk_widget_show (hbox_scr);
2034         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
2035
2036         label_scr = gtk_label_new (_("Step"));
2037         gtk_widget_show (label_scr);
2038         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2039
2040         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
2041         spinbtn_scrollstep = gtk_spin_button_new
2042                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
2043         gtk_widget_show (spinbtn_scrollstep);
2044         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
2045                             FALSE, FALSE, 0);
2046         gtk_widget_set_usize (spinbtn_scrollstep, 64, -1);
2047         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
2048                                      TRUE);
2049
2050         label_scr = gtk_label_new (_("pixel(s)"));
2051         gtk_widget_show (label_scr);
2052         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
2053
2054         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
2055
2056         message.chkbtn_enablecol   = chkbtn_enablecol;
2057         message.button_edit_col    = button_edit_col;
2058         message.chkbtn_mbalnum     = chkbtn_mbalnum;
2059         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
2060         message.chkbtn_disphdr     = chkbtn_disphdr;
2061         message.spinbtn_linespc    = spinbtn_linespc;
2062         message.chkbtn_headspc     = chkbtn_headspc;
2063
2064         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
2065         message.spinbtn_scrollstep     = spinbtn_scrollstep;
2066         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
2067         message.chkbtn_halfpage        = chkbtn_halfpage;
2068 }
2069
2070 #if USE_GPGME
2071 static void prefs_privacy_create(void)
2072 {
2073         GtkWidget *vbox1;
2074         GtkWidget *vbox2;
2075         GtkWidget *hbox1;
2076         GtkWidget *checkbtn_default_encrypt;
2077         GtkWidget *checkbtn_ascii_armored;
2078         GtkWidget *checkbtn_default_sign;
2079         GtkWidget *checkbtn_auto_check_signatures;
2080         GtkWidget *checkbtn_gpg_signature_popup;
2081         GtkWidget *checkbtn_passphrase_grab;
2082         GtkWidget *checkbtn_gpg_warning;
2083         GtkWidget *label;
2084         GtkWidget *menuitem;
2085         GtkWidget *optmenu;
2086         GtkWidget *optmenu_menu;
2087
2088         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2089         gtk_widget_show (vbox1);
2090         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2091         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2092
2093         vbox2 = gtk_vbox_new (FALSE, 0);
2094         gtk_widget_show (vbox2);
2095         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2096
2097         PACK_CHECK_BUTTON (vbox2, checkbtn_default_encrypt,
2098                            _("Encrypt message by default"));
2099
2100         PACK_CHECK_BUTTON (vbox2, checkbtn_ascii_armored,
2101                            _("Plain ASCII armored"));
2102         gtk_signal_connect(GTK_OBJECT(checkbtn_ascii_armored), "toggled",
2103                                 prefs_common_ascii_armored_warning, (gpointer)0);
2104
2105         PACK_CHECK_BUTTON (vbox2, checkbtn_default_sign,
2106                            _("Sign message by default"));
2107
2108         PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
2109                            _("Automatically check signatures"));
2110
2111         PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_signature_popup,
2112                            _("Show signature check result in a popup window"));
2113
2114 #ifndef __MINGW32__
2115         PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
2116                            _("Grab input while entering a passphrase"));
2117 #endif
2118
2119         PACK_CHECK_BUTTON
2120                 (vbox2, checkbtn_gpg_warning,
2121                  _("Display warning on startup if GnuPG doesn't work"));
2122
2123         hbox1 = gtk_hbox_new (FALSE, 8);
2124         gtk_widget_show (hbox1);
2125         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2126
2127         /* create default signkey box */
2128         label = gtk_label_new (_("Default Sign Key"));
2129         gtk_widget_show (label);
2130         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2131         optmenu = gtk_option_menu_new ();
2132         gtk_widget_show (optmenu);
2133         gtk_box_pack_start(GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
2134         optmenu_menu = gtk_menu_new ();
2135
2136         MENUITEM_ADD(optmenu_menu, menuitem, "Default Key", "def_key");
2137         MENUITEM_ADD(optmenu_menu, menuitem, "Second Key", "2nd_key");
2138         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
2139         /* FIXME: disabled because not implemented */
2140         gtk_widget_set_sensitive(optmenu, FALSE);
2141
2142         privacy.checkbtn_default_encrypt = checkbtn_default_encrypt;
2143         privacy.checkbtn_ascii_armored   = checkbtn_ascii_armored;
2144         privacy.checkbtn_default_sign    = checkbtn_default_sign;
2145         privacy.checkbtn_auto_check_signatures
2146                                          = checkbtn_auto_check_signatures;
2147         privacy.checkbtn_gpg_signature_popup
2148                                          = checkbtn_gpg_signature_popup;
2149         privacy.checkbtn_passphrase_grab = checkbtn_passphrase_grab;
2150         privacy.checkbtn_gpg_warning     = checkbtn_gpg_warning;
2151         privacy.optmenu_default_signkey  = optmenu;
2152 }
2153
2154 static void
2155 prefs_common_default_signkey_set_data_from_optmenu(PrefParam *pparam)
2156 {
2157 #if 0
2158         GtkWidget *menu;
2159         GtkWidget *menuitem;
2160         gchar *charset;
2161
2162         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2163         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2164         charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
2165         g_free(*((gchar **)pparam->data));
2166         *((gchar **)pparam->data) = g_strdup(charset);
2167 #endif
2168 }
2169
2170 static void prefs_common_default_signkey_set_optmenu(PrefParam *pparam)
2171 {
2172 #if 0
2173         GList *cur;
2174         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2175         GtkWidget *menu;
2176         GtkWidget *menuitem;
2177         gchar *charset;
2178         gint n = 0;
2179
2180         g_return_if_fail(optmenu != NULL);
2181         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2182
2183         menu = gtk_option_menu_get_menu(optmenu);
2184         for (cur = GTK_MENU_SHELL(menu)->children;
2185              cur != NULL; cur = cur->next) {
2186                 menuitem = GTK_WIDGET(cur->data);
2187                 charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
2188                 if (!strcmp(charset, *((gchar **)pparam->data))) {
2189                         gtk_option_menu_set_history(optmenu, n);
2190                         return;
2191                 }
2192                 n++;
2193         }
2194
2195         gtk_option_menu_set_history(optmenu, 0);
2196         prefs_common_charset_set_data_from_optmenu(pparam);
2197 #endif
2198 }
2199
2200 static void prefs_common_ascii_armored_warning(GtkWidget* widget,
2201                                                gpointer unused)
2202 {
2203         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))
2204                 && gtk_notebook_get_current_page(GTK_NOTEBOOK(dialog.notebook))) {
2205                 alertpanel_message(_("Warning - Privacy/Plain ASCII armored"),
2206                         _("Its not recommend to use the old style plain ASCII\n"
2207                         "armored mode for encypted messages. It doesn't comply\n"
2208                         "with the RFC 3156 - MIME security with OpenPGP."));
2209         }
2210 }
2211 #endif /* USE_GPGME */
2212
2213 static void prefs_interface_create(void)
2214 {
2215         GtkWidget *vbox1;
2216         GtkWidget *vbox2;
2217         GtkWidget *vbox3;
2218         /* GtkWidget *checkbtn_emacs; */
2219         GtkWidget *checkbtn_openunread;
2220         GtkWidget *checkbtn_openinbox;
2221         GtkWidget *checkbtn_immedexec;
2222         GtkWidget *hbox1;
2223         GtkWidget *label;
2224         GtkWidget *optmenu_recvdialog;
2225         GtkWidget *menu;
2226         GtkWidget *menuitem;
2227
2228         GtkWidget *frame_addr;
2229         GtkWidget *vbox_addr;
2230         GtkWidget *checkbtn_addaddrbyclick;
2231
2232         GtkWidget *frame_exit;
2233         GtkWidget *vbox_exit;
2234         GtkWidget *checkbtn_confonexit;
2235         GtkWidget *checkbtn_cleanonexit;
2236         GtkWidget *checkbtn_askonclean;
2237         GtkWidget *checkbtn_warnqueued;
2238
2239         GtkWidget *hbox2;
2240         GtkWidget *optmenu_nextunreadmsgdialog;
2241         GtkWidget *optmenu_nextunreadmsgdialog_menu;
2242         GtkWidget *nextunreadmsgdialog_menuitem;
2243
2244         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2245         gtk_widget_show (vbox1);
2246         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2247         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2248
2249         vbox2 = gtk_vbox_new (FALSE, 0);
2250         gtk_widget_show (vbox2);
2251         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2252
2253         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
2254                            _("Emulate the behavior of mouse operation of\n"
2255                              "Emacs-based mailer"));
2256         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
2257                                GTK_JUSTIFY_LEFT);   */
2258
2259         PACK_CHECK_BUTTON
2260                 (vbox2, checkbtn_openunread,
2261                  _("Open first unread message when entering a folder"));
2262
2263         PACK_CHECK_BUTTON
2264                 (vbox2, checkbtn_openinbox,
2265                  _("Go to inbox after receiving new mail"));
2266
2267         vbox3 = gtk_vbox_new (FALSE, 0);
2268         gtk_widget_show (vbox3);
2269         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
2270
2271         PACK_CHECK_BUTTON
2272                 (vbox3, checkbtn_immedexec,
2273                  _("Execute immediately when moving or deleting messages"));
2274
2275         hbox1 = gtk_hbox_new (FALSE, 0);
2276         gtk_widget_show (hbox1);
2277         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
2278
2279         label = gtk_label_new
2280                 (_("(Messages will be marked until execution\n"
2281                    " if this is turned off)"));
2282         gtk_widget_show (label);
2283         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8);
2284         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2285
2286         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
2287
2288         hbox1 = gtk_hbox_new (FALSE, 8);
2289         gtk_widget_show (hbox1);
2290         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
2291
2292         label = gtk_label_new (_("Show receive dialog"));
2293         gtk_widget_show (label);
2294         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2295
2296         optmenu_recvdialog = gtk_option_menu_new ();
2297         gtk_widget_show (optmenu_recvdialog);
2298         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_recvdialog,
2299                             FALSE, FALSE, 0);
2300
2301         menu = gtk_menu_new ();
2302         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
2303         MENUITEM_ADD (menu, menuitem, _("Only if a window is active"),
2304                       RECV_DIALOG_ACTIVE);
2305         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
2306
2307         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
2308
2309         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2310
2311         vbox_addr = gtk_vbox_new (FALSE, 0);
2312         gtk_widget_show (vbox_addr);
2313         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2314         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2315
2316         PACK_CHECK_BUTTON
2317                 (vbox_addr, checkbtn_addaddrbyclick,
2318                  _("Add address to destination when double-clicked"));
2319
2320         /* Next Unread Message Dialog */
2321         hbox2 = gtk_hbox_new (FALSE, 8);
2322         gtk_widget_show (hbox2);
2323         gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
2324
2325         label = gtk_label_new (_("Show no-unread-message dialog"));
2326         gtk_widget_show (label);
2327         gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2328
2329         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
2330         gtk_widget_show (optmenu_nextunreadmsgdialog);
2331         gtk_box_pack_start (GTK_BOX (hbox2), optmenu_nextunreadmsgdialog,
2332                             FALSE, FALSE, 0);
2333
2334         optmenu_nextunreadmsgdialog_menu = gtk_menu_new ();
2335         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2336                       _("Always"),  NEXTUNREADMSGDIALOG_ALWAYS);
2337         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2338                       _("Assume 'Yes'"),  NEXTUNREADMSGDIALOG_ASSUME_YES);
2339         MENUITEM_ADD (optmenu_nextunreadmsgdialog_menu, nextunreadmsgdialog_menuitem,
2340                       _("Assume 'No'"), NEXTUNREADMSGDIALOG_ASSUME_NO);
2341
2342         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog),
2343                                   optmenu_nextunreadmsgdialog_menu);
2344
2345
2346         /* Receive Dialog */
2347 /*      hbox = gtk_hbox_new (FALSE, 8);
2348         gtk_widget_show (hbox);
2349         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
2350
2351         label = gtk_label_new (_("Show receive Dialog"));
2352         gtk_widget_show (label);
2353         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2354
2355         recvdialog_optmenu = gtk_option_menu_new ();
2356         gtk_widget_show (recvdialog_optmenu);
2357         gtk_box_pack_start (GTK_BOX (hbox), recvdialog_optmenu, FALSE, FALSE, 0);
2358
2359         recvdialog_optmenu_menu = gtk_menu_new ();
2360
2361         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Always"),  RECVDIALOG_ALWAYS);
2362         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Only if a sylpheed window is active"),  RECVDIALOG_WINDOW_ACTIVE);
2363         MENUITEM_ADD (recvdialog_optmenu_menu, recvdialog_menuitem, _("Never"), RECVDIALOG_NEVER);
2364
2365         gtk_option_menu_set_menu (GTK_OPTION_MENU (recvdialog_optmenu), recvdialog_optmenu_menu);     */
2366
2367         /* On Exit */
2368         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2369
2370         vbox_exit = gtk_vbox_new (FALSE, 0);
2371         gtk_widget_show (vbox_exit);
2372         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2373         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2374
2375         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2376                            _("Confirm on exit"));
2377
2378         hbox1 = gtk_hbox_new (FALSE, 32);
2379         gtk_widget_show (hbox1);
2380         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2381
2382         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2383                            _("Empty trash on exit"));
2384         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2385                            _("Ask before emptying"));
2386         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2387
2388         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2389                            _("Warn if there are queued messages"));
2390
2391         /* interface.checkbtn_emacs          = checkbtn_emacs; */
2392         interface.checkbtn_openunread         = checkbtn_openunread;
2393         interface.checkbtn_openinbox          = checkbtn_openinbox;
2394         interface.checkbtn_immedexec          = checkbtn_immedexec;
2395         interface.optmenu_recvdialog          = optmenu_recvdialog;
2396         interface.checkbtn_addaddrbyclick     = checkbtn_addaddrbyclick;
2397         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
2398         interface.checkbtn_confonexit         = checkbtn_confonexit;
2399         interface.checkbtn_cleanonexit        = checkbtn_cleanonexit;
2400         interface.checkbtn_askonclean         = checkbtn_askonclean;
2401         interface.checkbtn_warnqueued         = checkbtn_warnqueued;
2402 }
2403
2404 static void prefs_other_create(void)
2405 {
2406         GtkWidget *vbox1;
2407         GtkWidget *hbox1;
2408
2409         GtkWidget *uri_frame;
2410         GtkWidget *uri_label;
2411         GtkWidget *uri_combo;
2412         GtkWidget *uri_entry;
2413
2414         GtkWidget *print_frame;
2415         GtkWidget *printcmd_label;
2416         GtkWidget *printcmd_entry;
2417
2418         GtkWidget *exteditor_frame;
2419         GtkWidget *exteditor_label;
2420         GtkWidget *exteditor_combo;
2421         GtkWidget *exteditor_entry;
2422
2423         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2424         gtk_widget_show (vbox1);
2425         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2426         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2427
2428         PACK_FRAME(vbox1, uri_frame,
2429                    _("External Web browser (%s will be replaced with URI)"));
2430
2431         hbox1 = gtk_hbox_new (FALSE, 8);
2432         gtk_widget_show (hbox1);
2433         gtk_container_add (GTK_CONTAINER (uri_frame), hbox1);
2434         gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
2435
2436         uri_label = gtk_label_new (_("Command"));
2437         gtk_widget_show(uri_label);
2438         gtk_box_pack_start (GTK_BOX (hbox1), uri_label, FALSE, TRUE, 0);
2439
2440         uri_combo = gtk_combo_new ();
2441         gtk_widget_show (uri_combo);
2442         gtk_box_pack_start (GTK_BOX (hbox1), uri_combo, TRUE, TRUE, 0);
2443         gtkut_combo_set_items (GTK_COMBO (uri_combo),
2444                                "netscape -remote 'openURL(%s,raise)'",
2445                                "netscape '%s'",
2446                                "gnome-moz-remote --raise --newwin '%s'",
2447                                "kterm -e w3m '%s'",
2448                                "kterm -e lynx '%s'",
2449                                NULL);
2450
2451         uri_entry = GTK_COMBO (uri_combo)->entry;
2452
2453         PACK_FRAME(vbox1, print_frame,
2454                    _("Printing (%s will be replaced with file name)"));
2455
2456         hbox1 = gtk_hbox_new (FALSE, 8);
2457         gtk_widget_show (hbox1);
2458         gtk_container_add (GTK_CONTAINER (print_frame), hbox1);
2459         gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
2460
2461         printcmd_label = gtk_label_new (_("Command"));
2462         gtk_widget_show (printcmd_label);
2463         gtk_box_pack_start (GTK_BOX (hbox1), printcmd_label, FALSE, FALSE, 0);
2464
2465         printcmd_entry = gtk_entry_new ();
2466         gtk_widget_show (printcmd_entry);
2467         gtk_box_pack_start (GTK_BOX (hbox1), printcmd_entry, TRUE, TRUE, 0);
2468
2469         PACK_FRAME(vbox1, exteditor_frame,
2470                    _("External editor (%s will be replaced with file name)"));
2471
2472         hbox1 = gtk_hbox_new (FALSE, 8);
2473         gtk_widget_show (hbox1);
2474         gtk_container_add (GTK_CONTAINER (exteditor_frame), hbox1);
2475         gtk_container_set_border_width (GTK_CONTAINER (hbox1), 8);
2476
2477         exteditor_label = gtk_label_new (_("Command"));
2478         gtk_widget_show (exteditor_label);
2479         gtk_box_pack_start (GTK_BOX (hbox1), exteditor_label, FALSE, FALSE, 0);
2480
2481         exteditor_combo = gtk_combo_new ();
2482         gtk_widget_show (exteditor_combo);
2483         gtk_box_pack_start (GTK_BOX (hbox1), exteditor_combo, TRUE, TRUE, 0);
2484         gtkut_combo_set_items (GTK_COMBO (exteditor_combo),
2485                                "gedit %s",
2486                                "kedit %s",
2487                                "mgedit --no-fork %s",
2488                                "emacs %s",
2489                                "xemacs %s",
2490                                "kterm -e jed %s",
2491                                "kterm -e vi %s",
2492                                NULL);
2493         exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
2494
2495         other.uri_combo = uri_combo;
2496         other.uri_entry = uri_entry;
2497         other.printcmd_entry = printcmd_entry;
2498
2499         other.exteditor_combo = exteditor_combo;
2500         other.exteditor_entry = exteditor_entry;
2501 }
2502
2503 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2504 {
2505         GtkWidget *datefmt_sample = NULL;
2506         gchar *text;
2507
2508         g_return_if_fail(widget != NULL);
2509         g_return_if_fail(*widget != NULL);
2510         g_return_if_fail(display.entry_datefmt != NULL);
2511
2512         datefmt_sample = GTK_WIDGET(gtk_object_get_data
2513                                     (GTK_OBJECT(*widget), "datefmt_sample"));
2514         g_return_if_fail(datefmt_sample != NULL);
2515
2516         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2517         g_free(prefs_common.date_format);
2518         prefs_common.date_format = text;
2519         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2520
2521         gtk_widget_destroy(*widget);
2522         *widget = NULL;
2523 }
2524
2525 static void date_format_cancel_btn_clicked(GtkButton *button,
2526                                            GtkWidget **widget)
2527 {
2528         g_return_if_fail(widget != NULL);
2529         g_return_if_fail(*widget != NULL);
2530
2531         gtk_widget_destroy(*widget);
2532         *widget = NULL;
2533 }
2534
2535 static void date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2536                                     GtkWidget **widget)
2537 {
2538         if (event && event->keyval == GDK_Escape)
2539                 date_format_cancel_btn_clicked(NULL, widget);
2540 }
2541
2542 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2543                                       GdkEventAny *event, GtkWidget **widget)
2544 {
2545         g_return_val_if_fail(widget != NULL, FALSE);
2546         g_return_val_if_fail(*widget != NULL, FALSE);
2547
2548         *widget = NULL;
2549         return FALSE;
2550 }
2551
2552 static void date_format_entry_on_change(GtkEditable *editable,
2553                                         GtkLabel *example)
2554 {
2555         time_t cur_time;
2556         struct tm *cal_time;
2557         gchar buffer[100];
2558         gchar *text;
2559
2560         cur_time = time(NULL);
2561         cal_time = localtime(&cur_time);
2562         buffer[0] = 0;
2563         text = gtk_editable_get_chars(editable, 0, -1);
2564         if (text)
2565                 strftime(buffer, sizeof buffer, text, cal_time); 
2566         gtk_label_set_text(example, buffer);
2567 }
2568
2569 static void date_format_select_row(GtkWidget *date_format_list, gint row,
2570                                    gint column, GdkEventButton *event,
2571                                    GtkWidget *date_format)
2572 {
2573         gint cur_pos;
2574         gchar *format;
2575         gchar *old_format;
2576         gchar *new_format;
2577         GtkWidget *datefmt_sample;
2578
2579         /* only on double click */
2580         if (!event || event->type != GDK_2BUTTON_PRESS) return;
2581
2582
2583         datefmt_sample = GTK_WIDGET(gtk_object_get_data
2584                                     (GTK_OBJECT(date_format), "datefmt_sample"));
2585
2586         g_return_if_fail(date_format_list != NULL);
2587         g_return_if_fail(date_format != NULL);
2588         g_return_if_fail(datefmt_sample != NULL);
2589
2590         /* get format from clist */
2591         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
2592
2593         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2594         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2595
2596         /* insert the format into the text entry */
2597         new_format = g_malloc(strlen(old_format) + 3);
2598
2599         strncpy(new_format, old_format, cur_pos);
2600         new_format[cur_pos] = '\0';
2601         strcat(new_format, format);
2602         strcat(new_format, &old_format[cur_pos]);
2603
2604         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2605         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2606
2607         g_free(new_format);
2608 }
2609
2610 static GtkWidget *date_format_create(GtkButton *button, void *data)
2611 {
2612         static GtkWidget *datefmt_win = NULL;
2613         GtkWidget *vbox1;
2614         GtkWidget *scrolledwindow1;
2615         GtkWidget *datefmt_clist;
2616         GtkWidget *table;
2617         GtkWidget *label1;
2618         GtkWidget *label2;
2619         GtkWidget *label3;
2620         GtkWidget *confirm_area;
2621         GtkWidget *ok_btn;
2622         GtkWidget *cancel_btn;
2623         GtkWidget *datefmt_entry;
2624
2625         const struct {
2626                 gchar *fmt;
2627                 gchar *txt;
2628         } time_format[] = {
2629                 { "%a", _("the full abbreviated weekday name") },
2630                 { "%A", _("the full weekday name") },
2631                 { "%b", _("the abbreviated month name") },
2632                 { "%B", _("the full month name") },
2633                 { "%c", _("the preferred date and time for the current locale") },
2634                 { "%C", _("the century number (year/100)") },
2635                 { "%d", _("the day of the month as a decimal number") },
2636                 { "%H", _("the hour as a decimal number using a 24-hour clock") },
2637                 { "%I", _("the hour as a decimal number using a 12-hour clock") },
2638                 { "%j", _("the day of the year as a decimal number") },
2639                 { "%m", _("the month as a decimal number") },
2640                 { "%M", _("the minute as a decimal number") },
2641                 { "%p", _("either AM or PM") },
2642                 { "%S", _("the second as a decimal number") },
2643                 { "%w", _("the day of the week as a decimal number") },
2644                 { "%x", _("the preferred date for the current locale") },
2645                 { "%y", _("the last two digits of a year") },
2646                 { "%Y", _("the year as a decimal number") },
2647                 { "%Z", _("the time zone or name or abbreviation") }
2648         };
2649
2650         gchar *titles[2];
2651         gint i;
2652         const gint TIME_FORMAT_ELEMS =
2653                 sizeof time_format / sizeof time_format[0];
2654
2655         if (datefmt_win) return datefmt_win;
2656
2657         datefmt_win = gtk_window_new(GTK_WINDOW_DIALOG);
2658         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2659         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2660         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2661         gtk_widget_set_usize(datefmt_win, 440, 280);
2662
2663         vbox1 = gtk_vbox_new(FALSE, 10);
2664         gtk_widget_show(vbox1);
2665         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2666
2667         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2668         gtk_scrolled_window_set_policy
2669                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
2670                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2671         gtk_widget_show(scrolledwindow1);
2672         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2673
2674         titles[0] = _("Specifier");
2675         titles[1] = _("Description");
2676         datefmt_clist = gtk_clist_new_with_titles(2, titles);
2677         gtk_widget_show(datefmt_clist);
2678         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
2679 /*      gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80);   */
2680
2681         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
2682                                      GTK_SELECTION_BROWSE);
2683
2684         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2685                 gchar *text[2];
2686                 /* phoney casting necessary because of gtk... */
2687                 text[0] = (gchar *)time_format[i].fmt;
2688                 text[1] = (gchar *)time_format[i].txt;
2689                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
2690         }
2691
2692         table = gtk_table_new(2, 2, FALSE);
2693         gtk_widget_show(table);
2694         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
2695         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
2696         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2697
2698         label1 = gtk_label_new(_("Date format"));
2699         gtk_widget_show(label1);
2700         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
2701                          GTK_FILL, 0, 0, 0);
2702         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
2703         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
2704
2705         datefmt_entry = gtk_entry_new_with_max_length(256);
2706         gtk_widget_show(datefmt_entry);
2707         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
2708                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2709
2710         /* we need the "sample" entry box; add it as data so callbacks can
2711          * get the entry box */
2712         gtk_object_set_data(GTK_OBJECT(datefmt_win), "datefmt_sample",
2713                             datefmt_entry);
2714
2715         label2 = gtk_label_new(_("Example"));
2716         gtk_widget_show(label2);
2717         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
2718                          GTK_FILL, 0, 0, 0);
2719         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
2720         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
2721
2722         label3 = gtk_label_new("");
2723         gtk_widget_show(label3);
2724         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
2725                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2726         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
2727         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
2728
2729         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
2730                                 &cancel_btn, _("Cancel"), NULL, NULL);
2731         gtk_widget_grab_default(ok_btn);
2732         gtk_widget_show(confirm_area);
2733
2734         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
2735
2736         /* set the current format */
2737         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
2738         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
2739                                     GTK_LABEL(label3));
2740
2741         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
2742                            GTK_SIGNAL_FUNC(date_format_ok_btn_clicked),
2743                            &datefmt_win);
2744         gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
2745                            GTK_SIGNAL_FUNC(date_format_cancel_btn_clicked),
2746                            &datefmt_win);
2747         gtk_signal_connect(GTK_OBJECT(datefmt_win), "key_press_event",
2748                            GTK_SIGNAL_FUNC(date_format_key_pressed),
2749                            &datefmt_win);
2750         gtk_signal_connect(GTK_OBJECT(datefmt_win), "delete_event",
2751                            GTK_SIGNAL_FUNC(date_format_on_delete),
2752                            &datefmt_win);
2753         gtk_signal_connect(GTK_OBJECT(datefmt_entry), "changed",
2754                            GTK_SIGNAL_FUNC(date_format_entry_on_change),
2755                            label3);
2756
2757         gtk_signal_connect(GTK_OBJECT(datefmt_clist), "select_row",
2758                            GTK_SIGNAL_FUNC(date_format_select_row),
2759                            datefmt_win);
2760
2761         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2762         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
2763
2764         gtk_widget_show(datefmt_win);
2765         manage_window_set_transient(GTK_WINDOW(datefmt_win));
2766
2767         gtk_widget_grab_focus(ok_btn);
2768
2769         return datefmt_win;
2770 }
2771
2772 void prefs_quote_colors_dialog(void)
2773 {
2774         if (!quote_color_win)
2775                 prefs_quote_colors_dialog_create();
2776         gtk_widget_show(quote_color_win);
2777         manage_window_set_transient(GTK_WINDOW(quote_color_win));
2778
2779         gtk_main();
2780         gtk_widget_hide(quote_color_win);
2781
2782         textview_update_message_colors();
2783         main_window_reflect_prefs_all();
2784 }
2785
2786 static void prefs_quote_colors_dialog_create(void)
2787 {
2788         GtkWidget *window;
2789         GtkWidget *vbox;
2790         GtkWidget *table;
2791         GtkWidget *quotelevel1_label;
2792         GtkWidget *quotelevel2_label;
2793         GtkWidget *quotelevel3_label;
2794         GtkWidget *uri_label;
2795         GtkWidget *tgt_folder_label;
2796         GtkWidget *hbbox;
2797         GtkWidget *ok_btn;
2798         //GtkWidget *cancel_btn;
2799         GtkWidget *recycle_colors_btn;
2800         GtkWidget *frame_colors;
2801
2802         window = gtk_window_new(GTK_WINDOW_DIALOG);
2803         gtk_container_set_border_width(GTK_CONTAINER(window), 2);
2804         gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
2805         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
2806         gtk_window_set_modal(GTK_WINDOW(window), TRUE);
2807         gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
2808
2809         vbox = gtk_vbox_new (FALSE, VSPACING);
2810         gtk_container_add (GTK_CONTAINER (window), vbox);
2811         gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
2812         PACK_FRAME(vbox, frame_colors, _("Colors"));
2813
2814         table = gtk_table_new (4, 2, FALSE);
2815         gtk_container_add (GTK_CONTAINER (frame_colors), table);
2816         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
2817         gtk_table_set_row_spacings (GTK_TABLE (table), 2);
2818         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2819
2820
2821         color_buttons.quote_level1_btn = gtk_button_new();
2822         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
2823                           0, 1, 0, 1, 0, 0, 0, 0);
2824         gtk_widget_set_usize (color_buttons.quote_level1_btn, 40, 30);
2825         gtk_container_set_border_width
2826                 (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
2827
2828         color_buttons.quote_level2_btn = gtk_button_new();
2829         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
2830                           0, 1, 1, 2, 0, 0, 0, 0);
2831         gtk_widget_set_usize (color_buttons.quote_level2_btn, 40, 30);
2832         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
2833
2834         color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
2835         gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
2836                           0, 1, 2, 3, 0, 0, 0, 0);
2837         gtk_widget_set_usize (color_buttons.quote_level3_btn, 40, 30);
2838         gtk_container_set_border_width
2839                 (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
2840
2841         color_buttons.uri_btn = gtk_button_new_with_label ("");
2842         gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
2843                           0, 1, 3, 4, 0, 0, 0, 0);
2844         gtk_widget_set_usize (color_buttons.uri_btn, 40, 30);
2845         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
2846
2847         color_buttons.tgt_folder_btn = gtk_button_new_with_label ("");
2848         gtk_table_attach (GTK_TABLE (table), color_buttons.tgt_folder_btn,
2849                           0, 1, 4, 5, 0, 0, 0, 0);
2850         gtk_widget_set_usize (color_buttons.tgt_folder_btn, 40, 30);
2851         gtk_container_set_border_width (GTK_CONTAINER (color_buttons.tgt_folder_btn), 5);
2852
2853         quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
2854         gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
2855                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2856         gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
2857         gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
2858
2859         quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
2860         gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
2861                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2862         gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
2863         gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
2864
2865         quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
2866         gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
2867                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2868         gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
2869         gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
2870
2871         uri_label = gtk_label_new (_("URI link"));
2872         gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
2873                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2874         gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
2875         gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
2876
2877         tgt_folder_label = gtk_label_new (_("Target folder"));
2878         gtk_table_attach (GTK_TABLE (table), tgt_folder_label, 1, 2, 4, 5,
2879                           (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2880         gtk_label_set_justify (GTK_LABEL (tgt_folder_label), GTK_JUSTIFY_LEFT);
2881         gtk_misc_set_alignment (GTK_MISC (tgt_folder_label), 0, 0.5);
2882
2883         PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
2884                            _("Recycle quote colors"));
2885
2886         gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
2887                                 NULL, NULL, NULL, NULL);
2888         gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
2889
2890         gtk_widget_grab_default(ok_btn);
2891         gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
2892                            GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
2893         gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
2894                            GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
2895         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
2896                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
2897         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
2898                            GTK_SIGNAL_FUNC(prefs_quote_colors_key_pressed),
2899                            NULL);
2900
2901         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level1_btn), "clicked",
2902                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL1");
2903         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level2_btn), "clicked",
2904                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL2");
2905         gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level3_btn), "clicked",
2906                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL3");
2907         gtk_signal_connect(GTK_OBJECT(color_buttons.uri_btn), "clicked",
2908                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "URI");
2909         gtk_signal_connect(GTK_OBJECT(color_buttons.tgt_folder_btn), "clicked",
2910                            GTK_SIGNAL_FUNC(quote_color_set_dialog), "TGTFLD");
2911         gtk_signal_connect(GTK_OBJECT(recycle_colors_btn), "toggled",
2912                            GTK_SIGNAL_FUNC(prefs_recycle_colors_toggled), NULL);
2913         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
2914                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
2915
2916         /* show message button colors and recycle options */
2917         set_button_bg_color(color_buttons.quote_level1_btn,
2918                             prefs_common.quote_level1_col);
2919         set_button_bg_color(color_buttons.quote_level2_btn,
2920                             prefs_common.quote_level2_col);
2921         set_button_bg_color(color_buttons.quote_level3_btn,
2922                             prefs_common.quote_level3_col);
2923         set_button_bg_color(color_buttons.uri_btn,
2924                             prefs_common.uri_col);
2925         set_button_bg_color(color_buttons.tgt_folder_btn,
2926                             prefs_common.tgt_folder_col);
2927         gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
2928                                      prefs_common.recycle_quote_colors);
2929
2930         gtk_widget_show_all(vbox);
2931         quote_color_win = window;
2932 }
2933
2934 static void prefs_quote_colors_key_pressed(GtkWidget *widget,
2935                                            GdkEventKey *event, gpointer data)
2936 {
2937         if (event && event->keyval == GDK_Escape)
2938                 gtk_main_quit();
2939 }
2940
2941 static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
2942 {
2943         gchar *type = (gchar *)data;
2944         gchar *title = NULL;
2945         gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
2946         gint rgbvalue = 0;
2947         GtkColorSelectionDialog *dialog;
2948
2949         if(g_strcasecmp(type, "LEVEL1") == 0) {
2950                 title = _("Pick color for quotation level 1");
2951                 rgbvalue = prefs_common.quote_level1_col;
2952         } else if(g_strcasecmp(type, "LEVEL2") == 0) {
2953                 title = _("Pick color for quotation level 2");
2954                 rgbvalue = prefs_common.quote_level2_col;
2955         } else if(g_strcasecmp(type, "LEVEL3") == 0) {
2956                 title = _("Pick color for quotation level 3");
2957                 rgbvalue = prefs_common.quote_level3_col;
2958         } else if(g_strcasecmp(type, "URI") == 0) {
2959                 title = _("Pick color for URI");
2960                 rgbvalue = prefs_common.uri_col;
2961         } else if(g_strcasecmp(type, "TGTFLD") == 0) {
2962                 title = _("Pick color for target folder");
2963                 rgbvalue = prefs_common.tgt_folder_col;
2964         } else {   /* Should never be called */
2965                 g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
2966                 return;
2967         }
2968
2969         color_dialog = gtk_color_selection_dialog_new(title);
2970         gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
2971         gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
2972         gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
2973         manage_window_set_transient(GTK_WINDOW(color_dialog));
2974
2975         gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
2976                            "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_ok), data);
2977         gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
2978                            "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_cancel), data);
2979         gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
2980                            GTK_SIGNAL_FUNC(quote_colors_set_dialog_key_pressed),
2981                            data);
2982
2983         /* preselect the previous color in the color selection dialog */
2984         color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
2985         color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
2986         color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
2987         dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
2988         gtk_color_selection_set_color
2989                 (GTK_COLOR_SELECTION(dialog->colorsel), color);
2990
2991         gtk_widget_show(color_dialog);
2992 }
2993
2994 static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
2995 {
2996         GtkColorSelection *colorsel = (GtkColorSelection *)
2997                                                 ((GtkColorSelectionDialog *)color_dialog)->colorsel;
2998         gdouble color[4];
2999         gint red, green, blue, rgbvalue;
3000         gchar *type = (gchar *)data;
3001
3002         gtk_color_selection_get_color(colorsel, color);
3003
3004         red      = (gint) (color[0] * 255.0);
3005         green    = (gint) (color[1] * 255.0);
3006         blue     = (gint) (color[2] * 255.0);
3007         rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
3008
3009 #if 0
3010         fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
3011         fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
3012         fprintf(stderr, "Color is %x\n", rgbvalue);
3013 #endif
3014
3015         if (g_strcasecmp(type, "LEVEL1") == 0) {
3016                 prefs_common.quote_level1_col = rgbvalue;
3017                 set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
3018         } else if (g_strcasecmp(type, "LEVEL2") == 0) {
3019                 prefs_common.quote_level2_col = rgbvalue;
3020                 set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
3021         } else if (g_strcasecmp(type, "LEVEL3") == 0) {
3022                 prefs_common.quote_level3_col = rgbvalue;
3023                 set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
3024         } else if (g_strcasecmp(type, "URI") == 0) {
3025                 prefs_common.uri_col = rgbvalue;
3026                 set_button_bg_color(color_buttons.uri_btn, rgbvalue);
3027         } else if (g_strcasecmp(type, "TGTFLD") == 0) {
3028                 prefs_common.tgt_folder_col = rgbvalue;
3029                 set_button_bg_color(color_buttons.tgt_folder_btn, rgbvalue);
3030                 folderview_set_target_folder_color(prefs_common.tgt_folder_col);
3031         } else
3032                 fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
3033
3034         gtk_widget_destroy(color_dialog);
3035 }
3036
3037 static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
3038 {
3039         gtk_widget_destroy(color_dialog);
3040 }
3041
3042 static void quote_colors_set_dialog_key_pressed(GtkWidget *widget,
3043                                                 GdkEventKey *event,
3044                                                 gpointer data)
3045 {
3046         gtk_widget_destroy(color_dialog);
3047 }
3048
3049 static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
3050 {
3051         GtkStyle *newstyle;
3052         GdkColor color;
3053
3054         gtkut_convert_int_to_gdk_color(rgbvalue, &color);
3055         newstyle = gtk_style_copy(gtk_widget_get_default_style());
3056         newstyle->bg[GTK_STATE_NORMAL]   = color;
3057         newstyle->bg[GTK_STATE_PRELIGHT] = color;
3058         newstyle->bg[GTK_STATE_ACTIVE]   = color;
3059
3060         gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
3061 }
3062
3063 static void prefs_enable_message_color_toggled(void)
3064 {
3065         gboolean is_active;
3066
3067         is_active = gtk_toggle_button_get_active
3068                 (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
3069         gtk_widget_set_sensitive(message.button_edit_col, is_active);
3070         prefs_common.enable_color = is_active;
3071 }
3072
3073 static void prefs_recycle_colors_toggled(GtkWidget *widget)
3074 {
3075         gboolean is_active;
3076
3077         is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3078         prefs_common.recycle_quote_colors = is_active;
3079 }
3080
3081 void prefs_quote_description(void)
3082 {
3083         if (!quote_desc_win)
3084                 prefs_quote_description_create();
3085
3086         manage_window_set_transient(GTK_WINDOW(quote_desc_win));
3087         gtk_widget_show(quote_desc_win);
3088         gtk_main();
3089         gtk_widget_hide(quote_desc_win);
3090 }
3091
3092 static void prefs_quote_description_create(void)
3093 {
3094         GtkWidget *vbox;
3095         GtkWidget *hbox;
3096         GtkWidget *hbbox;
3097         GtkWidget *label;
3098         GtkWidget *ok_btn;
3099
3100         quote_desc_win = gtk_window_new(GTK_WINDOW_DIALOG);
3101         gtk_window_set_title(GTK_WINDOW(quote_desc_win),
3102                              _("Description of symbols"));
3103         gtk_container_set_border_width(GTK_CONTAINER(quote_desc_win), 8);
3104         gtk_window_set_position(GTK_WINDOW(quote_desc_win), GTK_WIN_POS_CENTER);
3105         gtk_window_set_modal(GTK_WINDOW(quote_desc_win), TRUE);
3106         gtk_window_set_policy(GTK_WINDOW(quote_desc_win), FALSE, TRUE, FALSE);
3107
3108         vbox = gtk_vbox_new(FALSE, 8);
3109         gtk_container_add(GTK_CONTAINER(quote_desc_win), vbox);
3110
3111         hbox = gtk_hbox_new(FALSE, 4);
3112         gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
3113
3114         label = gtk_label_new
3115                 ("SYMBOL\n\n"
3116                  "%d\n"         /* date */
3117                  "%f\n"         /* from */
3118                  "%N\n"         /* full name of sender */
3119                  "%F\n"         /* first name of sender */
3120                  "%I\n"         /* initial of sender */
3121                  "%s\n"         /* subject */
3122                  "%t\n"         /* to */
3123                  "%c\n"         /* cc */
3124                  "%n\n"         /* newsgroups */
3125                  "%i\n"         /* message id */
3126                  "%r\n"         /* references */
3127                  "\n"
3128                  "%x\n"
3129                  "?x(expr)\n"   /* condition */
3130                  "\n"
3131                  "%M\n"         /* message body */
3132                  "%Q\n"         /* quoted message body */
3133                  "%m\n"         /* message body without signature */
3134                  "%q\n"         /* quoted message body without signature */
3135                  "%%");         /* literal percent */
3136
3137         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
3138         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
3139
3140         label = gtk_label_new
3141                 (_("DESCRIPTION\n\n"
3142                    "Date\n"
3143                    "From\n"
3144                    "Full Name of Sender\n"
3145                    "First Name of Sender\n"
3146                    "Initial of Sender\n"
3147                    "Subject\n"
3148                    "To\n"
3149                    "Cc\n"
3150                    "Newsgroups\n"
3151                    "Message-ID\n"
3152                    "References\n"
3153                    "\n"
3154                    "Display the information\n"
3155                    "If the information x is set, displays expr\n"
3156                    "\n"
3157                    "Message body\n"
3158                    "Quoted message body\n"
3159                    "Message body without signature\n"
3160                    "Quoted message body without signature\n"
3161                    "Literal %"));
3162
3163         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
3164         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
3165
3166         gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
3167                                 NULL, NULL, NULL, NULL);
3168         gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
3169
3170         gtk_widget_grab_default(ok_btn);
3171         gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
3172                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3173         gtk_signal_connect
3174                 (GTK_OBJECT(quote_desc_win), "key_press_event",
3175                  GTK_SIGNAL_FUNC(prefs_quote_description_key_pressed),
3176                  NULL);
3177         gtk_signal_connect(GTK_OBJECT(quote_desc_win), "delete_event",
3178                            GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
3179
3180         gtk_widget_show_all(vbox);
3181 }
3182
3183 static void prefs_quote_description_key_pressed(GtkWidget *widget,
3184                                                 GdkEventKey *event,
3185                                                 gpointer data)
3186 {
3187         if (event && event->keyval == GDK_Escape)
3188                 gtk_main_quit();
3189 }
3190
3191 static void prefs_font_select(GtkButton *button, GtkEntry *entry)
3192 {
3193         gchar *font_name;
3194         
3195         g_return_if_fail(entry != NULL);
3196         
3197         if (!font_sel_win) {
3198                 font_sel_win = gtk_font_selection_dialog_new
3199                         (_("Font selection"));
3200                 gtk_window_position(GTK_WINDOW(font_sel_win),
3201                                     GTK_WIN_POS_CENTER);
3202                 gtk_signal_connect(GTK_OBJECT(font_sel_win), "delete_event",
3203                                    GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
3204                                    NULL);
3205                 gtk_signal_connect
3206                         (GTK_OBJECT(font_sel_win), "key_press_event",
3207                          GTK_SIGNAL_FUNC(prefs_font_selection_key_pressed),
3208                          NULL);
3209                 gtk_signal_connect_object
3210                         (GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_sel_win)->cancel_button),
3211                          "clicked",
3212                          GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
3213                          GTK_OBJECT(font_sel_win));
3214         }
3215
3216         if(font_sel_conn_id) {
3217                 gtk_signal_disconnect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_sel_win)->ok_button), font_sel_conn_id);
3218         }
3219         font_sel_conn_id = gtk_signal_connect
3220                 (GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(font_sel_win)->ok_button),
3221                  "clicked",
3222                  GTK_SIGNAL_FUNC(prefs_font_selection_ok),
3223                  entry);
3224         printf("%i\n", font_sel_conn_id);
3225
3226         font_name = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
3227         gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(font_sel_win), font_name);
3228         g_free(font_name);
3229         manage_window_set_transient(GTK_WINDOW(font_sel_win));
3230         gtk_window_set_modal(GTK_WINDOW(font_sel_win), TRUE);
3231         gtk_widget_grab_focus
3232                 (GTK_FONT_SELECTION_DIALOG(font_sel_win)->ok_button);
3233         gtk_widget_show(font_sel_win);
3234 }
3235
3236 static void prefs_font_selection_key_pressed(GtkWidget *widget,
3237                                              GdkEventKey *event,
3238                                              gpointer data)
3239 {
3240         if (event && event->keyval == GDK_Escape)
3241                 gtk_widget_hide(font_sel_win);
3242 }
3243
3244 static void prefs_font_selection_ok(GtkButton *button, GtkEntry *entry)
3245 {
3246         gchar *fontname;
3247
3248         fontname = gtk_font_selection_dialog_get_font_name
3249                 (GTK_FONT_SELECTION_DIALOG(font_sel_win));
3250
3251         if (fontname) {
3252                 gtk_entry_set_text(entry, fontname);
3253
3254                 g_free(fontname);
3255         }
3256
3257         gtk_widget_hide(font_sel_win);
3258 }
3259
3260 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
3261 {
3262         GtkWidget *menu;
3263         GtkWidget *menuitem;
3264         gchar *charset;
3265
3266         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3267         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3268         charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
3269         g_free(*((gchar **)pparam->data));
3270         *((gchar **)pparam->data) = g_strdup(charset);
3271 }
3272
3273 static void prefs_common_charset_set_optmenu(PrefParam *pparam)
3274 {
3275         GList *cur;
3276         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3277         GtkWidget *menu;
3278         GtkWidget *menuitem;
3279         gchar *charset;
3280         gint n = 0;
3281
3282         g_return_if_fail(optmenu != NULL);
3283         g_return_if_fail(*((gchar **)pparam->data) != NULL);
3284
3285         menu = gtk_option_menu_get_menu(optmenu);
3286         for (cur = GTK_MENU_SHELL(menu)->children;
3287              cur != NULL; cur = cur->next) {
3288                 menuitem = GTK_WIDGET(cur->data);
3289                 charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
3290                 if (!strcmp(charset, *((gchar **)pparam->data))) {
3291                         gtk_option_menu_set_history(optmenu, n);
3292                         return;
3293                 }
3294                 n++;
3295         }
3296
3297         gtk_option_menu_set_history(optmenu, 0);
3298         prefs_common_charset_set_data_from_optmenu(pparam);
3299 }
3300
3301 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)
3302 {
3303         GtkWidget *menu;
3304         GtkWidget *menuitem;
3305
3306         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3307         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3308         *((RecvDialogMode *)pparam->data) = GPOINTER_TO_INT
3309                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3310 }
3311
3312 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
3313 {
3314         RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
3315         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3316         GtkWidget *menu;
3317         GtkWidget *menuitem;
3318
3319         switch (mode) {
3320         case RECV_DIALOG_ALWAYS:
3321                 gtk_option_menu_set_history(optmenu, 0);
3322                 break;
3323         case RECV_DIALOG_ACTIVE:
3324                 gtk_option_menu_set_history(optmenu, 1);
3325                 break;
3326         case RECV_DIALOG_NEVER:
3327                 gtk_option_menu_set_history(optmenu, 2);
3328                 break;
3329         default:
3330         }
3331
3332         menu = gtk_option_menu_get_menu(optmenu);
3333         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3334         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3335 }
3336
3337 static gint prefs_common_deleted(GtkWidget *widget, GdkEventAny *event,
3338                                  gpointer data)
3339 {
3340         prefs_common_cancel();
3341         return TRUE;
3342 }
3343
3344 static void prefs_common_key_pressed(GtkWidget *widget, GdkEventKey *event,
3345                                      gpointer data)
3346 {
3347         if (event && event->keyval == GDK_Escape)
3348                 prefs_common_cancel();
3349 }
3350
3351 static void prefs_common_ok(void)
3352 {
3353         prefs_common_apply();
3354         gtk_widget_hide(dialog.window);
3355         if (quote_desc_win && GTK_WIDGET_VISIBLE(quote_desc_win))
3356                 gtk_widget_hide(quote_desc_win);
3357
3358         inc_unlock();
3359 }
3360
3361 static void prefs_common_apply(void)
3362 {
3363         prefs_set_data_from_dialog(param);
3364         main_window_reflect_prefs_all();
3365         prefs_common_save_config();
3366
3367         inc_autocheck_timer_remove();
3368         inc_autocheck_timer_set();
3369 }
3370
3371 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam)
3372 {
3373         GtkWidget *menu;
3374         GtkWidget *menuitem;
3375
3376         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3377         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3378         *((NextUnreadMsgDialogShow *)pparam->data) = GPOINTER_TO_INT
3379                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3380 }
3381
3382 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam)
3383 {
3384         NextUnreadMsgDialogShow dialog_show;
3385         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3386         GtkWidget *menu;
3387         GtkWidget *menuitem;
3388
3389         dialog_show = *((NextUnreadMsgDialogShow *)pparam->data);
3390
3391         switch (dialog_show) {
3392         case NEXTUNREADMSGDIALOG_ALWAYS:
3393                 gtk_option_menu_set_history(optmenu, 0);
3394                 break;
3395         case NEXTUNREADMSGDIALOG_ASSUME_YES:
3396                 gtk_option_menu_set_history(optmenu, 1);
3397                 break;
3398         case NEXTUNREADMSGDIALOG_ASSUME_NO:
3399                 gtk_option_menu_set_history(optmenu, 2);
3400                 break;
3401         default:
3402         }
3403
3404         menu = gtk_option_menu_get_menu(optmenu);
3405         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3406         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3407 }
3408
3409 static void prefs_common_cancel(void)
3410 {
3411         gtk_widget_hide(dialog.window);
3412         inc_unlock();
3413 }
3414
3415
3416 static struct _ComposePrefs
3417 {
3418         GtkWidget *window;
3419
3420         GtkWidget *close_btn;
3421 } composeprefs;
3422
3423 static void compose_prefs_key_pressed(GtkWidget *widget, GdkEventKey *event);
3424 static gint compose_prefs_delete_event(GtkWidget *widget, GdkEventAny *event);
3425 static void compose_prefs_close(GtkWidget *widget);
3426 static void compose_prefs_fmt_create(void);
3427
3428 static void compose_prefs_close(GtkWidget *widget)
3429 {
3430         gtk_widget_hide(composeprefs.window);
3431 }
3432
3433 static gint compose_prefs_delete_event(GtkWidget *widget, GdkEventAny *event)
3434 {
3435         gtk_widget_hide(composeprefs.window);
3436
3437         return TRUE;
3438 }
3439
3440 static void compose_prefs_key_pressed(GtkWidget *widget, GdkEventKey *event)
3441 {
3442         if (event && event->keyval == GDK_Escape) {
3443                 gtk_widget_hide(composeprefs.window);
3444         }
3445 }
3446
3447 /* static void prefs_recvdialog_set_data_from_optmenu(PrefParam *pparam)
3448 {
3449         GtkWidget *menu;
3450         GtkWidget *menuitem;
3451
3452         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3453         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3454         *((RecvDialogShow *)pparam->data) = GPOINTER_TO_INT
3455                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3456 }  */
3457
3458 /* static void prefs_recvdialog_set_optmenu(PrefParam *pparam)
3459 {
3460         RecvDialogShow dialog_show;
3461         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3462         GtkWidget *menu;
3463         GtkWidget *menuitem;
3464
3465         dialog_show = *((RecvDialogShow *)pparam->data);
3466
3467         switch (dialog_show) {
3468         case RECVDIALOG_ALWAYS:
3469                 gtk_option_menu_set_history(optmenu, 0);
3470                 break;
3471         case RECVDIALOG_WINDOW_ACTIVE:
3472                 gtk_option_menu_set_history(optmenu, 1);
3473                 break;
3474         case RECVDIALOG_NEVER:
3475                 gtk_option_menu_set_history(optmenu, 2);
3476                 break;
3477         default:
3478         }
3479
3480         menu = gtk_option_menu_get_menu(optmenu);
3481         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3482         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3483 }     */