2006-12-01 [wwp] 2.6.0cvs77
[claws.git] / src / prefs_common.c
index ae6b0ddff2049de6d08e112f5df9cac0a891b0dd..a82e11327ee8ccc3f1275951be10546ae88a8bbe 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-2006 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},
@@ -565,6 +579,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 +637,10 @@ 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},
+
        /* Other */
        {"uri_open_command", DEFAULT_BROWSER_CMD,
         &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL},
@@ -628,7 +648,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,7 +722,12 @@ 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,
@@ -759,7 +783,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},
+       {"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},
@@ -779,6 +809,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,
@@ -857,6 +889,18 @@ void prefs_common_read_config(void)
                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();
 }
@@ -898,59 +942,162 @@ 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);
 
-       gtk_text_buffer_set_text(buffer, o_out?o_out:"", -1);
-       g_free(o_out);
+       pref_get_unescaped_pref(out, txt);
+
+       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:"";
 }