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