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