2007-01-17 [paul] 2.7.1cvs15
[claws.git] / src / prefs_common.c
index d2ac75311cfd0e7ea44eedd99a9b1e15a20f4c38..b56551b23df8b1d5118da99fa747db89fca0bf6c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -95,8 +95,8 @@ static PrefParam param_os_specific[] = {
          &prefs_common.widgetfont,             P_STRING, NULL, NULL, NULL},
        {"message_font_gtk2",   "Monospace 9",
         &prefs_common.textfont,                P_STRING, NULL, NULL, NULL},
-        {"print_font_gtk2",     "Monospace 9"
-         &prefs_common.printfont
+        {"print_font_gtk2",     "Monospace 9",
+         &prefs_common.printfont,              P_STRING, NULL, NULL, NULL},
        {"small_font_gtk2",     "Sans 9",
          &prefs_common.smallfont,              P_STRING, NULL, NULL, NULL},
        {"normal_font_gtk2",    "Sans 9",
@@ -164,6 +164,10 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM,
         NULL, NULL, NULL},
+       {"receivewin_width", "460", &prefs_common.receivewin_width, P_INT,
+        NULL, NULL, NULL},
+       {"receivewin_height", "-1", &prefs_common.receivewin_height, P_INT,
+        NULL, NULL, NULL},
        {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel,
         P_BOOL, NULL, NULL, NULL},
        {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog,
@@ -176,6 +180,10 @@ static PrefParam param[] = {
         P_BOOL, NULL, NULL, NULL},
        {"send_dialog_mode", "0", &prefs_common.send_dialog_mode, P_ENUM,
         NULL, NULL, NULL},
+       {"sendwin_width", "460", &prefs_common.sendwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"sendwin_height", "-1", &prefs_common.sendwin_height, P_INT,
+        NULL, NULL, NULL},
 
        {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING,
         NULL, NULL, NULL},
@@ -195,6 +203,12 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"undo_level", "50", &prefs_common.undolevels, P_INT,
         NULL, NULL, NULL},
+       {"compose_with_format", "FALSE", &prefs_common.compose_with_format, P_BOOL,
+        NULL, NULL, NULL},
+       {"compose_subject_format", "",
+        &prefs_common.compose_subject_format, P_STRING, NULL, NULL, NULL},
+       {"compose_body_format", N_("Hello,\\n"),
+        &prefs_common.compose_body_format, P_STRING, NULL, NULL, NULL},
 
        {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT,
         NULL, NULL, NULL},
@@ -215,6 +229,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"dictionary",  "", &prefs_common.dictionary, P_STRING,
         NULL, NULL, NULL},
+       {"alt_dictionary",  "", &prefs_common.alt_dictionary, P_STRING,
+        NULL, NULL, NULL},
        {"aspell_sugmode", "1", &prefs_common.aspell_sugmode, P_INT,
         NULL, NULL, NULL},
        {"use_alternate_dict", "FALSE", &prefs_common.use_alternate, P_BOOL,
@@ -225,6 +241,8 @@ static PrefParam param[] = {
         P_BOOL, NULL, NULL, NULL},
        {"misspelled_color", "16711680", &prefs_common.misspelled_col, P_COLOR,
         NULL, NULL, NULL},
+       {"use_both_dicts", "FALSE", &prefs_common.use_both_dicts, P_BOOL,
+        NULL, NULL, NULL},
 #endif
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
         NULL, NULL, NULL},
@@ -565,6 +583,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL,
         NULL, NULL, NULL},
+       {"respect_flowed_format", "FALSE", &prefs_common.respect_flowed_format, P_BOOL,
+        NULL, NULL, NULL},
 
        {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
         NULL, NULL, NULL},
@@ -621,6 +641,14 @@ static PrefParam param[] = {
        {"apply_per_account_filtering_rules", "0", &prefs_common.apply_per_account_filtering_rules, P_ENUM,
         NULL, NULL, NULL},
 
+       /* Addressbook */
+       {"addressbook_use_editaddress_dialog", "TRUE", &prefs_common.addressbook_use_editaddress_dialog,
+        P_BOOL, NULL, NULL, NULL},
+       {"addressbook_hpaned_pos", "-1", &prefs_common.addressbook_hpaned_pos,
+        P_INT, NULL, NULL, NULL},
+       {"addressbook_vpaned_pos", "-1", &prefs_common.addressbook_vpaned_pos,
+        P_INT, NULL, NULL, NULL},
+
        /* Other */
        {"uri_open_command", DEFAULT_BROWSER_CMD,
         &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL},
@@ -628,7 +656,6 @@ static PrefParam param[] = {
         &SPECIFIC_PREFS.print_cmd, P_STRING, NULL, NULL, NULL},
        {"ext_editor_command", DEFAULT_EDITOR_CMD,
         &SPECIFIC_PREFS.ext_editor_cmd, P_STRING, NULL, NULL, NULL},
-
        {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,
         P_BOOL, NULL, NULL, NULL},
        {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL,
@@ -703,10 +730,15 @@ static PrefParam param[] = {
 
        {"addressbookeditpersonwin_width", "640", &prefs_common.addressbookeditpersonwin_width, P_INT,
         NULL, NULL, NULL},
-       {"addressbookeditpersonwin_height", "-1", &prefs_common.addressbookeditpersonwin_height, P_INT,
+       {"addressbookeditpersonwin_height", "320", &prefs_common.addressbookeditpersonwin_height, P_INT,
+        NULL, NULL, NULL},
+
+       {"addressbookeditgroupwin_width", "580", &prefs_common.addressbookeditgroupwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"addressbookeditgroupwin_height", "340", &prefs_common.addressbookeditgroupwin_height, P_INT,
         NULL, NULL, NULL},
 
-       {"pluginswin_width", "480", &prefs_common.pluginswin_width, P_INT,
+       {"pluginswin_width", "-1", &prefs_common.pluginswin_width, P_INT,
         NULL, NULL, NULL},
        {"pluginswin_height", "-1", &prefs_common.pluginswin_height, P_INT,
         NULL, NULL, NULL},
@@ -759,9 +791,13 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
         NULL, NULL, NULL},
-       {"enable_rules_hint", "TRUE", &prefs_common.enable_rules_hint, P_BOOL,
+       {"use_stripes_everywhere", "TRUE", &prefs_common.use_stripes_everywhere, P_BOOL,
+        NULL, NULL, NULL},
+       {"use_stripes_in_summaries", "TRUE", &prefs_common.use_stripes_in_summaries, P_BOOL,
         NULL, NULL, NULL},
-       {"enable_dotted_lines", "FALSE", &prefs_common.enable_rules_hint, P_BOOL,
+       {"stripes_color_offset", "4000", &prefs_common.stripes_color_offset, P_INT,
+        NULL, NULL, NULL},
+       {"enable_dotted_lines", "FALSE", &prefs_common.enable_dotted_lines, P_BOOL,
         NULL, NULL, NULL},
        {"enable_hscrollbar", "TRUE", &prefs_common.enable_hscrollbar, P_BOOL,
         NULL, NULL, NULL},
@@ -781,6 +817,8 @@ static PrefParam param[] = {
        P_INT, NULL, NULL, NULL },
        {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
         NULL, NULL, NULL},
+       {"summary_quicksearch_dynamic", "0", &prefs_common.summary_quicksearch_dynamic, P_INT,
+        NULL, NULL, NULL},
        {"statusbar_update_step", "10", &prefs_common.statusbar_update_step, P_INT,
         NULL, NULL, NULL},
        {"compose_no_markup", "FALSE", &prefs_common.compose_no_markup, P_BOOL,
@@ -791,6 +829,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"hide_quotes", "0", &prefs_common.hide_quotes, P_INT,
         NULL, NULL, NULL},
+       {"unsafe_ssl_certs", "FALSE", &prefs_common.unsafe_ssl_certs, P_BOOL,
+        NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -855,10 +895,26 @@ void prefs_common_read_config(void)
        g_free(prefs_common.date_format);
        prefs_common.date_format = tmp;
 
+       tmp = g_strdup(gettext(prefs_common.compose_body_format));
+       g_free(prefs_common.compose_body_format);
+       prefs_common.compose_body_format = tmp;
+
        prefs_common.mime_open_cmd_history =
                prefs_common_read_history(COMMAND_HISTORY);
        prefs_common.summary_quicksearch_history =
                prefs_common_read_history(QUICKSEARCH_HISTORY);
+       prefs_common.summary_search_from_history =
+               prefs_common_read_history(SUMMARY_SEARCH_FROM_HISTORY);
+       prefs_common.summary_search_to_history =
+               prefs_common_read_history(SUMMARY_SEARCH_TO_HISTORY);
+       prefs_common.summary_search_subject_history =
+               prefs_common_read_history(SUMMARY_SEARCH_SUBJECT_HISTORY);
+       prefs_common.summary_search_body_history =
+               prefs_common_read_history(SUMMARY_SEARCH_BODY_HISTORY);
+       prefs_common.summary_search_adv_condition_history =
+               prefs_common_read_history(SUMMARY_SEARCH_ADV_CONDITION_HISTORY);
+       prefs_common.message_search_history =
+               prefs_common_read_history(MESSAGE_SEARCH_HISTORY);
 
        colorlabel_update_colortable_from_prefs();
 }
@@ -900,59 +956,168 @@ void prefs_common_write_config(void)
                prefs_common.mime_open_cmd_history);
        prefs_common_save_history(QUICKSEARCH_HISTORY, 
                prefs_common.summary_quicksearch_history);
+       prefs_common_save_history(SUMMARY_SEARCH_FROM_HISTORY, 
+               prefs_common.summary_search_from_history);
+       prefs_common_save_history(SUMMARY_SEARCH_TO_HISTORY, 
+               prefs_common.summary_search_to_history);
+       prefs_common_save_history(SUMMARY_SEARCH_SUBJECT_HISTORY, 
+               prefs_common.summary_search_subject_history);
+       prefs_common_save_history(SUMMARY_SEARCH_BODY_HISTORY, 
+               prefs_common.summary_search_body_history);
+       prefs_common_save_history(SUMMARY_SEARCH_ADV_CONDITION_HISTORY, 
+               prefs_common.summary_search_adv_condition_history);
+       prefs_common_save_history(MESSAGE_SEARCH_HISTORY, 
+               prefs_common.message_search_history);
+}
+
+/* make a copy of string 'in' into buffer 'out'. un-escape \ sequences.
+   both 'in' and 'out' must be non-NULL.
+   'out' must be a pointer to a buffer whose size is at least equal
+   to strlen(txt)+1, this buffer will get cleared. out's contents
+   will always get set to a valid string, even if it's "".*/
+void pref_get_unescaped_pref(gchar *out, const gchar *in)
+{
+       const gchar *i;
+       gchar *o;
+
+       *out = '\0';
+
+       g_return_if_fail( in != NULL );
+       g_return_if_fail( out != NULL );
+
+       i = in;
+       o = out;
+       memset(out, 0, strlen(in)+1);
+       while (*i != '\0') {
+               if (*i == '\\' && *(i+1) == 'n') {
+                       *o++ = '\n';
+                       i++;
+               } else if (*i == '\\' && *(i+1) == 't') {
+                       *o++ = '\t';
+                       i++;
+               } else if (*i == '\\' && *(i+1) == '\\') {
+                       *o++ = '\\';
+                       i++;
+               } else {
+                       *o++ = *i;
+               }
+               i++;
+       }
+       *o='\0';
 }
 
-void pref_set_textview_from_pref(GtkTextView *textview, gchar *txt)
+/* make a copy of string 'in' into buffer 'out'. escape \ sequences.
+   both 'in' and 'out' must be non-NULL.
+   'out' must be a pointer to a buffer whose size is at least equal
+   to 2*strlen(txt)+1. out's contents will always get set to a valid
+   string, even if it's "". */
+void pref_get_escaped_pref(gchar *out, const gchar *in)
 {
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview);
-       gchar *o_out, *out = malloc(txt?(strlen(txt)+1):1);
-       gchar *t = txt;
-       memset(out, 0, strlen(txt)+1);
-       o_out = out;
-       while (*t != '\0') {
-               if (*t == '\\' && *(t+1) == 'n') {
-                       *out++ = '\n';
-                       t++;
-               } else if (*t == '\\') {
-                       t++;
+       const gchar *i;
+       gchar *o;
+
+       *out = '\0';
+
+       g_return_if_fail( in != NULL );
+       g_return_if_fail( out != NULL );
+
+       i = in;
+       o = out;
+       while (*i != '\0') {
+               if (*i == '\n') {
+                       *o++ = '\\';
+                       *o++ = 'n';
+               } else if (*i == '\t') {
+                       *o++ = '\\';
+                       *o++ = 't';
+               } else if (*i == '\\') {
+                       *o++ = '\\';
+                       *o++ = '\\';
                } else {
-                       *out++ = *t;
+                       *o++ = *i;
                }
-               t++;
+               i++;
        }
-       *out='\0';
+       *o = '\0';
+}
+               
+/* set the contents of a textview widget from the internal \-escaped
+  representation of a pref string. both txt and textview must be non-NULL. */
+void pref_set_textview_from_pref(GtkTextView *textview, const gchar *txt)
+{
+       GtkTextBuffer *buffer;
+       gchar *out = NULL;
+
+       g_return_if_fail( txt != NULL );
+       g_return_if_fail( textview != NULL );
+
+       buffer = gtk_text_view_get_buffer(textview);
+       out = malloc(strlen(txt)+1);
+
+       pref_get_unescaped_pref(out, txt);
+
+       gtk_text_buffer_set_text(buffer, out?out:"", -1);
+       g_free(out);
+}
+
+/* set the contents of a gtkentry widget from the internal \-escaped
+  representation of a pref string. both txt and entry must be non-NULL. */
+void pref_set_entry_from_pref(GtkEntry *entry, const gchar *txt)
+{
+       gchar *out = NULL;
+
+       g_return_if_fail( txt != NULL );
+       g_return_if_fail( entry != NULL );
+
+       out = malloc(strlen(txt)+1);
+
+       pref_get_unescaped_pref(out, txt);
 
-       gtk_text_buffer_set_text(buffer, o_out?o_out:"", -1);
-       g_free(o_out);
+       gtk_entry_set_text(entry, out?out:"");
+       g_free(out);
 }
 
+/* get the \-escaped internal representation of a pref from the contents of
+   a textview widget. textview must be non-NULL. */
 gchar *pref_get_pref_from_textview(GtkTextView *textview) 
 {
        GtkTextBuffer *buffer;
        GtkTextIter start, end;
-       gchar *o_out, *out, *tmp, *t;
+       gchar *out, *tmp;
        
+       g_return_val_if_fail( textview != NULL, "" );
+
        buffer = gtk_text_view_get_buffer(textview);
        gtk_text_buffer_get_start_iter(buffer, &start);
        gtk_text_buffer_get_iter_at_offset(buffer, &end, -1);
        tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-       t = tmp;
-       o_out = out = malloc(2*strlen(tmp)+1);
+       out = malloc(2*strlen(tmp)+1);
        
-       while (*t != '\0') {
-               if (*t == '\n') {
-                       *out++ = '\\';
-                       *out++ = 'n';
-               } else if (*t == '\\') {
-                       *out++ = '\\';
-                       *out++ = '\\';
-               } else {
-                       *out++ = *t;
-               }
-               t++;
-       }
-       *out = '\0';
+       pref_get_escaped_pref(out, tmp);
+       g_free(tmp);
+
+       return out?out:"";
+}
+
+/* get the \-escaped internal representation of a pref from the contents of
+   a gtkentry widget. entry must be non-NULL. */
+gchar *pref_get_pref_from_entry(GtkEntry *entry) 
+{
+       gchar *out, *tmp;
+
+       g_return_val_if_fail( entry != NULL, "" );
+
+       tmp = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
+       out = malloc(2*strlen(tmp)+1);
+
+       pref_get_escaped_pref(out, tmp);
        g_free(tmp);
 
-       return o_out;
+       return out?out:"";
+}
+
+/* ugly hack to be able to get this pref from ssl_certificate.c */
+gboolean prefs_common_unsafe_ssl_certs(void)
+{
+       return prefs_common.unsafe_ssl_certs;
 }