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