[gnome-contacts] ListPane: use the search_changed signal.



commit ee91a316bb3ebd3cd44ffa3f0b0eb0201186ebdc
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Fri Jan 12 16:49:28 2018 +0100

    ListPane: use the search_changed signal.
    
    Rather than using the changed signal with its own timeout.

 data/ui/contacts-list-pane.ui |    2 +-
 src/contacts-list-pane.vala   |   42 ++++++++++------------------------------
 2 files changed, 12 insertions(+), 32 deletions(-)
---
diff --git a/data/ui/contacts-list-pane.ui b/data/ui/contacts-list-pane.ui
index 9b79537..e5c3af3 100644
--- a/data/ui/contacts-list-pane.ui
+++ b/data/ui/contacts-list-pane.ui
@@ -31,7 +31,7 @@
                     <property name="primary_icon_activatable">False</property>
                     <property name="primary_icon_sensitive">False</property>
                     <property name="placeholder_text" translatable="yes">Type to search</property>
-                    <signal name="changed" handler="filter_entry_changed" object="ContactsListPane" 
after="no" swapped="no"/>
+                    <signal name="search_changed" handler="filter_entry_changed" object="ContactsListPane" 
after="no" swapped="no"/>
                   </object>
                 </child>
               </object>
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index 4ad9830..9faa849 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -43,44 +43,13 @@ public class Contacts.ListPane : Frame {
   [GtkChild]
   public ActionBar actions_bar;
 
-  private uint filter_entry_changed_id;
   private bool ignore_selection_change;
 
   public signal void selection_changed (Contact? contact);
-
   public signal void link_contacts (LinkedList<Contact> contacts);
   public signal void delete_contacts (LinkedList<Contact> contacts);
-
   public signal void contacts_marked (int contacts_marked);
 
-  public void refilter () {
-    string []? values;
-    string str = filter_entry.get_text ();
-
-    if (Utils.string_is_empty (str))
-      values = null;
-    else {
-      str = Utils.canonicalize_for_search (str);
-      values = str.split(" ");
-    }
-
-    this.contacts_list.set_filter_values (values);
-  }
-
-  private bool filter_entry_changed_timeout () {
-    filter_entry_changed_id = 0;
-    refilter ();
-    return false;
-  }
-
-  [GtkCallback]
-  private void filter_entry_changed (Editable editable) {
-    if (filter_entry_changed_id != 0)
-      Source.remove (filter_entry_changed_id);
-
-    filter_entry_changed_id = Timeout.add (300, filter_entry_changed_timeout);
-  }
-
   public ListPane (Store contacts_store) {
     this.store = contacts_store;
 
@@ -100,6 +69,17 @@ public class Contacts.ListPane : Frame {
       });
   }
 
+  [GtkCallback]
+  private void filter_entry_changed (Editable editable) {
+    if (Utils.string_is_empty (this.filter_entry.text)) {
+      this.contacts_list.set_filter_values (null);
+      return;
+    }
+
+    var str = Utils.canonicalize_for_search (this.filter_entry.text);
+    this.contacts_list.set_filter_values (str.split(" "));
+  }
+
   public void select_contact (Contact? contact, bool ignore_change = false) {
     if (ignore_change)
       ignore_selection_change = true;


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