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