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