summaryrefslogtreecommitdiff
path: root/src/contacts-list-pane.vala
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2012-01-18 20:28:06 +0100
committerAlexander Larsson <alexl@redhat.com>2012-01-18 20:28:06 +0100
commitd59f380c8dccc56deb691fca8533983169c0fe5f (patch)
treeca59c9179c6f449de4dffcec23d4583396d4d8e2 /src/contacts-list-pane.vala
parentb14c4cee4309ca6254f7ea2b646ac4a7de8f46d1 (diff)
downloadgnome-contacts-d59f380c8dccc56deb691fca8533983169c0fe5f.tar.gz
Make the search toolbar hidden by default
Diffstat (limited to 'src/contacts-list-pane.vala')
-rw-r--r--src/contacts-list-pane.vala24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index 80d6913..4749ca8 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -28,6 +28,8 @@ public class Contacts.ListPane : Frame {
private ulong non_empty_id;
private EventBox empty_box;
private bool ignore_selection_change;
+ private Toolbar search_toolbar;
+ private bool search_visible;
public signal void selection_changed (Contact? contact);
@@ -55,6 +57,18 @@ public class Contacts.ListPane : Frame {
return false;
}
+ public void set_search_visible (bool visible) {
+ search_visible = visible;
+ if (visible) {
+ search_toolbar.show_all ();
+ search_toolbar.show ();
+ filter_entry.grab_focus ();
+ } else {
+ filter_entry.set_text ("");
+ search_toolbar.hide ();
+ }
+ }
+
private void filter_entry_changed (Editable editable) {
if (filter_entry_changed_id != 0)
Source.remove (filter_entry_changed_id);
@@ -76,6 +90,7 @@ public class Contacts.ListPane : Frame {
this.contacts_store = contacts_store;
this.contacts_view = new View (contacts_store);
var toolbar = new Toolbar ();
+ search_toolbar = toolbar;
toolbar.get_style_context ().add_class (STYLE_CLASS_PRIMARY_TOOLBAR);
toolbar.set_icon_size (IconSize.MENU);
toolbar.set_vexpand (false);
@@ -88,6 +103,13 @@ public class Contacts.ListPane : Frame {
filter_entry.changed.connect (filter_entry_changed);
filter_entry.icon_press.connect (filter_entry_clear);
+ filter_entry.key_press_event.connect ( (key_event) => {
+ if (key_event.keyval == Gdk.Key.Escape) {
+ set_search_visible (false);
+ }
+ return false;
+ });
+
var search_entry_item = new ToolItem ();
search_entry_item.is_important = false;
search_entry_item.set_expand (true);
@@ -165,6 +187,8 @@ public class Contacts.ListPane : Frame {
grid.add (empty_box);
this.show_all ();
+ toolbar.set_no_show_all (true);
+ toolbar.hide ();
if (contacts_store.is_empty ()) {
empty_box.show ();