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