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