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