[Xfce4-commits] <postler:master> Handle combination of search folder and search entry

Christian Dywan noreply at xfce.org
Sun Jun 6 08:20:01 CEST 2010


Updating branch refs/heads/master
         to 740b3d0f5cb1774ac8291ff779b3b383383e8e1c (commit)
       from 43696960ac253c24b6b061e0d6feaf032e43488a (commit)

commit 740b3d0f5cb1774ac8291ff779b3b383383e8e1c
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jun 6 07:29:37 2010 +0200

    Handle combination of search folder and search entry

 postler/postler-messages.vala |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 9fbefc6..7efbb74 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -337,15 +337,15 @@ public class Postler.Messages : Gtk.TreeView {
             to_or_from = "from";
 
         try {
-            string filter_header;
-            string real_filter = "";
+            string[] headers = {};
+            string[] filters = {};
             string[] folders = {};
 
             try {
                 var keyfile = new KeyFile ();
                 keyfile.load_from_file (location, 0);
-                filter_header = keyfile.get_string ("search", "header");
-                real_filter = keyfile.get_string ("search", "filter").down ();
+                headers += keyfile.get_string ("search", "header");
+                filters += keyfile.get_string ("search", "filter").down ();
                 string search_account = keyfile.get_string ("search", "account");
                 string toplevel = Environment.get_variable ("MAILDIR");
                 if (toplevel == null || toplevel == "")
@@ -353,11 +353,11 @@ public class Postler.Messages : Gtk.TreeView {
                 folders += toplevel + "/" + search_account + "/INBOX/cur";
                 folders += toplevel + "/" + search_account + "/INBOX/new";
             } catch (GLib.KeyFileError keyfile_error) {
-                filter_header = header;
-                real_filter = last_filter;
                 folders += location + "/cur";
                 folders += location + "/new";
             }
+            headers += header;
+            filters += last_filter != "" ? last_filter : null;
 
             foreach (var folder in folders) {
                 var folder_dir = File.new_for_path (folder);
@@ -398,25 +398,36 @@ public class Postler.Messages : Gtk.TreeView {
                             if (parts == null || parts[0] == null)
                                 continue;
                             string field = parts[0].down ();
-                            if (real_filter != "" && filter_header == field &&
-                                !(real_filter in parts[1].down ())) {
-                                skip = true;
-                                break;
+                            if (filters[0] != null && parts[1] != null) {
+                                string lowercased = parts[1].down ();
+                                if (headers[0] == field
+                                 && !(filters[0] in lowercased)) {
+                                    skip = true;
+                                    break;
+                                }
+                                else if (filters[1] != null && headers[1] == field
+                                 && !(filters[1] in lowercased)) {
+                                    skip = true;
+                                    break;
+                                }
                             }
                             if (field == "subject") {
                                 subject = parts[1].strip ();
-                                if (from != null && timestamp != 0)
+                                if (from != null && timestamp != 0
+                                 && filters[0] == null)
                                     break;
                             }
                             else if (field == to_or_from) {
                                 from = parts[1];
-                                if (subject != null && timestamp != 0)
+                                if (subject != null && timestamp != 0
+                                 && filters[0] == null)
                                     break;
                             }
                             else if (field == "date") {
                                 var parsed = new Soup.Date.from_string (parts[1]);
                                 timestamp = parsed != null ? (time_t)parsed.to_time_t () : 0;
-                                if (subject != null && from != null)
+                                if (subject != null && from != null
+                                 && filters[0] == null)
                                     break;
                             }
                         }



More information about the Xfce4-commits mailing list