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