Remove obsolete font prefs
[claws.git] / src / prefs_common.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #include "claws-features.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <glib/gi18n.h>
28 #include <gtk/gtk.h>
29 #include <gdk/gdkkeysyms.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <unistd.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <errno.h>
37
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 "prefs_folder_column.h"
44 #include "mainwindow.h"
45 #include "summaryview.h"
46 #include "folderview.h"
47 #include "messageview.h"
48 #include "manage_window.h"
49 #include "inc.h"
50 #include "menu.h"
51 #include "codeconv.h"
52 #include "utils.h"
53 #include "gtkutils.h"
54 #include "alertpanel.h"
55 #include "folder.h"
56 #include "socket.h"
57 #include "filesel.h"
58 #include "folderview.h"
59 #include "stock_pixmap.h"
60 #include "prefswindow.h"
61 #include "colorlabel.h"
62 #ifndef USE_ALT_ADDRBOOK
63         #include "addrcustomattr.h"
64 #endif
65
66 enum {
67         DATEFMT_FMT,
68         DATEFMT_TXT,
69         N_DATEFMT_COLUMNS
70 };
71
72 PrefsCommon prefs_common;
73
74 GtkWidget *notebook;
75
76 #ifdef G_OS_WIN32
77 /*
78  * In the Windows version prefs_common contains
79  *   - the non-OS-specific settings of the "Common" section and
80  *   - the OS-specific settings of the "CommonWin32" section
81  * The OS-specific settings of the "Common" section are not used
82  * but saved in prefs_unix.
83  */
84
85 #  define SPECIFIC_PREFS prefs_unix
86
87 static PrefsCommon prefs_unix;
88
89 static PrefParam param_os_specific[] = {
90         /* Receive */
91         {"ext_inc_path", "",
92          &prefs_common.extinc_cmd, P_STRING, NULL, NULL, NULL},
93         {"newmail_notify_cmd", "",
94          &prefs_common.newmail_notify_cmd, P_STRING, NULL, NULL, NULL},
95
96         /* new fonts */
97         {"widget_font_gtk2",    NULL,
98           &prefs_common.widgetfont,             P_STRING, NULL, NULL, NULL},
99         {"message_font_gtk2",   "Monospace 9",
100          &prefs_common.textfont,                P_STRING, NULL, NULL, NULL},
101         {"print_font_gtk2",     "Monospace 9",
102          &prefs_common.printfont,               P_STRING, NULL, NULL, NULL},
103         {"small_font_gtk2",     "Sans 9",
104           &prefs_common.smallfont,              P_STRING, NULL, NULL, NULL},
105         {"normal_font_gtk2",    "Sans 9",
106           &prefs_common.normalfont,             P_STRING, NULL, NULL, NULL},
107         {"bold_font_gtk2",      "Sans 9 Bold",
108           &prefs_common.boldfont,               P_STRING, NULL, NULL, NULL},
109         /* Message */
110         {"attach_save_directory", NULL,
111          &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL},
112         {"attach_load_directory", NULL,
113          &prefs_common.attach_load_dir, P_STRING, NULL, NULL, NULL},
114
115         /* MIME viewer */
116         {"mime_textviewer", NULL,
117          &prefs_common.mime_textviewer,   P_STRING, NULL, NULL, NULL},
118         {"mime_open_command", "notepad '%s'",
119          &prefs_common.mime_open_cmd,     P_STRING, NULL, NULL, NULL},
120
121         /* Interface */
122         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
123          &prefs_common.pixmap_theme_path, P_STRING, NULL, NULL, NULL},
124
125         /* Other */
126         {"ext_editor_command", "notepad %s",
127          &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
128
129         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
130 };
131 #else
132 #  define SPECIFIC_PREFS prefs_common
133 #endif
134
135 /*
136    parameter name, default value, pointer to the prefs variable, data type,
137    pointer to the widget pointer,
138    pointer to the function for data setting,
139    pointer to the function for widget setting
140  */
141
142 static PrefParam param[] = {
143         {"config_version", "0",
144          &prefs_common.config_version, P_INT, NULL, NULL, NULL},
145
146         /* Receive */
147         {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL,
148          NULL, NULL, NULL},
149         {"ext_inc_path", DEFAULT_INC_PATH, &SPECIFIC_PREFS.extinc_cmd, P_STRING,
150          NULL, NULL, NULL},
151
152         {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL,
153          NULL, NULL, NULL},
154         {"autochk_interval", "600", &prefs_common.autochk_itv, P_INT,
155          NULL, NULL, NULL},
156         {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL,
157          NULL, NULL, NULL},
158         {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc,
159          P_BOOL, NULL, NULL, NULL},
160         {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc,
161          P_BOOL, NULL, NULL, NULL},
162         {"newmail_notify_manu", "FALSE", &prefs_common.newmail_notify_manu,
163          P_BOOL, NULL, NULL, NULL},
164         {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto,
165         P_BOOL, NULL, NULL, NULL},
166         {"newmail_notify_cmd", "", &SPECIFIC_PREFS.newmail_notify_cmd, P_STRING,
167          NULL, NULL, NULL},
168         {"receive_dialog_mode", "2", &prefs_common.recv_dialog_mode, P_ENUM,
169          NULL, NULL, NULL},
170         {"receivewin_width", "460", &prefs_common.receivewin_width, P_INT,
171          NULL, NULL, NULL},
172         {"receivewin_height", "-1", &prefs_common.receivewin_height, P_INT,
173          NULL, NULL, NULL},
174         {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
175          P_BOOL, NULL, NULL, NULL},
176         {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
177          P_BOOL, NULL, NULL, NULL},
178  
179         /* Send */
180         {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL,
181          NULL, NULL, NULL},
182         {"confirm_send_queued_messages", "FALSE", &prefs_common.confirm_send_queued_messages,
183          P_BOOL, NULL, NULL, NULL},
184 #ifndef GENERIC_UMPC
185         {"send_dialog_mode", "0", &prefs_common.send_dialog_invisible, P_BOOL,
186          NULL, NULL, NULL},
187 #else
188         {"send_dialog_mode", "1", &prefs_common.send_dialog_invisible, P_BOOL,
189          NULL, NULL, NULL},
190 #endif
191         {"sendwin_width", "460", &prefs_common.sendwin_width, P_INT,
192          NULL, NULL, NULL},
193         {"sendwin_height", "-1", &prefs_common.sendwin_height, P_INT,
194          NULL, NULL, NULL},
195
196         {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
197          NULL, NULL, NULL},
198         {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM,
199          NULL, NULL, NULL},
200         {"outgoing_fallback_to_ascii", "TRUE", &prefs_common.outgoing_fallback_to_ascii, P_BOOL,
201          NULL, NULL, NULL},
202          {"rewrite_first_from", "TRUE", &prefs_common.rewrite_first_from,
203           P_BOOL, NULL, NULL, NULL},
204         {"warn_empty_subj", "TRUE", &prefs_common.warn_empty_subj,
205          P_BOOL, NULL, NULL, NULL},
206         {"warn_sending_many_recipients", "FALSE", &prefs_common.warn_sending_many_recipients,
207          P_BOOL, NULL, NULL, NULL},
208         {"warn_sending_many_recipients_num", "1", &prefs_common.warn_sending_many_recipients_num, P_INT,
209          NULL, NULL, NULL},
210         {"hide_timezone", "FALSE", &prefs_common.hide_timezone,
211          P_BOOL, NULL, NULL, NULL},
212         {"allow_jisx0201_kana", "FALSE", &prefs_common.allow_jisx0201_kana,
213          P_BOOL, NULL, NULL, NULL},
214
215         /* Compose */
216         {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL,
217          NULL, NULL, NULL},
218         {"forward_as_attachment", "FALSE", &prefs_common.forward_as_attachment,
219          P_BOOL, NULL, NULL, NULL},
220         {"redirect_keep_from", "FALSE",
221          &prefs_common.redirect_keep_from, P_BOOL,
222          NULL, NULL, NULL},
223         {"undo_level", "50", &prefs_common.undolevels, P_INT,
224          NULL, NULL, NULL},
225         {"compose_with_format", "FALSE", &prefs_common.compose_with_format, P_BOOL,
226          NULL, NULL, NULL},
227         {"compose_subject_format", "",
228          &prefs_common.compose_subject_format, P_STRING, NULL, NULL, NULL},
229         {"compose_body_format", N_("Hello,\\n"),
230          &prefs_common.compose_body_format, P_STRING, NULL, NULL, NULL},
231         {"show_compose_margin", "FALSE", &prefs_common.show_compose_margin, P_BOOL,
232          NULL, NULL, NULL},
233         {"type_any_header", "FALSE", &prefs_common.type_any_header, P_BOOL,
234          NULL, NULL, NULL},
235         
236
237         {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
238          NULL, NULL, NULL},
239         {"linewrap_quotation", "TRUE", &prefs_common.linewrap_quote, P_BOOL,
240          NULL, NULL, NULL},
241         {"linewrap_pastes", "TRUE", &prefs_common.linewrap_pastes, P_BOOL,
242          NULL, NULL, NULL},
243         {"primary_paste_unselects", "FALSE", &prefs_common.primary_paste_unselects, P_BOOL,
244          NULL, NULL, NULL},
245         {"linewrap_auto", "TRUE", &prefs_common.autowrap, P_BOOL,
246          NULL, NULL, NULL},
247         {"auto_indent", "TRUE", &prefs_common.auto_indent, P_BOOL,
248          NULL, NULL, NULL},
249         {"autosave", "TRUE", &prefs_common.autosave,
250          P_BOOL, NULL, NULL, NULL},
251         {"autosave_length", "50", &prefs_common.autosave_length, P_INT,
252          NULL, NULL, NULL},
253         {"autosave_encrypted", "FALSE", &prefs_common.autosave_encrypted,
254          P_BOOL, NULL, NULL, NULL},
255         {"warn_large_insert", "TRUE", &prefs_common.warn_large_insert,
256          P_BOOL, NULL, NULL, NULL},
257         {"warn_large_insert_size", "500", &prefs_common.warn_large_insert_size,
258          P_INT, NULL, NULL, NULL},
259
260         {"enable_aspell", "TRUE", &prefs_common.enable_aspell, P_BOOL,
261          NULL, NULL, NULL},
262         {"dictionary",  "", &prefs_common.dictionary, P_STRING,
263          NULL, NULL, NULL},
264         {"alt_dictionary",  "", &prefs_common.alt_dictionary, P_STRING,
265          NULL, NULL, NULL},
266         {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL,
267          NULL, NULL, NULL},
268         {"check_while_typing", "TRUE", &prefs_common.check_while_typing, P_BOOL,
269          NULL, NULL, NULL},
270         {"recheck_when_changing_dict", "TRUE", &prefs_common.recheck_when_changing_dict,
271          P_BOOL, NULL, NULL, NULL},
272         {"misspelled_color", "#ff0000", &prefs_common.misspelled_col, P_COLOR,
273          NULL, NULL, NULL},
274         {"use_both_dicts", "FALSE", &prefs_common.use_both_dicts, P_BOOL,
275          NULL, NULL, NULL},
276
277         {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
278          NULL, NULL, NULL},
279         {"compose_dnd_insert_or_attach", "0", &prefs_common.compose_dnd_mode, P_ENUM,
280          NULL, NULL, NULL},
281
282         /* Account autoselection */
283         {"reply_account_autoselect", "TRUE",
284          &prefs_common.reply_account_autosel, P_BOOL,
285          NULL, NULL, NULL},
286         {"forward_account_autoselect", "TRUE",
287          &prefs_common.forward_account_autosel, P_BOOL,
288          NULL, NULL, NULL},
289         {"reedit_account_autoselect", "TRUE",
290          &prefs_common.reedit_account_autosel, P_BOOL,
291          NULL, NULL, NULL},
292
293         {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
294          NULL, NULL, NULL},
295
296 #ifndef GENERIC_UMPC
297         {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
298          NULL, NULL, NULL},
299 #else
300         {"show_ruler", "FALSE", &prefs_common.show_ruler, P_BOOL,
301          NULL, NULL, NULL},
302 #endif
303
304         /* Quote */
305         {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
306          NULL, NULL, NULL},
307         {"reply_quote_format", N_("On %d\\n%f wrote:\\n\\n%q\\n%X"),
308          &prefs_common.quotefmt, P_STRING, NULL, NULL, NULL},
309
310         {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING,
311          NULL, NULL, NULL},
312         {"forward_quote_format",
313          N_("\\n\\nBegin forwarded message:\\n\\n"
314          "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}"
315          "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M"),
316          &prefs_common.fw_quotefmt, P_STRING,
317          NULL, NULL, NULL},
318         {"quote_chars", ">", &prefs_common.quote_chars, P_STRING,
319          NULL, NULL, NULL},
320
321         /* Display */
322         /* fonts */
323 #ifndef GENERIC_UMPC
324         {"widget_font_gtk2",    NULL,
325           &SPECIFIC_PREFS.widgetfont,           P_STRING, NULL, NULL, NULL},
326         {"message_font_gtk2",   "Monospace 9",
327          &SPECIFIC_PREFS.textfont,                      P_STRING, NULL, NULL, NULL},
328         {"print_font_gtk2",     "Monospace 9",
329          &SPECIFIC_PREFS.printfont,             P_STRING, NULL, NULL, NULL},
330         {"small_font_gtk2",     "Sans 9",
331           &SPECIFIC_PREFS.smallfont,            P_STRING, NULL, NULL, NULL},
332         {"normal_font_gtk2",    "Sans 9",
333           &SPECIFIC_PREFS.normalfont,           P_STRING, NULL, NULL, NULL},
334         {"bold_font_gtk2",      "Sans Bold 9",
335           &SPECIFIC_PREFS.boldfont,             P_STRING, NULL, NULL, NULL},
336 #else
337         {"widget_font_gtk2",    NULL,
338           &SPECIFIC_PREFS.widgetfont,           P_STRING, NULL, NULL, NULL},
339         {"message_font_gtk2",   "Monospace 8",
340          &SPECIFIC_PREFS.textfont,                      P_STRING, NULL, NULL, NULL},
341         {"print_font_gtk2",     "Monospace 8",
342          &SPECIFIC_PREFS.printfont,             P_STRING, NULL, NULL, NULL},
343         {"small_font_gtk2",     "Sans 8",
344           &SPECIFIC_PREFS.smallfont,            P_STRING, NULL, NULL, NULL},
345         {"normal_font_gtk2",    "Sans 8",
346           &SPECIFIC_PREFS.normalfont,           P_STRING, NULL, NULL, NULL},
347         {"bold_font_gtk2",      "Sans Bold 8",
348           &SPECIFIC_PREFS.boldfont,             P_STRING, NULL, NULL, NULL},
349 #endif
350
351         {"use_different_print_font", "FALSE", &prefs_common.use_different_print_font, P_BOOL,
352          NULL, NULL, NULL},
353         {"derive_from_normal_font", "TRUE", &prefs_common.derive_from_normal_font, P_BOOL,
354          NULL, NULL, NULL},
355
356         /* custom colors */
357         {"custom_color1", "#ff9900", &prefs_common.custom_colorlabel[0].color, P_COLOR,
358          NULL, NULL, NULL},
359         {"custom_colorlabel1", N_("Orange"), &prefs_common.custom_colorlabel[0].label, P_STRING,
360          NULL, NULL, NULL},
361         {"custom_color2", "#ff0000", &prefs_common.custom_colorlabel[1].color, P_COLOR,
362          NULL, NULL, NULL},
363         {"custom_colorlabel2", N_("Red"), &prefs_common.custom_colorlabel[1].label, P_STRING,
364          NULL, NULL, NULL},
365         {"custom_color3", "#ff66ff", &prefs_common.custom_colorlabel[2].color, P_COLOR,
366          NULL, NULL, NULL},
367         {"custom_colorlabel3", N_("Pink"), &prefs_common.custom_colorlabel[2].label, P_STRING,
368          NULL, NULL, NULL},
369         {"custom_color4", "#00ccff", &prefs_common.custom_colorlabel[3].color, P_COLOR,
370          NULL, NULL, NULL},
371         {"custom_colorlabel4", N_("Sky blue"), &prefs_common.custom_colorlabel[3].label, P_STRING,
372          NULL, NULL, NULL},
373         {"custom_color5", "#0000ff", &prefs_common.custom_colorlabel[4].color, P_COLOR,
374          NULL, NULL, NULL},
375         {"custom_colorlabel5", N_("Blue"), &prefs_common.custom_colorlabel[4].label, P_STRING,
376          NULL, NULL, NULL},
377         {"custom_color6", "#009900", &prefs_common.custom_colorlabel[5].color, P_COLOR,
378          NULL, NULL, NULL},
379         {"custom_colorlabel6", N_("Green"), &prefs_common.custom_colorlabel[5].label, P_STRING,
380          NULL, NULL, NULL},
381         {"custom_color7", "#663333", &prefs_common.custom_colorlabel[6].color, P_COLOR,
382          NULL, NULL, NULL},
383         {"custom_colorlabel7", N_("Brown"), &prefs_common.custom_colorlabel[6].label, P_STRING,
384          NULL, NULL, NULL},
385         {"custom_color8", "#aaaaaa", &prefs_common.custom_colorlabel[7].color, P_COLOR,
386          NULL, NULL, NULL},
387         {"custom_colorlabel8", N_("Grey"), &prefs_common.custom_colorlabel[7].label, P_STRING,
388          NULL, NULL, NULL},
389         {"custom_color9", "#c07254", &prefs_common.custom_colorlabel[8].color, P_COLOR,
390          NULL, NULL, NULL},
391         {"custom_colorlabel9", N_("Light brown"), &prefs_common.custom_colorlabel[8].label, P_STRING,
392          NULL, NULL, NULL},
393         {"custom_color10", "#c00000", &prefs_common.custom_colorlabel[9].color, P_COLOR,
394          NULL, NULL, NULL},
395         {"custom_colorlabel10", N_("Dark red"), &prefs_common.custom_colorlabel[9].label, P_STRING,
396          NULL, NULL, NULL},
397         {"custom_color11", "#cc1074", &prefs_common.custom_colorlabel[10].color, P_COLOR,
398          NULL, NULL, NULL},
399         {"custom_colorlabel11", N_("Dark pink"), &prefs_common.custom_colorlabel[10].label, P_STRING,
400          NULL, NULL, NULL},
401         {"custom_color12", "#5094cd", &prefs_common.custom_colorlabel[11].color, P_COLOR,
402          NULL, NULL, NULL},
403         {"custom_colorlabel12", N_("Steel blue"), &prefs_common.custom_colorlabel[11].label, P_STRING,
404          NULL, NULL, NULL},
405         {"custom_color13", "#ffd500", &prefs_common.custom_colorlabel[12].color, P_COLOR,
406          NULL, NULL, NULL},
407         {"custom_colorlabel13", N_("Gold"), &prefs_common.custom_colorlabel[12].label, P_STRING,
408          NULL, NULL, NULL},
409         {"custom_color14", "#00d800", &prefs_common.custom_colorlabel[13].color, P_COLOR,
410          NULL, NULL, NULL},
411         {"custom_colorlabel14", N_("Bright green"), &prefs_common.custom_colorlabel[13].label, P_STRING,
412          NULL, NULL, NULL},
413         {"custom_color15", "#c060c0", &prefs_common.custom_colorlabel[14].color, P_COLOR,
414          NULL, NULL, NULL},
415         {"custom_colorlabel15", N_("Magenta"), &prefs_common.custom_colorlabel[14].label, P_STRING,
416          NULL, NULL, NULL},
417
418         /* image viewer */
419         {"display_image", "TRUE", &prefs_common.display_img, P_BOOL,
420          NULL, NULL, NULL},
421         {"resize_image", "TRUE", &prefs_common.resize_img, P_BOOL,
422          NULL, NULL, NULL},
423         {"inline_image", "TRUE", &prefs_common.inline_img, P_BOOL,
424          NULL, NULL, NULL},
425
426         {"display_folder_unread_num", "0",
427          &prefs_common.display_folder_unread, P_INT,
428          NULL, NULL, NULL},
429         {"newsgroup_abbrev_len", "16",
430          &prefs_common.ng_abbrev_len, P_INT,
431          NULL, NULL, NULL},
432
433         {"translate_header", "FALSE", &prefs_common.trans_hdr, P_BOOL,
434          NULL, NULL, NULL},
435
436         /* Display: Summary View */
437         {"default_sort_key", "3", &prefs_common.default_sort_key, P_ENUM,
438          NULL, NULL, NULL},
439         {"default_sort_type", "1", &prefs_common.default_sort_type, P_ENUM,
440          NULL, NULL, NULL},
441         {"use_address_book", "FALSE", &prefs_common.use_addr_book, P_BOOL,
442          NULL, NULL, NULL},
443         {"thread_by_subject", "TRUE", &prefs_common.thread_by_subject, P_BOOL,
444          NULL, NULL, NULL},
445         {"date_format", N_("%x(%a) %H:%M"), &prefs_common.date_format,
446          P_STRING, NULL, NULL, NULL},
447         {"msgview_date_format", "FALSE", &prefs_common.msgview_date_format, P_BOOL,
448          NULL, NULL, NULL},
449
450         {"next_on_delete", "FALSE", &prefs_common.next_on_delete, P_BOOL,
451          NULL, NULL, NULL},
452
453          {"bold_unread", "TRUE", &prefs_common.bold_unread, P_BOOL,
454          NULL, NULL, NULL},
455
456         {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL,
457          NULL, NULL, NULL},
458 #ifndef GENERIC_UMPC
459         {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM,
460          NULL, NULL, NULL},
461 #else
462         {"toolbar_style", "1", &prefs_common.toolbar_style, P_ENUM,
463          NULL, NULL, NULL},
464 #endif
465         {"toolbar_detachable", "FALSE", &prefs_common.toolbar_detachable, P_BOOL,
466          NULL, NULL, NULL},
467         {"show_col_headers", "TRUE", &prefs_common.show_col_headers, P_BOOL,
468          NULL, NULL, NULL},
469 #ifndef GENERIC_UMPC
470         {"show_statusbar", "TRUE", &prefs_common.show_statusbar, P_BOOL,
471          NULL, NULL, NULL},
472         {"show_searchbar", "TRUE", &prefs_common.show_searchbar, P_BOOL,
473          NULL, NULL, NULL},
474 #else
475         {"show_statusbar", "FALSE", &prefs_common.show_statusbar, P_BOOL,
476          NULL, NULL, NULL},
477         {"show_searchbar", "FALSE", &prefs_common.show_searchbar, P_BOOL,
478          NULL, NULL, NULL},
479 #endif
480
481         {"summary_col_show_mark", "TRUE",
482          &prefs_common.summary_col_visible[S_COL_MARK], P_BOOL, NULL, NULL, NULL},
483         {"summary_col_show_unread", "TRUE",
484          &prefs_common.summary_col_visible[S_COL_STATUS], P_BOOL, NULL, NULL, NULL},
485         {"summary_col_show_subject", "TRUE",
486          &prefs_common.summary_col_visible[S_COL_SUBJECT], P_BOOL, NULL, NULL, NULL},
487         {"summary_col_show_from", "TRUE",
488          &prefs_common.summary_col_visible[S_COL_FROM], P_BOOL, NULL, NULL, NULL},
489         {"summary_col_show_to", "FALSE",
490          &prefs_common.summary_col_visible[S_COL_TO], P_BOOL, NULL, NULL, NULL},
491         {"summary_col_show_date", "TRUE",
492          &prefs_common.summary_col_visible[S_COL_DATE], P_BOOL, NULL, NULL, NULL},
493         {"summary_col_show_mime", "TRUE",
494          &prefs_common.summary_col_visible[S_COL_MIME], P_BOOL, NULL, NULL, NULL},
495         {"summary_col_show_size", "TRUE",
496          &prefs_common.summary_col_visible[S_COL_SIZE], P_BOOL, NULL, NULL, NULL},
497         {"summary_col_show_number", "FALSE",
498          &prefs_common.summary_col_visible[S_COL_NUMBER], P_BOOL, NULL, NULL, NULL},
499         {"summary_col_show_score", "FALSE",
500          &prefs_common.summary_col_visible[S_COL_SCORE], P_BOOL, NULL, NULL, NULL},
501         {"summary_col_show_locked", "FALSE",
502          &prefs_common.summary_col_visible[S_COL_LOCKED], P_BOOL, NULL, NULL, NULL},
503         {"summary_col_show_tags", "FALSE",
504          &prefs_common.summary_col_visible[S_COL_TAGS], P_BOOL, NULL, NULL, NULL},
505
506         {"summary_col_pos_mark", "0",
507           &prefs_common.summary_col_pos[S_COL_MARK], P_INT, NULL, NULL, NULL},
508         {"summary_col_pos_unread", "1",
509           &prefs_common.summary_col_pos[S_COL_STATUS], P_INT, NULL, NULL, NULL},
510         {"summary_col_pos_mime", "2",
511           &prefs_common.summary_col_pos[S_COL_MIME], P_INT, NULL, NULL, NULL},
512         {"summary_col_pos_subject", "3",
513           &prefs_common.summary_col_pos[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
514         {"summary_col_pos_from", "4",
515           &prefs_common.summary_col_pos[S_COL_FROM], P_INT, NULL, NULL, NULL},
516         {"summary_col_pos_date", "5",
517           &prefs_common.summary_col_pos[S_COL_DATE], P_INT, NULL, NULL, NULL},
518         {"summary_col_pos_size", "6",
519           &prefs_common.summary_col_pos[S_COL_SIZE], P_INT, NULL, NULL, NULL},
520         {"summary_col_pos_number", "7",
521           &prefs_common.summary_col_pos[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
522         {"summary_col_pos_score", "8",
523          &prefs_common.summary_col_pos[S_COL_SCORE], P_INT, NULL, NULL, NULL},
524         {"summary_col_pos_locked", "9",
525          &prefs_common.summary_col_pos[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
526         {"summary_col_pos_to", "10",
527           &prefs_common.summary_col_pos[S_COL_TO], P_INT, NULL, NULL, NULL},
528         {"summary_col_pos_tags", "11",
529           &prefs_common.summary_col_pos[S_COL_TAGS], P_INT, NULL, NULL, NULL},
530
531         {"summary_col_size_mark", "10",
532          &prefs_common.summary_col_size[S_COL_MARK], P_INT, NULL, NULL, NULL},
533         {"summary_col_size_unread", "13",
534          &prefs_common.summary_col_size[S_COL_STATUS], P_INT, NULL, NULL, NULL},
535         {"summary_col_size_mime", "10",
536          &prefs_common.summary_col_size[S_COL_MIME], P_INT, NULL, NULL, NULL},
537 #ifndef GENERIC_UMPC
538         {"summary_col_size_subject", "200",
539          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
540         {"summary_col_size_from", "120",
541          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
542         {"summary_col_size_to", "120",
543          &prefs_common.summary_col_size[S_COL_TO], P_INT, NULL, NULL, NULL},
544 #else
545         {"summary_col_size_subject", "300",
546          &prefs_common.summary_col_size[S_COL_SUBJECT], P_INT, NULL, NULL, NULL},
547         {"summary_col_size_from", "150",
548          &prefs_common.summary_col_size[S_COL_FROM], P_INT, NULL, NULL, NULL},
549         {"summary_col_size_to", "150",
550          &prefs_common.summary_col_size[S_COL_TO], P_INT, NULL, NULL, NULL},
551
552 #endif
553         {"summary_col_size_date", "118",
554          &prefs_common.summary_col_size[S_COL_DATE], P_INT, NULL, NULL, NULL},
555         {"summary_col_size_size", "45",
556          &prefs_common.summary_col_size[S_COL_SIZE], P_INT, NULL, NULL, NULL},
557         {"summary_col_size_number", "40",
558          &prefs_common.summary_col_size[S_COL_NUMBER], P_INT, NULL, NULL, NULL},
559         {"summary_col_size_score", "40",
560          &prefs_common.summary_col_size[S_COL_SCORE], P_INT, NULL, NULL, NULL},
561         {"summary_col_size_locked", "13",
562          &prefs_common.summary_col_size[S_COL_LOCKED], P_INT, NULL, NULL, NULL},
563         {"summary_col_size_tags", "150",
564          &prefs_common.summary_col_size[S_COL_TAGS], P_INT, NULL, NULL, NULL},
565
566         /* Widget size */
567         {"folderwin_x", "16", &prefs_common.folderwin_x, P_INT,
568          NULL, NULL, NULL},
569         {"folderwin_y", "16", &prefs_common.folderwin_y, P_INT,
570          NULL, NULL, NULL},
571         {"folderview_width", "270", &prefs_common.folderview_width, P_INT,
572          NULL, NULL, NULL},
573         {"folderview_height", "450", &prefs_common.folderview_height, P_INT,
574          NULL, NULL, NULL},
575         {"folderview_visible", "TRUE", &prefs_common.folderview_visible, P_BOOL,
576          NULL, NULL, NULL},
577
578         {"folder_col_show_folder", "TRUE",
579          &prefs_common.folder_col_visible[F_COL_FOLDER], P_BOOL, NULL, NULL, NULL},
580         {"folder_col_show_new", "TRUE",
581          &prefs_common.folder_col_visible[F_COL_NEW], P_BOOL, NULL, NULL, NULL},
582         {"folder_col_show_unread", "TRUE",
583          &prefs_common.folder_col_visible[F_COL_UNREAD], P_BOOL, NULL, NULL, NULL},
584         {"folder_col_show_total", "TRUE",
585          &prefs_common.folder_col_visible[F_COL_TOTAL], P_BOOL, NULL, NULL, NULL},
586
587         {"folder_col_pos_folder", "0",
588          &prefs_common.folder_col_pos[F_COL_FOLDER], P_INT, NULL, NULL, NULL},
589         {"folder_col_pos_new", "1",
590          &prefs_common.folder_col_pos[F_COL_NEW], P_INT, NULL, NULL, NULL},
591         {"folder_col_pos_unread", "2",
592          &prefs_common.folder_col_pos[F_COL_UNREAD], P_INT, NULL, NULL, NULL},
593         {"folder_col_pos_total", "3",
594          &prefs_common.folder_col_pos[F_COL_TOTAL], P_INT, NULL, NULL, NULL},
595
596 #ifndef GENERIC_UMPC
597         {"folder_col_size_folder", "120",
598          &prefs_common.folder_col_size[F_COL_FOLDER], P_INT, NULL, NULL, NULL},
599         {"folder_col_size_new", "32",
600          &prefs_common.folder_col_size[F_COL_NEW], P_INT, NULL, NULL, NULL},
601         {"folder_col_size_unread", "32",
602          &prefs_common.folder_col_size[F_COL_UNREAD], P_INT, NULL, NULL, NULL},
603         {"folder_col_size_total", "32",
604          &prefs_common.folder_col_size[F_COL_TOTAL], P_INT, NULL, NULL, NULL},
605 #else
606         {"folder_col_size_folder", "400",
607          &prefs_common.folder_col_size[F_COL_FOLDER], P_INT, NULL, NULL, NULL},
608         {"folder_col_size_new", "32",
609          &prefs_common.folder_col_size[F_COL_NEW], P_INT, NULL, NULL, NULL},
610         {"folder_col_size_unread", "32",
611          &prefs_common.folder_col_size[F_COL_UNREAD], P_INT, NULL, NULL, NULL},
612         {"folder_col_size_total", "32",
613          &prefs_common.folder_col_size[F_COL_TOTAL], P_INT, NULL, NULL, NULL},
614 #endif
615         {"summaryview_width", "500", &prefs_common.summaryview_width, P_INT,
616          NULL, NULL, NULL},
617         {"summaryview_height", "244", &prefs_common.summaryview_height, P_INT,
618          NULL, NULL, NULL},
619
620         {"main_messagewin_x", "256", &prefs_common.main_msgwin_x, P_INT,
621          NULL, NULL, NULL},
622         {"main_messagewin_y", "210", &prefs_common.main_msgwin_y, P_INT,
623          NULL, NULL, NULL},
624         {"messageview_width", "500", &prefs_common.msgview_width, P_INT,
625          NULL, NULL, NULL},
626         {"messageview_height", "213", &prefs_common.msgview_height, P_INT,
627          NULL, NULL, NULL},
628         {"messageview_visible", "TRUE", &prefs_common.msgview_visible, P_BOOL,
629          NULL, NULL, NULL},
630
631         {"mainview_x", "64", &prefs_common.mainview_x, P_INT,
632          NULL, NULL, NULL},
633         {"mainview_y", "64", &prefs_common.mainview_y, P_INT,
634          NULL, NULL, NULL},
635         {"mainview_width", "500", &prefs_common.mainview_width, P_INT,
636          NULL, NULL, NULL},
637         {"mainview_height", "400", &prefs_common.mainview_height, P_INT,
638          NULL, NULL, NULL},
639         {"mainwin_x", "64", &prefs_common.mainwin_x, P_INT,
640          NULL, NULL, NULL},
641         {"mainwin_y", "64", &prefs_common.mainwin_y, P_INT,
642          NULL, NULL, NULL},
643         {"mainwin_maximised", "FALSE", &prefs_common.mainwin_maximised, P_BOOL,
644          NULL, NULL, NULL},
645         {"mainwin_fullscreen", "FALSE", &prefs_common.mainwin_fullscreen, P_BOOL,
646          NULL, NULL, NULL},
647         {"mainwin_menubar", "TRUE", &prefs_common.mainwin_menubar, P_BOOL,
648          NULL, NULL, NULL},
649 #ifndef GENERIC_UMPC
650         {"mainwin_width", "800", &prefs_common.mainwin_width, P_INT,
651          NULL, NULL, NULL},
652         {"mainwin_height", "600", &prefs_common.mainwin_height, P_INT,
653          NULL, NULL, NULL},
654         {"messagewin_width", "600", &prefs_common.msgwin_width, P_INT,
655          NULL, NULL, NULL},
656         {"messagewin_height", "540", &prefs_common.msgwin_height, P_INT,
657          NULL, NULL, NULL},
658         {"mimeview_tree_height", "60", &prefs_common.mimeview_tree_height, P_INT,
659          NULL, NULL, NULL},      
660         {"sourcewin_width", "600", &prefs_common.sourcewin_width, P_INT,
661          NULL, NULL, NULL},
662         {"sourcewin_height", "500", &prefs_common.sourcewin_height, P_INT,
663          NULL, NULL, NULL},
664         {"compose_width", "600", &prefs_common.compose_width, P_INT,
665          NULL, NULL, NULL},
666         {"compose_height", "560", &prefs_common.compose_height, P_INT,
667          NULL, NULL, NULL},
668 #else
669         {"mainwin_width", "700", &prefs_common.mainwin_width, P_INT,
670          NULL, NULL, NULL},
671         {"mainwin_height", "470", &prefs_common.mainwin_height, P_INT,
672          NULL, NULL, NULL},
673         {"messagewin_width", "700", &prefs_common.msgwin_width, P_INT,
674          NULL, NULL, NULL},
675         {"messagewin_height", "470", &prefs_common.msgwin_height, P_INT,
676          NULL, NULL, NULL},
677         {"sourcewin_width", "700", &prefs_common.sourcewin_width, P_INT,
678          NULL, NULL, NULL},
679         {"sourcewin_height", "470", &prefs_common.sourcewin_height, P_INT,
680          NULL, NULL, NULL},
681         {"compose_width", "700", &prefs_common.compose_width, P_INT,
682          NULL, NULL, NULL},
683         {"compose_height", "470", &prefs_common.compose_height, P_INT,
684          NULL, NULL, NULL},
685 #endif
686         {"compose_notebook_height", "130", &prefs_common.compose_notebook_height, P_INT,
687          NULL, NULL, NULL},
688         {"compose_x", "0", &prefs_common.compose_x, P_INT,
689          NULL, NULL, NULL},
690         {"compose_y", "0", &prefs_common.compose_y, P_INT,
691          NULL, NULL, NULL},
692         /* Message */
693         {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
694          NULL, NULL, NULL},
695
696         {"quote_level1_color", "#0000b3", &prefs_common.quote_level1_col, P_COLOR,
697          NULL, NULL, NULL},
698         {"quote_level2_color", "#0000b3", &prefs_common.quote_level2_col, P_COLOR,
699          NULL, NULL, NULL},
700         {"quote_level3_color", "#0000b3", &prefs_common.quote_level3_col, P_COLOR,
701          NULL, NULL, NULL},
702         {"enable_bgcolor", "FALSE", &prefs_common.enable_bgcolor, P_BOOL,
703          NULL, NULL, NULL},
704         {"quote_level1_bgcolor", "#cccccc", &prefs_common.quote_level1_bgcol, P_COLOR,
705          NULL, NULL, NULL},
706         {"quote_level2_bgcolor", "#d4d4d4", &prefs_common.quote_level2_bgcol, P_COLOR,
707          NULL, NULL, NULL},
708         {"quote_level3_bgcolor", "#dddddd", &prefs_common.quote_level3_bgcol, P_COLOR,
709          NULL, NULL, NULL},
710         {"uri_color", "#007f00", &prefs_common.uri_col, P_COLOR,
711          NULL, NULL, NULL},
712         {"emphasis_color", "#0000cf", &prefs_common.emphasis_col, P_COLOR,
713          NULL, NULL, NULL},
714         {"target_folder_color", "#da1cca", &prefs_common.tgt_folder_col, P_COLOR,
715          NULL, NULL, NULL},
716         {"signature_color", "#797979", &prefs_common.signature_col, P_COLOR,
717          NULL, NULL, NULL},
718         {"recycle_quote_colors", "FALSE", &prefs_common.recycle_quote_colors,
719          P_BOOL, NULL, NULL, NULL},
720
721         {"default_header_color", "#000000", &prefs_common.default_header_color, P_COLOR,
722          NULL, NULL, NULL},
723         {"default_header_bgcolor", "#f5f6be", &prefs_common.default_header_bgcolor, P_COLOR,
724          NULL, NULL, NULL},
725         {"tags_color", "#000000", &prefs_common.tags_color, P_COLOR,
726          NULL, NULL, NULL},
727         {"tags_bgcolor", "#f5f6be", &prefs_common.tags_bgcolor, P_COLOR,
728          NULL, NULL, NULL},
729         {"qs_active_color", "#000000", &prefs_common.qs_active_color, P_COLOR,
730          NULL, NULL, NULL},
731         {"qs_active_bgcolor", "#f5f6be", &prefs_common.qs_active_bgcolor, P_COLOR,
732          NULL, NULL, NULL},
733         {"qs_error_color", "#000000", &prefs_common.qs_error_color, P_COLOR,
734          NULL, NULL, NULL},
735         {"qs_error_bgcolor", "#ff7070", &prefs_common.qs_error_bgcolor, P_COLOR,
736          NULL, NULL, NULL},
737
738         {"display_header_pane", "FALSE", &prefs_common.display_header_pane,
739          P_BOOL, NULL, NULL, NULL},
740         {"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
741          NULL, NULL, NULL},
742         {"display_xface", "TRUE", &prefs_common.display_xface,
743          P_BOOL, NULL, NULL, NULL},
744         {"render_html", "TRUE", &prefs_common.render_html, P_BOOL,
745          NULL, NULL, NULL},
746         {"invoke_plugin_on_html", "FALSE", &prefs_common.invoke_plugin_on_html, P_BOOL,
747          NULL, NULL, NULL},
748         {"promote_html_part", "FALSE", &prefs_common.promote_html_part, P_BOOL,
749          NULL, NULL, NULL},
750         {"line_space", "2", &prefs_common.line_space, P_INT,
751          NULL, NULL, NULL},
752         {"never_send_retrcpt", "FALSE", &prefs_common.never_send_retrcpt, P_BOOL,
753          NULL, NULL, NULL},
754
755         {"enable_smooth_scroll", "FALSE",
756          &prefs_common.enable_smooth_scroll, P_BOOL,
757          NULL, NULL, NULL},
758         {"scroll_step", "1", &prefs_common.scroll_step, P_INT,
759          NULL, NULL, NULL},
760         {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
761          NULL, NULL, NULL},
762         {"hide_quoted", "TRUE",
763          &prefs_common.hide_quoted, P_BOOL,
764          NULL, NULL, NULL},
765         {"respect_flowed_format", "FALSE", &prefs_common.respect_flowed_format, P_BOOL,
766          NULL, NULL, NULL},
767         {"show_all_headers", "FALSE", &prefs_common.show_all_headers, P_BOOL,
768          NULL, NULL, NULL},
769
770         {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
771          NULL, NULL, NULL},
772
773         {"attach_desc", "TRUE", &prefs_common.attach_desc, P_BOOL,
774          NULL, NULL, NULL},
775         {"attach_save_directory", NULL,
776          &SPECIFIC_PREFS.attach_save_dir, P_STRING, NULL, NULL, NULL},
777         {"attach_load_directory", NULL,
778          &SPECIFIC_PREFS.attach_load_dir, P_STRING, NULL, NULL, NULL},
779
780         /* MIME viewer */
781         {"mime_textviewer",   NULL,
782          &SPECIFIC_PREFS.mime_textviewer,   P_STRING, NULL, NULL, NULL},
783         {"mime_open_command", "gedit '%s'",
784          &SPECIFIC_PREFS.mime_open_cmd,     P_STRING, NULL, NULL, NULL},
785         {"show_inline_attachments", "TRUE", 
786          &prefs_common.show_inline_attachments, P_BOOL, NULL, NULL, NULL},
787
788         /* Interface */
789 #ifndef GENERIC_UMPC
790         {"layout_mode", "0", &prefs_common.layout_mode, P_INT,
791          NULL, NULL, NULL},
792 #else
793         {"layout_mode", "5", &prefs_common.layout_mode, P_INT,
794          NULL, NULL, NULL},
795 #endif
796         /* {"emulate_emacs", "FALSE", &prefs_common.emulate_emacs, P_BOOL,
797          NULL, NULL, NULL}, */
798         {"open_selected_message_on_folder_open", "FALSE",
799          &prefs_common.open_selected_on_folder_open,
800          P_BOOL, NULL, NULL, NULL},
801         {"always_show_message_when_selected", "0",
802          &prefs_common.always_show_msg,
803          P_ENUM, NULL, NULL, NULL},
804         {"select_on_entry", "3", &prefs_common.select_on_entry,
805          P_ENUM, NULL, NULL, NULL},
806         {"show_tooltips", "TRUE", &prefs_common.show_tooltips,
807          P_BOOL, NULL, NULL, NULL},
808
809         /* do it SUMMARY_OPEN_ACTIONS-1 times */
810         {"summary_select_prio1", "0", &prefs_common.summary_select_prio[0], P_ENUM,
811          NULL, NULL, NULL},
812         {"summary_select_prio2", "0", &prefs_common.summary_select_prio[1], P_ENUM,
813          NULL, NULL, NULL},
814         {"summary_select_prio3", "0", &prefs_common.summary_select_prio[2], P_ENUM,
815          NULL, NULL, NULL},
816         {"summary_select_prio4", "0", &prefs_common.summary_select_prio[3], P_ENUM,
817          NULL, NULL, NULL},
818         {"summary_select_prio5", "0", &prefs_common.summary_select_prio[4], P_ENUM,
819          NULL, NULL, NULL},
820         {"summary_select_prio6", "0", &prefs_common.summary_select_prio[5], P_ENUM,
821          NULL, NULL, NULL},
822         {"summary_select_prio7", "0", &prefs_common.summary_select_prio[6], P_ENUM,
823          NULL, NULL, NULL},
824
825         {"mark_as_read_on_new_window", "FALSE",
826          &prefs_common.mark_as_read_on_new_window,
827          P_BOOL, NULL, NULL, NULL},
828         {"mark_as_read_delay", "0",
829          &prefs_common.mark_as_read_delay, P_INT, 
830          NULL, NULL, NULL},
831         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
832          NULL, NULL, NULL},
833         {"nextunreadmsg_dialog", "1", &prefs_common.next_unread_msg_dialog, P_ENUM,
834          NULL, NULL, NULL},
835         {"summary_from_show", "0", &prefs_common.summary_from_show, P_ENUM,
836          NULL, NULL, NULL},
837
838         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
839          &SPECIFIC_PREFS.pixmap_theme_path, P_STRING,
840          NULL, NULL, NULL},
841
842         {"ask_mark_all_read", "TRUE", &prefs_common.ask_mark_all_read, P_BOOL,
843          NULL, NULL, NULL},
844
845         {"ask_apply_per_account_filtering_rules", "TRUE", &prefs_common.ask_apply_per_account_filtering_rules, P_BOOL,
846          NULL, NULL, NULL},
847         {"apply_per_account_filtering_rules", "0", &prefs_common.apply_per_account_filtering_rules, P_ENUM,
848          NULL, NULL, NULL},
849
850         /* Addressbook */
851         {"addressbook_use_editaddress_dialog", "TRUE", &prefs_common.addressbook_use_editaddress_dialog,
852          P_BOOL, NULL, NULL, NULL},
853         {"addressbook_hpaned_pos", "-1", &prefs_common.addressbook_hpaned_pos,
854          P_INT, NULL, NULL, NULL},
855         {"addressbook_vpaned_pos", "-1", &prefs_common.addressbook_vpaned_pos,
856          P_INT, NULL, NULL, NULL},
857
858         /* Other */
859 #ifndef G_OS_WIN32
860         {"uri_open_command", DEFAULT_BROWSER_CMD,
861          &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL},
862 #else
863         {"gtk_theme", DEFAULT_W32_GTK_THEME,
864          &SPECIFIC_PREFS.gtk_theme, P_STRING, NULL, NULL, NULL},
865 #endif
866         {"ext_editor_command", DEFAULT_EDITOR_CMD,
867          &SPECIFIC_PREFS.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
868         {"cmds_use_system_default", "TRUE",
869          &prefs_common.cmds_use_system_default, P_BOOL, NULL, NULL, NULL},
870         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
871          P_BOOL, NULL, NULL, NULL},
872         {"session_passwords", "FALSE", &prefs_common.session_passwords,
873          P_BOOL, NULL, NULL, NULL},
874         {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
875          NULL, NULL, NULL},
876         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
877          NULL, NULL, NULL},
878         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
879          NULL, NULL, NULL},
880         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
881          P_BOOL, NULL, NULL, NULL},
882         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
883          NULL, NULL, NULL},
884         {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
885          NULL, NULL, NULL},
886 #ifndef GENERIC_UMPC
887         {"summary_quicksearch_recurse", "1", &prefs_common.summary_quicksearch_recurse, P_INT,
888          NULL, NULL, NULL},
889 #else
890         {"summary_quicksearch_recurse", "0", &prefs_common.summary_quicksearch_recurse, P_INT,
891          NULL, NULL, NULL},
892 #endif
893
894 #if defined(__OpenBSD__)
895         {"io_timeout_secs", "80", &prefs_common.io_timeout_secs,
896          P_INT, NULL, NULL, NULL},
897 #else
898         {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
899          P_INT, NULL, NULL, NULL},
900 #endif
901         {"hide_score", "-9999", &prefs_common.kill_score, P_INT,
902          NULL, NULL, NULL},
903         {"important_score", "1", &prefs_common.important_score, P_INT,
904          NULL, NULL, NULL},
905
906         {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
907          NULL, NULL, NULL},
908         {"log_length", "500", &prefs_common.loglength, P_INT,
909          NULL, NULL, NULL},
910 #ifndef GENERIC_UMPC
911         {"enable_log_standard", "TRUE", &prefs_common.enable_log_standard, P_BOOL,
912          NULL, NULL, NULL},
913         {"enable_log_warning", "TRUE", &prefs_common.enable_log_warning, P_BOOL,
914          NULL, NULL, NULL},
915         {"enable_log_error", "TRUE", &prefs_common.enable_log_error, P_BOOL,
916          NULL, NULL, NULL},
917         {"enable_log_status", "TRUE", &prefs_common.enable_log_status, P_BOOL,
918          NULL, NULL, NULL},
919 #else
920         {"enable_log_standard", "FALSE", &prefs_common.enable_log_standard, P_BOOL,
921          NULL, NULL, NULL},
922         {"enable_log_warning", "FALSE", &prefs_common.enable_log_warning, P_BOOL,
923          NULL, NULL, NULL},
924         {"enable_log_error", "FALSE", &prefs_common.enable_log_error, P_BOOL,
925          NULL, NULL, NULL},
926         {"enable_log_status", "FALSE", &prefs_common.enable_log_status, P_BOOL,
927          NULL, NULL, NULL},
928 #endif
929         {"log_msg_color", "#00af00", &prefs_common.log_msg_color, P_COLOR,
930          NULL, NULL, NULL},
931         {"log_warn_color", "#af0000", &prefs_common.log_warn_color, P_COLOR,
932          NULL, NULL, NULL},
933         {"log_error_color", "#af0000", &prefs_common.log_error_color, P_COLOR,
934          NULL, NULL, NULL},
935         {"log_in_color", "#000000", &prefs_common.log_in_color, P_COLOR,
936          NULL, NULL, NULL},
937         {"log_out_color", "#0000ef", &prefs_common.log_out_color, P_COLOR,
938          NULL, NULL, NULL},
939         {"log_status_ok_color", "#00af00", &prefs_common.log_status_ok_color, P_COLOR,
940          NULL, NULL, NULL},
941         {"log_status_nok_color", "#0000af", &prefs_common.log_status_nok_color, P_COLOR,
942          NULL, NULL, NULL},
943         {"log_status_skip_color", "#aa00aa", &prefs_common.log_status_skip_color, P_COLOR,
944          NULL, NULL, NULL},
945
946     {"enable_filtering_debug", "FALSE", &prefs_common.enable_filtering_debug, P_BOOL,
947          NULL, NULL, NULL},
948     {"filtering_debug_level", "1", &prefs_common.filtering_debug_level, P_INT,
949          NULL, NULL, NULL},
950     {"enable_filtering_debug_inc", "TRUE", &prefs_common.enable_filtering_debug_inc, P_BOOL,
951          NULL, NULL, NULL},
952     {"enable_filtering_debug_manual", "TRUE", &prefs_common.enable_filtering_debug_manual, P_BOOL,
953          NULL, NULL, NULL},
954     {"enable_filtering_debug_folder_proc", "FALSE", &prefs_common.enable_filtering_debug_folder_proc, P_BOOL,
955          NULL, NULL, NULL},
956     {"enable_filtering_debug_pre_proc", "FALSE", &prefs_common.enable_filtering_debug_pre_proc, P_BOOL,
957          NULL, NULL, NULL},
958     {"enable_filtering_debug_post_proc", "FALSE", &prefs_common.enable_filtering_debug_post_proc, P_BOOL,
959          NULL, NULL, NULL},
960     {"filtering_debug_clip_log", "TRUE", &prefs_common.filtering_debug_cliplog, P_BOOL,
961          NULL, NULL, NULL},
962         {"filtering_debug_log_length", "500", &prefs_common.filtering_debug_loglength, P_INT,
963          NULL, NULL, NULL},
964
965         {"gtk_can_change_accels", "FALSE", &prefs_common.gtk_can_change_accels, P_BOOL,
966          NULL, NULL, NULL},
967
968         {"color_new", "#0000b3", &prefs_common.color_new, P_COLOR,
969          NULL, NULL, NULL},
970
971         /* Some windows' sizes */
972         {"filteringwin_width", "500", &prefs_common.filteringwin_width, P_INT,
973          NULL, NULL, NULL},
974         {"filteringwin_height", "-1", &prefs_common.filteringwin_height, P_INT,
975          NULL, NULL, NULL},
976
977         {"filteringactionwin_width", "490", &prefs_common.filteringactionwin_width, P_INT,
978          NULL, NULL, NULL},
979         {"filteringactionwin_height", "-1", &prefs_common.filteringactionwin_height, P_INT,
980          NULL, NULL, NULL},
981
982         {"matcherwin_width", "520", &prefs_common.matcherwin_width, P_INT,
983          NULL, NULL, NULL},
984         {"matcherwin_height", "-1", &prefs_common.matcherwin_height, P_INT,
985          NULL, NULL, NULL},
986
987         {"templateswin_width", "480", &prefs_common.templateswin_width, P_INT,
988          NULL, NULL, NULL},
989         {"templateswin_height", "-1", &prefs_common.templateswin_height, P_INT,
990          NULL, NULL, NULL},
991
992         {"actionswin_width", "486", &prefs_common.actionswin_width, P_INT,
993          NULL, NULL, NULL},
994         {"actionswin_height", "-1", &prefs_common.actionswin_height, P_INT,
995          NULL, NULL, NULL},
996
997         {"tagswin_width", "486", &prefs_common.tagswin_width, P_INT,
998          NULL, NULL, NULL},
999         {"tagswin_height", "-1", &prefs_common.tagswin_height, P_INT,
1000          NULL, NULL, NULL},
1001
1002         {"addressbookwin_width", "520", &prefs_common.addressbookwin_width, P_INT,
1003          NULL, NULL, NULL},
1004         {"addressbookwin_height", "-1", &prefs_common.addressbookwin_height, P_INT,
1005          NULL, NULL, NULL},
1006
1007         {"addressbookeditpersonwin_width", "640", &prefs_common.addressbookeditpersonwin_width, P_INT,
1008          NULL, NULL, NULL},
1009         {"addressbookeditpersonwin_height", "320", &prefs_common.addressbookeditpersonwin_height, P_INT,
1010          NULL, NULL, NULL},
1011
1012         {"addressbookeditgroupwin_width", "580", &prefs_common.addressbookeditgroupwin_width, P_INT,
1013          NULL, NULL, NULL},
1014         {"addressbookeditgroupwin_height", "340", &prefs_common.addressbookeditgroupwin_height, P_INT,
1015          NULL, NULL, NULL},
1016
1017         {"pluginswin_width", "-1", &prefs_common.pluginswin_width, P_INT,
1018          NULL, NULL, NULL},
1019         {"pluginswin_height", "-1", &prefs_common.pluginswin_height, P_INT,
1020          NULL, NULL, NULL},
1021
1022         {"prefswin_width", "600", &prefs_common.prefswin_width, P_INT,
1023          NULL, NULL, NULL},
1024         {"prefswin_height", "-1", &prefs_common.prefswin_height, P_INT,
1025          NULL, NULL, NULL},
1026
1027         {"folderitemwin_width", "500", &prefs_common.folderitemwin_width, P_INT,
1028          NULL, NULL, NULL},
1029         {"folderitemwin_height", "-1", &prefs_common.folderitemwin_height, P_INT,
1030          NULL, NULL, NULL},
1031
1032         {"zero_replacement_char", "0", &prefs_common.zero_replacement, P_STRING,
1033          NULL, NULL, NULL},
1034
1035         {"editaccountwin_width", "500", &prefs_common.editaccountwin_width, P_INT,
1036          NULL, NULL, NULL},
1037         {"editaccountwin_height", "-1", &prefs_common.editaccountwin_height, P_INT,
1038          NULL, NULL, NULL},
1039
1040         {"accountswin_width", "500", &prefs_common.accountswin_width, P_INT,
1041          NULL, NULL, NULL},
1042         {"accountswin_height", "-1", &prefs_common.accountswin_height, P_INT,
1043          NULL, NULL, NULL},
1044
1045         {"logwin_width", "520", &prefs_common.logwin_width, P_INT,
1046          NULL, NULL, NULL},
1047         {"logwin_height", "-1", &prefs_common.logwin_height, P_INT,
1048          NULL, NULL, NULL},
1049
1050         {"filtering_debugwin_width", "600", &prefs_common.filtering_debugwin_width, P_INT,
1051          NULL, NULL, NULL},
1052         {"filtering_debugwin_height", "-1", &prefs_common.filtering_debugwin_height, P_INT,
1053          NULL, NULL, NULL},
1054
1055         {"folderselwin_width", "300", &prefs_common.folderselwin_width, P_INT,
1056          NULL, NULL, NULL},
1057         {"folderselwin_height", "-1", &prefs_common.folderselwin_height, P_INT,
1058          NULL, NULL, NULL},
1059
1060         {"addressaddwin_width", "300", &prefs_common.addressaddwin_width, P_INT,
1061          NULL, NULL, NULL},
1062         {"addressaddwin_height", "-1", &prefs_common.addressaddwin_height, P_INT,
1063          NULL, NULL, NULL},
1064
1065         {"addressbook_folderselwin_width", "300", &prefs_common.addressbook_folderselwin_width, P_INT,
1066          NULL, NULL, NULL},
1067         {"addressbook_folderselwin_height", "-1", &prefs_common.addressbook_folderselwin_height, P_INT,
1068          NULL, NULL, NULL},
1069
1070         {"aboutwin_width", "450", &prefs_common.aboutwin_width, P_INT,
1071          NULL, NULL, NULL},
1072         {"aboutwin_height", "500", &prefs_common.aboutwin_height, P_INT,
1073          NULL, NULL, NULL},
1074
1075         {"addrgather_width", "450", &prefs_common.addrgather_width, P_INT,
1076          NULL, NULL, NULL},
1077         {"addrgather_height", "-1", &prefs_common.addrgather_height, P_INT,
1078          NULL, NULL, NULL},
1079
1080         {"news_subscribe_width", "450", &prefs_common.news_subscribe_width, P_INT,
1081          NULL, NULL, NULL},
1082         {"news_subscribe_height", "400", &prefs_common.news_subscribe_height, P_INT,
1083          NULL, NULL, NULL},
1084
1085         /* Hidden */
1086         {"warn_dnd", "1", &prefs_common.warn_dnd, P_INT,
1087          NULL, NULL, NULL},
1088         {"utf8_instead_of_locale_for_broken_mail", "0", 
1089          &prefs_common.broken_are_utf8, P_INT,
1090          NULL, NULL, NULL},
1091         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
1092          NULL, NULL, NULL},
1093         {"use_stripes_everywhere", "TRUE", &prefs_common.use_stripes_everywhere, P_BOOL,
1094          NULL, NULL, NULL},
1095         {"use_stripes_in_summaries", "TRUE", &prefs_common.use_stripes_in_summaries, P_BOOL,
1096          NULL, NULL, NULL},
1097         {"stripes_color_offset", "4000", &prefs_common.stripes_color_offset, P_INT,
1098          NULL, NULL, NULL},
1099         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
1100          NULL, NULL, NULL},
1101         {"folderview_vscrollbar_policy", "0",
1102          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
1103          NULL, NULL, NULL},
1104         {"textview_cursor_visible", "FALSE",
1105          &prefs_common.textview_cursor_visible, P_BOOL,
1106          NULL, NULL, NULL},
1107         {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
1108          NULL, NULL, NULL},
1109 #ifndef GENERIC_UMPC
1110         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
1111          NULL, NULL, NULL},
1112         {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
1113          NULL, NULL, NULL},
1114 #else
1115         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
1116          NULL, NULL, NULL},
1117         {"cache_min_keep_time", "0", &prefs_common.cache_min_keep_time, P_INT,
1118          NULL, NULL, NULL},
1119 #endif
1120         {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
1121         P_INT, NULL, NULL, NULL },
1122         {"last_opened_folder", "", &prefs_common.last_opened_folder,
1123         P_STRING, NULL, NULL, NULL },
1124         {"goto_last_folder_on_startup", "FALSE", &prefs_common.goto_last_folder_on_startup,
1125         P_BOOL, NULL, NULL, NULL },
1126         {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
1127          NULL, NULL, NULL},
1128         {"summary_quicksearch_dynamic", "0", &prefs_common.summary_quicksearch_dynamic, P_INT,
1129          NULL, NULL, NULL},
1130         {"summary_quicksearch_autorun", "0", &prefs_common.summary_quicksearch_autorun, P_INT,
1131          NULL, NULL, NULL},
1132         {"statusbar_update_step", "10", &prefs_common.statusbar_update_step, P_INT,
1133          NULL, NULL, NULL},
1134         {"compose_no_markup", "FALSE", &prefs_common.compose_no_markup, P_BOOL,
1135          NULL, NULL, NULL},
1136         {"skip_ssl_cert_check", "FALSE", &prefs_common.skip_ssl_cert_check, P_BOOL,
1137          NULL, NULL, NULL},
1138         {"live_dangerously", "FALSE", &prefs_common.live_dangerously, P_BOOL,
1139          NULL, NULL, NULL},
1140         {"save_parts_readwrite", "FALSE", &prefs_common.save_parts_readwrite, P_BOOL,
1141          NULL, NULL, NULL},
1142         {"hide_quotes", "0", &prefs_common.hide_quotes, P_INT,
1143          NULL, NULL, NULL},
1144         {"unsafe_ssl_certs", "FALSE", &prefs_common.unsafe_ssl_certs, P_BOOL,
1145          NULL, NULL, NULL},
1146 #ifndef GENERIC_UMPC
1147         {"real_time_sync", "FALSE", &prefs_common.real_time_sync, P_BOOL,
1148          NULL, NULL, NULL},
1149 #else
1150         {"real_time_sync", "TRUE", &prefs_common.real_time_sync, P_BOOL,
1151          NULL, NULL, NULL},
1152 #endif
1153
1154         {"print_paper_type", NULL, &prefs_common.print_paper_type, P_STRING,
1155          NULL, NULL, NULL},
1156         {"print_paper_orientation", "0", &prefs_common.print_paper_orientation, P_INT,
1157          NULL, NULL, NULL},
1158         {"print_margin_top", "-1", &prefs_common.print_margin_top, P_INT,
1159          NULL, NULL, NULL},
1160         {"print_margin_bottom", "-1", &prefs_common.print_margin_bottom, P_INT,
1161          NULL, NULL, NULL},
1162         {"print_margin_left", "-1", &prefs_common.print_margin_left, P_INT,
1163          NULL, NULL, NULL},
1164         {"print_margin_right", "-1", &prefs_common.print_margin_right, P_INT,
1165          NULL, NULL, NULL},
1166         {"print_use_color", "0", &prefs_common.print_use_color, P_INT,
1167          NULL, NULL, NULL},
1168         {"print_use_collate", "0", &prefs_common.print_use_collate, P_INT,
1169          NULL, NULL, NULL},
1170         {"print_use_reverse", "0", &prefs_common.print_use_reverse, P_INT,
1171          NULL, NULL, NULL},
1172         {"print_use_duplex", "0", &prefs_common.print_use_duplex, P_INT,
1173          NULL, NULL, NULL},
1174         {"print_imgs", "1", &prefs_common.print_imgs, P_INT,
1175          NULL, NULL, NULL},
1176         {"print_previewwin_width", "600", &prefs_common.print_previewwin_width, P_INT,
1177          NULL, NULL, NULL},
1178         {"print_previewwin_height", "-1", &prefs_common.print_previewwin_height, P_INT,
1179          NULL, NULL, NULL},
1180         {"use_networkmanager", "TRUE", &prefs_common.use_networkmanager, P_BOOL,
1181          NULL, NULL, NULL},
1182         {"use_shred", "FALSE", &prefs_common.use_shred, P_BOOL,
1183          NULL, NULL, NULL},
1184
1185         {"two_line_vertical", "TRUE", &prefs_common.two_line_vert,
1186         P_BOOL, NULL, NULL, NULL },
1187
1188         {"inherit_folder_properties", "FALSE", &prefs_common.inherit_folder_props, P_BOOL,
1189          NULL, NULL, NULL},
1190
1191         {"flush_metadata", "TRUE", &prefs_common.flush_metadata, P_BOOL,
1192          NULL, NULL, NULL},
1193
1194         {"nav_history_length", "50", &prefs_common.nav_history_length, P_INT,
1195          NULL, NULL, NULL},
1196
1197         {"diff_added_color", "#008b8b", &prefs_common.diff_added_color, P_COLOR,
1198          NULL, NULL, NULL},
1199         {"diff_deleted_color", "#6a5acd", &prefs_common.diff_deleted_color, P_COLOR,
1200          NULL, NULL, NULL},
1201         {"diff_hunk_color", "#a52a2a", &prefs_common.diff_hunk_color, P_COLOR,
1202          NULL, NULL, NULL},
1203
1204         {"folder_search_wildcard", "TRUE", &prefs_common.folder_search_wildcard, P_BOOL,
1205          NULL, NULL, NULL},
1206         {"address_search_wildcard", "TRUE", &prefs_common.address_search_wildcard, P_BOOL,
1207          NULL, NULL, NULL},
1208         {"enable_avatars", "3", &prefs_common.enable_avatars, P_INT, NULL, NULL, NULL},
1209 #ifndef PASSWORD_CRYPTO_OLD
1210         {"use_master_passphrase", FALSE, &prefs_common.use_master_passphrase, P_BOOL, NULL, NULL, NULL },
1211         {"master_passphrase", "", &prefs_common.master_passphrase, P_STRING, NULL, NULL, NULL },
1212         {"master_passphrase_salt", "", &prefs_common.master_passphrase_salt, P_STRING, NULL, NULL, NULL },
1213         {"master_passphrase_pbkdf2_rounds", "50000", &prefs_common.master_passphrase_pbkdf2_rounds, P_INT, NULL, NULL, NULL},
1214 #endif
1215
1216         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
1217 };
1218
1219 /*
1220  * Read history list from the specified history file in the specified directory (subdir of rc_dir)
1221  * Fallback to default_list if history file is not found
1222  */
1223 GList *prefs_common_read_history_from_dir_with_defaults(const gchar *dirname, const gchar *history,
1224                                                                                                                           GList *default_list)
1225 {
1226         FILE *fp;
1227         gchar *path;
1228         gchar buf[PREFSBUFSIZE];
1229         GList *tmp = NULL;
1230
1231         if (dirname) {
1232                 path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, dirname,
1233                                    G_DIR_SEPARATOR_S, history,
1234                                    NULL);
1235         } else {
1236         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
1237                            NULL);
1238         }
1239         if ((fp = g_fopen(path, "rb")) == NULL) {
1240                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
1241                 g_free(path);
1242                 /* returns default list if set, otherwise NULL */
1243                 return default_list;
1244         }
1245         g_free(path);
1246         while (fgets(buf, sizeof(buf), fp) != NULL) {
1247                 g_strstrip(buf);
1248                 if (buf[0] == '\0') continue;
1249                 tmp = add_history(tmp, buf);
1250         }
1251         fclose(fp);
1252
1253         tmp = g_list_reverse(tmp);
1254
1255         return tmp;
1256 }
1257
1258 /*
1259  * Read history list from the specified history file in the specified directory (subdir of rc_dir)
1260  */
1261 static GList *prefs_common_read_history_from_dir(const gchar *dirname, const gchar *history) 
1262 {
1263         return prefs_common_read_history_from_dir_with_defaults(dirname, history, NULL);
1264 }
1265
1266 /*
1267  * Read history list from the specified history file
1268  */
1269 static GList *prefs_common_read_history(const gchar *history) 
1270 {
1271         return prefs_common_read_history_from_dir(NULL, history);
1272 }
1273
1274 void prefs_common_read_config(void)
1275 {
1276         gchar *rcpath;
1277         gchar *tmp;
1278
1279         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
1280         prefs_read_config(param, "Common", rcpath, NULL);
1281 #ifdef G_OS_WIN32
1282         prefs_read_config(param_os_specific, "CommonWin32", rcpath, NULL);
1283 #endif
1284
1285         g_free(rcpath);
1286
1287         tmp = g_strdup(gettext(prefs_common.date_format));
1288         g_free(prefs_common.date_format);
1289         prefs_common.date_format = tmp;
1290
1291         prefs_common.mime_open_cmd_history =
1292                 prefs_common_read_history(COMMAND_HISTORY);
1293         prefs_common.summary_quicksearch_history =
1294                 prefs_common_read_history(QUICKSEARCH_HISTORY);
1295         prefs_common.summary_search_from_history =
1296                 prefs_common_read_history(SUMMARY_SEARCH_FROM_HISTORY);
1297         prefs_common.summary_search_to_history =
1298                 prefs_common_read_history(SUMMARY_SEARCH_TO_HISTORY);
1299         prefs_common.summary_search_subject_history =
1300                 prefs_common_read_history(SUMMARY_SEARCH_SUBJECT_HISTORY);
1301         prefs_common.summary_search_body_history =
1302                 prefs_common_read_history(SUMMARY_SEARCH_BODY_HISTORY);
1303         prefs_common.summary_search_adv_condition_history =
1304                 prefs_common_read_history(SUMMARY_SEARCH_ADV_CONDITION_HISTORY);
1305         prefs_common.message_search_history =
1306                 prefs_common_read_history(MESSAGE_SEARCH_HISTORY);
1307         prefs_common.compose_save_to_history =
1308                 prefs_common_read_history(COMPOSE_SAVE_TO_HISTORY);
1309 #ifndef USE_ALT_ADDRBOOK
1310         prefs_common.addressbook_custom_attributes = addressbook_update_custom_attr_from_prefs();
1311 #endif
1312         colorlabel_update_colortable_from_prefs();
1313 }
1314
1315 #define TRY(func) \
1316 if (!(func)) \
1317 { \
1318         g_warning("failed to write"); \
1319         goto out;                       \
1320 } \
1321
1322 /*
1323  * Save history list to the specified history file in the specified directory (subdir of rc_dir)
1324  */
1325 static void prefs_common_save_history_to_dir(const gchar *dirname, const gchar *history, GList *list)
1326 {
1327         GList *cur;
1328         FILE *fp;
1329         gchar *path, *tmp_path;
1330
1331         if (dirname) {
1332                 path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, dirname,
1333                                    G_DIR_SEPARATOR_S, history,
1334                                    NULL);
1335         } else {
1336         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
1337                            NULL);
1338         }
1339         tmp_path = g_strconcat(path, ".tmp", NULL);
1340
1341         if ((fp = g_fopen(tmp_path, "wb")) == NULL) {
1342                 FILE_OP_ERROR(tmp_path, "fopen");
1343                 goto out;
1344         }
1345
1346         for (cur = list; cur != NULL; cur = cur->next) {
1347                 TRY(fputs((gchar *)cur->data, fp) != EOF &&
1348                     fputc('\n', fp) != EOF);
1349         }
1350
1351         if (fclose(fp) == EOF) {
1352                 FILE_OP_ERROR(tmp_path, "fclose");
1353                 fp = NULL;
1354                 goto out;
1355         }
1356         fp = NULL;
1357 #ifdef G_OS_WIN32
1358         claws_unlink(path);
1359 #endif
1360         if (g_rename(tmp_path, path) < 0) {
1361                 FILE_OP_ERROR(path, "rename");
1362                 goto out;
1363         }
1364
1365 out:
1366         if (fp)
1367                 fclose(fp);
1368         g_free(tmp_path);
1369         g_free(path);
1370 }
1371
1372 /*
1373  * Save history list to the specified history file
1374  */
1375 static void prefs_common_save_history(const gchar *history, GList *list)
1376 {
1377         prefs_common_save_history_to_dir(NULL, history, list);
1378 }
1379
1380 #undef TRY
1381
1382 void prefs_common_write_config(void)
1383 {
1384         prefs_write_config(param, "Common", COMMON_RC);
1385 #ifdef G_OS_WIN32
1386         prefs_write_config(param_os_specific, "CommonWin32", COMMON_RC);
1387 #endif
1388
1389         prefs_common_save_history(COMMAND_HISTORY, 
1390                 prefs_common.mime_open_cmd_history);
1391         prefs_common_save_history(QUICKSEARCH_HISTORY, 
1392                 prefs_common.summary_quicksearch_history);
1393         prefs_common_save_history(SUMMARY_SEARCH_FROM_HISTORY, 
1394                 prefs_common.summary_search_from_history);
1395         prefs_common_save_history(SUMMARY_SEARCH_TO_HISTORY, 
1396                 prefs_common.summary_search_to_history);
1397         prefs_common_save_history(SUMMARY_SEARCH_SUBJECT_HISTORY, 
1398                 prefs_common.summary_search_subject_history);
1399         prefs_common_save_history(SUMMARY_SEARCH_BODY_HISTORY, 
1400                 prefs_common.summary_search_body_history);
1401         prefs_common_save_history(SUMMARY_SEARCH_ADV_CONDITION_HISTORY, 
1402                 prefs_common.summary_search_adv_condition_history);
1403         prefs_common_save_history(MESSAGE_SEARCH_HISTORY, 
1404                 prefs_common.message_search_history);
1405         prefs_common_save_history(COMPOSE_SAVE_TO_HISTORY, 
1406                 prefs_common.compose_save_to_history);
1407
1408 #ifndef USE_ALT_ADDRBOOK
1409                 prefs_common_save_history_to_dir(ADDRBOOK_DIR,
1410                 ADDRESSBOOK_CUSTOM_ATTRIBUTES, 
1411                 prefs_common.addressbook_custom_attributes);
1412 #endif
1413 }
1414
1415 /* make a copy of string 'in' into buffer 'out'. un-escape \ sequences.
1416    both 'in' and 'out' must be non-NULL.
1417    'out' must be a pointer to a buffer whose size is at least equal
1418    to strlen(txt)+1, this buffer will get cleared. out's contents
1419    will always get set to a valid string, even if it's "".*/
1420 void pref_get_unescaped_pref(gchar *out, const gchar *in)
1421 {
1422         const gchar *i;
1423         gchar *o;
1424
1425         *out = '\0';
1426
1427         cm_return_if_fail( in != NULL );
1428         cm_return_if_fail( out != NULL );
1429
1430         i = in;
1431         o = out;
1432         memset(out, 0, strlen(in)+1);
1433         while (*i != '\0') {
1434                 if (*i == '\\' && *(i+1) == 'n') {
1435                         *o++ = '\n';
1436                         i++;
1437                 } else if (*i == '\\' && *(i+1) == 't') {
1438                         *o++ = '\t';
1439                         i++;
1440                 } else if (*i == '\\' && *(i+1) == '\\') {
1441                         *o++ = '\\';
1442                         i++;
1443                 } else {
1444                         *o++ = *i;
1445                 }
1446                 i++;
1447         }
1448         *o='\0';
1449 }
1450
1451 /* make a copy of string 'in' into buffer 'out'. escape \ sequences.
1452    both 'in' and 'out' must be non-NULL.
1453    'out' must be a pointer to a buffer whose size is at least equal
1454    to 2*strlen(txt)+1. out's contents will always get set to a valid
1455    string, even if it's "". */
1456 void pref_get_escaped_pref(gchar *out, const gchar *in)
1457 {
1458         const gchar *i;
1459         gchar *o;
1460
1461         *out = '\0';
1462
1463         cm_return_if_fail( in != NULL );
1464         cm_return_if_fail( out != NULL );
1465
1466         i = in;
1467         o = out;
1468         while (*i != '\0') {
1469                 if (*i == '\n') {
1470                         *o++ = '\\';
1471                         *o++ = 'n';
1472                 } else if (*i == '\t') {
1473                         *o++ = '\\';
1474                         *o++ = 't';
1475                 } else if (*i == '\\') {
1476                         *o++ = '\\';
1477                         *o++ = '\\';
1478                 } else {
1479                         *o++ = *i;
1480                 }
1481                 i++;
1482         }
1483         *o = '\0';
1484 }
1485                 
1486 /* set the contents of a textview widget from the internal \-escaped
1487   representation of a pref string. both txt and textview must be non-NULL. */
1488 void pref_set_textview_from_pref(GtkTextView *textview, const gchar *txt)
1489 {
1490         GtkTextBuffer *buffer;
1491         gchar *out = NULL;
1492
1493         cm_return_if_fail( textview != NULL );
1494
1495         buffer = gtk_text_view_get_buffer(textview);
1496
1497         if (!txt) {
1498                 gtk_text_buffer_set_text(buffer, "", -1);
1499         } else {
1500                 out = g_malloc(strlen(txt)+1);
1501
1502                 pref_get_unescaped_pref(out, txt);
1503
1504                 gtk_text_buffer_set_text(buffer, out, -1);
1505                 g_free(out);
1506         }
1507 }
1508
1509 /* set the contents of a gtkentry widget from the internal \-escaped
1510   representation of a pref string. both txt and entry must be non-NULL. */
1511 void pref_set_entry_from_pref(GtkEntry *entry, const gchar *txt)
1512 {
1513         gchar *out = NULL;
1514
1515         cm_return_if_fail( entry != NULL );
1516         if (!txt) {
1517                 gtk_entry_set_text(entry, "");
1518         } else {
1519                 out = g_malloc(strlen(txt)+1);
1520
1521                 pref_get_unescaped_pref(out, txt);
1522
1523                 gtk_entry_set_text(entry, out);
1524                 g_free(out);
1525         }
1526 }
1527
1528 /* get the \-escaped internal representation of a pref from the contents of
1529    a textview widget. textview must be non-NULL. */
1530 gchar *pref_get_pref_from_textview(GtkTextView *textview) 
1531 {
1532         GtkTextBuffer *buffer;
1533         GtkTextIter start, end;
1534         gchar *out, *tmp;
1535         
1536         cm_return_val_if_fail( textview != NULL, "" );
1537
1538         buffer = gtk_text_view_get_buffer(textview);
1539         gtk_text_buffer_get_start_iter(buffer, &start);
1540         gtk_text_buffer_get_iter_at_offset(buffer, &end, -1);
1541         tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
1542         out = malloc(2*strlen(tmp)+1);
1543         if (out)
1544                 pref_get_escaped_pref(out, tmp);
1545         g_free(tmp);
1546
1547         return out?out:"";
1548 }
1549
1550 /* get the \-escaped internal representation of a pref from the contents of
1551    a gtkentry widget. entry must be non-NULL. */
1552 gchar *pref_get_pref_from_entry(GtkEntry *entry) 
1553 {
1554         gchar *out, *tmp;
1555
1556         cm_return_val_if_fail( entry != NULL, "" );
1557
1558         tmp = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
1559         out = malloc(2*strlen(tmp)+1);
1560         
1561         if (out)
1562                 pref_get_escaped_pref(out, tmp);
1563         g_free(tmp);
1564
1565         return out?out:"";
1566 }
1567
1568 /* ugly hack to be able to get this pref from ssl_certificate.c */
1569 gboolean prefs_common_unsafe_ssl_certs(void)
1570 {
1571         return prefs_common.unsafe_ssl_certs;
1572 }
1573
1574 gboolean prefs_common_enable_log_standard(void)
1575 {
1576         return prefs_common.enable_log_standard;
1577 }
1578
1579 gboolean prefs_common_enable_log_warning(void)
1580 {
1581         return prefs_common.enable_log_warning;
1582 }
1583 gboolean prefs_common_enable_log_error(void)
1584 {
1585         return prefs_common.enable_log_error;
1586 }
1587 gboolean prefs_common_enable_log_status(void)
1588 {
1589         return prefs_common.enable_log_status;
1590 }
1591
1592 /**
1593    return the translated name of a header, if the translate_header option is
1594    set, otherwise return the untranslated header name (header_name itself).
1595    this function is provided for convenience, it's an interface to
1596    prefs_common.trans_hdr.
1597    works with header names either with or without trailing colon, provided
1598    that gettext found such header name in the sources (they should all be
1599    found in src/gtk/headers.h anyway).
1600 */
1601 const gchar *prefs_common_translated_header_name(const gchar *header_name)
1602 {
1603         if (header_name == NULL || *header_name == '\0')
1604                 return header_name;
1605
1606         return prefs_common.trans_hdr ? gettext(header_name) : header_name;
1607 }
1608
1609 const gchar *prefs_common_get_uri_cmd(void)
1610 {
1611 #ifdef G_OS_WIN32
1612         return NULL;
1613 #else
1614         gchar *tmp = NULL;
1615         
1616         if (!prefs_common.cmds_use_system_default)
1617                 return prefs_common.uri_cmd;
1618         
1619         tmp = g_find_program_in_path("xdg-open");
1620         if (!tmp) 
1621                 return prefs_common.uri_cmd;
1622         
1623         g_free(tmp);
1624         return "xdg-open %s";
1625 #endif
1626 }
1627
1628 const gchar *prefs_common_get_ext_editor_cmd(void)
1629 {
1630         return prefs_common.ext_editor_cmd;
1631 #if 0 /* we should do that, but it detaches the editor and breaks
1632          compose.c's external composition. */
1633         gchar *tmp = NULL;
1634         
1635         if (!prefs_common.cmds_use_system_default)
1636                 return prefs_common.ext_editor_cmd;
1637         
1638         tmp = g_find_program_in_path("xdg-open");
1639         if (!tmp) 
1640                 return prefs_common.ext_editor_cmd;
1641         
1642         g_free(tmp);
1643         return "xdg-open %s";
1644 #endif 
1645 }
1646
1647 gboolean prefs_common_get_use_shred(void)
1648 {
1649         return prefs_common.use_shred;
1650 }
1651
1652 gboolean prefs_common_get_flush_metadata (void)
1653 {
1654         return prefs_common.flush_metadata;
1655 }
1656
1657 PrefsCommon *prefs_common_get_prefs(void)
1658 {
1659         return &prefs_common;
1660 }