ed86cd0c90ac2e4e7d31ede6dc1f7995641f542b
[claws.git] / src / prefs_common.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2013 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 #ifndef __PREFS_COMMON_H__
21 #define __PREFS_COMMON_H__
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #include "claws-features.h"
26 #endif
27
28 #include <glib.h>
29
30 #include "mainwindow.h"
31 #include "summaryview.h"
32 #include "folderview.h"
33 #include "codeconv.h"
34 #include "textview.h"
35 #include "procmime.h"
36 #include "prefs_msg_colors.h"
37 #include "prefs_summary_open.h"
38
39 typedef struct _PrefsCommon     PrefsCommon;
40
41 typedef enum {
42         RECV_DIALOG_ALWAYS,
43         RECV_DIALOG_MANUAL,
44         RECV_DIALOG_NEVER
45 } RecvDialogMode;
46
47 typedef enum {
48         COMPOSE_DND_ASK,
49         COMPOSE_DND_INSERT,
50         COMPOSE_DND_ATTACH
51 } ComposeDndInsertOrAttach;
52
53 typedef enum {
54         CTE_AUTO,
55         CTE_BASE64,
56         CTE_QUOTED_PRINTABLE,
57         CTE_8BIT
58 } TransferEncodingMethod;
59
60 typedef enum
61 {
62 /* U = unread, N = new, M = marked */
63         SELECTONENTRY_NOTHING,
64         SELECTONENTRY_UNM,
65         SELECTONENTRY_UMN,
66         SELECTONENTRY_NUM,
67         SELECTONENTRY_NMU,
68         SELECTONENTRY_MNU,
69         SELECTONENTRY_MUN,
70         SELECTONENTRY_LAST
71 } SelectOnEntry;
72
73 typedef enum
74 {
75         ACTION_UNSET = 0, /* for backward compatibility */
76         ACTION_MARKED,
77         ACTION_NEW,
78         ACTION_UNREAD,
79         ACTION_LAST_OPENED,
80         ACTION_LAST_LIST,
81         ACTION_NOTHING,
82         ACTION_FIRST_LIST
83 } EntryAction;
84
85 typedef enum
86 {
87         NEXTUNREADMSGDIALOG_ALWAYS,
88         NEXTUNREADMSGDIALOG_ASSUME_YES,
89         NEXTUNREADMSGDIALOG_ASSUME_NO
90 } NextUnreadMsgDialogShow;
91
92 typedef enum
93 {
94         OPENMSG_REQUEST_ONLY = 0,
95         OPENMSG_ALWAYS = 1,
96         OPENMSG_WHEN_VIEW_VISIBLE
97 } ShowMsgPolicy;
98
99 typedef enum
100 {
101         SHOW_NAME,
102         SHOW_ADDR,
103         SHOW_BOTH
104 } SummaryFromShow;
105
106 typedef enum
107 {
108         AVATARS_DISABLE = 0,
109         AVATARS_ENABLE_CAPTURE = 1,
110         AVATARS_ENABLE_RENDER = 2,
111         AVATARS_ENABLE_BOTH = 3
112 } EnableAvatars;
113
114 struct _PrefsCommon
115 {
116         /* Receive */
117         gboolean use_extinc;
118         gchar *extinc_cmd;
119         gboolean scan_all_after_inc;
120         gboolean autochk_newmail;
121         gint autochk_itv;
122         gboolean chk_on_startup;
123         gboolean open_inbox_on_inc;
124         gboolean newmail_notify_auto;
125         gboolean newmail_notify_manu;
126         gchar   *newmail_notify_cmd;
127         RecvDialogMode recv_dialog_mode;
128         gint receivewin_width;
129         gint receivewin_height;
130         gboolean close_recv_dialog;
131         gboolean no_recv_err_panel;
132
133         /* Send */
134         gboolean savemsg;
135         gboolean confirm_send_queued_messages;
136         gboolean send_dialog_invisible;
137         gint sendwin_width;
138         gint sendwin_height;
139         gchar *outgoing_charset;
140         TransferEncodingMethod encoding_method;
141         gboolean outgoing_fallback_to_ascii;
142         gboolean warn_empty_subj;
143
144         gboolean allow_jisx0201_kana;
145
146         /* Compose */
147         gint undolevels;
148         gint linewrap_len;
149         gboolean linewrap_quote;
150         gboolean linewrap_pastes;
151         gboolean primary_paste_unselects;
152         gboolean autowrap;
153         gboolean auto_indent;
154         gboolean auto_exteditor;
155         gboolean reply_account_autosel;
156         gboolean default_reply_list;
157         gboolean forward_account_autosel;
158         gboolean reedit_account_autosel;
159         gboolean show_ruler;
160         gboolean autosave;
161         gint autosave_length;
162         gboolean autosave_encrypted;
163         gboolean warn_large_insert;
164         gint warn_large_insert_size;
165         gboolean compose_no_markup;
166         ComposeDndInsertOrAttach compose_dnd_mode;
167         gboolean compose_with_format;
168         gchar *compose_subject_format;
169         gchar *compose_body_format;
170         gboolean show_compose_margin;
171         gboolean type_any_header;
172
173         /* Quote */
174         gboolean reply_with_quote;
175         gchar *quotemark;
176         gchar *quotefmt;
177         gchar *fw_quotemark;
178         gchar *fw_quotefmt;
179         gboolean forward_as_attachment;
180         gboolean redirect_keep_from;
181         gchar *quote_chars;
182         
183         gboolean enable_aspell;
184         gchar *dictionary;
185         gchar *alt_dictionary;
186         gulong misspelled_col;
187         gboolean check_while_typing;
188         gboolean recheck_when_changing_dict;
189         gboolean use_alternate;
190         gboolean use_both_dicts;
191         
192         /* Display */
193         /* obsolete fonts */
194         gchar *widgetfont_gtk1;
195         gchar *textfont_gtk1;
196         gchar *normalfont_gtk1;
197         gchar *boldfont_gtk1;
198         gchar *smallfont_gtk1;
199
200         /* new fonts */
201         gchar *widgetfont;
202         gchar *textfont;
203         gchar *printfont;
204         gchar *boldfont;
205         gchar *normalfont;
206         gchar *smallfont;
207         gchar *titlefont;
208         gboolean use_different_print_font;
209         gboolean derive_from_normal_font;
210
211         /* custom colors */
212         ColorlabelPrefs custom_colorlabel[COLORLABELS];
213
214         /* image viewer */
215         gboolean display_img;
216         gboolean resize_img;
217         gboolean inline_img;
218
219         gboolean trans_hdr;
220         gint display_folder_unread;
221         gint ng_abbrev_len;
222
223         gboolean show_searchbar;
224         gboolean expand_thread;
225         gboolean swap_from;
226         gboolean use_addr_book;
227         gchar *date_format;
228         gboolean *msgview_date_format;
229
230         gboolean use_stripes_everywhere;
231         gboolean use_stripes_in_summaries; /* overrides if use_stripes_everywhere is set to TRUE */
232         gint stripes_color_offset;
233         gboolean enable_hscrollbar;
234         gboolean bold_unread;
235         gboolean next_on_delete;
236         gboolean enable_thread;
237         gboolean thread_by_subject;
238         gint thread_by_subject_max_age; /*!< Max. age of a thread which was threaded
239                                          *   by subject (days) */
240         FolderSortKey default_sort_key;
241         FolderSortType default_sort_type;
242
243         gchar *last_opened_folder;
244         gboolean goto_last_folder_on_startup;
245
246         ToolbarStyle toolbar_style;
247         gboolean toolbar_detachable;
248         gboolean show_statusbar;
249         gboolean show_col_headers;
250
251         gint folderview_vscrollbar_policy;
252
253         /* Filtering */
254         GSList *fltlist;
255
256         gint kill_score;
257         gint important_score;
258
259         /* Actions */
260         GSList *actions_list;
261
262         /* Summary columns visibility, position and size */
263         gboolean summary_col_visible[N_SUMMARY_COLS];
264         gint summary_col_pos[N_SUMMARY_COLS];
265         gint summary_col_size[N_SUMMARY_COLS];
266
267         gboolean folder_col_visible[N_FOLDER_COLS];
268         gint folder_col_pos[N_FOLDER_COLS];
269         gint folder_col_size[N_FOLDER_COLS];
270
271         /* Widget visibility, position and size */
272         gint folderwin_x;
273         gint folderwin_y;
274         gint folderview_width;
275         gint folderview_height;
276         gboolean folderview_visible;
277
278         gint summaryview_width;
279         gint summaryview_height;
280
281         gint main_msgwin_x;
282         gint main_msgwin_y;
283         gint msgview_width;
284         gint msgview_height;
285         gboolean msgview_visible;
286
287         gint mainview_x;
288         gint mainview_y;
289         gint mainview_width;
290         gint mainview_height;
291         gint mainwin_x;
292         gint mainwin_y;
293         gint mainwin_width;
294         gint mainwin_height;
295         gint mainwin_maximised;
296         gint mainwin_fullscreen;
297         gint mainwin_menubar;
298
299         gint msgwin_width;
300         gint msgwin_height;
301
302         gint mimeview_tree_height;
303         
304         gint sourcewin_width;
305         gint sourcewin_height;
306
307         gint compose_width;
308         gint compose_height;
309         gint compose_notebook_height;
310         gint compose_x;
311         gint compose_y;
312
313         /* Message */
314         gboolean enable_color;
315         gboolean enable_bgcolor;
316         gulong quote_level1_col;
317         gulong quote_level2_col;
318         gulong quote_level3_col;
319         gulong quote_level1_bgcol;
320         gulong quote_level2_bgcol;
321         gulong quote_level3_bgcol;
322         gulong uri_col;
323         gulong tgt_folder_col;
324         gulong signature_col;
325         gulong emphasis_col;
326         gboolean recycle_quote_colors;
327         gboolean display_header_pane;
328         gboolean display_header;
329         gboolean display_xface;
330         gint line_space;
331         gboolean render_html;
332         gboolean invoke_plugin_on_html;
333         gboolean promote_html_part;
334         gboolean textview_cursor_visible;
335         gboolean enable_smooth_scroll;
336         gint scroll_step;
337         gboolean scroll_halfpage;
338         gboolean hide_quoted;
339         gboolean respect_flowed_format;
340         gboolean show_all_headers;
341
342         gboolean show_other_header;
343         GSList *disphdr_list;
344
345         gboolean attach_desc;
346
347         /* MIME viewer */
348         gchar *mime_textviewer;
349         gchar *mime_open_cmd;
350         gchar *attach_save_dir;
351         gchar *attach_load_dir;
352
353         GList *mime_open_cmd_history;
354         gboolean show_inline_attachments;
355
356         /* Addressbook */
357         gboolean addressbook_use_editaddress_dialog;
358         gint addressbook_hpaned_pos;
359         gint addressbook_vpaned_pos;
360         GList *addressbook_custom_attributes;
361
362         /* Interface */
363         gboolean layout_mode;
364
365         gint statusbar_update_step;
366         gboolean emulate_emacs;
367         ShowMsgPolicy always_show_msg;
368         gboolean mark_as_read_on_new_window;
369         gboolean mark_as_read_delay;
370         gboolean immediate_exec;
371         SelectOnEntry select_on_entry;
372         gboolean show_tooltips;
373
374         EntryAction summary_select_prio[SUMMARY_OPEN_ACTIONS-1];
375
376         NextUnreadMsgDialogShow next_unread_msg_dialog;
377         SummaryFromShow summary_from_show;
378         gboolean add_address_by_click;
379         gchar *pixmap_theme_path;
380         int hover_timeout; /* msecs mouse hover timeout */
381         gboolean ask_mark_all_read;
382         gboolean ask_apply_per_account_filtering_rules;
383         gint apply_per_account_filtering_rules;
384
385         /* Other */
386 #ifndef G_OS_WIN32
387         gchar *uri_cmd;
388 #else
389         gchar *gtk_theme;
390 #endif
391         gchar *ext_editor_cmd;
392         gboolean cmds_use_system_default;
393
394         gboolean cliplog;
395         guint loglength;
396         gboolean enable_log_standard;
397         gboolean enable_log_warning;
398         gboolean enable_log_error;
399         gboolean enable_log_status;
400
401         gulong log_msg_color;
402         gulong log_warn_color;
403         gulong log_error_color;
404         gulong log_in_color;
405         gulong log_out_color;
406         gulong log_status_ok_color;
407         gulong log_status_nok_color;
408         gulong log_status_skip_color;
409
410         gboolean enable_filtering_debug;
411         gint filtering_debug_level;
412         gboolean enable_filtering_debug_inc;
413         gboolean enable_filtering_debug_manual;
414         gboolean enable_filtering_debug_folder_proc;
415         gboolean enable_filtering_debug_pre_proc;
416         gboolean enable_filtering_debug_post_proc;
417         gboolean filtering_debug_cliplog;
418         guint filtering_debug_loglength;
419
420         gboolean confirm_on_exit;
421         gboolean session_passwords;
422         gboolean clean_on_exit;
423         gboolean ask_on_clean;
424         gboolean warn_queued_on_exit;
425
426         gint io_timeout_secs;
427
428         gboolean gtk_can_change_accels;
429         
430         /* Memory cache*/
431         gint cache_max_mem_usage;
432         gint cache_min_keep_time;
433         
434         /* boolean for work offline 
435            stored here for use in inc.c */
436         gboolean work_offline;
437         
438         gint summary_quicksearch_type;
439         gint summary_quicksearch_sticky;
440         gint summary_quicksearch_recurse;
441         gint summary_quicksearch_dynamic;
442         gint summary_quicksearch_autorun;
443         gulong color_new;
444         
445         GList *summary_quicksearch_history;
446         GList *summary_search_from_history;
447         GList *summary_search_to_history;
448         GList *summary_search_subject_history;
449         GList *summary_search_body_history;
450         GList *summary_search_adv_condition_history;
451         GList *message_search_history;
452         GList *compose_save_to_history;
453
454         gint filteringwin_width;
455         gint filteringwin_height;
456         gint filteringactionwin_width;
457         gint filteringactionwin_height;
458         gint matcherwin_width;
459         gint matcherwin_height;
460         gint templateswin_width;
461         gint templateswin_height;
462         gint actionswin_width;
463         gint actionswin_height;
464         gint tagswin_width;
465         gint tagswin_height;
466         gint addressbookwin_width;
467         gint addressbookwin_height;
468         gint addressbookeditpersonwin_width;
469         gint addressbookeditpersonwin_height;
470         gint addressbookeditgroupwin_width;
471         gint addressbookeditgroupwin_height;
472         gint pluginswin_width;
473         gint pluginswin_height;
474         gint prefswin_width;
475         gint prefswin_height;
476         gint folderitemwin_width;
477         gint folderitemwin_height;
478         gchar *zero_replacement;
479         gint editaccountwin_width;
480         gint editaccountwin_height;
481         gint accountswin_width;
482         gint accountswin_height;
483         gint logwin_width;
484         gint logwin_height;
485         gint filtering_debugwin_width;
486         gint filtering_debugwin_height;
487         gint folderselwin_width;
488         gint folderselwin_height;
489         gint addressaddwin_width;
490         gint addressaddwin_height;
491         gint addressbook_folderselwin_width;
492         gint addressbook_folderselwin_height;
493         gint aboutwin_width;
494         gint aboutwin_height;
495         gint addrgather_width;
496         gint addrgather_height;
497         gint news_subscribe_width;
498         gint news_subscribe_height;
499
500         gint warn_dnd;
501         gint broken_are_utf8;
502         gint skip_ssl_cert_check;
503         gint live_dangerously;
504         gint save_parts_readwrite;
505         gint never_send_retrcpt;
506         gint hide_quotes;
507         gboolean unsafe_ssl_certs;
508         gboolean real_time_sync;
509         
510         gchar *print_paper_type;
511         gint print_paper_orientation;
512         gint print_margin_top;
513         gint print_margin_bottom;
514         gint print_margin_left;
515         gint print_margin_right;
516   
517         gint print_use_color;
518         gint print_use_collate;
519         gint print_use_reverse;
520         gint print_use_duplex;
521         gint print_imgs;
522         gint print_previewwin_width;
523         gint print_previewwin_height;
524         
525         gboolean use_networkmanager;
526         gboolean use_shred;
527         gboolean two_line_vert;
528         gboolean inherit_folder_props;
529         gboolean flush_metadata;
530
531         gint nav_history_length;
532
533         gulong diff_added_color;
534         gulong diff_deleted_color;
535         gulong diff_hunk_color;
536         
537         gboolean folder_search_wildcard;
538         gboolean address_search_wildcard;
539
540         guint enable_avatars;
541
542 #ifndef PASSWORD_CRYPTO_OLD
543         gboolean use_master_password;
544         gchar *master_password_hash;
545 #endif
546 };
547
548 extern PrefsCommon prefs_common;
549
550 PrefsCommon *prefs_common_get_prefs(void);
551
552 GList *prefs_common_read_history_from_dir_with_defaults(const gchar *dirname, const gchar *history,
553                                                                                                                           GList *default_list);
554 void prefs_common_read_config   (void);
555 void prefs_common_write_config  (void);
556 void prefs_common_open          (void);
557 void pref_get_unescaped_pref(gchar *out, const gchar *in);
558 void pref_get_escaped_pref(gchar *out, const gchar *in);
559 void pref_set_textview_from_pref(GtkTextView *textview, const gchar *txt);
560 void pref_set_entry_from_pref(GtkEntry *entry, const gchar *txt);
561 gchar *pref_get_pref_from_textview(GtkTextView *textview);
562 gchar *pref_get_pref_from_entry(GtkEntry *entry);
563 const gchar *prefs_common_translated_header_name(const gchar *header_name);
564 const gchar *prefs_common_get_uri_cmd(void);
565 const gchar *prefs_common_get_ext_editor_cmd(void);
566 #endif /* __PREFS_COMMON_H__ */