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