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