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