[balsa] New user pref to control quoting text



commit 3b3f2358047312fbb0473106eb7deb1dc425b968
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri Feb 5 20:28:59 2010 -0500

    New user pref to control quoting text
    
    	* src/balsa-app.h: new boolean mark_quoted.
    	* src/balsa-mime-widget-text.c (balsa_mime_widget_new_text):
    	respect it.
    	* src/pref-manager.c (open_preferences_manager), (apply_prefs),
    	(set_prefs), (quoted_group), (mark_quoted_modified_cb): manage
    	it.
    	* src/save-restore.c (config_global_load), (config_save): save
    	and restore it.

 ChangeLog                    |   11 +++++++++++
 src/balsa-app.h              |    1 +
 src/balsa-mime-widget-text.c |    7 ++++---
 src/pref-manager.c           |   42 +++++++++++++++++++++++++++++++++++-------
 src/save-restore.c           |    3 +++
 5 files changed, 54 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9d869cc..5e34383 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-02-05  Peter Bloomfield
 
+	* src/balsa-app.h: new boolean mark_quoted.
+	* src/balsa-mime-widget-text.c (balsa_mime_widget_new_text):
+	respect it.
+	* src/pref-manager.c (open_preferences_manager), (apply_prefs),
+	(set_prefs), (quoted_group), (mark_quoted_modified_cb): manage
+	it.
+	* src/save-restore.c (config_global_load), (config_save): save
+	and restore it.
+
+2010-02-05  Peter Bloomfield
+
 	* libbalsa/mime.c (libbalsa_match_regex): do not loop
 	indefinitely when regex matches zero characters.
 
diff --git a/src/balsa-app.h b/src/balsa-app.h
index 0bbd9a6..f045f9c 100644
--- a/src/balsa-app.h
+++ b/src/balsa-app.h
@@ -270,6 +270,7 @@ extern struct BalsaApplication {
     GdkColormap *colormap;
 
     /* Colour of quoted text. */
+    gboolean mark_quoted;
     gchar *quote_regex;
     GdkColor quoted_color[MAX_QUOTED_COLOR];
 
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index c246ac5..3ec2e42 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -253,9 +253,10 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
     if (!(rex = balsa_quote_regex_new()))
 	gtk_text_buffer_insert_at_cursor(buffer, ptr, -1);
 #else                           /* USE_GREGEX */
-    if (regcomp(&rex, balsa_app.quote_regex, REG_EXTENDED) != 0) {
-	g_warning
-	    ("part_info_init_mimetext: quote regex compilation failed.");
+    if (!balsa_app.mark_quoted
+        || regcomp(&rex, balsa_app.quote_regex, REG_EXTENDED)) {
+	if (balsa_app.mark_quoted)
+            g_warning("%s: quote regex compilation failed.", __func__);
 	gtk_text_buffer_insert_at_cursor(buffer, ptr, -1);
     }
 #endif                          /* USE_GREGEX */
diff --git a/src/pref-manager.c b/src/pref-manager.c
index 905ca3e..00631b6 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -165,6 +165,7 @@ typedef struct _PropertyUI {
     gint threading_type_index;
 
     /* quote regex */
+    GtkWidget *mark_quoted;
     GtkWidget *quote_pattern;
 
     /* wrap incoming text/plain */
@@ -373,6 +374,7 @@ static void timer_modified_cb(GtkWidget * widget, GtkWidget * pbox);
 static void mailbox_close_timer_modified_cb(GtkWidget * widget,
                                             GtkWidget * pbox);
 static void browse_modified_cb(GtkWidget * widget, GtkWidget * pbox);
+static void mark_quoted_modified_cb(GtkWidget * widget, GtkWidget * pbox);
 static void wrap_modified_cb(GtkWidget * widget, GtkWidget * pbox);
 
 static void font_modified_cb(GtkWidget * widget, GtkWidget * pbox);
@@ -699,6 +701,9 @@ open_preferences_manager(GtkWidget * widget, gpointer data)
     /* arp */
     g_signal_connect(G_OBJECT(pui->quote_str), "changed",
                      G_CALLBACK(properties_modified_cb), property_box);
+    g_signal_connect(G_OBJECT(pui->mark_quoted), "toggled",
+                     G_CALLBACK(mark_quoted_modified_cb),
+                     property_box);
     g_signal_connect(G_OBJECT(pui->quote_pattern), "changed",
                      G_CALLBACK(properties_modified_cb), property_box);
 
@@ -993,6 +998,9 @@ apply_prefs(GtkDialog * pbox)
     check_font_button(pui->message_font_button, &balsa_app.message_font);
     check_font_button(pui->subject_font_button, &balsa_app.subject_font);
 
+    balsa_app.mark_quoted =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->mark_quoted));
     g_free(balsa_app.quote_regex);
     tmp = gtk_entry_get_text(GTK_ENTRY(pui->quote_pattern));
     balsa_app.quote_regex = g_strcompress(tmp);
@@ -1238,6 +1246,9 @@ set_prefs(void)
 
     /* arp */
     gtk_entry_set_text(GTK_ENTRY(pui->quote_str), balsa_app.quote_str);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->mark_quoted),
+                                 balsa_app.mark_quoted);
+    gtk_widget_set_sensitive(pui->quote_pattern, balsa_app.mark_quoted);
     tmp = g_strescape(balsa_app.quote_regex, NULL);
     gtk_entry_set_text(GTK_ENTRY(pui->quote_pattern), tmp);
     g_free(tmp);
@@ -1910,37 +1921,44 @@ quoted_group(GtkWidget * page)
     GtkWidget *table;
     GtkObject *spinbutton_adj;
     GtkWidget *label;
+    guint row = 0;
 
     /* Quoted text regular expression */
     /* and RFC2646-style flowed text  */
 
     group = pm_group_new(_("Quoted and flowed text"));
-    table = create_table(2, 3, page);
+    table = create_table(3, 3, page);
     pm_group_add(group, table, FALSE);
 
-    attach_label(_("Quoted text\n" "regular expression:"), table, 0, page);
+    pui->mark_quoted =
+        gtk_check_button_new_with_label(_("Mark quoted text"));
+    gtk_table_attach(GTK_TABLE(table), pui->mark_quoted,
+                     0, 2, row, row + 1, GTK_FILL, 0, 0, 0);
+    ++row;
+
+    attach_label(_("Quoted text\n" "regular expression:"), table, row, page);
 
     pui->quote_pattern = gtk_entry_new();
     gtk_table_attach(GTK_TABLE(table), pui->quote_pattern,
-                     1, 3, 0, 1,
+                     1, 3, row, row + 1,
                      GTK_EXPAND | GTK_FILL, 0, 0, 0);
+    ++row;
 
     pui->browse_wrap =
 	gtk_check_button_new_with_label(_("Wrap text at"));
     gtk_table_attach(GTK_TABLE(table), pui->browse_wrap,
-                     0, 1, 1, 2, GTK_FILL, 0, 0, 0);
+                     0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
     pm_page_add_to_size_group(page, pui->browse_wrap);
 
     spinbutton_adj = gtk_adjustment_new(1.0, 40.0, 200.0, 1.0, 5.0, 0.0);
     pui->browse_wrap_length =
 	gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_adj), 1, 0);
     gtk_table_attach(GTK_TABLE(table), pui->browse_wrap_length,
-                     1, 2, 1, 2,
+                     1, 2, row, row + 1,
                      GTK_EXPAND | GTK_FILL, 0, 0, 0);
-    gtk_widget_set_sensitive(pui->browse_wrap_length, FALSE);
     label = gtk_label_new(_("characters"));
     gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2,
+    gtk_table_attach(GTK_TABLE(table), label, 2, 3, row, row + 1,
                      GTK_FILL, 0, 0, 0);
 
     return group;
@@ -3306,6 +3324,16 @@ browse_modified_cb(GtkWidget * widget, GtkWidget * pbox)
 }
 
 static void
+mark_quoted_modified_cb(GtkWidget * widget, GtkWidget * pbox)
+{
+    gboolean newstate =
+	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->mark_quoted));
+
+    gtk_widget_set_sensitive(GTK_WIDGET(pui->quote_pattern), newstate);
+    properties_modified_cb(widget, pbox);
+}
+
+static void
 wrap_modified_cb(GtkWidget * widget, GtkWidget * pbox)
 {
     gboolean newstate =
diff --git a/src/save-restore.c b/src/save-restore.c
index 21ffecb..07595b9 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -713,6 +713,8 @@ config_global_load(void)
     }
 
     /* ... Quote colouring */
+    balsa_app.mark_quoted =
+        libbalsa_conf_get_bool_with_default("MarkQuoted=true", &def_used);
     g_free(balsa_app.quote_regex);
     balsa_app.quote_regex =
 	libbalsa_conf_get_string("QuoteRegex=" DEFAULT_QUOTE_REGEX);
@@ -1261,6 +1263,7 @@ config_save(void)
 			 libbalsa_mailbox_get_sort_field(NULL));
     libbalsa_conf_set_int("ThreadingType",
 			 libbalsa_mailbox_get_threading_type(NULL));
+    libbalsa_conf_set_bool("MarkQuoted", balsa_app.mark_quoted);
     libbalsa_conf_set_string("QuoteRegex", balsa_app.quote_regex);
     libbalsa_conf_set_string("MessageFont", balsa_app.message_font);
     libbalsa_conf_set_string("SubjectFont", balsa_app.subject_font);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]