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