2006-11-09 [wwp] 2.6.0cvs21
[claws.git] / src / prefs_common.c
index 42bd4fdf3a515e2dd8e8f7b4baa65976f78fe835..c304b5a4b23879259b12c8017312281eb0642936 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",
@@ -109,12 +109,10 @@ static PrefParam param_os_specific[] = {
         &prefs_common.attach_load_dir, P_STRING, NULL, NULL, NULL},
 
        /* MIME viewer */
-       {"mime_image_viewer", NULL,
-        &prefs_common.mime_image_viewer, P_STRING, NULL, NULL, NULL},
-       {"mime_audio_player", NULL,
-        &prefs_common.mime_audio_player, P_STRING, NULL, NULL, NULL},
+       {"mime_textviewer", NULL,
+        &prefs_common.mime_textviewer,   P_STRING, NULL, NULL, NULL},
        {"mime_open_command", "notepad '%s'",
-        &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL},
+        &prefs_common.mime_open_cmd,     P_STRING, NULL, NULL, NULL},
 
        /* Interface */
        {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
@@ -166,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,
@@ -178,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},
@@ -197,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},
@@ -230,6 +242,8 @@ static PrefParam param[] = {
 #endif
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
         NULL, NULL, NULL},
+       {"compose_dnd_insert_or_attach", "0", &prefs_common.compose_dnd_mode, P_ENUM,
+        NULL, NULL, NULL},
 
        /* Account autoselection */
        {"reply_account_autoselect", "TRUE",
@@ -555,6 +569,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"line_space", "2", &prefs_common.line_space, P_INT,
         NULL, NULL, NULL},
+       {"never_send_retrcpt", "FALSE", &prefs_common.never_send_retrcpt, P_BOOL,
+        NULL, NULL, NULL},
 
        {"enable_smooth_scroll", "FALSE",
         &prefs_common.enable_smooth_scroll, P_BOOL,
@@ -563,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},
@@ -578,12 +596,10 @@ static PrefParam param[] = {
         &SPECIFIC_PREFS.attach_load_dir, P_STRING, NULL, NULL, NULL},
 
        /* MIME viewer */
-       {"mime_image_viewer", DEFAULT_IMAGE_VIEWER_CMD,
-        &SPECIFIC_PREFS.mime_image_viewer,     P_STRING, NULL, NULL, NULL},
-       {"mime_audio_player", DEFAULT_AUDIO_PLAYER_CMD,
-        &SPECIFIC_PREFS.mime_audio_player, P_STRING, NULL, NULL, NULL},
+       {"mime_textviewer",   NULL,
+        &SPECIFIC_PREFS.mime_textviewer,   P_STRING, NULL, NULL, NULL},
        {"mime_open_command", "gedit '%s'",
-        &SPECIFIC_PREFS.mime_open_cmd, P_STRING, NULL, NULL, NULL},
+        &SPECIFIC_PREFS.mime_open_cmd,     P_STRING, NULL, NULL, NULL},
 
        /* Interface */
        {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL,
@@ -616,6 +632,11 @@ static PrefParam param[] = {
        {"ask_mark_all_read", "TRUE", &prefs_common.ask_mark_all_read, P_BOOL,
         NULL, NULL, NULL},
 
+       {"ask_apply_per_account_filtering_rules", "TRUE", &prefs_common.ask_apply_per_account_filtering_rules, P_BOOL,
+        NULL, NULL, NULL},
+       {"apply_per_account_filtering_rules", "0", &prefs_common.apply_per_account_filtering_rules, P_ENUM,
+        NULL, NULL, NULL},
+
        /* Other */
        {"uri_open_command", DEFAULT_BROWSER_CMD,
         &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL},
@@ -701,6 +722,11 @@ static PrefParam param[] = {
        {"addressbookeditpersonwin_height", "-1", &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,
         NULL, NULL, NULL},
        {"pluginswin_height", "-1", &prefs_common.pluginswin_height, P_INT,
@@ -741,6 +767,11 @@ static PrefParam param[] = {
        {"addressaddwin_height", "-1", &prefs_common.addressaddwin_height, P_INT,
         NULL, NULL, NULL},
 
+       {"addressbook_folderselwin_width", "300", &prefs_common.addressbook_folderselwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"addressbook_folderselwin_height", "-1", &prefs_common.addressbook_folderselwin_height, P_INT,
+        NULL, NULL, NULL},
+
        /* Hidden */
        {"warn_dnd", "1", &prefs_common.warn_dnd, P_INT,
         NULL, NULL, NULL},
@@ -749,7 +780,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},
@@ -769,6 +806,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,
@@ -777,6 +816,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"live_dangerously", "FALSE", &prefs_common.live_dangerously, P_BOOL,
         NULL, NULL, NULL},
+       {"hide_quotes", "0", &prefs_common.hide_quotes, P_INT,
+        NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -888,57 +929,148 @@ void prefs_common_write_config(void)
                prefs_common.summary_quicksearch_history);
 }
 
-void pref_set_textview_from_pref(GtkTextView *textview, gchar *txt)
+/* 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';
+}
+
+/* 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 );
 
-       gtk_text_buffer_set_text(buffer, o_out?o_out:"", -1);
-       g_free(o_out);
+       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_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:"";
 }