[Xfce4-commits] <postler:master> Make sure work again and replace the folderbar

Christian Dywan noreply at xfce.org
Thu Jul 7 05:02:02 CEST 2011


Updating branch refs/heads/master
         to aa98a4d0c01eab119024cda450d5efb229756dcd (commit)
       from b0faca18cc0c60b4e7fe7c5be59cbffa6ede733d (commit)

commit aa98a4d0c01eab119024cda450d5efb229756dcd
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Jul 7 00:33:16 2011 +0200

    Make sure work again and replace the folderbar

 postler/postler-bureau.vala   |   68 ++++++++++++++++++----------------------
 postler/postler-index.vala    |    2 +
 postler/postler-messages.vala |    7 +---
 3 files changed, 34 insertions(+), 43 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 956003f..0cca419 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -162,35 +162,48 @@ public class Postler.Bureau : Gtk.Window {
     }
 
     void action_search_options () {
-        search.activate ();
+        search_apply ();
     }
 
     void search_entry_activated () {
-        var action = actions.get_action ("SearchSubject") as Gtk.RadioAction;
-        if (search.get_text () == search.hint_string || search.get_text () == "") {
-            search_options.hide ();
-            action.set_current_value (0);
-            messages.search ("");
-            return;
-        }
+        search_apply ();
+        messages.grab_focus ();
+    }
 
+    string get_search_uri () {
+        var action = actions.get_action ("SearchSubject") as Gtk.RadioAction;
+        string field;
         switch (action.get_current_value ()) {
         case 0:
-            messages.search (search.get_text (), "subject");
+            field = "subject";
             break;
         case 1:
-            messages.search (search.get_text (), "from");
+            field = "sender";
             break;
         case 2:
-            messages.search (search.get_text (), "to");
+            field = "recipients";
             break;
         case 3:
-            messages.search (search.get_text (), "fulltext");
+            field = "excerpt";
             break;
         default:
             assert_not_reached ();
         }
-        messages.grab_focus ();
+        return "search:%s/%s".printf (field, search.get_text ());
+    }
+
+    void search_apply () {
+        if (search.get_text () == search.hint_string || search.get_text () == "") {
+            search_options.hide ();
+            folders.show ();
+            var action = actions.get_action ("SearchSubject") as Gtk.RadioAction;
+            action.set_current_value (0);
+            messages.populate (folders.selected_location);
+            return;
+        }
+
+        messages.populate (get_search_uri ());
+        folders.hide ();
         search_options.show ();
     }
 
@@ -198,26 +211,7 @@ public class Postler.Bureau : Gtk.Window {
         var account_info = new AccountInfo ();
         account_info.name = search.get_text ();
         account_info.type = AccountType.SEARCH;
-
-        unowned string header;
-        var action = actions.get_action ("SearchSubject") as Gtk.RadioAction;
-        switch (action.get_current_value ()) {
-        case 0:
-            header = "subject";
-            break;
-        case 1:
-            header = "from";
-            break;
-        case 2:
-            header = "to";
-            break;
-        case 3:
-            header = "fulltext";
-            break;
-        default:
-            assert_not_reached ();
-        }
-        account_info.path = "search:" + header + "/" + search.get_text ();
+        account_info.path = get_search_uri ();
         accounts.add_info (account_info);
     }
 
@@ -466,7 +460,7 @@ public class Postler.Bureau : Gtk.Window {
         var infobar = new Gtk.InfoBar ();
         infobar.set_message_type (Gtk.MessageType.ERROR);
         shelf.pack_start (infobar, false, false, 0);
-        shelf.reorder_child (infobar, 3);
+        shelf.reorder_child (infobar, 4);
         var infobox = infobar.get_content_area () as Gtk.Box;
         var image = new Gtk.Image.from_stock (Gtk.STOCK_DIALOG_ERROR,
                                               Gtk.IconSize.BUTTON);
@@ -657,7 +651,7 @@ public class Postler.Bureau : Gtk.Window {
         search = new Elementary.SearchEntry (_("Type To Search..."));
         search.activate.connect (search_entry_activated);
         search.icon_press.connect_after ((position, event) => {
-            search.activate ();
+            search_apply ();
         } );
         toolitem.add (search);
         toolitem.show_all ();
@@ -685,7 +679,7 @@ public class Postler.Bureau : Gtk.Window {
             search.sensitive = selected_location != null;
             if (search_options.visible)
                 GLib.Idle.add (() => {
-                    search.activate ();
+                    search_apply ();
                     return false;
                 });
 
@@ -893,7 +887,7 @@ public class Postler.Bureau : Gtk.Window {
             statuslabel.label = "Receiving 4 of 7 - Inbox";
             statusitem.get_child ().show ();
             search.set_text ("elementary");
-            search.activate ();
+            search_apply ();
             messages.notify["selected-message"].connect_after ((object, pspec) => {
                 var infobar = show_fetch_error_infobar ("elementary", "Everything's working as expected");
                 infobar.set_message_type (Gtk.MessageType.WARNING);
diff --git a/postler/postler-index.vala b/postler/postler-index.vala
index 0d0e0a5..6925225 100644
--- a/postler/postler-index.vala
+++ b/postler/postler-index.vala
@@ -241,6 +241,8 @@ namespace Postler {
                     field = "sender";
                 else if (field == "to")
                     field = "recipients";
+                else if (field == "fulltext")
+                    field = "excerpt";
                 /* We can use the prepared statement for uri search */
                 if (field != "uri") {
                     /* Filter out Trash and Junk */
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 750c161..0cf4a5a 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -335,12 +335,7 @@ public class Postler.Messages : Gtk.TreeView {
         return parts[1];
     }
 
-    public void search (string filter, string header="subject") {
-        populate (location, FolderType.GENERIC, filter.down (), header);
-    }
-
-    public async bool populate (string location, FolderType folder_type,
-        string? filter=null, string? header=null) {
+    public async bool populate (string location, FolderType folder_type=FolderType.GENERIC) {
 
         if (this.location == location)
             return false;



More information about the Xfce4-commits mailing list