[gnome-games/wip/exalm/views: 58/68] collection-view: Handle search
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views: 58/68] collection-view: Handle search
- Date: Wed, 14 Nov 2018 18:45:05 +0000 (UTC)
commit 2fdc31fa0513ccd3de23424e9c7708289dc14a75
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Oct 4 23:41:32 2018 +0500
collection-view: Handle search
Move 'search_mode' property out of ApplicationWindow.
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 dcc98449..413e9f83 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);
@@ -223,7 +209,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]
@@ -590,23 +579,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 6e2ee518..cb93b2ef 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -21,6 +21,9 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
return;
_is_view_active = value;
+
+ if (!is_view_active)
+ search_mode = false;
}
}
@@ -40,15 +43,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);
@@ -67,7 +79,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]