[gnome-contacts] Make the search toolbar hidden by default
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Make the search toolbar hidden by default
- Date: Wed, 18 Jan 2012 19:29:20 +0000 (UTC)
commit d59f380c8dccc56deb691fca8533983169c0fe5f
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jan 18 20:28:06 2012 +0100
Make the search toolbar hidden by default
src/contacts-app.vala | 23 +++++++++++++----------
src/contacts-list-pane.vala | 24 ++++++++++++++++++++++++
2 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 6b2e04f..09b3ce2 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -32,21 +32,25 @@ public class Contacts.App : Gtk.Application {
return false;
}
- private bool window_map_event (Gdk.EventAny event) {
- list_pane.filter_entry.grab_focus ();
- return true;
- }
-
private bool window_key_press_event (Gdk.EventKey event) {
if ((event.keyval == Gdk.keyval_from_name ("q")) &&
((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
// Clear the contacts so any changed information is stored
contacts_pane.show_contact (null);
window.destroy ();
- } else if (((event.keyval == Gdk.keyval_from_name ("s")) ||
- (event.keyval == Gdk.keyval_from_name ("f"))) &&
+ } else if (((event.keyval == Gdk.Key.s) ||
+ (event.keyval == Gdk.Key.f)) &&
((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
- list_pane.filter_entry.grab_focus ();
+ list_pane.set_search_visible (true);
+ } else if (event.length >= 1 &&
+ Gdk.keyval_to_unicode (event.keyval) != 0 &&
+ (event.state & Gdk.ModifierType.CONTROL_MASK) == 0 &&
+ (event.state & Gdk.ModifierType.MOD1_MASK) == 0 &&
+ (event.keyval != Gdk.Key.Escape) &&
+ (event.keyval != Gdk.Key.Tab) &&
+ (event.keyval != Gdk.Key.BackSpace) ) {
+ list_pane.set_search_visible (true);
+ window.propagate_key_event (event);
}
return false;
@@ -249,8 +253,7 @@ public class Contacts.App : Gtk.Application {
window.set_size_request (745, 510);
window.hide_titlebar_when_maximized = true;
window.delete_event.connect (window_delete_event);
- window.map_event.connect (window_map_event);
- window.key_press_event.connect (window_key_press_event);
+ window.key_press_event.connect_after (window_key_press_event);
var grid = new Grid();
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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]