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