Merge branch 'master' of ssh+git://git.claws-mail.org/home/git/claws
[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.misspelled_col, P_COLOR,
280          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.quote_level1_col, P_COLOR,
700          NULL, NULL, NULL},
701         {"quote_level2_color", "#0000b3", &prefs_common.quote_level2_col, P_COLOR,
702          NULL, NULL, NULL},
703         {"quote_level3_color", "#0000b3", &prefs_common.quote_level3_col, P_COLOR,
704          NULL, NULL, NULL},
705         {"enable_bgcolor", "FALSE", &prefs_common.enable_bgcolor, P_BOOL,
706          NULL, NULL, NULL},
707         {"quote_level1_bgcolor", "#cccccc", &prefs_common.quote_level1_bgcol, P_COLOR,
708          NULL, NULL, NULL},
709         {"quote_level2_bgcolor", "#d4d4d4", &prefs_common.quote_level2_bgcol, P_COLOR,
710          NULL, NULL, NULL},
711         {"quote_level3_bgcolor", "#dddddd", &prefs_common.quote_level3_bgcol, P_COLOR,
712          NULL, NULL, NULL},
713         {"uri_color", "#007f00", &prefs_common.uri_col, P_COLOR,
714          NULL, NULL, NULL},
715         {"emphasis_color", "#0000cf", &prefs_common.emphasis_col, P_COLOR,
716          NULL, NULL, NULL},
717         {"target_folder_color", "#da1cca", &prefs_common.tgt_folder_col, P_COLOR,
718          NULL, NULL, NULL},
719         {"signature_color", "#797979", &prefs_common.signature_col, P_COLOR,
720          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.default_header_color, P_COLOR,
725          NULL, NULL, NULL},
726         {"default_header_bgcolor", "#f5f6be", &prefs_common.default_header_bgcolor, P_COLOR,
727          NULL, NULL, NULL},
728         {"tags_color", "#000000", &prefs_common.tags_color, P_COLOR,
729          NULL, NULL, NULL},
730         {"tags_bgcolor", "#f5f6be", &prefs_common.tags_bgcolor, P_COLOR,
731          NULL, NULL, NULL},
732         {"qs_active_color", "#000000", &prefs_common.qs_active_color, P_COLOR,
733          NULL, NULL, NULL},
734         {"qs_active_bgcolor", "#f5f6be", &prefs_common.qs_active_bgcolor, P_COLOR,
735          NULL, NULL, NULL},
736         {"qs_error_color", "#000000", &prefs_common.qs_error_color, P_COLOR,
737          NULL, NULL, NULL},
738         {"qs_error_bgcolor", "#ff7070", &prefs_common.qs_error_bgcolor, P_COLOR,
739          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
840         {"mark_as_read_on_new_window", "FALSE",
841          &prefs_common.mark_as_read_on_new_window,
842          P_BOOL, NULL, NULL, NULL},
843         {"mark_as_read_delay", "0",
844          &prefs_common.mark_as_read_delay, P_INT, 
845          NULL, NULL, NULL},
846         {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL,
847          NULL, NULL, NULL},
848         {"nextunreadmsg_dialog", "1", &prefs_common.next_unread_msg_dialog, P_ENUM,
849          NULL, NULL, NULL},
850         {"summary_from_show", "0", &prefs_common.summary_from_show, P_ENUM,
851          NULL, NULL, NULL},
852
853         {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
854          &SPECIFIC_PREFS.pixmap_theme_path, P_STRING,
855          NULL, NULL, NULL},
856 #ifdef HAVE_SVG
857         {"enable_alpha_svg", "TRUE",
858          &SPECIFIC_PREFS.enable_alpha_svg, P_BOOL,
859          NULL, NULL, NULL},
860         {"enable_pixmap_scaling", "TRUE",
861          &SPECIFIC_PREFS.enable_pixmap_scaling, P_BOOL,
862          NULL, NULL, NULL},
863         {"pixmap_scaling_auto", "TRUE",
864          &SPECIFIC_PREFS.pixmap_scaling_auto, P_BOOL,
865          NULL, NULL, NULL},
866         {"pixmap_scaling_ppi", "96",
867          &SPECIFIC_PREFS.pixmap_scaling_ppi, P_INT,
868          NULL, NULL, NULL},
869 #endif
870
871         {"ask_mark_all_read", "TRUE", &prefs_common.ask_mark_all_read, P_BOOL,
872          NULL, NULL, NULL},
873
874         {"ask_apply_per_account_filtering_rules", "TRUE", &prefs_common.ask_apply_per_account_filtering_rules, P_BOOL,
875          NULL, NULL, NULL},
876         {"apply_per_account_filtering_rules", "0", &prefs_common.apply_per_account_filtering_rules, P_ENUM,
877          NULL, NULL, NULL},
878
879         /* Addressbook */
880         {"addressbook_use_editaddress_dialog", "TRUE", &prefs_common.addressbook_use_editaddress_dialog,
881          P_BOOL, NULL, NULL, NULL},
882         {"addressbook_hpaned_pos", "-1", &prefs_common.addressbook_hpaned_pos,
883          P_INT, NULL, NULL, NULL},
884         {"addressbook_vpaned_pos", "-1", &prefs_common.addressbook_vpaned_pos,
885          P_INT, NULL, NULL, NULL},
886
887         /* Other */
888 #ifndef G_OS_WIN32
889         {"uri_open_command", DEFAULT_BROWSER_CMD,
890          &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL},
891 #else
892         {"gtk_theme", DEFAULT_W32_GTK_THEME,
893          &SPECIFIC_PREFS.gtk_theme, P_STRING, NULL, NULL, NULL},
894 #endif
895         {"ext_editor_command", DEFAULT_EDITOR_CMD,
896          &SPECIFIC_PREFS.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
897         {"cmds_use_system_default", "TRUE",
898          &prefs_common.cmds_use_system_default, P_BOOL, NULL, NULL, NULL},
899         {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
900          P_BOOL, NULL, NULL, NULL},
901         {"session_passwords", "FALSE", &prefs_common.session_passwords,
902          P_BOOL, NULL, NULL, NULL},
903         {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
904          NULL, NULL, NULL},
905         {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL,
906          NULL, NULL, NULL},
907         {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL,
908          NULL, NULL, NULL},
909         {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit,
910          P_BOOL, NULL, NULL, NULL},
911         {"work_offline", "FALSE", &prefs_common.work_offline, P_BOOL,
912          NULL, NULL, NULL},
913         {"summary_quicksearch_type", "0", &prefs_common.summary_quicksearch_type, P_INT,
914          NULL, NULL, NULL},
915 #ifndef GENERIC_UMPC
916         {"summary_quicksearch_recurse", "1", &prefs_common.summary_quicksearch_recurse, P_INT,
917          NULL, NULL, NULL},
918 #else
919         {"summary_quicksearch_recurse", "0", &prefs_common.summary_quicksearch_recurse, P_INT,
920          NULL, NULL, NULL},
921 #endif
922
923 #if defined(__OpenBSD__)
924         {"io_timeout_secs", "80", &prefs_common.io_timeout_secs,
925          P_INT, NULL, NULL, NULL},
926 #else
927         {"io_timeout_secs", "60", &prefs_common.io_timeout_secs,
928          P_INT, NULL, NULL, NULL},
929 #endif
930         {"hide_score", "-9999", &prefs_common.kill_score, P_INT,
931          NULL, NULL, NULL},
932         {"important_score", "1", &prefs_common.important_score, P_INT,
933          NULL, NULL, NULL},
934
935         {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
936          NULL, NULL, NULL},
937         {"log_length", "500", &prefs_common.loglength, P_INT,
938          NULL, NULL, NULL},
939 #ifndef GENERIC_UMPC
940         {"enable_log_standard", "TRUE", &prefs_common.enable_log_standard, P_BOOL,
941          NULL, NULL, NULL},
942         {"enable_log_warning", "TRUE", &prefs_common.enable_log_warning, P_BOOL,
943          NULL, NULL, NULL},
944         {"enable_log_error", "TRUE", &prefs_common.enable_log_error, P_BOOL,
945          NULL, NULL, NULL},
946         {"enable_log_status", "TRUE", &prefs_common.enable_log_status, P_BOOL,
947          NULL, NULL, NULL},
948 #else
949         {"enable_log_standard", "FALSE", &prefs_common.enable_log_standard, P_BOOL,
950          NULL, NULL, NULL},
951         {"enable_log_warning", "FALSE", &prefs_common.enable_log_warning, P_BOOL,
952          NULL, NULL, NULL},
953         {"enable_log_error", "FALSE", &prefs_common.enable_log_error, P_BOOL,
954          NULL, NULL, NULL},
955         {"enable_log_status", "FALSE", &prefs_common.enable_log_status, P_BOOL,
956          NULL, NULL, NULL},
957 #endif
958         {"log_msg_color", "#00af00", &prefs_common.log_msg_color, P_COLOR,
959          NULL, NULL, NULL},
960         {"log_warn_color", "#af0000", &prefs_common.log_warn_color, P_COLOR,
961          NULL, NULL, NULL},
962         {"log_error_color", "#af0000", &prefs_common.log_error_color, P_COLOR,
963          NULL, NULL, NULL},
964         {"log_in_color", "#000000", &prefs_common.log_in_color, P_COLOR,
965          NULL, NULL, NULL},
966         {"log_out_color", "#0000ef", &prefs_common.log_out_color, P_COLOR,
967          NULL, NULL, NULL},
968         {"log_status_ok_color", "#00af00", &prefs_common.log_status_ok_color, P_COLOR,
969          NULL, NULL, NULL},
970         {"log_status_nok_color", "#0000af", &prefs_common.log_status_nok_color, P_COLOR,
971          NULL, NULL, NULL},
972         {"log_status_skip_color", "#aa00aa", &prefs_common.log_status_skip_color, P_COLOR,
973          NULL, NULL, NULL},
974
975     {"enable_filtering_debug", "FALSE", &prefs_common.enable_filtering_debug, P_BOOL,
976          NULL, NULL, NULL},
977     {"filtering_debug_level", "1", &prefs_common.filtering_debug_level, P_INT,
978          NULL, NULL, NULL},
979     {"enable_filtering_debug_inc", "TRUE", &prefs_common.enable_filtering_debug_inc, P_BOOL,
980          NULL, NULL, NULL},
981     {"enable_filtering_debug_manual", "TRUE", &prefs_common.enable_filtering_debug_manual, P_BOOL,
982          NULL, NULL, NULL},
983     {"enable_filtering_debug_folder_proc", "FALSE", &prefs_common.enable_filtering_debug_folder_proc, P_BOOL,
984          NULL, NULL, NULL},
985     {"enable_filtering_debug_pre_proc", "FALSE", &prefs_common.enable_filtering_debug_pre_proc, P_BOOL,
986          NULL, NULL, NULL},
987     {"enable_filtering_debug_post_proc", "FALSE", &prefs_common.enable_filtering_debug_post_proc, P_BOOL,
988          NULL, NULL, NULL},
989     {"filtering_debug_clip_log", "TRUE", &prefs_common.filtering_debug_cliplog, P_BOOL,
990          NULL, NULL, NULL},
991         {"filtering_debug_log_length", "500", &prefs_common.filtering_debug_loglength, P_INT,
992          NULL, NULL, NULL},
993
994         {"gtk_can_change_accels", "FALSE", &prefs_common.gtk_can_change_accels, P_BOOL,
995          NULL, NULL, NULL},
996
997         {"color_new", "#0000b3", &prefs_common.color_new, P_COLOR,
998          NULL, NULL, NULL},
999
1000         /* Some windows' sizes */
1001         {"filteringwin_width", "500", &prefs_common.filteringwin_width, P_INT,
1002          NULL, NULL, NULL},
1003         {"filteringwin_height", "-1", &prefs_common.filteringwin_height, P_INT,
1004          NULL, NULL, NULL},
1005
1006         {"filteringactionwin_width", "490", &prefs_common.filteringactionwin_width, P_INT,
1007          NULL, NULL, NULL},
1008         {"filteringactionwin_height", "-1", &prefs_common.filteringactionwin_height, P_INT,
1009          NULL, NULL, NULL},
1010
1011         {"matcherwin_width", "520", &prefs_common.matcherwin_width, P_INT,
1012          NULL, NULL, NULL},
1013         {"matcherwin_height", "-1", &prefs_common.matcherwin_height, P_INT,
1014          NULL, NULL, NULL},
1015
1016         {"templateswin_width", "480", &prefs_common.templateswin_width, P_INT,
1017          NULL, NULL, NULL},
1018         {"templateswin_height", "-1", &prefs_common.templateswin_height, P_INT,
1019          NULL, NULL, NULL},
1020
1021         {"actionswin_width", "486", &prefs_common.actionswin_width, P_INT,
1022          NULL, NULL, NULL},
1023         {"actionswin_height", "-1", &prefs_common.actionswin_height, P_INT,
1024          NULL, NULL, NULL},
1025
1026         {"tagswin_width", "486", &prefs_common.tagswin_width, P_INT,
1027          NULL, NULL, NULL},
1028         {"tagswin_height", "-1", &prefs_common.tagswin_height, P_INT,
1029          NULL, NULL, NULL},
1030
1031         {"addressbookwin_width", "520", &prefs_common.addressbookwin_width, P_INT,
1032          NULL, NULL, NULL},
1033         {"addressbookwin_height", "-1", &prefs_common.addressbookwin_height, P_INT,
1034          NULL, NULL, NULL},
1035
1036         {"addressbookeditpersonwin_width", "640", &prefs_common.addressbookeditpersonwin_width, P_INT,
1037          NULL, NULL, NULL},
1038         {"addressbookeditpersonwin_height", "320", &prefs_common.addressbookeditpersonwin_height, P_INT,
1039          NULL, NULL, NULL},
1040
1041         {"addressbookeditgroupwin_width", "580", &prefs_common.addressbookeditgroupwin_width, P_INT,
1042          NULL, NULL, NULL},
1043         {"addressbookeditgroupwin_height", "340", &prefs_common.addressbookeditgroupwin_height, P_INT,
1044          NULL, NULL, NULL},
1045
1046         {"pluginswin_width", "-1", &prefs_common.pluginswin_width, P_INT,
1047          NULL, NULL, NULL},
1048         {"pluginswin_height", "-1", &prefs_common.pluginswin_height, P_INT,
1049          NULL, NULL, NULL},
1050
1051         {"prefswin_width", "600", &prefs_common.prefswin_width, P_INT,
1052          NULL, NULL, NULL},
1053         {"prefswin_height", "-1", &prefs_common.prefswin_height, P_INT,
1054          NULL, NULL, NULL},
1055
1056         {"folderitemwin_width", "500", &prefs_common.folderitemwin_width, P_INT,
1057          NULL, NULL, NULL},
1058         {"folderitemwin_height", "-1", &prefs_common.folderitemwin_height, P_INT,
1059          NULL, NULL, NULL},
1060
1061         {"zero_replacement_char", "0", &prefs_common.zero_replacement, P_STRING,
1062          NULL, NULL, NULL},
1063
1064         {"editaccountwin_width", "500", &prefs_common.editaccountwin_width, P_INT,
1065          NULL, NULL, NULL},
1066         {"editaccountwin_height", "-1", &prefs_common.editaccountwin_height, P_INT,
1067          NULL, NULL, NULL},
1068
1069         {"accountswin_width", "500", &prefs_common.accountswin_width, P_INT,
1070          NULL, NULL, NULL},
1071         {"accountswin_height", "-1", &prefs_common.accountswin_height, P_INT,
1072          NULL, NULL, NULL},
1073
1074         {"logwin_width", "520", &prefs_common.logwin_width, P_INT,
1075          NULL, NULL, NULL},
1076         {"logwin_height", "-1", &prefs_common.logwin_height, P_INT,
1077          NULL, NULL, NULL},
1078
1079         {"filtering_debugwin_width", "600", &prefs_common.filtering_debugwin_width, P_INT,
1080          NULL, NULL, NULL},
1081         {"filtering_debugwin_height", "-1", &prefs_common.filtering_debugwin_height, P_INT,
1082          NULL, NULL, NULL},
1083
1084         {"folderselwin_width", "300", &prefs_common.folderselwin_width, P_INT,
1085          NULL, NULL, NULL},
1086         {"folderselwin_height", "-1", &prefs_common.folderselwin_height, P_INT,
1087          NULL, NULL, NULL},
1088
1089         {"addressaddwin_width", "300", &prefs_common.addressaddwin_width, P_INT,
1090          NULL, NULL, NULL},
1091         {"addressaddwin_height", "-1", &prefs_common.addressaddwin_height, P_INT,
1092          NULL, NULL, NULL},
1093
1094         {"addressbook_folderselwin_width", "300", &prefs_common.addressbook_folderselwin_width, P_INT,
1095          NULL, NULL, NULL},
1096         {"addressbook_folderselwin_height", "-1", &prefs_common.addressbook_folderselwin_height, P_INT,
1097          NULL, NULL, NULL},
1098
1099         {"aboutwin_width", "450", &prefs_common.aboutwin_width, P_INT,
1100          NULL, NULL, NULL},
1101         {"aboutwin_height", "500", &prefs_common.aboutwin_height, P_INT,
1102          NULL, NULL, NULL},
1103
1104         {"addrgather_width", "450", &prefs_common.addrgather_width, P_INT,
1105          NULL, NULL, NULL},
1106         {"addrgather_height", "-1", &prefs_common.addrgather_height, P_INT,
1107          NULL, NULL, NULL},
1108
1109         {"news_subscribe_width", "450", &prefs_common.news_subscribe_width, P_INT,
1110          NULL, NULL, NULL},
1111         {"news_subscribe_height", "400", &prefs_common.news_subscribe_height, P_INT,
1112          NULL, NULL, NULL},
1113
1114         /* Hidden */
1115         {"warn_dnd", "1", &prefs_common.warn_dnd, P_INT,
1116          NULL, NULL, NULL},
1117         {"utf8_instead_of_locale_for_broken_mail", "0", 
1118          &prefs_common.broken_are_utf8, P_INT,
1119          NULL, NULL, NULL},
1120         {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
1121          NULL, NULL, NULL},
1122         {"use_stripes_everywhere", "TRUE", &prefs_common.use_stripes_everywhere, P_BOOL,
1123          NULL, NULL, NULL},
1124         {"use_stripes_in_summaries", "TRUE", &prefs_common.use_stripes_in_summaries, P_BOOL,
1125          NULL, NULL, NULL},
1126         {"stripes_color_offset", "4000", &prefs_common.stripes_color_offset, P_INT,
1127          NULL, NULL, NULL},
1128         {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
1129          NULL, NULL, NULL},
1130         {"folderview_vscrollbar_policy", "0",
1131          &prefs_common.folderview_vscrollbar_policy, P_ENUM,
1132          NULL, NULL, NULL},
1133         {"textview_cursor_visible", "FALSE",
1134          &prefs_common.textview_cursor_visible, P_BOOL,
1135          NULL, NULL, NULL},
1136         {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
1137          NULL, NULL, NULL},
1138 #ifndef GENERIC_UMPC
1139         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
1140          NULL, NULL, NULL},
1141         {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
1142          NULL, NULL, NULL},
1143 #else
1144         {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
1145          NULL, NULL, NULL},
1146         {"cache_min_keep_time", "0", &prefs_common.cache_min_keep_time, P_INT,
1147          NULL, NULL, NULL},
1148 #endif
1149         {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
1150         P_INT, NULL, NULL, NULL },
1151         {"last_opened_folder", "", &prefs_common.last_opened_folder,
1152         P_STRING, NULL, NULL, NULL },
1153         {"goto_last_folder_on_startup", "FALSE", &prefs_common.goto_last_folder_on_startup,
1154         P_BOOL, NULL, NULL, NULL },
1155         {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
1156          NULL, NULL, NULL},
1157         {"summary_quicksearch_dynamic", "0", &prefs_common.summary_quicksearch_dynamic, P_INT,
1158          NULL, NULL, NULL},
1159         {"summary_quicksearch_autorun", "0", &prefs_common.summary_quicksearch_autorun, P_INT,
1160          NULL, NULL, NULL},
1161         {"statusbar_update_step", "10", &prefs_common.statusbar_update_step, P_INT,
1162          NULL, NULL, NULL},
1163         {"compose_no_markup", "FALSE", &prefs_common.compose_no_markup, P_BOOL,
1164          NULL, NULL, NULL},
1165         {"skip_ssl_cert_check", "FALSE", &prefs_common.skip_ssl_cert_check, P_BOOL,
1166          NULL, NULL, NULL},
1167         {"live_dangerously", "FALSE", &prefs_common.live_dangerously, P_BOOL,
1168          NULL, NULL, NULL},
1169         {"save_parts_readwrite", "FALSE", &prefs_common.save_parts_readwrite, P_BOOL,
1170          NULL, NULL, NULL},
1171         {"hide_quotes", "0", &prefs_common.hide_quotes, P_INT,
1172          NULL, NULL, NULL},
1173         {"unsafe_ssl_certs", "FALSE", &prefs_common.unsafe_ssl_certs, P_BOOL,
1174          NULL, NULL, NULL},
1175 #ifndef GENERIC_UMPC
1176         {"real_time_sync", "FALSE", &prefs_common.real_time_sync, P_BOOL,
1177          NULL, NULL, NULL},
1178 #else
1179         {"real_time_sync", "TRUE", &prefs_common.real_time_sync, P_BOOL,
1180          NULL, NULL, NULL},
1181 #endif
1182
1183         {"print_paper_type", NULL, &prefs_common.print_paper_type, P_STRING,
1184          NULL, NULL, NULL},
1185         {"print_paper_orientation", "0", &prefs_common.print_paper_orientation, P_INT,
1186          NULL, NULL, NULL},
1187         {"print_margin_top", "-1", &prefs_common.print_margin_top, P_INT,
1188          NULL, NULL, NULL},
1189         {"print_margin_bottom", "-1", &prefs_common.print_margin_bottom, P_INT,
1190          NULL, NULL, NULL},
1191         {"print_margin_left", "-1", &prefs_common.print_margin_left, P_INT,
1192          NULL, NULL, NULL},
1193         {"print_margin_right", "-1", &prefs_common.print_margin_right, P_INT,
1194          NULL, NULL, NULL},
1195         {"print_use_color", "0", &prefs_common.print_use_color, P_INT,
1196          NULL, NULL, NULL},
1197         {"print_use_collate", "0", &prefs_common.print_use_collate, P_INT,
1198          NULL, NULL, NULL},
1199         {"print_use_reverse", "0", &prefs_common.print_use_reverse, P_INT,
1200          NULL, NULL, NULL},
1201         {"print_use_duplex", "0", &prefs_common.print_use_duplex, P_INT,
1202          NULL, NULL, NULL},
1203         {"print_imgs", "1", &prefs_common.print_imgs, P_INT,
1204          NULL, NULL, NULL},
1205         {"print_previewwin_width", "600", &prefs_common.print_previewwin_width, P_INT,
1206          NULL, NULL, NULL},
1207         {"print_previewwin_height", "-1", &prefs_common.print_previewwin_height, P_INT,
1208          NULL, NULL, NULL},
1209         {"use_networkmanager", "TRUE", &prefs_common.use_networkmanager, P_BOOL,
1210          NULL, NULL, NULL},
1211         {"use_shred", "FALSE", &prefs_common.use_shred, P_BOOL,
1212          NULL, NULL, NULL},
1213
1214         {"two_line_vertical", "TRUE", &prefs_common.two_line_vert,
1215         P_BOOL, NULL, NULL, NULL },
1216
1217         {"inherit_folder_properties", "FALSE", &prefs_common.inherit_folder_props, P_BOOL,
1218          NULL, NULL, NULL},
1219
1220         {"flush_metadata", "TRUE", &prefs_common.flush_metadata, P_BOOL,
1221          NULL, NULL, NULL},
1222
1223         {"nav_history_length", "50", &prefs_common.nav_history_length, P_INT,
1224          NULL, NULL, NULL},
1225
1226         {"diff_added_color", "#008b8b", &prefs_common.diff_added_color, P_COLOR,
1227          NULL, NULL, NULL},
1228         {"diff_deleted_color", "#6a5acd", &prefs_common.diff_deleted_color, P_COLOR,
1229          NULL, NULL, NULL},
1230         {"diff_hunk_color", "#a52a2a", &prefs_common.diff_hunk_color, P_COLOR,
1231          NULL, NULL, NULL},
1232
1233         {"folder_search_wildcard", "TRUE", &prefs_common.folder_search_wildcard, P_BOOL,
1234          NULL, NULL, NULL},
1235         {"address_search_wildcard", "TRUE", &prefs_common.address_search_wildcard, P_BOOL,
1236          NULL, NULL, NULL},
1237         {"enable_avatars", "3", &prefs_common.enable_avatars, P_INT, NULL, NULL, NULL},
1238 #ifndef PASSWORD_CRYPTO_OLD
1239         {"use_master_passphrase", FALSE, &prefs_common.use_master_passphrase, P_BOOL, NULL, NULL, NULL },
1240         {"master_passphrase", "", &prefs_common.master_passphrase, P_STRING, NULL, NULL, NULL },
1241         {"master_passphrase_salt", "", &prefs_common.master_passphrase_salt, P_STRING, NULL, NULL, NULL },
1242         {"master_passphrase_pbkdf2_rounds", "50000", &prefs_common.master_passphrase_pbkdf2_rounds, P_INT, NULL, NULL, NULL},
1243 #endif
1244
1245         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
1246 };
1247
1248 /*
1249  * Read history list from the specified history file in the specified directory (subdir of rc_dir)
1250  * Fallback to default_list if history file is not found
1251  */
1252 GList *prefs_common_read_history_from_dir_with_defaults(const gchar *dirname, const gchar *history,
1253                                                                                                                           GList *default_list)
1254 {
1255         FILE *fp;
1256         gchar *path;
1257         gchar buf[PREFSBUFSIZE];
1258         GList *tmp = NULL;
1259
1260         if (dirname) {
1261                 path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, dirname,
1262                                    G_DIR_SEPARATOR_S, history,
1263                                    NULL);
1264         } else {
1265         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
1266                            NULL);
1267         }
1268         if ((fp = g_fopen(path, "rb")) == NULL) {
1269                 if (ENOENT != errno) FILE_OP_ERROR(path, "fopen");
1270                 g_free(path);
1271                 /* returns default list if set, otherwise NULL */
1272                 return default_list;
1273         }
1274         g_free(path);
1275         while (fgets(buf, sizeof(buf), fp) != NULL) {
1276                 g_strstrip(buf);
1277                 if (buf[0] == '\0') continue;
1278                 tmp = add_history(tmp, buf);
1279         }
1280         fclose(fp);
1281
1282         tmp = g_list_reverse(tmp);
1283
1284         return tmp;
1285 }
1286
1287 /*
1288  * Read history list from the specified history file in the specified directory (subdir of rc_dir)
1289  */
1290 static GList *prefs_common_read_history_from_dir(const gchar *dirname, const gchar *history) 
1291 {
1292         return prefs_common_read_history_from_dir_with_defaults(dirname, history, NULL);
1293 }
1294
1295 /*
1296  * Read history list from the specified history file
1297  */
1298 static GList *prefs_common_read_history(const gchar *history) 
1299 {
1300         return prefs_common_read_history_from_dir(NULL, history);
1301 }
1302
1303 void prefs_common_read_config(void)
1304 {
1305         gchar *rcpath;
1306         gchar *tmp;
1307
1308         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
1309         prefs_read_config(param, "Common", rcpath, NULL);
1310 #ifdef G_OS_WIN32
1311         prefs_read_config(param_os_specific, "CommonWin32", rcpath, NULL);
1312 #endif
1313
1314         g_free(rcpath);
1315
1316         tmp = g_strdup(gettext(prefs_common.date_format));
1317         g_free(prefs_common.date_format);
1318         prefs_common.date_format = tmp;
1319
1320         prefs_common.mime_open_cmd_history =
1321                 prefs_common_read_history(COMMAND_HISTORY);
1322         prefs_common.summary_quicksearch_history =
1323                 prefs_common_read_history(QUICKSEARCH_HISTORY);
1324         prefs_common.summary_search_from_history =
1325                 prefs_common_read_history(SUMMARY_SEARCH_FROM_HISTORY);
1326         prefs_common.summary_search_to_history =
1327                 prefs_common_read_history(SUMMARY_SEARCH_TO_HISTORY);
1328         prefs_common.summary_search_subject_history =
1329                 prefs_common_read_history(SUMMARY_SEARCH_SUBJECT_HISTORY);
1330         prefs_common.summary_search_body_history =
1331                 prefs_common_read_history(SUMMARY_SEARCH_BODY_HISTORY);
1332         prefs_common.summary_search_adv_condition_history =
1333                 prefs_common_read_history(SUMMARY_SEARCH_ADV_CONDITION_HISTORY);
1334         prefs_common.message_search_history =
1335                 prefs_common_read_history(MESSAGE_SEARCH_HISTORY);
1336         prefs_common.compose_save_to_history =
1337                 prefs_common_read_history(COMPOSE_SAVE_TO_HISTORY);
1338 #ifndef USE_ALT_ADDRBOOK
1339         prefs_common.addressbook_custom_attributes = addressbook_update_custom_attr_from_prefs();
1340 #endif
1341         colorlabel_update_colortable_from_prefs();
1342 }
1343
1344 #define TRY(func) \
1345 if (!(func)) \
1346 { \
1347         g_warning("failed to write"); \
1348         goto out;                       \
1349 } \
1350
1351 /*
1352  * Save history list to the specified history file in the specified directory (subdir of rc_dir)
1353  */
1354 static void prefs_common_save_history_to_dir(const gchar *dirname, const gchar *history, GList *list)
1355 {
1356         GList *cur;
1357         FILE *fp;
1358         gchar *path, *tmp_path;
1359
1360         if (dirname) {
1361                 path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, dirname,
1362                                    G_DIR_SEPARATOR_S, history,
1363                                    NULL);
1364         } else {
1365         path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
1366                            NULL);
1367         }
1368         tmp_path = g_strconcat(path, ".tmp", NULL);
1369
1370         if ((fp = g_fopen(tmp_path, "wb")) == NULL) {
1371                 FILE_OP_ERROR(tmp_path, "fopen");
1372                 goto out;
1373         }
1374
1375         for (cur = list; cur != NULL; cur = cur->next) {
1376                 TRY(fputs((gchar *)cur->data, fp) != EOF &&
1377                     fputc('\n', fp) != EOF);
1378         }
1379
1380         if (fclose(fp) == EOF) {
1381                 FILE_OP_ERROR(tmp_path, "fclose");
1382                 fp = NULL;
1383                 goto out;
1384         }
1385         fp = NULL;
1386 #ifdef G_OS_WIN32
1387         claws_unlink(path);
1388 #endif
1389         if (g_rename(tmp_path, path) < 0) {
1390                 FILE_OP_ERROR(path, "rename");
1391                 goto out;
1392         }
1393
1394 out:
1395         if (fp)
1396                 fclose(fp);
1397         g_free(tmp_path);
1398         g_free(path);
1399 }
1400
1401 /*
1402  * Save history list to the specified history file
1403  */
1404 static void prefs_common_save_history(const gchar *history, GList *list)
1405 {
1406         prefs_common_save_history_to_dir(NULL, history, list);
1407 }
1408
1409 #undef TRY
1410
1411 void prefs_common_write_config(void)
1412 {
1413         prefs_write_config(param, "Common", COMMON_RC);
1414 #ifdef G_OS_WIN32
1415         prefs_write_config(param_os_specific, "CommonWin32", COMMON_RC);
1416 #endif
1417
1418         prefs_common_save_history(COMMAND_HISTORY, 
1419                 prefs_common.mime_open_cmd_history);
1420         prefs_common_save_history(QUICKSEARCH_HISTORY, 
1421                 prefs_common.summary_quicksearch_history);
1422         prefs_common_save_history(SUMMARY_SEARCH_FROM_HISTORY, 
1423                 prefs_common.summary_search_from_history);
1424         prefs_common_save_history(SUMMARY_SEARCH_TO_HISTORY, 
1425                 prefs_common.summary_search_to_history);
1426         prefs_common_save_history(SUMMARY_SEARCH_SUBJECT_HISTORY, 
1427                 prefs_common.summary_search_subject_history);
1428         prefs_common_save_history(SUMMARY_SEARCH_BODY_HISTORY, 
1429                 prefs_common.summary_search_body_history);
1430         prefs_common_save_history(SUMMARY_SEARCH_ADV_CONDITION_HISTORY, 
1431                 prefs_common.summary_search_adv_condition_history);
1432         prefs_common_save_history(MESSAGE_SEARCH_HISTORY, 
1433                 prefs_common.message_search_history);
1434         prefs_common_save_history(COMPOSE_SAVE_TO_HISTORY, 
1435                 prefs_common.compose_save_to_history);
1436
1437 #ifndef USE_ALT_ADDRBOOK
1438                 prefs_common_save_history_to_dir(ADDRBOOK_DIR,
1439                 ADDRESSBOOK_CUSTOM_ATTRIBUTES, 
1440                 prefs_common.addressbook_custom_attributes);
1441 #endif
1442 }
1443
1444 /* make a copy of string 'in' into buffer 'out'. un-escape \ sequences.
1445    both 'in' and 'out' must be non-NULL.
1446    'out' must be a pointer to a buffer whose size is at least equal
1447    to strlen(txt)+1, this buffer will get cleared. out's contents
1448    will always get set to a valid string, even if it's "".*/
1449 void pref_get_unescaped_pref(gchar *out, const gchar *in)
1450 {
1451         const gchar *i;
1452         gchar *o;
1453
1454         *out = '\0';
1455
1456         cm_return_if_fail( in != NULL );
1457         cm_return_if_fail( out != NULL );
1458
1459         i = in;
1460         o = out;
1461         memset(out, 0, strlen(in)+1);
1462         while (*i != '\0') {
1463                 if (*i == '\\' && *(i+1) == 'n') {
1464                         *o++ = '\n';
1465                         i++;
1466                 } else if (*i == '\\' && *(i+1) == 't') {
1467                         *o++ = '\t';
1468                         i++;
1469                 } else if (*i == '\\' && *(i+1) == '\\') {
1470                         *o++ = '\\';
1471                         i++;
1472                 } else {
1473                         *o++ = *i;
1474                 }
1475                 i++;
1476         }
1477         *o='\0';
1478 }
1479
1480 /* make a copy of string 'in' into buffer 'out'. escape \ sequences.
1481    both 'in' and 'out' must be non-NULL.
1482    'out' must be a pointer to a buffer whose size is at least equal
1483    to 2*strlen(txt)+1. out's contents will always get set to a valid
1484    string, even if it's "". */
1485 void pref_get_escaped_pref(gchar *out, const gchar *in)
1486 {
1487         const gchar *i;
1488         gchar *o;
1489
1490         *out = '\0';
1491
1492         cm_return_if_fail( in != NULL );
1493         cm_return_if_fail( out != NULL );
1494
1495         i = in;
1496         o = out;
1497         while (*i != '\0') {
1498                 if (*i == '\n') {
1499                         *o++ = '\\';
1500                         *o++ = 'n';
1501                 } else if (*i == '\t') {
1502                         *o++ = '\\';
1503                         *o++ = 't';
1504                 } else if (*i == '\\') {
1505                         *o++ = '\\';
1506                         *o++ = '\\';
1507                 } else {
1508                         *o++ = *i;
1509                 }
1510                 i++;
1511         }
1512         *o = '\0';
1513 }
1514                 
1515 /* set the contents of a textview widget from the internal \-escaped
1516   representation of a pref string. both txt and textview must be non-NULL. */
1517 void pref_set_textview_from_pref(GtkTextView *textview, const gchar *txt)
1518 {
1519         GtkTextBuffer *buffer;
1520         gchar *out = NULL;
1521
1522         cm_return_if_fail( textview != NULL );
1523
1524         buffer = gtk_text_view_get_buffer(textview);
1525
1526         if (!txt) {
1527                 gtk_text_buffer_set_text(buffer, "", -1);
1528         } else {
1529                 out = g_malloc(strlen(txt)+1);
1530
1531                 pref_get_unescaped_pref(out, txt);
1532
1533                 gtk_text_buffer_set_text(buffer, out, -1);
1534                 g_free(out);
1535         }
1536 }
1537
1538 /* set the contents of a gtkentry widget from the internal \-escaped
1539   representation of a pref string. both txt and entry must be non-NULL. */
1540 void pref_set_entry_from_pref(GtkEntry *entry, const gchar *txt)
1541 {
1542         gchar *out = NULL;
1543
1544         cm_return_if_fail( entry != NULL );
1545         if (!txt) {
1546                 gtk_entry_set_text(entry, "");
1547         } else {
1548                 out = g_malloc(strlen(txt)+1);
1549
1550                 pref_get_unescaped_pref(out, txt);
1551
1552                 gtk_entry_set_text(entry, out);
1553                 g_free(out);
1554         }
1555 }
1556
1557 /* get the \-escaped internal representation of a pref from the contents of
1558    a textview widget. textview must be non-NULL. */
1559 gchar *pref_get_pref_from_textview(GtkTextView *textview) 
1560 {
1561         GtkTextBuffer *buffer;
1562         GtkTextIter start, end;
1563         gchar *out, *tmp;
1564         
1565         cm_return_val_if_fail( textview != NULL, "" );
1566
1567         buffer = gtk_text_view_get_buffer(textview);
1568         gtk_text_buffer_get_start_iter(buffer, &start);
1569         gtk_text_buffer_get_iter_at_offset(buffer, &end, -1);
1570         tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
1571         out = malloc(2*strlen(tmp)+1);
1572         if (out)
1573                 pref_get_escaped_pref(out, tmp);
1574         g_free(tmp);
1575
1576         return out?out:"";
1577 }
1578
1579 /* get the \-escaped internal representation of a pref from the contents of
1580    a gtkentry widget. entry must be non-NULL. */
1581 gchar *pref_get_pref_from_entry(GtkEntry *entry) 
1582 {
1583         gchar *out, *tmp;
1584
1585         cm_return_val_if_fail( entry != NULL, "" );
1586
1587         tmp = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
1588         out = malloc(2*strlen(tmp)+1);
1589         
1590         if (out)
1591                 pref_get_escaped_pref(out, tmp);
1592         g_free(tmp);
1593
1594         return out?out:"";
1595 }
1596
1597 /* ugly hack to be able to get this pref from ssl_certificate.c */
1598 gboolean prefs_common_unsafe_ssl_certs(void)
1599 {
1600         return prefs_common.unsafe_ssl_certs;
1601 }
1602
1603 gboolean prefs_common_enable_log_standard(void)
1604 {
1605         return prefs_common.enable_log_standard;
1606 }
1607
1608 gboolean prefs_common_enable_log_warning(void)
1609 {
1610         return prefs_common.enable_log_warning;
1611 }
1612 gboolean prefs_common_enable_log_error(void)
1613 {
1614         return prefs_common.enable_log_error;
1615 }
1616 gboolean prefs_common_enable_log_status(void)
1617 {
1618         return prefs_common.enable_log_status;
1619 }
1620
1621 /**
1622    return the translated name of a header, if the translate_header option is
1623    set, otherwise return the untranslated header name (header_name itself).
1624    this function is provided for convenience, it's an interface to
1625    prefs_common.trans_hdr.
1626    works with header names either with or without trailing colon, provided
1627    that gettext found such header name in the sources (they should all be
1628    found in src/gtk/headers.h anyway).
1629 */
1630 const gchar *prefs_common_translated_header_name(const gchar *header_name)
1631 {
1632         if (header_name == NULL || *header_name == '\0')
1633                 return header_name;
1634
1635         return prefs_common.trans_hdr ? gettext(header_name) : header_name;
1636 }
1637
1638 const gchar *prefs_common_get_uri_cmd(void)
1639 {
1640 #ifdef G_OS_WIN32
1641         return NULL;
1642 #else
1643         gchar *tmp = NULL;
1644         
1645         if (!prefs_common.cmds_use_system_default)
1646                 return prefs_common.uri_cmd;
1647         
1648         tmp = g_find_program_in_path("xdg-open");
1649         if (!tmp) 
1650                 return prefs_common.uri_cmd;
1651         
1652         g_free(tmp);
1653         return "xdg-open %s";
1654 #endif
1655 }
1656
1657 const gchar *prefs_common_get_ext_editor_cmd(void)
1658 {
1659         return prefs_common.ext_editor_cmd;
1660 #if 0 /* we should do that, but it detaches the editor and breaks
1661          compose.c's external composition. */
1662         gchar *tmp = NULL;
1663         
1664         if (!prefs_common.cmds_use_system_default)
1665                 return prefs_common.ext_editor_cmd;
1666         
1667         tmp = g_find_program_in_path("xdg-open");
1668         if (!tmp) 
1669                 return prefs_common.ext_editor_cmd;
1670         
1671         g_free(tmp);
1672         return "xdg-open %s";
1673 #endif 
1674 }
1675
1676 gboolean prefs_common_get_use_shred(void)
1677 {
1678         return prefs_common.use_shred;
1679 }
1680
1681 gboolean prefs_common_get_flush_metadata (void)
1682 {
1683         return prefs_common.flush_metadata;
1684 }
1685
1686 PrefsCommon *prefs_common_get_prefs(void)
1687 {
1688         return &prefs_common;
1689 }