[Xfce4-commits] <postler:master> Default to "Any" search meaning subject, sender, excerpt

Christian Dywan noreply at xfce.org
Sun Jul 10 06:42:04 CEST 2011


Updating branch refs/heads/master
         to c9c53a6e10aa3ed74a6ae7107a27646dfb4867d4 (commit)
       from b529abf0696a6d66719cfcd2bf572eb423965542 (commit)

commit c9c53a6e10aa3ed74a6ae7107a27646dfb4867d4
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jul 10 04:39:16 2011 +0200

    Default to "Any" search meaning subject, sender, excerpt
    
    Also treat * and space as wildcards.

 postler/postler-bureau.vala |   21 ++++++++++++++-------
 postler/postler-index.vala  |    8 +++++++-
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 75442cb..c7a517a 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -91,6 +91,7 @@ public class Postler.Bureau : Gtk.Window {
                 <menuitem action="About"/>
             </popup>
             <toolbar name="search_options">
+                <toolitem action="SearchAny"/>
                 <toolitem action="SearchSubject"/>
                 <toolitem action="SearchSender"/>
                 <toolitem action="SearchRecipient"/>
@@ -175,15 +176,18 @@ public class Postler.Bureau : Gtk.Window {
         string field;
         switch (action.get_current_value ()) {
         case 0:
-            field = "subject";
+            field = "any";
             break;
         case 1:
-            field = "sender";
+            field = "subject";
             break;
         case 2:
-            field = "recipients";
+            field = "sender";
             break;
         case 3:
+            field = "recipients";
+            break;
+        case 4:
             field = "excerpt";
             break;
         default:
@@ -398,15 +402,17 @@ public class Postler.Bureau : Gtk.Window {
     };
 
     const Gtk.RadioActionEntry[] radio_entries = {
+        { "SearchAny", null, N_("_Any"), "",
+          N_("Search messages by subject, sender, attachments or body"), 0 },
         { "SearchSubject", null, N_("_Subject"), "",
-          N_("Search messages by subject"), 0 },
+          N_("Search messages by subject"), 1 },
         { "SearchSender", null, N_("S_ender"), "",
-          N_("Search messages by sender"), 1 },
+          N_("Search messages by sender"), 2 },
         { "SearchRecipient", null, N_("_Recipient"), "",
-          N_("Search messages by recipient"), 2 },
+          N_("Search messages by recipient"), 3 },
         /* i18n: The text contents of a message, when searching */
         { "SearchBody", null, N_("_Body"), "",
-          N_("Search the full message text"), 3}
+          N_("Search the full message text"), 4}
     };
 
     void account_check (AccountInfo? account_info) {
@@ -719,6 +725,7 @@ public class Postler.Bureau : Gtk.Window {
         #if HAVE_GTK3
         search_options.get_style_context ().add_class ("secondary-toolbar");
         #endif
+        actions.get_action ("SearchAny").is_important = true;
         actions.get_action ("SearchSubject").is_important = true;
         actions.get_action ("SearchSender").is_important = true;
         actions.get_action ("SearchRecipient").is_important = true;
diff --git a/postler/postler-index.vala b/postler/postler-index.vala
index d8e2542..ad940c9 100644
--- a/postler/postler-index.vala
+++ b/postler/postler-index.vala
@@ -245,6 +245,10 @@ namespace Postler {
                     field = "excerpt";
                 /* We can use the prepared statement for uri search */
                 if (field != "uri") {
+                    /* any is an alias for subject, sender, attachment, excerpt */
+                    /* FIXME: attachment is not indexed yet */
+                    if (field == "any")
+                        field = "sender LIKE ?2 OR excerpt LIKE ?2 OR subject";
                     /* Filter out Trash and Junk */
                     string real_sql = sql.replace ("$CASE",
                         "AND uri NOT LIKE '%/Trash/%' AND uri NOT LIKE '%/Junk/%'");
@@ -252,7 +256,9 @@ namespace Postler {
                                              -1, out statement) != Sqlite.OK)
                         throw new GLib.FileError.FAILED (_("Failed to list messages: %s"), database.errmsg ());
                 }
-                return "%%%s%%".printf (parts[1]);
+                /* Space is a wildcard */
+                /* * is a wildcard */
+                return "%%%s%%".printf (parts[1].replace (" ", "%").replace ("*", "%"));
             }
             return folder;
         }



More information about the Xfce4-commits mailing list