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