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