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