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