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