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