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