[gnome-games/wip/exalm/views: 7/17] application-window: Handle search in CollectionView
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views: 7/17] application-window: Handle search in CollectionView
- Date: Thu, 4 Oct 2018 18:47:44 +0000 (UTC)
commit 8c450fd7f37fc35f9162fb7b7cdeea2ed210d64e
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Oct 4 23:41:32 2018 +0500
application-window: Handle search in CollectionView
src/ui/application-window.vala | 36 ++++--------------------------------
src/ui/collection-view.vala | 24 +++++++++++++++++++++++-
2 files changed, 27 insertions(+), 33 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index cc2971ab..dc9c47df 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -39,8 +39,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
collection_view.is_view_active = false;
display_view.is_view_active = true;
- search_mode = false;
-
break;
}
@@ -61,12 +59,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
}
- private bool _search_mode;
- public bool search_mode {
- get { return _search_mode; }
- set { _search_mode = value && (ui_state == UiState.COLLECTION); }
- }
-
public bool loading_notification { get; set; }
[GtkChild]
@@ -81,9 +73,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
private Settings settings;
- private Binding box_search_binding;
private Binding box_fullscreen_binding;
- private Binding header_bar_search_binding;
private Binding header_bar_fullscreen_binding;
private Binding loading_notification_binding;
@@ -127,12 +117,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if (settings.get_boolean ("window-maximized"))
maximize ();
- box_search_binding = bind_property ("search-mode", collection_view.box, "search-mode",
- BindingFlags.BIDIRECTIONAL);
loading_notification_binding = bind_property ("loading-notification", collection_view.box,
"loading-notification",
BindingFlags.DEFAULT);
- header_bar_search_binding = bind_property ("search-mode", collection_view._header_bar,
"search-mode",
- BindingFlags.BIDIRECTIONAL);
box_fullscreen_binding = bind_property ("is-fullscreen", display_view.box, "is-fullscreen",
BindingFlags.BIDIRECTIONAL);
@@ -221,7 +207,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return true;
}
- return handle_collection_key_event (event) || handle_display_key_event (event);
+ if (ui_state == UiState.COLLECTION)
+ return collection_view.on_key_pressed (event);
+
+ return handle_display_key_event (event);
}
[GtkCallback]
@@ -588,23 +577,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return true;
}
- private bool handle_collection_key_event (Gdk.EventKey event) {
- if (ui_state != UiState.COLLECTION)
- return false;
-
- var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
-
- if ((event.keyval == Gdk.Key.f || event.keyval == Gdk.Key.F) &&
- (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
- if (!search_mode)
- search_mode = true;
-
- return true;
- }
-
- return collection_view.box.search_bar_handle_event (event);
- }
-
private bool handle_display_key_event (Gdk.EventKey event) {
if (ui_state != UiState.DISPLAY)
return false;
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 16d1b398..17ad6370 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -22,6 +22,9 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
return;
_is_view_active = value;
+
+ if (!is_view_active)
+ search_mode = false;
}
}
@@ -41,15 +44,24 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
}
}
+ public bool search_mode { get; set; }
public bool is_collection_empty { get; set; }
+ private Binding box_search_binding;
private Binding box_empty_collection_binding;
+ private Binding header_bar_search_binding;
private Binding header_bar_empty_collection_binding;
construct {
_header_bar.viewstack = box.viewstack;
is_collection_empty = true;
+ box_search_binding = bind_property ("search-mode", box, "search-mode",
+ BindingFlags.BIDIRECTIONAL);
+ header_bar_search_binding = bind_property ("search-mode", _header_bar,
+ "search-mode",
+ BindingFlags.BIDIRECTIONAL);
+
box_empty_collection_binding = bind_property ("is-collection-empty", box,
"is-collection-empty",
BindingFlags.BIDIRECTIONAL);
@@ -68,7 +80,17 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
}
public bool on_key_pressed (Gdk.EventKey event) {
- return false;
+ var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
+
+ if ((event.keyval == Gdk.Key.f || event.keyval == Gdk.Key.F) &&
+ (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
+ if (!search_mode)
+ search_mode = true;
+
+ return true;
+ }
+
+ return box.search_bar_handle_event (event);
}
public bool gamepad_button_press_event (Manette.Event event) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]