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