diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2018-01-12 16:49:28 +0100 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2018-01-12 16:49:28 +0100 |
commit | ee91a316bb3ebd3cd44ffa3f0b0eb0201186ebdc (patch) | |
tree | d3c4b897c213df690f7e0568f6e406be750922ff /src/contacts-list-pane.vala | |
parent | a842f12d9a8b2533a5450d106faeff67634cf361 (diff) | |
download | gnome-contacts-ee91a316bb3ebd3cd44ffa3f0b0eb0201186ebdc.tar.gz |
ListPane: use the search_changed signal.
Rather than using the changed signal with its own timeout.
Diffstat (limited to 'src/contacts-list-pane.vala')
-rw-r--r-- | src/contacts-list-pane.vala | 42 |
1 files changed, 11 insertions, 31 deletions
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; |