910bff44c7d6b6913701c011d3a182ce6b895388
[claws.git] / src / prefs_common.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2004 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 *optmenu_senddialog;
89
90         GtkWidget *optmenu_charset;
91         GtkWidget *optmenu_encoding_method;
92 } p_send;
93
94 static struct Compose {
95         GtkWidget *entry_fw_quotemark;
96         GtkWidget *text_fw_quotefmt;
97
98         GtkWidget *checkbtn_autoextedit;
99         GtkWidget *spinbtn_undolevel;
100         GtkObject *spinbtn_undolevel_adj;
101
102         GtkWidget *checkbtn_reply_account_autosel;
103         GtkWidget *checkbtn_forward_account_autosel;
104         GtkWidget *checkbtn_reedit_account_autosel;
105         GtkWidget *checkbtn_quote;
106         GtkWidget *checkbtn_default_reply_list;
107         GtkWidget *checkbtn_forward_as_attachment;
108         GtkWidget *checkbtn_redirect_keep_from;
109         GtkWidget *checkbtn_reply_with_quote;
110         
111         GtkWidget *checkbtn_autosave;
112         GtkWidget *entry_autosave_length;
113 } compose;
114
115 static struct Quote {
116         GtkWidget *entry_quotemark;
117         GtkWidget *text_quotefmt;
118
119         GtkWidget *entry_fw_quotemark;
120         GtkWidget *text_fw_quotefmt;
121         
122         GtkWidget *entry_quote_chars;
123 } quote;
124
125 static struct Display {
126         GtkWidget *chkbtn_folder_unread;
127         GtkWidget *entry_ng_abbrev_len;
128         GtkWidget *spinbtn_ng_abbrev_len;
129         GtkObject *spinbtn_ng_abbrev_len_adj;
130
131         GtkWidget *chkbtn_transhdr;
132
133         GtkWidget *chkbtn_swapfrom;
134         GtkWidget *chkbtn_useaddrbook;
135         GtkWidget *chkbtn_threadsubj;
136         GtkWidget *entry_datefmt;
137 } display;
138
139 static struct Message {
140         GtkWidget *chkbtn_mbalnum;
141         GtkWidget *chkbtn_disphdrpane;
142         GtkWidget *chkbtn_disphdr;
143         GtkWidget *spinbtn_linespc;
144         GtkObject *spinbtn_linespc_adj;
145         GtkWidget *chkbtn_headspc;
146
147         GtkWidget *chkbtn_smoothscroll;
148         GtkWidget *spinbtn_scrollstep;
149         GtkObject *spinbtn_scrollstep_adj;
150         GtkWidget *chkbtn_halfpage;
151
152         GtkWidget *chkbtn_attach_desc;
153 } message;
154
155 static struct Interface {
156         /* GtkWidget *checkbtn_emacs; */
157         GtkWidget *checkbtn_always_show_msg;
158         GtkWidget *checkbtn_openunread;
159         GtkWidget *checkbtn_mark_as_read_on_newwin;
160         GtkWidget *checkbtn_openinbox;
161         GtkWidget *checkbtn_immedexec;
162         GtkWidget *optmenu_nextunreadmsgdialog;
163 } interface;
164
165 static struct Other {
166         GtkWidget *checkbtn_addaddrbyclick;
167         GtkWidget *checkbtn_confonexit;
168         GtkWidget *checkbtn_cleanonexit;
169         GtkWidget *checkbtn_askonclean;
170         GtkWidget *checkbtn_warnqueued;
171         GtkWidget *checkbtn_cliplog;
172         GtkWidget *loglength_entry;
173 #if 0
174 #ifdef USE_OPENSSL
175         GtkWidget *checkbtn_ssl_ask_unknown_valid;
176 #endif
177 #endif
178
179         GtkWidget *spinbtn_iotimeout;
180         GtkObject *spinbtn_iotimeout_adj;
181 } other;
182
183 static struct KeybindDialog {
184         GtkWidget *window;
185         GtkWidget *combo;
186 } keybind;
187
188 static void prefs_common_charset_set_data_from_optmenu     (PrefParam *pparam);
189 static void prefs_common_charset_set_optmenu               (PrefParam *pparam);
190 static void prefs_common_encoding_set_data_from_optmenu    (PrefParam *pparam);
191 static void prefs_common_encoding_set_optmenu              (PrefParam *pparam);
192 static void prefs_common_recv_dialog_set_data_from_optmenu (PrefParam *pparam);
193 static void prefs_common_recv_dialog_set_optmenu           (PrefParam *pparam);
194 static void prefs_common_recv_dialog_newmail_notify_toggle_cb   (GtkWidget *w,
195                                                                  gpointer data);
196 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
197 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
198 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam);
199 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam);
200 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam);
201 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam);
202
203 /*
204    parameter name, default value, pointer to the prefs variable, data type,
205    pointer to the widget pointer,
206    pointer to the function for data setting,
207    pointer to the function for widget setting
208  */
209
210 static PrefParam param[] = {
211         /* Receive */
212         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
213          &receive.checkbtn_incext,
214          prefs_set_data_from_toggle, prefs_set_toggle},
215         {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING,
216          &receive.entry_incext,
217          prefs_set_data_from_entry, prefs_set_entry},
218
219         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
220          &receive.checkbtn_autochk,
221          prefs_set_data_from_toggle, prefs_set_toggle},
222         {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT,
223          &receive.spinbtn_autochk,
224          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
225         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
226          &receive.checkbtn_chkonstartup,
227          prefs_set_data_from_toggle, prefs_set_toggle},
228         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
229          P_BOOL, &receive.checkbtn_scan_after_inc,
230          prefs_set_data_from_toggle, prefs_set_toggle},
231         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
232          P_BOOL, &receive.checkbtn_newmail_manu,
233          prefs_set_data_from_toggle, prefs_set_toggle},
234         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
235         P_BOOL, &receive.checkbtn_newmail_auto,
236          prefs_set_data_from_toggle, prefs_set_toggle},
237         {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING,
238          &receive.entry_newmail_notify_cmd,
239          prefs_set_data_from_entry, prefs_set_entry},
240         {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
241          &receive.optmenu_recvdialog,
242          prefs_common_recv_dialog_set_data_from_optmenu,
243          prefs_common_recv_dialog_set_optmenu},
244         {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
245          P_BOOL, &receive.checkbtn_no_recv_err_panel,
246          prefs_set_data_from_toggle, prefs_set_toggle},
247         {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
248          P_BOOL, &receive.checkbtn_close_recv_dialog,
249          prefs_set_data_from_toggle, prefs_set_toggle},
250  
251         /* Send */
252         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
253          &p_send.checkbtn_savemsg,
254          prefs_set_data_from_toggle, prefs_set_toggle},
255         {"send_dialog_mode", "0", &prefs_common.send_dialog_mode, P_ENUM,
256          &p_send.optmenu_senddialog,
257          prefs_common_send_dialog_set_data_from_optmenu,
258          prefs_common_send_dialog_set_optmenu},
259
260         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
261          &p_send.optmenu_charset,
262          prefs_common_charset_set_data_from_optmenu,
263          prefs_common_charset_set_optmenu},
264         {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM,
265          &p_send.optmenu_encoding_method,
266          prefs_common_encoding_set_data_from_optmenu,
267          prefs_common_encoding_set_optmenu},
268
269         {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
270          P_BOOL, NULL, NULL, NULL},
271
272         /* Compose */
273         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
274          &compose.checkbtn_autoextedit,
275          prefs_set_data_from_toggle, prefs_set_toggle},
276         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
277          P_BOOL, &compose.checkbtn_forward_as_attachment,
278          prefs_set_data_from_toggle, prefs_set_toggle},
279         {"redirect_keep_from", "FALSE",
280          &prefs_common.redirect_keep_from, P_BOOL,
281          &compose.checkbtn_redirect_keep_from,
282          prefs_set_data_from_toggle, prefs_set_toggle},
283         {"undo_level", "50", &prefs_common.undolevels, P_INT,
284          &compose.spinbtn_undolevel,
285          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
286
287         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
288          NULL, NULL, NULL},
289         {"linewrap_quotation", "TRUE", &prefs_common.linewrap_quote, P_BOOL,
290          NULL, NULL, NULL},
291         {"linewrap_auto", "TRUE", &prefs_common.autowrap, P_BOOL,
292          NULL, NULL, NULL},
293         {"linewrap_before_sending", "FALSE", &prefs_common.linewrap_at_send, P_BOOL, 
294          NULL, NULL, NULL},
295         {"autosave", "FALSE", &prefs_common.autosave,
296          P_BOOL, &compose.checkbtn_autosave,
297          prefs_set_data_from_toggle, prefs_set_toggle},
298         {"autosave_length", "50", &prefs_common.autosave_length,
299          P_INT, &compose.entry_autosave_length,
300          prefs_set_data_from_entry, prefs_set_entry},
301 #if USE_ASPELL
302         {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL,
303          NULL, NULL, NULL},
304         {"aspell_path", ASPELL_PATH, &prefs_common.aspell_path, P_STRING,
305          NULL, NULL, NULL},
306         {"dictionary",  "", &prefs_common.dictionary, P_STRING,
307          NULL, NULL, NULL},
308         {"aspell_sugmode", "1", &prefs_common.aspell_sugmode, P_INT,
309          NULL, NULL, NULL},
310         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL,
311          NULL, NULL, NULL},
312         {"check_while_typing", "TRUE", &prefs_common.check_while_typing, P_BOOL,
313          NULL, NULL, NULL},
314         {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_COLOR,
315          NULL, NULL, NULL},
316 #endif
317         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
318          &compose.checkbtn_reply_with_quote, prefs_set_data_from_toggle, prefs_set_toggle},
319
320         /* Account autoselection */
321         {"reply_account_autoselect", "TRUE",
322          &prefs_common.reply_account_autosel, P_BOOL,
323          &compose.checkbtn_reply_account_autosel,
324          prefs_set_data_from_toggle, prefs_set_toggle},
325         {"forward_account_autoselect", "TRUE",
326          &prefs_common.forward_account_autosel, P_BOOL,
327          &compose.checkbtn_forward_account_autosel,
328          prefs_set_data_from_toggle, prefs_set_toggle},
329         {"reedit_account_autoselect", "TRUE",
330          &prefs_common.reedit_account_autosel, P_BOOL,
331          &compose.checkbtn_reedit_account_autosel,
332          prefs_set_data_from_toggle, prefs_set_toggle},
333
334         {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
335          &compose.checkbtn_default_reply_list,
336          prefs_set_data_from_toggle, prefs_set_toggle},
337
338         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
339          NULL, NULL, NULL},
340
341         /* Quote */
342         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
343          &quote.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry},
344         {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q",
345          &prefs_common.quotefmt, P_STRING, &quote.text_quotefmt,
346          prefs_set_data_from_text, prefs_set_text},
347
348         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
349          &quote.entry_fw_quotemark,
350          prefs_set_data_from_entry, prefs_set_entry},
351         {"forward_quote_format",
352          "\\n\\nBegin forwarded message:\\n\\n"
353          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
354          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M",
355          &prefs_common.fw_quotefmt, P_STRING, &quote.text_fw_quotefmt,
356          prefs_set_data_from_text, prefs_set_text},
357         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
358          &quote.entry_quote_chars, prefs_set_data_from_entry, prefs_set_entry},
359
360         /* Display */
361         /* Obsolete fonts. For coexisting with Gtk+-1.2 version */
362         {"widget_font",         NULL,
363           &prefs_common.widgetfont_gtk1,        P_STRING, NULL, NULL, NULL},
364         {"message_font",        "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
365          &prefs_common.textfont_gtk1,           P_STRING, NULL, NULL, NULL},
366         {"small_font",          "-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*",
367           &prefs_common.smallfont_gtk1,         P_STRING, NULL, NULL, NULL},
368         {"bold_font",           "-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*",
369           &prefs_common.boldfont_gtk1,          P_STRING, NULL, NULL, NULL},
370         {"normal_font",         "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*",
371           &prefs_common.normalfont_gtk1,        P_STRING, NULL, NULL, NULL},
372
373         /* new fonts */
374         {"widget_font_gtk2",    NULL,
375           &prefs_common.widgetfont,             P_STRING, NULL, NULL, NULL},
376         {"message_font_gtk2",   "fixed 9",
377          &prefs_common.textfont,                P_STRING, NULL, NULL, NULL},
378         {"small_font_gtk2",     "Sans 9",
379           &prefs_common.smallfont,              P_STRING, NULL, NULL, NULL},
380         {"bold_font_gtk2",      "Sans Bold 9",
381           &prefs_common.boldfont,               P_STRING, NULL, NULL, NULL},
382         {"normal_font_gtk2",    "Sans 9", 
383           &prefs_common.normalfont,             P_STRING, NULL, NULL, NULL},
384
385         {"display_folder_unread_num", "TRUE",
386          &prefs_common.display_folder_unread, P_BOOL,
387          &display.chkbtn_folder_unread,
388          prefs_set_data_from_toggle, prefs_set_toggle},
389         {"newsgroup_abbrev_len", "16",
390          &prefs_common.ng_abbrev_len, P_INT,
391          &display.spinbtn_ng_abbrev_len,
392          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
393
394         {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
395          &display.chkbtn_transhdr,
396          prefs_set_data_from_toggle, prefs_set_toggle},
397
398         /* Display: Summary View */
399         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
400          &display.chkbtn_swapfrom,
401          prefs_set_data_from_toggle, prefs_set_toggle},
402         {"use_address_book", "TRUE", &prefs_common.use_addr_book, P_BOOL,
403          &display.chkbtn_useaddrbook,
404          prefs_set_data_from_toggle, prefs_set_toggle},
405         {"thread_by_subject", "TRUE", &prefs_common.thread_by_subject, P_BOOL,
406          &display.chkbtn_threadsubj,
407          prefs_set_data_from_toggle, prefs_set_toggle},
408         {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
409          P_STRING, &display.entry_datefmt,
410          prefs_set_data_from_entry, prefs_set_entry},
411
412         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
413          NULL, NULL, NULL},
414         {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
415          NULL, NULL, NULL},
416         {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
417         P_INT, NULL, NULL, NULL },
418
419         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
420          NULL, NULL, NULL},
421         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
422          NULL, NULL, NULL},
423         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
424          NULL, NULL, NULL},
425         {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
426          NULL, NULL, NULL},
427
428         {"folderview_vscrollbar_policy", "0",
429          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
430          NULL, NULL, NULL},
431
432         {"summary_col_show_mark", "TRUE",
433          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
434         {"summary_col_show_unread", "TRUE",
435          &prefs_common.summary_col_visible[S_COL_STATUS], P_BOOL, NULL, NULL, NULL},
436         {"summary_col_show_mime", "TRUE",
437          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
438         {"summary_col_show_subject", "TRUE",
439          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
440         {"summary_col_show_from", "TRUE",
441          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
442         {"summary_col_show_date", "TRUE",
443          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
444         {"summary_col_show_size", "TRUE",
445          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
446         {"summary_col_show_number", "FALSE",
447          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
448         {"summary_col_show_score", "FALSE",
449          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
450         {"summary_col_show_locked", "FALSE",
451          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
452
453         {"summary_col_pos_mark", "0",
454           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
455         {"summary_col_pos_unread", "1",
456           &prefs_common.summary_col_pos[S_COL_STATUS], P_INT, NULL, NULL, NULL},
457         {"summary_col_pos_mime", "2",
458           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
459         {"summary_col_pos_subject", "3",
460           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
461         {"summary_col_pos_from", "4",
462           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
463         {"summary_col_pos_date", "5",
464           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
465         {"summary_col_pos_size", "6",
466           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
467         {"summary_col_pos_number", "7",
468           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
469         {"summary_col_pos_score", "8",
470          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
471         {"summary_col_pos_locked", "9",
472          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
473
474         {"summary_col_size_mark", "10",
475          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
476         {"summary_col_size_unread", "13",
477          &prefs_common.summary_col_size[S_COL_STATUS], P_INT, NULL, NULL, NULL},
478         {"summary_col_size_mime", "10",
479          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
480         {"summary_col_size_subject", "200",
481          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
482         {"summary_col_size_from", "120",
483          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
484         {"summary_col_size_date", "118",
485          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
486         {"summary_col_size_size", "45",
487          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
488         {"summary_col_size_number", "40",
489          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
490         {"summary_col_size_score", "40",
491          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
492         {"summary_col_size_locked", "13",
493          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
494
495         /* Widget size */
496         {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT,
497          NULL, NULL, NULL},
498         {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT,
499          NULL, NULL, NULL},
500         {"folderview_width", "179", &prefs_common.folderview_width, P_INT,
501          NULL, NULL, NULL},
502         {"folderview_height", "450", &prefs_common.folderview_height, P_INT,
503          NULL, NULL, NULL},
504         {"folderview_visible", "TRUE", &prefs_common.folderview_visible, P_BOOL,
505          NULL, NULL, NULL},
506
507         {"folder_col_folder", "150", &prefs_common.folder_col_folder, P_INT,
508          NULL, NULL, NULL},
509         {"folder_col_new", "32", &prefs_common.folder_col_new, P_INT,
510          NULL, NULL, NULL},
511         {"folder_col_unread", "32", &prefs_common.folder_col_unread, P_INT,
512          NULL, NULL, NULL},
513         {"folder_col_total", "32", &prefs_common.folder_col_total, P_INT,
514          NULL, NULL, NULL},
515
516         {"summaryview_width", "600", &prefs_common.summaryview_width, P_INT,
517          NULL, NULL, NULL},
518         {"summaryview_height", "157", &prefs_common.summaryview_height, P_INT,
519          NULL, NULL, NULL},
520
521         {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT,
522          NULL, NULL, NULL},
523         {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT,
524          NULL, NULL, NULL},
525         {"messageview_width", "600", &prefs_common.msgview_width, P_INT,
526          NULL, NULL, NULL},
527         {"messageview_height", "300", &prefs_common.msgview_height, P_INT,
528          NULL, NULL, NULL},
529         {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL,
530          NULL, NULL, NULL},
531
532         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
533          NULL, NULL, NULL},
534         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
535          NULL, NULL, NULL},
536         {"mainview_width", "600", &prefs_common.mainview_width, P_INT,
537          NULL, NULL, NULL},
538         {"mainview_height", "600", &prefs_common.mainview_height, P_INT,
539          NULL, NULL, NULL},
540         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
541          NULL, NULL, NULL},
542         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
543          NULL, NULL, NULL},
544         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
545          NULL, NULL, NULL},
546         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
547          NULL, NULL, NULL},
548         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
549          NULL, NULL, NULL},
550         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
551          NULL, NULL, NULL},
552         {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT,
553          NULL, NULL, NULL},
554         {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT,
555          NULL, NULL, NULL},
556         {"compose_width", "600", &prefs_common.compose_width, P_INT,
557          NULL, NULL, NULL},
558         {"compose_height", "560", &prefs_common.compose_height, P_INT,
559          NULL, NULL, NULL},
560         {"compose_x", "0", &prefs_common.compose_x, P_INT,
561          NULL, NULL, NULL},
562         {"compose_y", "0", &prefs_common.compose_y, P_INT,
563          NULL, NULL, NULL},
564         /* Message */
565         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
566          NULL, NULL, NULL},
567
568         {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_COLOR,
569          NULL, NULL, NULL},
570         {"quote_level2_color", "179", &prefs_common.quote_level2_col, P_COLOR,
571          NULL, NULL, NULL},
572         {"quote_level3_color", "179", &prefs_common.quote_level3_col, P_COLOR,
573          NULL, NULL, NULL},
574         {"uri_color", "32512", &prefs_common.uri_col, P_COLOR,
575          NULL, NULL, NULL},
576         {"target_folder_color", "14294218", &prefs_common.tgt_folder_col, P_COLOR,
577          NULL, NULL, NULL},
578         {"signature_color", "7960953", &prefs_common.signature_col, P_COLOR,
579          NULL, NULL, NULL},
580         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
581          P_BOOL, NULL, NULL, NULL},
582
583         {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL,
584          &message.chkbtn_mbalnum,
585          prefs_set_data_from_toggle, prefs_set_toggle},
586         {"display_header_pane", "TRUE", &prefs_common.display_header_pane,
587          P_BOOL, &message.chkbtn_disphdrpane,
588          prefs_set_data_from_toggle, prefs_set_toggle},
589         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
590          &message.chkbtn_disphdr,
591          prefs_set_data_from_toggle, prefs_set_toggle},
592         {"line_space", "2", &prefs_common.line_space, P_INT,
593          &message.spinbtn_linespc,
594          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
595         {"enable_head_space", "FALSE", &prefs_common.head_space, P_BOOL,
596          &message.chkbtn_headspc,
597          prefs_set_data_from_toggle, prefs_set_toggle},
598
599         {"enable_smooth_scroll", "FALSE",
600          &prefs_common.enable_smooth_scroll, P_BOOL,
601          &message.chkbtn_smoothscroll,
602          prefs_set_data_from_toggle, prefs_set_toggle},
603         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
604          &message.spinbtn_scrollstep,
605          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
606         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
607          &message.chkbtn_halfpage,
608          prefs_set_data_from_toggle, prefs_set_toggle},
609
610         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
611          NULL, NULL, NULL},
612
613         {"attach_desc", "TRUE", &prefs_common.attach_desc, P_BOOL,
614          &message.chkbtn_attach_desc,
615          prefs_set_data_from_toggle, prefs_set_toggle},
616         {"attach_save_directory", NULL,
617          &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL},
618
619         /* MIME viewer */
620         {"mime_image_viewer", "display '%s'",
621          &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
622         {"mime_audio_player", "play '%s'",
623          &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
624         {"mime_open_command", "gedit '%s'",
625          &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
626
627         /* Interface */
628         {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
629          NULL, NULL, NULL},
630         {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL,
631          NULL, NULL, NULL},
632
633         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
634          NULL, NULL, NULL}, */
635         {"always_show_message_when_selected", "FALSE",
636          &prefs_common.always_show_msg,
637          P_BOOL, &interface.checkbtn_always_show_msg,
638          prefs_set_data_from_toggle, prefs_set_toggle},
639         {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter,
640          P_BOOL, &interface.checkbtn_openunread,
641          prefs_set_data_from_toggle, prefs_set_toggle},
642         {"mark_as_read_on_new_window", "FALSE",
643          &prefs_common.mark_as_read_on_new_window,
644          P_BOOL, &interface.checkbtn_mark_as_read_on_newwin,
645          prefs_set_data_from_toggle, prefs_set_toggle},
646         {"mark_as_read_delay", "0",
647          &prefs_common.mark_as_read_delay, P_INT, 
648          NULL, NULL, NULL},
649         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
650          P_BOOL, &interface.checkbtn_openinbox,
651          prefs_set_data_from_toggle, prefs_set_toggle},
652         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
653          &interface.checkbtn_immedexec,
654          prefs_set_data_from_toggle, prefs_set_toggle},
655         {"nextunreadmsg_dialog", NULL, &prefs_common.next_unread_msg_dialog, P_ENUM,
656          &interface.optmenu_nextunreadmsgdialog,
657          prefs_nextunreadmsgdialog_set_data_from_optmenu,
658          prefs_nextunreadmsgdialog_set_optmenu},
659
660         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
661          &prefs_common.pixmap_theme_path, P_STRING,
662          NULL, NULL, NULL},
663
664         {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
665          NULL, NULL, NULL},
666         
667         /* Other */
668         {"uri_open_command", DEFAULT_BROWSER_CMD,
669          &prefs_common.uri_cmd, P_STRING, NULL, NULL, NULL},
670         {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING,
671          NULL, NULL, NULL},
672         {"ext_editor_command", "gedit %s",
673          &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
674
675         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
676          P_BOOL, &other.checkbtn_addaddrbyclick,
677          prefs_set_data_from_toggle, prefs_set_toggle},
678
679         {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
680          &other.checkbtn_confonexit,
681          prefs_set_data_from_toggle, prefs_set_toggle},
682         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
683          &other.checkbtn_cleanonexit,
684          prefs_set_data_from_toggle, prefs_set_toggle},
685         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
686          &other.checkbtn_askonclean,
687          prefs_set_data_from_toggle, prefs_set_toggle},
688         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
689          P_BOOL, &other.checkbtn_warnqueued,
690          prefs_set_data_from_toggle, prefs_set_toggle},
691 #if 0
692 #ifdef USE_OPENSSL
693         {"ssl_ask_unknown_valid", "TRUE", &prefs_common.ssl_ask_unknown_valid,
694          P_BOOL, &other.checkbtn_ssl_ask_unknown_valid,
695          prefs_set_data_from_toggle, prefs_set_toggle},
696 #endif
697 #endif
698         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
699          NULL, NULL, NULL},
700         {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
701          NULL, NULL, NULL},
702         {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
703          NULL, NULL, NULL},
704
705         {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
706          P_INT, &other.spinbtn_iotimeout,
707          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
708         {"hide_score", "-9999", &prefs_common.kill_score, P_INT,
709          NULL, NULL, NULL},
710         {"important_score", "1", &prefs_common.important_score, P_INT,
711          NULL, NULL, NULL},
712         {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
713          &other.checkbtn_cliplog,
714          prefs_set_data_from_toggle, prefs_set_toggle},
715         {"log_length", "500", &prefs_common.loglength, P_INT,
716          &other.loglength_entry,
717          prefs_set_data_from_entry, prefs_set_entry},
718
719         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
720          NULL, NULL, NULL},
721         {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
722          NULL, NULL, NULL},
723
724         {"color_new", "179", &prefs_common.color_new, P_COLOR,
725          NULL, NULL, NULL},
726
727         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
728 };
729
730 /* widget creating functions */
731 static void prefs_common_create         (void);
732 static void prefs_receive_create        (void);
733 static void prefs_send_create           (void);
734 static void prefs_compose_create        (void);
735 static void prefs_quote_create          (void);
736 static void prefs_display_create        (void);
737 static void prefs_message_create        (void);
738 static void prefs_interface_create      (void);
739 static void prefs_other_create          (void);
740
741 static void date_format_ok_btn_clicked          (GtkButton      *button,
742                                                  GtkWidget     **widget);
743 static void date_format_cancel_btn_clicked      (GtkButton      *button,
744                                                  GtkWidget     **widget);
745 static gboolean date_format_key_pressed         (GtkWidget      *keywidget,
746                                                  GdkEventKey    *event,
747                                                  GtkWidget     **widget);
748 static gboolean date_format_on_delete           (GtkWidget      *dialogwidget,
749                                                  GdkEventAny    *event,
750                                                  GtkWidget     **widget);
751 static void date_format_entry_on_change         (GtkEditable    *editable,
752                                                  GtkLabel       *example);
753 static void date_format_select_row              (GtkWidget      *date_format_list,
754                                                  gint            row,
755                                                  gint            column,
756                                                  GdkEventButton *event,
757                                                  GtkWidget      *date_format);
758 static GtkWidget *date_format_create            (GtkButton      *button,
759                                                  void           *data);
760
761 static void prefs_keybind_select                (void);
762 static gint prefs_keybind_deleted               (GtkWidget      *widget,
763                                                  GdkEventAny    *event,
764                                                  gpointer        data);
765 static gboolean prefs_keybind_key_pressed       (GtkWidget      *widget,
766                                                  GdkEventKey    *event,
767                                                  gpointer        data);
768 static void prefs_keybind_cancel                (void);
769 static void prefs_keybind_apply_clicked         (GtkWidget      *widget);
770
771 static gint prefs_common_deleted        (GtkWidget      *widget,
772                                          GdkEventAny    *event,
773                                          gpointer        data);
774 static gboolean prefs_common_key_pressed(GtkWidget      *widget,
775                                          GdkEventKey    *event,
776                                          gpointer        data);
777 static void prefs_common_ok             (void);
778 static void prefs_common_apply          (void);
779 static void prefs_common_cancel         (void);
780
781 void prefs_common_init(void) 
782 {
783         prefs_common.disphdr_list = NULL;
784 }
785
786 PrefsCommon *prefs_common_get(void)
787 {
788         return &prefs_common;
789 }
790
791 /*
792  * Read history list from the specified history file
793  */
794 GList *prefs_common_read_history(const gchar *history) 
795 {
796         FILE *fp;
797         gchar *path;
798         gchar buf[PREFSBUFSIZE];
799         GList *tmp = NULL;
800
801         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
802                            NULL);
803         if ((fp = fopen(path, "rb")) == NULL) {
804                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
805                 g_free(path);
806                 return NULL;
807         }
808         g_free(path);
809         while (fgets(buf, sizeof(buf), fp) != NULL) {
810                 g_strstrip(buf);
811                 if (buf[0] == '\0') continue;
812                 tmp = add_history(tmp, buf);
813         }
814         fclose(fp);
815
816         tmp = g_list_reverse(tmp);
817
818         return tmp;
819 }
820
821 void prefs_common_read_config(void)
822 {
823         prefs_read_config(param, "Common", COMMON_RC);
824
825         prefs_common.mime_open_cmd_history =
826                 prefs_common_read_history(COMMAND_HISTORY);
827         prefs_common.summary_quicksearch_history =
828                 prefs_common_read_history(QUICKSEARCH_HISTORY);
829 }
830
831 /*
832  * Save history list to the specified history file
833  */
834 void prefs_common_save_history(const gchar *history, GList *list)
835 {
836         GList *cur;
837         FILE *fp;
838         gchar *path;
839
840         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
841                            NULL);
842         if ((fp = fopen(path, "wb")) == NULL) {
843                 FILE_OP_ERROR(path, "fopen");
844                 g_free(path);
845                 return;
846         }
847
848         for (cur = list; cur != NULL; cur = cur->next) {
849                 fputs((gchar *)cur->data, fp);
850                 fputc('\n', fp);
851         }
852
853         fclose(fp);
854         g_free(path);
855 }
856
857 void prefs_common_write_config(void)
858 {
859         prefs_write_config(param, "Common", COMMON_RC);
860
861         prefs_common_save_history(COMMAND_HISTORY, 
862                 prefs_common.mime_open_cmd_history);
863         prefs_common_save_history(QUICKSEARCH_HISTORY, 
864                 prefs_common.summary_quicksearch_history);
865 }
866
867 void prefs_common_open(void)
868 {
869         if (prefs_rc_is_readonly(COMMON_RC))
870                 return;
871
872         inc_lock();
873
874         if (!dialog.window) {
875                 prefs_common_create();
876         }
877
878         manage_window_set_transient(GTK_WINDOW(dialog.window));
879         gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
880         gtk_widget_grab_focus(dialog.ok_btn);
881
882         prefs_set_dialog(param);
883
884         gtk_widget_show(dialog.window);
885 }
886
887 static void prefs_common_create(void)
888 {
889         gint page = 0;
890
891         debug_print("Creating common preferences window...\n");
892
893         prefs_dialog_create(&dialog);
894         gtk_window_set_title (GTK_WINDOW(dialog.window),
895                               _("Common Preferences"));
896         g_signal_connect (G_OBJECT(dialog.window), "delete_event",
897                           G_CALLBACK(prefs_common_deleted), NULL);
898         g_signal_connect (G_OBJECT(dialog.window), "key_press_event",
899                           G_CALLBACK(prefs_common_key_pressed), NULL);
900         MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
901
902         g_signal_connect (G_OBJECT(dialog.ok_btn), "clicked",
903                           G_CALLBACK(prefs_common_ok), NULL);
904         g_signal_connect (G_OBJECT(dialog.apply_btn), "clicked",
905                           G_CALLBACK(prefs_common_apply), NULL);
906         g_signal_connect_swapped(G_OBJECT(dialog.cancel_btn), "clicked",
907                                  G_CALLBACK(prefs_common_cancel),
908                                  G_OBJECT(dialog.window));
909
910         /* create all widgets on notebook */
911         prefs_receive_create();
912         SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"),   page++);
913         prefs_send_create();
914         SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"),      page++);
915         prefs_compose_create();
916         SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"),   page++);
917         prefs_quote_create();
918         SET_NOTEBOOK_LABEL(dialog.notebook, _("Quote"),   page++);
919         prefs_display_create();
920         SET_NOTEBOOK_LABEL(dialog.notebook, _("Display"),   page++);
921         prefs_message_create();
922         SET_NOTEBOOK_LABEL(dialog.notebook, _("Message"),   page++);
923         prefs_interface_create();
924         SET_NOTEBOOK_LABEL(dialog.notebook, _("Interface"), page++);
925         prefs_other_create();
926         SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"),     page++);
927
928         gtk_widget_show_all(dialog.window);
929 }
930
931 static void prefs_receive_create(void)
932 {
933         GtkWidget *vbox1;
934         GtkWidget *vbox2;
935         GtkWidget *frame_incext;
936         GtkWidget *checkbtn_incext;
937         GtkWidget *hbox;
938         GtkWidget *label_incext;
939         GtkWidget *entry_incext;
940         /* GtkWidget *button_incext; */
941
942         GtkWidget *hbox_autochk;
943         GtkWidget *checkbtn_autochk;
944         GtkWidget *label_autochk1;
945         GtkObject *spinbtn_autochk_adj;
946         GtkWidget *spinbtn_autochk;
947         GtkWidget *label_autochk2;
948         GtkWidget *checkbtn_chkonstartup;
949         GtkWidget *checkbtn_scan_after_inc;
950
951
952         GtkWidget *frame_newmail;
953         GtkWidget *hbox_newmail_notify;
954         GtkWidget *checkbtn_newmail_auto;
955         GtkWidget *checkbtn_newmail_manu;
956         GtkWidget *entry_newmail_notify_cmd;
957         GtkWidget *label_newmail_notify_cmd;
958
959         GtkWidget *hbox_recvdialog;
960         GtkWidget *label_recvdialog;
961         GtkWidget *menu;
962         GtkWidget *menuitem;
963         GtkWidget *optmenu_recvdialog;
964         GtkWidget *checkbtn_no_recv_err_panel;
965         GtkWidget *checkbtn_close_recv_dialog;
966
967         vbox1 = gtk_vbox_new (FALSE, VSPACING);
968         gtk_widget_show (vbox1);
969         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
970         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
971
972         PACK_FRAME(vbox1, frame_incext, _("External program"));
973
974         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
975         gtk_widget_show (vbox2);
976         gtk_container_add (GTK_CONTAINER (frame_incext), vbox2);
977         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
978
979         /* Use of external incorporation program */
980         PACK_CHECK_BUTTON (vbox2, checkbtn_incext,
981                            _("Use external program for incorporation"));
982
983         hbox = gtk_hbox_new (FALSE, 8);
984         gtk_widget_show (hbox);
985         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
986         SET_TOGGLE_SENSITIVITY (checkbtn_incext, hbox);
987
988         label_incext = gtk_label_new (_("Command"));
989         gtk_widget_show (label_incext);
990         gtk_box_pack_start (GTK_BOX (hbox), label_incext, FALSE, FALSE, 0);
991
992         entry_incext = gtk_entry_new ();
993         gtk_widget_show (entry_incext);
994         gtk_box_pack_start (GTK_BOX (hbox), entry_incext, TRUE, TRUE, 0);
995
996 #if 0
997         button_incext = gtk_button_new_with_label ("... ");
998         gtk_widget_show (button_incext);
999         gtk_box_pack_start (GTK_BOX (hbox), button_incext, FALSE, FALSE, 0);
1000 #endif
1001
1002         vbox2 = gtk_vbox_new (FALSE, 0);
1003         gtk_widget_show (vbox2);
1004         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1005
1006         /* Auto-checking */
1007         hbox_autochk = gtk_hbox_new (FALSE, 8);
1008         gtk_widget_show (hbox_autochk);
1009         gtk_box_pack_start (GTK_BOX (vbox2), hbox_autochk, FALSE, FALSE, 0);
1010
1011         PACK_CHECK_BUTTON (hbox_autochk, checkbtn_autochk,
1012                            _("Auto-check new mail"));
1013
1014         label_autochk1 = gtk_label_new (_("every"));
1015         gtk_widget_show (label_autochk1);
1016         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk1, FALSE, FALSE, 0);
1017
1018         spinbtn_autochk_adj = gtk_adjustment_new (5, 1, 100, 1, 10, 10);
1019         spinbtn_autochk = gtk_spin_button_new
1020                 (GTK_ADJUSTMENT (spinbtn_autochk_adj), 1, 0);
1021         gtk_widget_show (spinbtn_autochk);
1022         gtk_box_pack_start (GTK_BOX (hbox_autochk), spinbtn_autochk, FALSE, FALSE, 0);
1023         gtk_widget_set_size_request (spinbtn_autochk, 64, -1);
1024         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_autochk), TRUE);
1025
1026         label_autochk2 = gtk_label_new (_("minute(s)"));
1027         gtk_widget_show (label_autochk2);
1028         gtk_box_pack_start (GTK_BOX (hbox_autochk), label_autochk2, FALSE, FALSE, 0);
1029
1030         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk1);
1031         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, spinbtn_autochk);
1032         SET_TOGGLE_SENSITIVITY(checkbtn_autochk, label_autochk2);
1033
1034         PACK_CHECK_BUTTON (vbox2, checkbtn_chkonstartup,
1035                            _("Check new mail on startup"));
1036         PACK_CHECK_BUTTON (vbox2, checkbtn_scan_after_inc,
1037                            _("Update all local folders after incorporation"));
1038
1039
1040         /* receive dialog */
1041         hbox_recvdialog = gtk_hbox_new (FALSE, 8);
1042         gtk_widget_show (hbox_recvdialog);
1043         gtk_box_pack_start (GTK_BOX (vbox2), hbox_recvdialog, FALSE, FALSE, 0);
1044
1045         label_recvdialog = gtk_label_new (_("Show receive dialog"));
1046         gtk_misc_set_alignment(GTK_MISC(label_recvdialog), 0, 0.5);
1047         gtk_widget_show (label_recvdialog);
1048         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), label_recvdialog, FALSE, FALSE, 0);
1049
1050         optmenu_recvdialog = gtk_option_menu_new ();
1051         gtk_widget_show (optmenu_recvdialog);
1052         gtk_box_pack_start (GTK_BOX (hbox_recvdialog), optmenu_recvdialog, FALSE, FALSE, 0);
1053
1054         menu = gtk_menu_new ();
1055         MENUITEM_ADD (menu, menuitem, _("Always"), RECV_DIALOG_ALWAYS);
1056         MENUITEM_ADD (menu, menuitem, _("Only on manual receiving"),
1057                       RECV_DIALOG_MANUAL);
1058         MENUITEM_ADD (menu, menuitem, _("Never"), RECV_DIALOG_NEVER);
1059
1060         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_recvdialog), menu);
1061
1062         PACK_CHECK_BUTTON (vbox2, checkbtn_no_recv_err_panel,
1063                            _("Don't popup error dialog on receive error"));
1064
1065         PACK_CHECK_BUTTON (vbox2, checkbtn_close_recv_dialog,
1066                            _("Close receive dialog when finished"));
1067         
1068         PACK_FRAME(vbox1, frame_newmail, _("Run command when new mail "
1069                                            "arrives"));
1070         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1071         gtk_widget_show (vbox2);
1072         gtk_container_add (GTK_CONTAINER (frame_newmail), vbox2);
1073         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1074
1075         hbox = gtk_hbox_new (TRUE, 8);
1076         gtk_widget_show (hbox);
1077         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_auto,
1078                            _("after autochecking"));
1079         PACK_CHECK_BUTTON (hbox, checkbtn_newmail_manu,
1080                            _("after manual checking"));
1081         gtk_box_pack_start (GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
1082         g_signal_connect(G_OBJECT(checkbtn_newmail_auto), "toggled",
1083                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1084                          NULL);
1085         g_signal_connect(G_OBJECT(checkbtn_newmail_manu), "toggled",
1086                          G_CALLBACK(prefs_common_recv_dialog_newmail_notify_toggle_cb),
1087                          NULL);
1088
1089         hbox_newmail_notify = gtk_hbox_new (FALSE, 8);
1090         gtk_widget_show (hbox);
1091         gtk_box_pack_start (GTK_BOX (vbox2), hbox_newmail_notify, FALSE, 
1092                             FALSE, 0);
1093
1094         label_newmail_notify_cmd = gtk_label_new (_("Command to execute:\n"
1095                                                     "(use %d as number of new "
1096                                                     "mails)"));
1097         gtk_label_set_justify(GTK_LABEL(label_newmail_notify_cmd), 
1098                               GTK_JUSTIFY_RIGHT);
1099         gtk_widget_show (label_newmail_notify_cmd);
1100         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1101                             label_newmail_notify_cmd, FALSE, FALSE, 0);
1102
1103         entry_newmail_notify_cmd = gtk_entry_new ();
1104         gtk_widget_show (entry_newmail_notify_cmd);
1105         gtk_box_pack_start (GTK_BOX (hbox_newmail_notify), 
1106                             entry_newmail_notify_cmd, TRUE, TRUE, 0);
1107
1108         gtk_widget_set_sensitive(hbox_newmail_notify, 
1109                                  prefs_common.newmail_notify_auto || 
1110                                  prefs_common.newmail_notify_manu);
1111
1112         receive.checkbtn_incext = checkbtn_incext;
1113         receive.entry_incext    = entry_incext;
1114         /* receive.button_incext   = button_incext; */
1115
1116         receive.checkbtn_autochk    = checkbtn_autochk;
1117         receive.spinbtn_autochk     = spinbtn_autochk;
1118         receive.spinbtn_autochk_adj = spinbtn_autochk_adj;
1119
1120         receive.checkbtn_chkonstartup = checkbtn_chkonstartup;
1121         receive.checkbtn_scan_after_inc = checkbtn_scan_after_inc;
1122
1123
1124         receive.checkbtn_newmail_auto  = checkbtn_newmail_auto;
1125         receive.checkbtn_newmail_manu  = checkbtn_newmail_manu;
1126         receive.hbox_newmail_notify    = hbox_newmail_notify;
1127         receive.entry_newmail_notify_cmd = entry_newmail_notify_cmd;
1128         receive.optmenu_recvdialog          = optmenu_recvdialog;
1129         receive.checkbtn_no_recv_err_panel  = checkbtn_no_recv_err_panel;
1130         receive.checkbtn_close_recv_dialog  = checkbtn_close_recv_dialog;
1131 }
1132
1133 static void prefs_send_create(void)
1134 {
1135         GtkWidget *vbox1;
1136         GtkWidget *vbox2;
1137         GtkWidget *hbox1;
1138         GtkWidget *checkbtn_savemsg;
1139         GtkWidget *label_outcharset;
1140         GtkWidget *optmenu_charset;
1141         GtkWidget *optmenu_menu;
1142         GtkWidget *menuitem;
1143         GtkTooltips *charset_tooltip;
1144         GtkWidget *optmenu_encoding;
1145         GtkWidget *label_encoding;
1146         GtkTooltips *encoding_tooltip;
1147         GtkWidget *label_senddialog;
1148         GtkWidget *menu;
1149         GtkWidget *optmenu_senddialog;
1150         GtkWidget *hbox_senddialog;
1151
1152         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1153         gtk_widget_show (vbox1);
1154         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1155         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1156
1157         vbox2 = gtk_vbox_new (FALSE, 0);
1158         gtk_widget_show (vbox2);
1159         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1160
1161         PACK_CHECK_BUTTON (vbox2, checkbtn_savemsg,
1162                            _("Save sent messages to Sent folder"));
1163
1164         hbox_senddialog = gtk_hbox_new (FALSE, 8);
1165         gtk_box_pack_start (GTK_BOX (vbox1), hbox_senddialog, FALSE, FALSE, 0);
1166
1167         label_senddialog = gtk_label_new (_("Show send dialog"));
1168         gtk_widget_show (label_senddialog);
1169         gtk_box_pack_start (GTK_BOX (hbox_senddialog), label_senddialog, FALSE, FALSE, 0);
1170
1171         optmenu_senddialog = gtk_option_menu_new ();
1172         gtk_widget_show (optmenu_senddialog);
1173         gtk_box_pack_start (GTK_BOX (hbox_senddialog), optmenu_senddialog, FALSE, FALSE, 0);
1174         
1175         menu = gtk_menu_new ();
1176         MENUITEM_ADD (menu, menuitem, _("Always"), SEND_DIALOG_ALWAYS);
1177         MENUITEM_ADD (menu, menuitem, _("Never"), SEND_DIALOG_NEVER);
1178
1179         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_senddialog), menu);
1180
1181         hbox1 = gtk_hbox_new (FALSE, 8);
1182         gtk_widget_show (hbox1);
1183         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1184
1185         label_outcharset = gtk_label_new (_("Outgoing codeset"));
1186         gtk_widget_show (label_outcharset);
1187         gtk_box_pack_start (GTK_BOX (hbox1), label_outcharset, FALSE, FALSE, 0);
1188
1189         charset_tooltip = gtk_tooltips_new();
1190
1191         optmenu_charset = gtk_option_menu_new ();
1192         gtk_widget_show (optmenu_charset);
1193         gtk_tooltips_set_tip(GTK_TOOLTIPS(charset_tooltip), optmenu_charset,
1194                              _("If `Automatic' is selected, the optimal encoding"
1195                                " for the current locale will be used"),
1196                              NULL);
1197         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_charset, FALSE, FALSE, 0);
1198
1199         optmenu_menu = gtk_menu_new ();
1200
1201 #define SET_MENUITEM(str, data) \
1202 { \
1203         MENUITEM_ADD(optmenu_menu, menuitem, str, data); \
1204 }
1205
1206         SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
1207         SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
1208 #if HAVE_ICONV
1209         SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
1210 #endif
1211         SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
1212         SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
1213         SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
1214         SET_MENUITEM(_("Baltic (ISO-8859-13)"),           CS_ISO_8859_13);
1215         SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
1216         SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
1217         SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
1218 #if HAVE_ICONV
1219         SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
1220 #endif
1221         SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
1222 #if HAVE_ICONV
1223         SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
1224         SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
1225 #endif
1226         SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
1227 #if 0
1228         SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
1229         SET_MENUITEM(_("Japanese (Shift_JIS)"),          CS_SHIFT_JIS);
1230 #endif /* 0 */
1231         SET_MENUITEM(_("Simplified Chinese (GB2312)"),   CS_GB2312);
1232         SET_MENUITEM(_("Traditional Chinese (Big5)"),    CS_BIG5);
1233 #if 0
1234         SET_MENUITEM(_("Traditional Chinese (EUC-TW)"),  CS_EUC_TW);
1235         SET_MENUITEM(_("Chinese (ISO-2022-CN)"),         CS_ISO_2022_CN);
1236 #endif /* 0 */
1237         SET_MENUITEM(_("Korean (EUC-KR)"),               CS_EUC_KR);
1238         SET_MENUITEM(_("Thai (TIS-620)"),                CS_TIS_620);
1239         SET_MENUITEM(_("Thai (Windows-874)"),            CS_WINDOWS_874);
1240
1241         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_charset),
1242                                   optmenu_menu);
1243
1244         hbox1 = gtk_hbox_new (FALSE, 8);
1245         gtk_widget_show (hbox1);
1246         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1247
1248         hbox1 = gtk_hbox_new (FALSE, 8);
1249         gtk_widget_show (hbox1);
1250         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1251
1252         label_encoding = gtk_label_new (_("Transfer encoding"));
1253         gtk_widget_show (label_encoding);
1254         gtk_box_pack_start (GTK_BOX (hbox1), label_encoding, FALSE, FALSE, 0);
1255
1256         encoding_tooltip = gtk_tooltips_new();
1257
1258         optmenu_encoding = gtk_option_menu_new ();
1259         gtk_widget_show (optmenu_encoding);
1260         gtk_tooltips_set_tip(GTK_TOOLTIPS(encoding_tooltip), optmenu_encoding,
1261                              _("Specify Content-Transfer-Encoding used when"
1262                                " message body contains non-ASCII characters"),
1263                              NULL);
1264         gtk_box_pack_start (GTK_BOX (hbox1), optmenu_encoding, FALSE, FALSE, 0);
1265
1266         optmenu_menu = gtk_menu_new ();
1267
1268         SET_MENUITEM(_("Automatic"),     CTE_AUTO);
1269         SET_MENUITEM("base64",           CTE_BASE64);
1270         SET_MENUITEM("quoted-printable", CTE_QUOTED_PRINTABLE);
1271         SET_MENUITEM("8bit",             CTE_8BIT);
1272
1273         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_encoding),
1274                                   optmenu_menu);
1275
1276         hbox1 = gtk_hbox_new (FALSE, 8);
1277         gtk_widget_show (hbox1);
1278         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1279
1280         p_send.checkbtn_savemsg  = checkbtn_savemsg;
1281         p_send.optmenu_senddialog = optmenu_senddialog;
1282
1283         p_send.optmenu_charset = optmenu_charset;
1284         p_send.optmenu_encoding_method = optmenu_encoding;
1285 }
1286
1287 static void prefs_common_recv_dialog_newmail_notify_toggle_cb(GtkWidget *w, gpointer data)
1288 {
1289         gboolean toggled;
1290
1291         toggled = gtk_toggle_button_get_active
1292                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_manu)) ||
1293                   gtk_toggle_button_get_active
1294                         (GTK_TOGGLE_BUTTON(receive.checkbtn_newmail_auto));
1295         gtk_widget_set_sensitive(receive.hbox_newmail_notify, toggled);
1296 }
1297
1298 static void prefs_compose_create(void)
1299 {
1300         GtkWidget *vbox1;
1301         GtkWidget *vbox2;
1302
1303         GtkWidget *checkbtn_autoextedit;
1304
1305         GtkWidget *frame_autosel;
1306         GtkWidget *hbox_autosel;
1307         GtkWidget *checkbtn_reply_account_autosel;
1308         GtkWidget *checkbtn_forward_account_autosel;
1309         GtkWidget *checkbtn_reedit_account_autosel;
1310
1311         GtkWidget *hbox_undolevel;
1312         GtkWidget *label_undolevel;
1313         GtkObject *spinbtn_undolevel_adj;
1314         GtkWidget *spinbtn_undolevel;
1315
1316         GtkWidget *hbox5;
1317
1318         GtkWidget *checkbtn_default_reply_list;
1319
1320         GtkWidget *checkbtn_forward_as_attachment;
1321         GtkWidget *checkbtn_redirect_keep_from;
1322
1323         GtkWidget *hbox_autosave;
1324         GtkWidget *checkbtn_autosave;
1325         GtkWidget *entry_autosave_length;
1326         GtkWidget *label_autosave_length;
1327         
1328         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1329         gtk_widget_show (vbox1);
1330         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1331         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1332
1333         /* Account autoselection */
1334         PACK_FRAME(vbox1, frame_autosel, _("Automatic account selection"));
1335
1336         hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
1337         gtk_widget_show (hbox_autosel);
1338         gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
1339         gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
1340
1341         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
1342                            _("when replying"));
1343         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
1344                            _("when forwarding"));
1345         PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
1346                            _("when re-editing"));
1347
1348         vbox2 = gtk_vbox_new (FALSE, 0);
1349         gtk_widget_show (vbox2);
1350         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1351
1352         PACK_CHECK_BUTTON (vbox2, checkbtn_default_reply_list,
1353                            _("Reply button invokes mailing list reply"));
1354
1355         PACK_CHECK_BUTTON (vbox2, checkbtn_autoextedit,
1356                            _("Automatically launch the external editor"));
1357
1358         hbox5 = gtk_hbox_new (FALSE, 8);
1359         gtk_widget_show (hbox5);
1360         gtk_box_pack_start (GTK_BOX (vbox2), hbox5, FALSE, FALSE, 0);
1361
1362         PACK_CHECK_BUTTON (hbox5, checkbtn_forward_as_attachment,
1363                            _("Forward as attachment"));
1364
1365         PACK_CHECK_BUTTON (vbox2, checkbtn_redirect_keep_from,
1366                            _("Keep the original 'From' header when redirecting"));
1367
1368         
1369         hbox_autosave = gtk_hbox_new (FALSE, 8);
1370         gtk_widget_show (hbox_autosave);
1371         gtk_box_pack_start (GTK_BOX (vbox1), hbox_autosave, FALSE, FALSE, 0);
1372         
1373         PACK_CHECK_BUTTON (hbox_autosave, checkbtn_autosave,
1374                            _("Autosave to Drafts folder every "));
1375
1376         entry_autosave_length = gtk_entry_new();
1377         gtk_widget_set_size_request (entry_autosave_length, 64, -1);    
1378         gtk_widget_show (entry_autosave_length);
1379         gtk_box_pack_start (GTK_BOX (hbox_autosave), entry_autosave_length, FALSE, FALSE, 0);
1380         
1381         label_autosave_length = gtk_label_new(_("characters"));
1382         gtk_widget_show (label_autosave_length);
1383         gtk_box_pack_start (GTK_BOX (hbox_autosave), label_autosave_length, FALSE, FALSE, 0);
1384         
1385         hbox_undolevel = gtk_hbox_new (FALSE, 8);
1386         gtk_widget_show (hbox_undolevel);
1387         gtk_box_pack_start (GTK_BOX (vbox1), hbox_undolevel, FALSE, FALSE, 0);
1388
1389         label_undolevel = gtk_label_new (_("Undo level"));
1390         gtk_widget_show (label_undolevel);
1391         gtk_box_pack_start (GTK_BOX (hbox_undolevel), label_undolevel, FALSE, FALSE, 0);
1392
1393         spinbtn_undolevel_adj = gtk_adjustment_new (50, 0, 100, 1, 10, 10);
1394         spinbtn_undolevel = gtk_spin_button_new
1395                 (GTK_ADJUSTMENT (spinbtn_undolevel_adj), 1, 0);
1396         gtk_widget_show (spinbtn_undolevel);
1397         gtk_box_pack_start (GTK_BOX (hbox_undolevel), spinbtn_undolevel, FALSE, FALSE, 0);
1398         gtk_widget_set_size_request (spinbtn_undolevel, 64, -1);
1399         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_undolevel), TRUE);
1400
1401        /*
1402         compose.checkbtn_quote   = checkbtn_quote;
1403         compose.entry_quotemark  = entry_quotemark;
1404         compose.text_quotefmt    = text_quotefmt;
1405         */
1406
1407         compose.checkbtn_autoextedit = checkbtn_autoextedit;
1408
1409         compose.checkbtn_reply_account_autosel   = checkbtn_reply_account_autosel;
1410         compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
1411         compose.checkbtn_reedit_account_autosel  = checkbtn_reedit_account_autosel;
1412
1413         compose.spinbtn_undolevel     = spinbtn_undolevel;
1414         compose.spinbtn_undolevel_adj = spinbtn_undolevel_adj;
1415
1416         compose.checkbtn_autosave     = checkbtn_autosave;
1417         compose.entry_autosave_length = entry_autosave_length;
1418         
1419         compose.checkbtn_forward_as_attachment =
1420                 checkbtn_forward_as_attachment;
1421         compose.checkbtn_redirect_keep_from =
1422                 checkbtn_redirect_keep_from;
1423         compose.checkbtn_default_reply_list = checkbtn_default_reply_list;
1424 }
1425
1426 static void prefs_quote_create(void)
1427 {
1428         GtkWidget *vbox1;
1429         GtkWidget *frame_quote;
1430         GtkWidget *vbox_quote;
1431         GtkWidget *hbox1;
1432         GtkWidget *hbox2;
1433         GtkWidget *label_quotemark;
1434         GtkWidget *entry_quotemark;
1435         GtkWidget *scrolledwin_quotefmt;
1436         GtkWidget *text_quotefmt;
1437
1438         GtkWidget *entry_fw_quotemark;
1439         GtkWidget *text_fw_quotefmt;
1440
1441         GtkWidget *entry_quote_chars;
1442         GtkWidget *label_quote_chars;
1443         
1444         GtkWidget *btn_quotedesc;
1445
1446         GtkWidget *checkbtn_reply_with_quote;
1447
1448         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1449         gtk_widget_show (vbox1);
1450         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1451         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1452
1453         /* reply */
1454
1455         PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
1456
1457         PACK_FRAME (vbox1, frame_quote, _("Reply format"));
1458
1459         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1460         gtk_widget_show (vbox_quote);
1461         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1462         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1463
1464         hbox1 = gtk_hbox_new (FALSE, 32);
1465         gtk_widget_show (hbox1);
1466         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1467
1468         hbox2 = gtk_hbox_new (FALSE, 8);
1469         gtk_widget_show (hbox2);
1470         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1471
1472         label_quotemark = gtk_label_new (_("Quotation mark"));
1473         gtk_widget_show (label_quotemark);
1474         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1475
1476         entry_quotemark = gtk_entry_new ();
1477         gtk_widget_show (entry_quotemark);
1478         gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
1479         gtk_widget_set_size_request (entry_quotemark, 64, -1);
1480
1481         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1482         gtk_widget_show (scrolledwin_quotefmt);
1483         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1484         gtk_scrolled_window_set_policy
1485                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1486                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1487
1488         text_quotefmt = gtk_text_view_new ();
1489         gtk_widget_show (text_quotefmt);
1490         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
1491         gtk_text_view_set_editable (GTK_TEXT_VIEW(text_quotefmt), TRUE);
1492         gtk_widget_set_size_request(text_quotefmt, -1, 60);
1493
1494         /* forward */
1495
1496         PACK_FRAME (vbox1, frame_quote, _("Forward format"));
1497
1498         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1499         gtk_widget_show (vbox_quote);
1500         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1501         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1502
1503         hbox1 = gtk_hbox_new (FALSE, 32);
1504         gtk_widget_show (hbox1);
1505         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1506
1507         hbox2 = gtk_hbox_new (FALSE, 8);
1508         gtk_widget_show (hbox2);
1509         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1510
1511         label_quotemark = gtk_label_new (_("Quotation mark"));
1512         gtk_widget_show (label_quotemark);
1513         gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
1514
1515         entry_fw_quotemark = gtk_entry_new ();
1516         gtk_widget_show (entry_fw_quotemark);
1517         gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
1518                             FALSE, FALSE, 0);
1519         gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
1520
1521         scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
1522         gtk_widget_show (scrolledwin_quotefmt);
1523         gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
1524         gtk_scrolled_window_set_policy
1525                 (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
1526                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1527
1528         text_fw_quotefmt = gtk_text_view_new ();
1529         gtk_widget_show (text_fw_quotefmt);
1530         gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
1531                           text_fw_quotefmt);
1532         gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
1533         gtk_widget_set_size_request(text_fw_quotefmt, -1, 60);
1534
1535         hbox1 = gtk_hbox_new (FALSE, 32);
1536         gtk_widget_show (hbox1);
1537         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1538
1539         btn_quotedesc =
1540                 gtk_button_new_with_label (_(" Description of symbols "));
1541         gtk_widget_show (btn_quotedesc);
1542         gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
1543         g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
1544                          G_CALLBACK(quote_fmt_quote_description), NULL);
1545
1546         /* quote chars */
1547
1548         PACK_FRAME (vbox1, frame_quote, _("Quotation characters"));
1549
1550         vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
1551         gtk_widget_show (vbox_quote);
1552         gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
1553         gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
1554
1555         hbox1 = gtk_hbox_new (FALSE, 32);
1556         gtk_widget_show (hbox1);
1557         gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
1558
1559         hbox2 = gtk_hbox_new (FALSE, 8);
1560         gtk_widget_show (hbox2);
1561         gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
1562
1563         label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks: "));
1564         gtk_widget_show (label_quote_chars);
1565         gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
1566
1567         entry_quote_chars = gtk_entry_new ();
1568         gtk_widget_show (entry_quote_chars);
1569         gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
1570                             FALSE, FALSE, 0);
1571         gtk_widget_set_size_request (entry_quote_chars, 64, -1);
1572
1573
1574         compose.checkbtn_reply_with_quote= checkbtn_reply_with_quote;
1575         quote.entry_quotemark    = entry_quotemark;
1576         quote.text_quotefmt      = text_quotefmt;
1577         quote.entry_fw_quotemark = entry_fw_quotemark;
1578         quote.text_fw_quotefmt   = text_fw_quotefmt;
1579         quote.entry_quote_chars  = entry_quote_chars;
1580 }
1581
1582 static void prefs_display_create(void)
1583 {
1584         GtkWidget *vbox1;
1585         GtkWidget *chkbtn_transhdr;
1586         GtkWidget *chkbtn_folder_unread;
1587         GtkWidget *hbox1;
1588         GtkWidget *label_ng_abbrev;
1589         GtkWidget *spinbtn_ng_abbrev_len;
1590         GtkObject *spinbtn_ng_abbrev_len_adj;
1591         GtkWidget *frame_summary;
1592         GtkWidget *vbox2;
1593         GtkWidget *chkbtn_swapfrom;
1594         GtkWidget *chkbtn_useaddrbook;
1595         GtkWidget *chkbtn_threadsubj;
1596         GtkWidget *vbox3;
1597         GtkWidget *label_datefmt;
1598         GtkWidget *button_datefmt;
1599         GtkWidget *entry_datefmt;
1600         GtkWidget *button_dispitem;
1601
1602         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1603         gtk_widget_show (vbox1);
1604         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1605         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1606
1607         vbox2 = gtk_vbox_new (FALSE, 0);
1608         gtk_widget_show (vbox2);
1609         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
1610
1611         PACK_CHECK_BUTTON
1612                 (vbox2, chkbtn_transhdr,
1613                  _("Translate header name (such as `From:', `Subject:')"));
1614
1615         PACK_CHECK_BUTTON (vbox2, chkbtn_folder_unread,
1616                            _("Display unread number next to folder name"));
1617
1618         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1619
1620         hbox1 = gtk_hbox_new (FALSE, 8);
1621         gtk_widget_show (hbox1);
1622         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1623
1624         label_ng_abbrev = gtk_label_new
1625                 (_("Abbreviate newsgroup names longer than"));
1626         gtk_widget_show (label_ng_abbrev);
1627         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1628
1629         spinbtn_ng_abbrev_len_adj = gtk_adjustment_new (16, 0, 999, 1, 10, 10);
1630         spinbtn_ng_abbrev_len = gtk_spin_button_new
1631                 (GTK_ADJUSTMENT (spinbtn_ng_abbrev_len_adj), 1, 0);
1632         gtk_widget_show (spinbtn_ng_abbrev_len);
1633         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_ng_abbrev_len,
1634                             FALSE, FALSE, 0);
1635         gtk_widget_set_size_request (spinbtn_ng_abbrev_len, 56, -1);
1636         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_ng_abbrev_len),
1637                                      TRUE);
1638
1639         label_ng_abbrev = gtk_label_new
1640                 (_("letters"));
1641         gtk_widget_show (label_ng_abbrev);
1642         gtk_box_pack_start (GTK_BOX (hbox1), label_ng_abbrev, FALSE, FALSE, 0);
1643
1644         /* ---- Summary ---- */
1645
1646         PACK_FRAME(vbox1, frame_summary, _("Summary View"));
1647
1648         vbox2 = gtk_vbox_new (FALSE, 0);
1649         gtk_widget_show (vbox2);
1650         gtk_container_add (GTK_CONTAINER (frame_summary), vbox2);
1651         gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1652
1653         PACK_CHECK_BUTTON
1654                 (vbox2, chkbtn_swapfrom,
1655                  _("Display recipient in `From' column if sender is yourself"));
1656         PACK_CHECK_BUTTON
1657                 (vbox2, chkbtn_useaddrbook,
1658                  _("Display sender using address book"));
1659         PACK_CHECK_BUTTON
1660                 (vbox2, chkbtn_threadsubj,
1661                  _("Thread using subject in addition to standard headers"));
1662
1663         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1664
1665         hbox1 = gtk_hbox_new (FALSE, 8);
1666         gtk_widget_show (hbox1);
1667         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1668
1669         label_datefmt = gtk_label_new (_("Date format"));
1670         gtk_widget_show (label_datefmt);
1671         gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
1672
1673         entry_datefmt = gtk_entry_new ();
1674         gtk_widget_show (entry_datefmt);
1675         gtk_box_pack_start (GTK_BOX (hbox1), entry_datefmt, TRUE, TRUE, 0);
1676
1677         button_datefmt = gtk_button_new_with_label (" ... ");
1678
1679         gtk_widget_show (button_datefmt);
1680         gtk_box_pack_start (GTK_BOX (hbox1), button_datefmt, FALSE, FALSE, 0);
1681         g_signal_connect (G_OBJECT (button_datefmt), "clicked",
1682                           G_CALLBACK (date_format_create), NULL);
1683
1684         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW);
1685
1686         hbox1 = gtk_hbox_new (FALSE, 8);
1687         gtk_widget_show (hbox1);
1688         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1689
1690         button_dispitem = gtk_button_new_with_label
1691                 (_(" Set displayed items in summary... "));
1692         gtk_widget_show (button_dispitem);
1693         gtk_box_pack_start (GTK_BOX (hbox1), button_dispitem, FALSE, TRUE, 0);
1694         g_signal_connect (G_OBJECT (button_dispitem), "clicked",
1695                           G_CALLBACK (prefs_summary_column_open),
1696                           NULL);
1697
1698         display.chkbtn_transhdr           = chkbtn_transhdr;
1699         display.chkbtn_folder_unread      = chkbtn_folder_unread;
1700         display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
1701         display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
1702
1703         display.chkbtn_swapfrom      = chkbtn_swapfrom;
1704         display.chkbtn_useaddrbook   = chkbtn_useaddrbook;
1705         display.chkbtn_threadsubj    = chkbtn_threadsubj;
1706         display.entry_datefmt        = entry_datefmt;
1707 }
1708
1709 static void prefs_message_create(void)
1710 {
1711         GtkWidget *vbox1;
1712         GtkWidget *vbox2;
1713         GtkWidget *vbox3;
1714         GtkWidget *hbox1;
1715         GtkWidget *chkbtn_mbalnum;
1716         GtkWidget *chkbtn_disphdrpane;
1717         GtkWidget *chkbtn_disphdr;
1718         GtkWidget *button_edit_disphdr;
1719         GtkWidget *hbox_linespc;
1720         GtkWidget *label_linespc;
1721         GtkObject *spinbtn_linespc_adj;
1722         GtkWidget *spinbtn_linespc;
1723         GtkWidget *chkbtn_headspc;
1724
1725         GtkWidget *frame_scr;
1726         GtkWidget *vbox_scr;
1727         GtkWidget *chkbtn_smoothscroll;
1728         GtkWidget *hbox_scr;
1729         GtkWidget *label_scr;
1730         GtkObject *spinbtn_scrollstep_adj;
1731         GtkWidget *spinbtn_scrollstep;
1732         GtkWidget *chkbtn_halfpage;
1733
1734         GtkWidget *chkbtn_attach_desc;
1735
1736         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1737         gtk_widget_show (vbox1);
1738         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1739         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1740
1741         vbox2 = gtk_vbox_new (FALSE, 0);
1742         gtk_widget_show (vbox2);
1743         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1744
1745         PACK_CHECK_BUTTON
1746                 (vbox2, chkbtn_mbalnum,
1747                  _("Display multi-byte alphanumeric as\n"
1748                    "ASCII character (Japanese only)"));
1749         gtk_label_set_justify (GTK_LABEL (GTK_BIN(chkbtn_mbalnum)->child),
1750                                GTK_JUSTIFY_LEFT);
1751
1752         PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
1753                           _("Display header pane above message view"));
1754
1755         hbox1 = gtk_hbox_new (FALSE, 8);
1756         gtk_widget_show (hbox1);
1757         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1758
1759         PACK_CHECK_BUTTON(hbox1, chkbtn_disphdr,
1760                           _("Display short headers on message view"));
1761
1762         button_edit_disphdr = gtk_button_new_with_label (_(" Edit... "));
1763         gtk_widget_show (button_edit_disphdr);
1764         gtk_box_pack_end (GTK_BOX (hbox1), button_edit_disphdr,
1765                           FALSE, TRUE, 0);
1766         g_signal_connect (G_OBJECT (button_edit_disphdr), "clicked",
1767                           G_CALLBACK (prefs_display_header_open),
1768                           NULL);
1769
1770         SET_TOGGLE_SENSITIVITY(chkbtn_disphdr, button_edit_disphdr);
1771
1772         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1773
1774         hbox1 = gtk_hbox_new (FALSE, 32);
1775         gtk_widget_show (hbox1);
1776         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
1777
1778         hbox_linespc = gtk_hbox_new (FALSE, 8);
1779         gtk_widget_show (hbox1);
1780         gtk_box_pack_start (GTK_BOX (hbox1), hbox_linespc, FALSE, TRUE, 0);
1781
1782         label_linespc = gtk_label_new (_("Line space"));
1783         gtk_widget_show (label_linespc);
1784         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1785                             FALSE, FALSE, 0);
1786
1787         spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
1788         spinbtn_linespc = gtk_spin_button_new
1789                 (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
1790         gtk_widget_show (spinbtn_linespc);
1791         gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
1792                             FALSE, FALSE, 0);
1793         gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
1794         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
1795
1796         label_linespc = gtk_label_new (_("pixel(s)"));
1797         gtk_widget_show (label_linespc);
1798         gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
1799                             FALSE, FALSE, 0);
1800
1801         PACK_CHECK_BUTTON(hbox1, chkbtn_headspc, _("Indent text"));
1802
1803         PACK_FRAME(vbox1, frame_scr, _("Scroll"));
1804
1805         vbox_scr = gtk_vbox_new (FALSE, 0);
1806         gtk_widget_show (vbox_scr);
1807         gtk_container_add (GTK_CONTAINER (frame_scr), vbox_scr);
1808         gtk_container_set_border_width (GTK_CONTAINER (vbox_scr), 8);
1809
1810         PACK_CHECK_BUTTON(vbox_scr, chkbtn_halfpage, _("Half page"));
1811
1812         hbox1 = gtk_hbox_new (FALSE, 32);
1813         gtk_widget_show (hbox1);
1814         gtk_box_pack_start (GTK_BOX (vbox_scr), hbox1, FALSE, TRUE, 0);
1815
1816         PACK_CHECK_BUTTON(hbox1, chkbtn_smoothscroll, _("Smooth scroll"));
1817
1818         hbox_scr = gtk_hbox_new (FALSE, 8);
1819         gtk_widget_show (hbox_scr);
1820         gtk_box_pack_start (GTK_BOX (hbox1), hbox_scr, FALSE, FALSE, 0);
1821
1822         label_scr = gtk_label_new (_("Step"));
1823         gtk_widget_show (label_scr);
1824         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1825
1826         spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
1827         spinbtn_scrollstep = gtk_spin_button_new
1828                 (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
1829         gtk_widget_show (spinbtn_scrollstep);
1830         gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
1831                             FALSE, FALSE, 0);
1832         gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
1833         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
1834                                      TRUE);
1835
1836         label_scr = gtk_label_new (_("pixel(s)"));
1837         gtk_widget_show (label_scr);
1838         gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
1839
1840         SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
1841
1842         vbox3 = gtk_vbox_new (FALSE, 0);
1843         gtk_widget_show (vbox3);
1844         gtk_box_pack_start (GTK_BOX (vbox1), vbox3, FALSE, FALSE, 0);
1845
1846         PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
1847                           _("Show attachment descriptions (rather than names)"));
1848
1849         message.chkbtn_mbalnum     = chkbtn_mbalnum;
1850         message.chkbtn_disphdrpane = chkbtn_disphdrpane;
1851         message.chkbtn_disphdr     = chkbtn_disphdr;
1852         message.spinbtn_linespc    = spinbtn_linespc;
1853         message.chkbtn_headspc     = chkbtn_headspc;
1854
1855         message.chkbtn_smoothscroll    = chkbtn_smoothscroll;
1856         message.spinbtn_scrollstep     = spinbtn_scrollstep;
1857         message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
1858         message.chkbtn_halfpage        = chkbtn_halfpage;
1859
1860         message.chkbtn_attach_desc  = chkbtn_attach_desc;
1861 }
1862
1863 static void prefs_interface_create(void)
1864 {
1865         GtkWidget *vbox1;
1866         GtkWidget *vbox2;
1867         GtkWidget *vbox3;
1868         /* GtkWidget *checkbtn_emacs; */
1869         GtkWidget *checkbtn_always_show_msg;
1870         GtkWidget *checkbtn_openunread;
1871         GtkWidget *checkbtn_mark_as_read_on_newwin;
1872         GtkWidget *checkbtn_openinbox;
1873         GtkWidget *checkbtn_immedexec;
1874         GtkTooltips *immedexec_tooltip;
1875         GtkWidget *hbox1;
1876         GtkWidget *label;
1877         GtkWidget *menu;
1878         GtkWidget *menuitem;
1879
1880         GtkWidget *button_keybind;
1881
1882         GtkWidget *hbox_nextunreadmsgdialog;
1883         GtkWidget *optmenu_nextunreadmsgdialog;
1884
1885         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1886         gtk_widget_show (vbox1);
1887         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1888         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1889
1890         vbox2 = gtk_vbox_new (FALSE, 0);
1891         gtk_widget_show (vbox2);
1892         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1893
1894         /* PACK_CHECK_BUTTON (vbox2, checkbtn_emacs,
1895                            _("Emulate the behavior of mouse operation of\n"
1896                              "Emacs-based mailer"));
1897         gtk_label_set_justify (GTK_LABEL (GTK_BIN (checkbtn_emacs)->child),
1898                                GTK_JUSTIFY_LEFT);   */
1899
1900         PACK_CHECK_BUTTON
1901                 (vbox2, checkbtn_always_show_msg,
1902                  _("Always open messages in summary when selected"));
1903
1904         PACK_CHECK_BUTTON
1905                 (vbox2, checkbtn_openunread,
1906                  _("Open first unread message when entering a folder"));
1907
1908         PACK_CHECK_BUTTON
1909                 (vbox2, checkbtn_mark_as_read_on_newwin,
1910                  _("Only mark message as read when opened in new window"));
1911
1912         PACK_CHECK_BUTTON
1913                 (vbox2, checkbtn_openinbox,
1914                  _("Go to inbox after receiving new mail"));
1915
1916         vbox3 = gtk_vbox_new (FALSE, 0);
1917         gtk_widget_show (vbox3);
1918         gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
1919
1920         immedexec_tooltip = gtk_tooltips_new();
1921
1922         PACK_CHECK_BUTTON
1923                 (vbox3, checkbtn_immedexec,
1924                  _("Execute immediately when moving or deleting messages"));
1925         gtk_tooltips_set_tip(GTK_TOOLTIPS(immedexec_tooltip), checkbtn_immedexec,
1926                              _("Messages will be marked until execution"
1927                                " if this is turned off"),
1928                              NULL);
1929
1930         hbox1 = gtk_hbox_new (FALSE, 0);
1931         gtk_widget_show (hbox1);
1932         gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1933
1934         /* Next Unread Message Dialog */
1935         hbox_nextunreadmsgdialog = gtk_hbox_new (FALSE, 8);
1936         gtk_widget_show (hbox1);
1937         gtk_box_pack_start (GTK_BOX (vbox1), hbox_nextunreadmsgdialog, FALSE, FALSE, 0);
1938
1939         label = gtk_label_new (_("Show no-unread-message dialog"));
1940         gtk_widget_show (label);
1941         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), label, FALSE, FALSE, 8);
1942
1943         optmenu_nextunreadmsgdialog = gtk_option_menu_new ();
1944         gtk_widget_show (optmenu_nextunreadmsgdialog);
1945         gtk_box_pack_start (GTK_BOX (hbox_nextunreadmsgdialog), optmenu_nextunreadmsgdialog, FALSE, FALSE, 8);
1946         
1947         menu = gtk_menu_new ();
1948         MENUITEM_ADD (menu, menuitem, _("Always"), NEXTUNREADMSGDIALOG_ALWAYS);
1949         MENUITEM_ADD (menu, menuitem, _("Assume 'Yes'"), 
1950                       NEXTUNREADMSGDIALOG_ASSUME_YES);
1951         MENUITEM_ADD (menu, menuitem, _("Assume 'No'"), 
1952                       NEXTUNREADMSGDIALOG_ASSUME_NO);
1953
1954         gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_nextunreadmsgdialog), menu);
1955
1956         hbox1 = gtk_hbox_new (FALSE, 8);
1957         gtk_widget_show (hbox1);
1958         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
1959
1960         button_keybind = gtk_button_new_with_label (_(" Set key bindings... "));
1961         gtk_widget_show (button_keybind);
1962         gtk_box_pack_start (GTK_BOX (hbox1), button_keybind, FALSE, FALSE, 0);
1963         g_signal_connect (G_OBJECT (button_keybind), "clicked",
1964                           G_CALLBACK (prefs_keybind_select), NULL);
1965
1966         /* interface.checkbtn_emacs          = checkbtn_emacs; */
1967         interface.checkbtn_always_show_msg    = checkbtn_always_show_msg;
1968         interface.checkbtn_openunread         = checkbtn_openunread;
1969         interface.checkbtn_mark_as_read_on_newwin
1970                                               = checkbtn_mark_as_read_on_newwin;
1971         interface.checkbtn_openinbox          = checkbtn_openinbox;
1972         interface.checkbtn_immedexec          = checkbtn_immedexec;
1973         interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
1974 }
1975
1976 static void prefs_other_create(void)
1977 {
1978         GtkWidget *vbox1;
1979         GtkWidget *hbox1;
1980
1981         GtkWidget *frame_addr;
1982         GtkWidget *vbox_addr;
1983         GtkWidget *checkbtn_addaddrbyclick;
1984         
1985         GtkWidget *frame_cliplog;
1986         GtkWidget *vbox_cliplog;
1987         GtkWidget *hbox_cliplog;
1988         GtkWidget *checkbtn_cliplog;
1989         GtkWidget *loglength_label;
1990         GtkWidget *loglength_entry;
1991         GtkTooltips *loglength_tooltip;
1992
1993         GtkWidget *frame_exit;
1994         GtkWidget *vbox_exit;
1995         GtkWidget *checkbtn_confonexit;
1996         GtkWidget *checkbtn_cleanonexit;
1997         GtkWidget *checkbtn_askonclean;
1998         GtkWidget *checkbtn_warnqueued;
1999
2000         GtkWidget *label_iotimeout;
2001         GtkWidget *spinbtn_iotimeout;
2002         GtkObject *spinbtn_iotimeout_adj;
2003
2004 #if 0
2005 #ifdef USE_OPENSSL
2006         GtkWidget *frame_ssl;
2007         GtkWidget *vbox_ssl;
2008         GtkWidget *hbox_ssl;
2009         GtkWidget *checkbtn_ssl_ask_unknown_valid;
2010 #endif
2011 #endif
2012         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2013         gtk_widget_show (vbox1);
2014         gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
2015         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2016
2017         PACK_FRAME (vbox1, frame_addr, _("Address book"));
2018
2019         vbox_addr = gtk_vbox_new (FALSE, 0);
2020         gtk_widget_show (vbox_addr);
2021         gtk_container_add (GTK_CONTAINER (frame_addr), vbox_addr);
2022         gtk_container_set_border_width (GTK_CONTAINER (vbox_addr), 8);
2023
2024         PACK_CHECK_BUTTON
2025                 (vbox_addr, checkbtn_addaddrbyclick,
2026                  _("Add address to destination when double-clicked"));
2027
2028         /* Clip Log */
2029         PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
2030
2031         vbox_cliplog = gtk_vbox_new (FALSE, 0);
2032         gtk_widget_show (vbox_cliplog);
2033         gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
2034         gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
2035         PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
2036                            _("Clip the log size"));
2037         hbox_cliplog = gtk_hbox_new (FALSE, 3);
2038         gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
2039         gtk_widget_show (hbox_cliplog);
2040         
2041         loglength_label = gtk_label_new (_("Log window length"));
2042         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
2043                             FALSE, TRUE, 0);
2044         gtk_widget_show (GTK_WIDGET (loglength_label));
2045         
2046         loglength_tooltip = gtk_tooltips_new();
2047         
2048         loglength_entry = gtk_entry_new ();
2049         gtk_widget_set_size_request (GTK_WIDGET (loglength_entry), 64, -1);
2050         gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
2051                             FALSE, TRUE, 0);
2052         gtk_widget_show (GTK_WIDGET (loglength_entry));
2053         gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), loglength_entry,
2054                              _("0 to stop logging in the log window"),
2055                              NULL);
2056         SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
2057
2058 #if 0
2059 #ifdef USE_OPENSSL
2060         /* SSL */
2061         PACK_FRAME (vbox1, frame_ssl, _("Security"));
2062
2063         vbox_ssl = gtk_vbox_new (FALSE, 0);
2064         gtk_widget_show (vbox_ssl);
2065         gtk_container_add (GTK_CONTAINER (frame_ssl), vbox_ssl);
2066         gtk_container_set_border_width (GTK_CONTAINER (vbox_ssl), 8);
2067         PACK_CHECK_BUTTON (vbox_ssl, checkbtn_ssl_ask_unknown_valid, 
2068                            _("Ask before accepting SSL certificates"));
2069         hbox_ssl = gtk_hbox_new (FALSE, 3);
2070         gtk_container_add (GTK_CONTAINER (vbox_ssl), hbox_ssl);
2071         gtk_widget_show (hbox_ssl);
2072 #endif
2073 #endif
2074         
2075         /* On Exit */
2076         PACK_FRAME (vbox1, frame_exit, _("On exit"));
2077
2078         vbox_exit = gtk_vbox_new (FALSE, 0);
2079         gtk_widget_show (vbox_exit);
2080         gtk_container_add (GTK_CONTAINER (frame_exit), vbox_exit);
2081         gtk_container_set_border_width (GTK_CONTAINER (vbox_exit), 8);
2082
2083         PACK_CHECK_BUTTON (vbox_exit, checkbtn_confonexit,
2084                            _("Confirm on exit"));
2085
2086         hbox1 = gtk_hbox_new (FALSE, 32);
2087         gtk_widget_show (hbox1);
2088         gtk_box_pack_start (GTK_BOX (vbox_exit), hbox1, FALSE, FALSE, 0);
2089
2090         PACK_CHECK_BUTTON (hbox1, checkbtn_cleanonexit,
2091                            _("Empty trash on exit"));
2092         PACK_CHECK_BUTTON (hbox1, checkbtn_askonclean,
2093                            _("Ask before emptying"));
2094         SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
2095
2096         PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
2097                            _("Warn if there are queued messages"));
2098
2099         hbox1 = gtk_hbox_new (FALSE, 8);
2100         gtk_widget_show (hbox1);
2101         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2102
2103         label_iotimeout = gtk_label_new (_("Socket I/O timeout:"));
2104         gtk_widget_show (label_iotimeout);
2105         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2106
2107         spinbtn_iotimeout_adj = gtk_adjustment_new (60, 0, 1000, 1, 10, 10);
2108         spinbtn_iotimeout = gtk_spin_button_new
2109                 (GTK_ADJUSTMENT (spinbtn_iotimeout_adj), 1, 0);
2110         gtk_widget_show (spinbtn_iotimeout);
2111         gtk_box_pack_start (GTK_BOX (hbox1), spinbtn_iotimeout,
2112                             FALSE, FALSE, 0);
2113         gtk_widget_set_size_request (spinbtn_iotimeout, 64, -1);
2114         gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_iotimeout), TRUE);
2115
2116         label_iotimeout = gtk_label_new (_("seconds"));
2117         gtk_widget_show (label_iotimeout);
2118         gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0);
2119
2120         other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick;
2121         
2122         other.checkbtn_cliplog     = checkbtn_cliplog;
2123         other.loglength_entry      = loglength_entry;
2124
2125         other.checkbtn_confonexit  = checkbtn_confonexit;
2126         other.checkbtn_cleanonexit = checkbtn_cleanonexit;
2127         other.checkbtn_askonclean  = checkbtn_askonclean;
2128         other.checkbtn_warnqueued  = checkbtn_warnqueued;
2129
2130         other.spinbtn_iotimeout     = spinbtn_iotimeout;
2131         other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj;
2132         
2133 #if 0
2134 #ifdef USE_OPENSSL
2135         other.checkbtn_ssl_ask_unknown_valid = checkbtn_ssl_ask_unknown_valid;
2136 #endif
2137 #endif
2138 }
2139
2140 static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget)
2141 {
2142         GtkWidget *datefmt_sample = NULL;
2143         gchar *text;
2144
2145         g_return_if_fail(widget != NULL);
2146         g_return_if_fail(*widget != NULL);
2147         g_return_if_fail(display.entry_datefmt != NULL);
2148
2149         datefmt_sample = GTK_WIDGET(g_object_get_data
2150                                     (G_OBJECT(*widget), "datefmt_sample"));
2151         g_return_if_fail(datefmt_sample != NULL);
2152
2153         text = gtk_editable_get_chars(GTK_EDITABLE(datefmt_sample), 0, -1);
2154         g_free(prefs_common.date_format);
2155         prefs_common.date_format = text;
2156         gtk_entry_set_text(GTK_ENTRY(display.entry_datefmt), text);
2157
2158         gtk_widget_destroy(*widget);
2159         *widget = NULL;
2160 }
2161
2162 static void date_format_cancel_btn_clicked(GtkButton *button,
2163                                            GtkWidget **widget)
2164 {
2165         g_return_if_fail(widget != NULL);
2166         g_return_if_fail(*widget != NULL);
2167
2168         gtk_widget_destroy(*widget);
2169         *widget = NULL;
2170 }
2171
2172 static gboolean date_format_key_pressed(GtkWidget *keywidget, GdkEventKey *event,
2173                                         GtkWidget **widget)
2174 {
2175         if (event && event->keyval == GDK_Escape)
2176                 date_format_cancel_btn_clicked(NULL, widget);
2177         return FALSE;
2178 }
2179
2180 static gboolean date_format_on_delete(GtkWidget *dialogwidget,
2181                                       GdkEventAny *event, GtkWidget **widget)
2182 {
2183         g_return_val_if_fail(widget != NULL, FALSE);
2184         g_return_val_if_fail(*widget != NULL, FALSE);
2185
2186         *widget = NULL;
2187         return FALSE;
2188 }
2189
2190 static void date_format_entry_on_change(GtkEditable *editable,
2191                                         GtkLabel *example)
2192 {
2193         time_t cur_time;
2194         struct tm *cal_time;
2195         gchar buffer[100];
2196         gchar *text;
2197
2198         cur_time = time(NULL);
2199         cal_time = localtime(&cur_time);
2200         buffer[0] = 0;
2201         text = gtk_editable_get_chars(editable, 0, -1);
2202         if (text)
2203                 strftime(buffer, sizeof buffer, text, cal_time); 
2204         g_free(text);
2205
2206         text = conv_codeset_strdup(buffer,
2207                                    conv_get_current_charset_str(),
2208                                    CS_UTF_8);
2209         if (!text)
2210                 text = g_strdup(buffer);
2211
2212         gtk_label_set_text(example, text);
2213
2214         g_free(text);
2215 }
2216
2217 static void date_format_select_row(GtkWidget *date_format_list, gint row,
2218                                    gint column, GdkEventButton *event,
2219                                    GtkWidget *date_format)
2220 {
2221         gint cur_pos;
2222         gchar *format;
2223         const gchar *old_format;
2224         gchar *new_format;
2225         GtkWidget *datefmt_sample;
2226
2227         /* only on double click */
2228         if (!event || event->type != GDK_2BUTTON_PRESS) return;
2229
2230
2231         datefmt_sample = GTK_WIDGET(g_object_get_data(G_OBJECT(date_format), 
2232                                                       "datefmt_sample"));
2233
2234         g_return_if_fail(date_format_list != NULL);
2235         g_return_if_fail(date_format != NULL);
2236         g_return_if_fail(datefmt_sample != NULL);
2237
2238         /* get format from clist */
2239         gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
2240
2241         cur_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
2242         old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
2243
2244         /* insert the format into the text entry */
2245         new_format = g_malloc(strlen(old_format) + 3);
2246
2247         strncpy(new_format, old_format, cur_pos);
2248         new_format[cur_pos] = '\0';
2249         strcat(new_format, format);
2250         strcat(new_format, &old_format[cur_pos]);
2251
2252         gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
2253         gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), cur_pos + 2);
2254
2255         g_free(new_format);
2256 }
2257
2258 static GtkWidget *date_format_create(GtkButton *button, void *data)
2259 {
2260         static GtkWidget *datefmt_win = NULL;
2261         GtkWidget *vbox1;
2262         GtkWidget *scrolledwindow1;
2263         GtkWidget *datefmt_clist;
2264         GtkWidget *table;
2265         GtkWidget *label1;
2266         GtkWidget *label2;
2267         GtkWidget *label3;
2268         GtkWidget *confirm_area;
2269         GtkWidget *ok_btn;
2270         GtkWidget *cancel_btn;
2271         GtkWidget *datefmt_entry;
2272
2273         struct {
2274                 gchar *fmt;
2275                 gchar *txt;
2276         } time_format[] = {
2277                 { "%a", NULL },
2278                 { "%A", NULL },
2279                 { "%b", NULL },
2280                 { "%B", NULL },
2281                 { "%c", NULL },
2282                 { "%C", NULL },
2283                 { "%d", NULL },
2284                 { "%H", NULL },
2285                 { "%I", NULL },
2286                 { "%j", NULL },
2287                 { "%m", NULL },
2288                 { "%M", NULL },
2289                 { "%p", NULL },
2290                 { "%S", NULL },
2291                 { "%w", NULL },
2292                 { "%x", NULL },
2293                 { "%y", NULL },
2294                 { "%Y", NULL },
2295                 { "%Z", NULL }
2296         };
2297
2298         gchar *titles[2];
2299         gint i;
2300         const gint TIME_FORMAT_ELEMS =
2301                 sizeof time_format / sizeof time_format[0];
2302
2303         time_format[0].txt  = _("the full abbreviated weekday name");
2304         time_format[1].txt  = _("the full weekday name");
2305         time_format[2].txt  = _("the abbreviated month name");
2306         time_format[3].txt  = _("the full month name");
2307         time_format[4].txt  = _("the preferred date and time for the current locale");
2308         time_format[5].txt  = _("the century number (year/100)");
2309         time_format[6].txt  = _("the day of the month as a decimal number");
2310         time_format[7].txt  = _("the hour as a decimal number using a 24-hour clock");
2311         time_format[8].txt  = _("the hour as a decimal number using a 12-hour clock");
2312         time_format[9].txt  = _("the day of the year as a decimal number");
2313         time_format[10].txt = _("the month as a decimal number");
2314         time_format[11].txt = _("the minute as a decimal number");
2315         time_format[12].txt = _("either AM or PM");
2316         time_format[13].txt = _("the second as a decimal number");
2317         time_format[14].txt = _("the day of the week as a decimal number");
2318         time_format[15].txt = _("the preferred date for the current locale");
2319         time_format[16].txt = _("the last two digits of a year");
2320         time_format[17].txt = _("the year as a decimal number");
2321         time_format[18].txt = _("the time zone or name or abbreviation");
2322
2323         if (datefmt_win) return datefmt_win;
2324
2325         datefmt_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2326         gtk_container_set_border_width(GTK_CONTAINER(datefmt_win), 8);
2327         gtk_window_set_title(GTK_WINDOW(datefmt_win), _("Date format"));
2328         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2329         gtk_widget_set_size_request(datefmt_win, 440, 280);
2330
2331         vbox1 = gtk_vbox_new(FALSE, 10);
2332         gtk_widget_show(vbox1);
2333         gtk_container_add(GTK_CONTAINER(datefmt_win), vbox1);
2334
2335         scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
2336         gtk_scrolled_window_set_policy
2337                 (GTK_SCROLLED_WINDOW(scrolledwindow1),
2338                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2339         gtk_widget_show(scrolledwindow1);
2340         gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
2341
2342         titles[0] = _("Specifier");
2343         titles[1] = _("Description");
2344         datefmt_clist = gtk_clist_new_with_titles(2, titles);
2345         gtk_widget_show(datefmt_clist);
2346         gtk_container_add(GTK_CONTAINER(scrolledwindow1), datefmt_clist);
2347         /* gtk_clist_set_column_width(GTK_CLIST(datefmt_clist), 0, 80); */
2348         gtk_clist_set_selection_mode(GTK_CLIST(datefmt_clist),
2349                                      GTK_SELECTION_BROWSE);
2350
2351         for (i = 0; i < TIME_FORMAT_ELEMS; i++) {
2352                 gchar *text[2];
2353                 /* phoney casting necessary because of gtk... */
2354                 text[0] = (gchar *)time_format[i].fmt;
2355                 text[1] = (gchar *)time_format[i].txt;
2356                 gtk_clist_append(GTK_CLIST(datefmt_clist), text);
2357         }
2358
2359         table = gtk_table_new(2, 2, FALSE);
2360         gtk_widget_show(table);
2361         gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0);
2362         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
2363         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
2364
2365         label1 = gtk_label_new(_("Date format"));
2366         gtk_widget_show(label1);
2367         gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
2368                          GTK_FILL, 0, 0, 0);
2369         gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_LEFT);
2370         gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
2371
2372         datefmt_entry = gtk_entry_new();
2373         gtk_entry_set_max_length(GTK_ENTRY(datefmt_entry), 256);
2374         gtk_widget_show(datefmt_entry);
2375         gtk_table_attach(GTK_TABLE(table), datefmt_entry, 1, 2, 0, 1,
2376                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2377
2378         /* we need the "sample" entry box; add it as data so callbacks can
2379          * get the entry box */
2380         g_object_set_data(G_OBJECT(datefmt_win), "datefmt_sample",
2381                           datefmt_entry);
2382
2383         label2 = gtk_label_new(_("Example"));
2384         gtk_widget_show(label2);
2385         gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
2386                          GTK_FILL, 0, 0, 0);
2387         gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_LEFT);
2388         gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
2389
2390         label3 = gtk_label_new("");
2391         gtk_widget_show(label3);
2392         gtk_table_attach(GTK_TABLE(table), label3, 1, 2, 1, 2,
2393                          (GTK_EXPAND | GTK_FILL), 0, 0, 0);
2394         gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_LEFT);
2395         gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
2396
2397         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
2398                                 &cancel_btn, _("Cancel"), NULL, NULL);
2399         gtk_widget_grab_default(ok_btn);
2400         gtk_widget_show(confirm_area);
2401
2402         gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
2403
2404         /* set the current format */
2405         gtk_entry_set_text(GTK_ENTRY(datefmt_entry), prefs_common.date_format);
2406         date_format_entry_on_change(GTK_EDITABLE(datefmt_entry),
2407                                     GTK_LABEL(label3));
2408
2409         g_signal_connect(G_OBJECT(ok_btn), "clicked",
2410                          G_CALLBACK(date_format_ok_btn_clicked),
2411                          &datefmt_win);
2412         g_signal_connect(G_OBJECT(cancel_btn), "clicked",
2413                          G_CALLBACK(date_format_cancel_btn_clicked),
2414                          &datefmt_win);
2415         g_signal_connect(G_OBJECT(datefmt_win), "key_press_event",
2416                          G_CALLBACK(date_format_key_pressed),
2417                          &datefmt_win);
2418         g_signal_connect(G_OBJECT(datefmt_win), "delete_event",
2419                          G_CALLBACK(date_format_on_delete),
2420                          &datefmt_win);
2421         g_signal_connect(G_OBJECT(datefmt_entry), "changed",
2422                          G_CALLBACK(date_format_entry_on_change),
2423                          label3);
2424
2425         g_signal_connect(G_OBJECT(datefmt_clist), "select_row",
2426                          G_CALLBACK(date_format_select_row),
2427                          datefmt_win);
2428
2429         gtk_window_set_position(GTK_WINDOW(datefmt_win), GTK_WIN_POS_CENTER);
2430         gtk_window_set_modal(GTK_WINDOW(datefmt_win), TRUE);
2431
2432         gtk_widget_show(datefmt_win);
2433         manage_window_set_transient(GTK_WINDOW(datefmt_win));
2434
2435         gtk_widget_grab_focus(ok_btn);
2436
2437         return datefmt_win;
2438 }
2439
2440 static void prefs_keybind_select(void)
2441 {
2442         GtkWidget *window;
2443         GtkWidget *vbox1;
2444         GtkWidget *hbox1;
2445         GtkWidget *label;
2446         GtkWidget *combo;
2447         GtkWidget *confirm_area;
2448         GtkWidget *ok_btn;
2449         GtkWidget *cancel_btn;
2450
2451         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2452         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
2453         gtk_window_set_title (GTK_WINDOW (window), _("Key bindings"));
2454         gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
2455         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
2456         gtk_window_set_resizable(GTK_WINDOW (window), FALSE);
2457         manage_window_set_transient (GTK_WINDOW (window));
2458
2459         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2460         gtk_container_add (GTK_CONTAINER (window), vbox1);
2461         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
2462
2463         hbox1 = gtk_hbox_new (FALSE, 8);
2464         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2465
2466         label = gtk_label_new
2467                 (_("Select preset:"));
2468         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2469         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2470
2471         hbox1 = gtk_hbox_new (FALSE, 8);
2472         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2473
2474         combo = gtk_combo_new ();
2475         gtk_box_pack_start (GTK_BOX (hbox1), combo, TRUE, TRUE, 0);
2476         gtkut_combo_set_items (GTK_COMBO (combo),
2477                                _("Default"),
2478                                "Mew / Wanderlust",
2479                                "Mutt",
2480                                _("Old Sylpheed"),
2481                                NULL);
2482         gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO (combo)->entry), FALSE);
2483
2484         hbox1 = gtk_hbox_new (FALSE, 8);
2485         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2486
2487         label = gtk_label_new
2488                 (_("You can also modify each menu shortcut by pressing\n"
2489                    "any key(s) when placing the mouse pointer on the item."));
2490         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2491         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2492
2493         hbox1 = gtk_hbox_new (FALSE, 8);
2494         gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
2495
2496         gtkut_button_set_create (&confirm_area, &ok_btn, _("OK"),
2497                                  &cancel_btn, _("Cancel"), NULL, NULL);
2498         gtk_box_pack_end (GTK_BOX (hbox1), confirm_area, FALSE, FALSE, 0);
2499         gtk_widget_grab_default (ok_btn);
2500
2501         MANAGE_WINDOW_SIGNALS_CONNECT(window);
2502         g_signal_connect (G_OBJECT (window), "delete_event",
2503                           G_CALLBACK (prefs_keybind_deleted), NULL);
2504         g_signal_connect (G_OBJECT (window), "key_press_event",
2505                           G_CALLBACK (prefs_keybind_key_pressed), NULL);
2506         g_signal_connect (G_OBJECT (ok_btn), "clicked",
2507                           G_CALLBACK (prefs_keybind_apply_clicked),
2508                           NULL);
2509         g_signal_connect (G_OBJECT (cancel_btn), "clicked",
2510                           G_CALLBACK (prefs_keybind_cancel),
2511                           NULL);
2512
2513         gtk_widget_show_all(window);
2514
2515         keybind.window = window;
2516         keybind.combo = combo;
2517 }
2518
2519 static gboolean prefs_keybind_key_pressed(GtkWidget *widget, GdkEventKey *event,
2520                                           gpointer data)
2521 {
2522         if (event && event->keyval == GDK_Escape)
2523                 prefs_keybind_cancel();
2524         return FALSE;
2525 }
2526
2527 static gint prefs_keybind_deleted(GtkWidget *widget, GdkEventAny *event,
2528                                   gpointer data)
2529 {
2530         prefs_keybind_cancel();
2531         return TRUE;
2532 }
2533
2534 static void prefs_keybind_cancel(void)
2535 {
2536         gtk_widget_destroy(keybind.window);
2537         keybind.window = NULL;
2538         keybind.combo = NULL;
2539 }
2540   
2541 struct KeyBind {
2542         const gchar *accel_path;
2543         const gchar *accel_key;
2544 };
2545
2546 static void prefs_keybind_apply(struct KeyBind keybind[], gint num)
2547 {
2548         gint i;
2549         guint key;
2550         GdkModifierType mods;
2551
2552         for (i = 0; i < num; i++) {
2553                 const gchar *accel_key
2554                         = keybind[i].accel_key ? keybind[i].accel_key : "";
2555                 gtk_accelerator_parse(accel_key, &key, &mods);
2556                 gtk_accel_map_change_entry(keybind[i].accel_path,
2557                                            key, mods, TRUE);
2558         }
2559 }
2560
2561 static void prefs_keybind_apply_clicked(GtkWidget *widget)
2562 {
2563         GtkEntry *entry = GTK_ENTRY(GTK_COMBO(keybind.combo)->entry);
2564         const gchar *text;
2565         struct KeyBind *menurc;
2566         gint n_menurc;
2567
2568         static struct KeyBind default_menurc[] = {
2569                 {"<Main>/File/Empty trash",                     ""},
2570                 {"<Main>/File/Save as...",                      "<control>S"},
2571                 {"<Main>/File/Print...",                        ""},
2572                 {"<Main>/File/Exit",                            "<control>Q"},
2573
2574                 {"<Main>/Edit/Copy",                            "<control>C"},
2575                 {"<Main>/Edit/Select all",                      "<control>A"},
2576                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2577                 {"<Main>/Edit/Search folder...",                "<shift><control>F"},
2578
2579                 {"<Main>/View/Expand Summary View",             "V"},
2580                 {"<Main>/View/Expand Message View",             "<shift>V"},
2581                 {"<Main>/View/Thread view",                     "<control>T"},
2582                 {"<Main>/View/Go to/Prev message",              "P"},
2583                 {"<Main>/View/Go to/Next message",              "N"},
2584                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2585                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2586                 {"<Main>/View/Go to/Other folder...",           "G"},
2587                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2588                 {"<Main>/View/View source",                     "<control>U"},
2589                 {"<Main>/View/Show all headers",                "<control>H"},
2590                 {"<Main>/View/Update",                          "<control><alt>U"},
2591
2592                 {"<Main>/Message/Receive/Get new mail",         "<control>I"},
2593                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2594                 {"<Main>/Message/Compose an email message",     "<control>M"},
2595                 {"<Main>/Message/Reply",                        "<control>R"},
2596                 {"<Main>/Message/Reply to/all",                 "<shift><control>R"},
2597                 {"<Main>/Message/Reply to/sender",              ""},
2598                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2599                 {"<Main>/Message/Forward",                      "<control><alt>F"},
2600                 /* {"<Main>/Message/Forward as attachment",      ""}, */
2601                 {"<Main>/Message/Move...",                      "<control>O"},
2602                 {"<Main>/Message/Copy...",                      "<shift><control>O"},
2603                 {"<Main>/Message/Delete",                       "<control>D"},
2604                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2605                 {"<Main>/Message/Mark/Unmark",                  "U"},
2606                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2607                 {"<Main>/Message/Mark/Mark as read",            ""},
2608
2609                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2610                 {"<Main>/Tools/Execute",                        "X"},
2611                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2612
2613                 {"<Compose>/File/Close",                                "<control>W"},
2614                 {"<Compose>/Edit/Select all",                           "<control>A"},
2615                 {"<Compose>/Edit/Advanced/Move a word backward",        ""},
2616                 {"<Compose>/Edit/Advanced/Move a word forward",         ""},
2617                 {"<Compose>/Edit/Advanced/Move to beginning of line",   ""},
2618                 {"<Compose>/Edit/Advanced/Delete a word backward",      ""},
2619                 {"<Compose>/Edit/Advanced/Delete a word forward",       ""},
2620         };
2621
2622         static struct KeyBind mew_wl_menurc[] = {
2623                 {"<Main>/File/Empty trash",                     "<shift>D"},
2624                 {"<Main>/File/Save as...",                      "Y"},
2625                 {"<Main>/File/Print...",                        "<shift>numbersign"},
2626                 {"<Main>/File/Exit",                            "<shift>Q"},
2627
2628                 {"<Main>/Edit/Copy",                            "<control>C"},
2629                 {"<Main>/Edit/Select all",                      "<control>A"},
2630                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2631                 {"<Main>/Edit/Search folder...",                "<control>S"},
2632
2633                 {"<Main>/View/Expand Summary View",             ""},
2634                 {"<Main>/View/Expand Message View",             ""},
2635                 {"<Main>/View/Thread view",                     "<shift>T"},
2636                 {"<Main>/View/Go to/Prev message",              "P"},
2637                 {"<Main>/View/Go to/Next message",              "N"},
2638                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2639                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2640                 {"<Main>/View/Go to/Other folder...",           "G"},
2641                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2642                 {"<Main>/View/View source",                     "<control>U"},
2643                 {"<Main>/View/Show all headers",                "<shift>H"},
2644                 {"<Main>/View/Update",                          "<shift>S"},
2645
2646                 {"<Main>/Message/Receive/Get new mail",         "<control>I"},
2647                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2648                 {"<Main>/Message/Compose an email message",     "W"},
2649                 {"<Main>/Message/Reply",                        "<control>R"},
2650                 {"<Main>/Message/Reply to/all",                 "<shift>A"},
2651                 {"<Main>/Message/Reply to/sender",              ""},
2652                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2653                 {"<Main>/Message/Forward",                      "F"},
2654                 /* {"<Main>/Message/Forward as attachment", "<shift>F"}, */
2655                 {"<Main>/Message/Move...",                      "O"},
2656                 {"<Main>/Message/Copy...",                      "<shift>O"},
2657                 {"<Main>/Message/Delete",                       "D"},
2658                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2659                 {"<Main>/Message/Mark/Unmark",                  "U"},
2660                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2661                 {"<Main>/Message/Mark/Mark as read",            "<shift>R"},
2662
2663                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2664                 {"<Main>/Tools/Execute",                        "X"},
2665                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2666
2667                 {"<Compose>/File/Close",                                "<alt>W"},
2668                 {"<Compose>/Edit/Select all",                           ""},
2669                 {"<Compose>/Edit/Advanced/Move a word backward,"        "<alt>B"},
2670                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2671                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2672                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2673                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2674         };
2675
2676         static struct KeyBind mutt_menurc[] = {
2677                 {"<Main>/File/Empty trash",                     ""},
2678                 {"<Main>/File/Save as...",                      "S"},
2679                 {"<Main>/File/Print...",                        "P"},
2680                 {"<Main>/File/Exit",                            "Q"},
2681
2682                 {"<Main>/Edit/Copy",                            "<control>C"},
2683                 {"<Main>/Edit/Select all",                      "<control>A"},
2684                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2685                 {"<Main>/Edit/Search messages...",              "slash"},
2686
2687                 {"<Main>/View/Toggle summary view",             "V"},
2688                 {"<Main>/View/Thread view",                     "<control>T"},
2689                 {"<Main>/View/Go to/Prev message",              ""},
2690                 {"<Main>/View/Go to/Next message",              ""},
2691                 {"<Main>/View/Go to/Prev unread message",       ""},
2692                 {"<Main>/View/Go to/Next unread message",       ""},
2693                 {"<Main>/View/Go to/Other folder...",           "C"},
2694                 {"<Main>/View/Open in new window",              "<control><alt>N"},
2695                 {"<Main>/View/View source",                     "<control>U"},
2696                 {"<Main>/View/Show all headers",                "<control>H"},
2697                 {"<Main>/View/Update",                          "<control><alt>U"},
2698
2699                 {"<Main>/Message/Receive/Get new mail",                 "<control>I"},
2700                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><control>I"},
2701                 {"<Main>/Message/Compose an email message",             "M"},
2702                 {"<Main>/Message/Reply",                        "R"},
2703                 {"<Main>/Message/Reply to/all",                 "G"},
2704                 {"<Main>/Message/Reply to/sender",              ""},
2705                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2706                 {"<Main>/Message/Forward",                      "F"},
2707                 {"<Main>/Message/Forward as attachment",        ""},
2708                 {"<Main>/Message/Move...",                      "<control>O"},
2709                 {"<Main>/Message/Copy...",                      "<shift>C"},
2710                 {"<Main>/Message/Delete",                       "D"},
2711                 {"<Main>/Message/Mark/Mark",                    "<shift>F"},
2712                 {"<Main>/Message/Mark/Unmark",                  "U"},
2713                 {"<Main>/Message/Mark/Mark as unread",          "<shift>N"},
2714                 {"<Main>/Message/Mark/Mark as read",            ""},
2715
2716                 {"<Main>/Tools/Address book",                   "<shift><control>A"},
2717                 {"<Main>/Tools/Execute",                        "X"},
2718                 {"<Main>/Tools/Log window",                     "<shift><control>L"},
2719
2720                 {"<Compose>/File/Close",                                "<alt>W"},
2721                 {"<Compose>/Edit/Select all",                           ""},
2722                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2723                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2724                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2725                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2726                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2727         };
2728
2729         static struct KeyBind old_sylpheed_menurc[] = {
2730                 {"<Main>/File/Empty trash",                     ""},
2731                 {"<Main>/File/Save as...",                      ""},
2732                 {"<Main>/File/Print...",                        "<alt>P"},
2733                 {"<Main>/File/Exit",                            "<alt>Q"},
2734
2735                 {"<Main>/Edit/Copy",                            "<control>C"},
2736                 {"<Main>/Edit/Select all",                      "<control>A"},
2737                 {"<Main>/Edit/Find in current message...",      "<control>F"},
2738                 {"<Main>/Edit/Search folder...",                "<control>S"},
2739
2740                 {"<Main>/View/Expand Summary View",             ""},
2741                 {"<Main>/View/Expand Message View",             ""},
2742                 {"<Main>/View/Thread view",                     "<control>T"},
2743                 {"<Main>/View/Go to/Prev message",              "P"},
2744                 {"<Main>/View/Go to/Next message",              "N"},
2745                 {"<Main>/View/Go to/Prev unread message",       "<shift>P"},
2746                 {"<Main>/View/Go to/Next unread message",       "<shift>N"},
2747                 {"<Main>/View/Go to/Other folder...",           "<alt>G"},
2748                 {"<Main>/View/Open in new window",              "<shift><control>N"},
2749                 {"<Main>/View/View source",                     "<control>U"},
2750                 {"<Main>/View/Show all headers",                "<control>H"},
2751                 {"<Main>/View/Update",                          "<alt>U"},
2752
2753                 {"<Main>/Message/Receive/Get new mail",                 "<alt>I"},
2754                 {"<Main>/Message/Receive/Get from all accounts",        "<shift><alt>I"},
2755                 {"<Main>/Message/Compose an email message",     "<alt>N"},
2756                 {"<Main>/Message/Reply",                        "<alt>R"},
2757                 {"<Main>/Message/Reply to/all",                 "<shift><alt>R"},
2758                 {"<Main>/Message/Reply to/sender",              "<control><alt>R"},
2759                 {"<Main>/Message/Reply to/mailing list",        "<control>L"},
2760                 {"<Main>/Message/Forward",                       "<shift><alt>F"},
2761                 /* "(menu-path \"<Main>/Message/Forward as attachment", "<shift><control>F"}, */
2762                 {"<Main>/Message/Move...",                      "<alt>O"},
2763                 {"<Main>/Message/Copy...",                      ""},
2764                 {"<Main>/Message/Delete",                       "<alt>D"},
2765                 {"<Main>/Message/Mark/Mark",                    "<shift>asterisk"},
2766                 {"<Main>/Message/Mark/Unmark",                  "U"},
2767                 {"<Main>/Message/Mark/Mark as unread",          "<shift>exclam"},
2768                 {"<Main>/Message/Mark/Mark as read",            ""},
2769
2770                 {"<Main>/Tools/Address book",                   "<alt>A"},
2771                 {"<Main>/Tools/Execute",                        "<alt>X"},
2772                 {"<Main>/Tools/Log window",                     "<alt>L"},
2773
2774                 {"<Compose>/File/Close",                                "<alt>W"},
2775                 {"<Compose>/Edit/Select all",                           ""},
2776                 {"<Compose>/Edit/Advanced/Move a word backward",        "<alt>B"},
2777                 {"<Compose>/Edit/Advanced/Move a word forward",         "<alt>F"},
2778                 {"<Compose>/Edit/Advanced/Move to beginning of line",   "<control>A"},
2779                 {"<Compose>/Edit/Advanced/Delete a word backward",      "<control>W"},
2780                 {"<Compose>/Edit/Advanced/Delete a word forward",       "<alt>D"},
2781         };
2782   
2783         text = gtk_entry_get_text(entry);
2784   
2785         if (!strcmp(text, _("Default"))) {
2786                 menurc = default_menurc;
2787                 n_menurc = G_N_ELEMENTS(default_menurc);
2788         } else if (!strcmp(text, "Mew / Wanderlust")) {
2789                 menurc = mew_wl_menurc;
2790                 n_menurc = G_N_ELEMENTS(mew_wl_menurc);
2791         } else if (!strcmp(text, "Mutt")) {
2792                 menurc = mutt_menurc;
2793                 n_menurc = G_N_ELEMENTS(mutt_menurc);
2794         } else if (!strcmp(text, _("Old Sylpheed"))) {
2795                 menurc = old_sylpheed_menurc;
2796                 n_menurc = G_N_ELEMENTS(old_sylpheed_menurc);
2797         } else {
2798                 return;
2799         }
2800
2801         /* prefs_keybind_apply(empty_menurc, G_N_ELEMENTS(empty_menurc)); */
2802         prefs_keybind_apply(menurc, n_menurc);
2803
2804         gtk_widget_destroy(keybind.window);
2805         keybind.window = NULL;
2806         keybind.combo = NULL;
2807 }
2808
2809 static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
2810 {
2811         GtkWidget *menu;
2812         GtkWidget *menuitem;
2813         gchar *charset;
2814
2815         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2816         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2817         charset = g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
2818         g_free(*((gchar **)pparam->data));
2819         *((gchar **)pparam->data) = g_strdup(charset);
2820 }
2821
2822 static void prefs_common_charset_set_optmenu(PrefParam *pparam)
2823 {
2824         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2825         gint index;
2826
2827         g_return_if_fail(optmenu != NULL);
2828         g_return_if_fail(*((gchar **)pparam->data) != NULL);
2829
2830         index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
2831                                             (GCompareFunc)strcmp);
2832         if (index >= 0)
2833                 gtk_option_menu_set_history(optmenu, index);
2834         else {
2835                 gtk_option_menu_set_history(optmenu, 0);
2836                 prefs_common_charset_set_data_from_optmenu(pparam);
2837         }
2838 }
2839
2840 static void prefs_common_encoding_set_data_from_optmenu(PrefParam *pparam)
2841 {
2842         GtkWidget *menu;
2843         GtkWidget *menuitem;
2844
2845         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2846         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2847         *((TransferEncodingMethod *)pparam->data) = GPOINTER_TO_INT
2848                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2849 }
2850
2851 static void prefs_common_encoding_set_optmenu(PrefParam *pparam)
2852 {
2853         TransferEncodingMethod method =
2854                 *((TransferEncodingMethod *)pparam->data);
2855         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2856         gint index;
2857
2858         g_return_if_fail(optmenu != NULL);
2859
2860         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(method),
2861                                             NULL);
2862         if (index >= 0)
2863                 gtk_option_menu_set_history(optmenu, index);
2864         else {
2865                 gtk_option_menu_set_history(optmenu, 0);
2866                 prefs_common_encoding_set_data_from_optmenu(pparam);
2867         }
2868 }
2869
2870 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)
2871 {
2872         GtkWidget *menu;
2873         GtkWidget *menuitem;
2874
2875         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2876         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2877         *((RecvDialogMode *)pparam->data) = GPOINTER_TO_INT
2878                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2879 }
2880
2881 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam)
2882 {
2883         RecvDialogMode mode = *((RecvDialogMode *)pparam->data);
2884         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2885         GtkWidget *menu;
2886         GtkWidget *menuitem;
2887         gint index;
2888
2889         index = menu_find_option_menu_index(optmenu, GINT_TO_POINTER(mode),
2890                                             NULL);
2891         if (index >= 0)
2892                 gtk_option_menu_set_history(optmenu, index);
2893         else {
2894                 gtk_option_menu_set_history(optmenu, 0);
2895                 prefs_common_recv_dialog_set_data_from_optmenu(pparam);
2896         }
2897
2898         menu = gtk_option_menu_get_menu(optmenu);
2899         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2900         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2901 }
2902
2903 static void prefs_common_send_dialog_set_data_from_optmenu(PrefParam *pparam)
2904 {
2905         GtkWidget *menu;
2906         GtkWidget *menuitem;
2907
2908         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2909         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2910         *((SendDialogMode *)pparam->data) = GPOINTER_TO_INT
2911                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2912 }
2913
2914 static void prefs_common_send_dialog_set_optmenu(PrefParam *pparam)
2915 {
2916         SendDialogMode mode = *((SendDialogMode *)pparam->data);
2917         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2918         GtkWidget *menu;
2919         GtkWidget *menuitem;
2920
2921         switch (mode) {
2922         case SEND_DIALOG_ALWAYS:
2923                 gtk_option_menu_set_history(optmenu, 0);
2924                 break;
2925         case SEND_DIALOG_NEVER:
2926                 gtk_option_menu_set_history(optmenu, 1);
2927                 break;
2928         default:
2929                 break;
2930         }
2931
2932         menu = gtk_option_menu_get_menu(optmenu);
2933         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2934         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2935 }
2936
2937 static gint prefs_common_deleted(GtkWidget *widget, GdkEventAny *event,
2938                                  gpointer data)
2939 {
2940         prefs_common_cancel();
2941         return TRUE;
2942 }
2943
2944 static gboolean prefs_common_key_pressed(GtkWidget *widget, GdkEventKey *event,
2945                                          gpointer data)
2946 {
2947         if (event && event->keyval == GDK_Escape)
2948                 prefs_common_cancel();
2949         return FALSE;
2950 }
2951
2952 static void prefs_common_ok(void)
2953 {
2954         prefs_common_apply();
2955         gtk_widget_hide(dialog.window);
2956
2957         inc_unlock();
2958 }
2959
2960 static void prefs_common_apply(void)
2961 {
2962         MainWindow *mainwindow;
2963
2964         prefs_set_data_from_dialog(param);
2965         sock_set_io_timeout(prefs_common.io_timeout_secs);
2966         main_window_reflect_prefs_all_real(FALSE);
2967         prefs_common_write_config();
2968
2969         mainwindow = mainwindow_get_mainwindow();
2970         log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
2971                                 prefs_common.loglength);
2972         
2973         inc_autocheck_timer_remove();
2974         inc_autocheck_timer_set();
2975 }
2976
2977 static void prefs_nextunreadmsgdialog_set_data_from_optmenu(PrefParam *pparam)
2978 {
2979         GtkWidget *menu;
2980         GtkWidget *menuitem;
2981
2982         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2983         menuitem = gtk_menu_get_active(GTK_MENU(menu));
2984         *((NextUnreadMsgDialogShow *)pparam->data) = GPOINTER_TO_INT
2985                 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2986 }
2987
2988 static void prefs_nextunreadmsgdialog_set_optmenu(PrefParam *pparam)
2989 {
2990         NextUnreadMsgDialogShow dialog_show;
2991         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2992         GtkWidget *menu;
2993         GtkWidget *menuitem;
2994
2995         dialog_show = *((NextUnreadMsgDialogShow *)pparam->data);
2996
2997         switch (dialog_show) {
2998         case NEXTUNREADMSGDIALOG_ALWAYS:
2999                 gtk_option_menu_set_history(optmenu, 0);
3000                 break;
3001         case NEXTUNREADMSGDIALOG_ASSUME_YES:
3002                 gtk_option_menu_set_history(optmenu, 1);
3003                 break;
3004         case NEXTUNREADMSGDIALOG_ASSUME_NO:
3005                 gtk_option_menu_set_history(optmenu, 2);
3006                 break;
3007         }
3008
3009         menu = gtk_option_menu_get_menu(optmenu);
3010         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3011         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3012 }
3013
3014 static void prefs_common_cancel(void)
3015 {
3016         gtk_widget_hide(dialog.window);
3017         inc_unlock();
3018 }
3019
3020
3021 /* static void prefs_recvdialog_set_data_from_optmenu(PrefParam *pparam)
3022 {
3023         GtkWidget *menu;
3024         GtkWidget *menuitem;
3025
3026         menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
3027         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3028         *((RecvDialogShow *)pparam->data) = GPOINTER_TO_INT
3029                 (gtk_object_get_user_data(GTK_OBJECT(menuitem)));
3030 }  */
3031
3032 /* static void prefs_recvdialog_set_optmenu(PrefParam *pparam)
3033 {
3034         RecvDialogShow dialog_show;
3035         GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
3036         GtkWidget *menu;
3037         GtkWidget *menuitem;
3038
3039         dialog_show = *((RecvDialogShow *)pparam->data);
3040
3041         switch (dialog_show) {
3042         case RECVDIALOG_ALWAYS:
3043                 gtk_option_menu_set_history(optmenu, 0);
3044                 break;
3045         case RECVDIALOG_WINDOW_ACTIVE:
3046                 gtk_option_menu_set_history(optmenu, 1);
3047                 break;
3048         case RECVDIALOG_NEVER:
3049                 gtk_option_menu_set_history(optmenu, 2);
3050                 break;
3051         default:
3052         }
3053
3054         menu = gtk_option_menu_get_menu(optmenu);
3055         menuitem = gtk_menu_get_active(GTK_MENU(menu));
3056         gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
3057 }     */