[gnome-music/wip/jfelder/searchbar-child: 6/10] window: Introduce search_mode_allowed property
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/searchbar-child: 6/10] window: Introduce search_mode_allowed property
- Date: Fri, 16 Nov 2018 13:57:59 +0000 (UTC)
commit 9deaf40bd0ba4f66f1bf249b4040a6b352dc351b
Author: Jean Felder <jfelder src gnome org>
Date: Thu Nov 15 22:54:01 2018 +0100
window: Introduce search_mode_allowed property
Search mode cannot be changed if the search is in CHILD state.
gnomemusic/widgets/headerbar.py | 6 +++---
gnomemusic/window.py | 12 +++++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index 3b362982..f72305b1 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -98,6 +98,7 @@ class HeaderBar(Gtk.HeaderBar):
_back_button = Gtk.Template.Child()
_menu_button = Gtk.Template.Child()
+ search_mode_allowed = GObject.Property(type=bool, default=True)
search_mode_enabled = GObject.Property(type=bool, default=False)
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode_allowed = GObject.Property(type=bool, default=True)
@@ -143,6 +144,8 @@ class HeaderBar(Gtk.HeaderBar):
"search-mode-enabled", self._search_button, "active",
GObject.BindingFlags.BIDIRECTIONAL
| GObject.BindingFlags.SYNC_CREATE)
+ self.bind_property(
+ "search-mode-allowed", self._search_button, "visible")
self.connect(
"notify::selection-mode-allowed",
@@ -193,9 +196,6 @@ class HeaderBar(Gtk.HeaderBar):
self._state = value
self._update()
- search_visible = self.props.state != HeaderBar.State.SEARCH
- self._search_button.props.visible = search_visible
-
if value == HeaderBar.State.EMPTY:
self._search_button.props.sensitive = False
self._select_button.props.sensitive = False
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index c2c9ab8d..2e12e72a 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -64,6 +64,7 @@ class Window(Gtk.ApplicationWindow):
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode = GObject.Property(type=bool, default=False)
+ search_mode_allowed = GObject.Property(type=bool, default=True)
def __repr__(self):
return '<Window>'
@@ -141,6 +142,8 @@ class Window(Gtk.ApplicationWindow):
'back-button-clicked', self._switch_back_from_childview)
self.connect('notify::selection-mode', self._on_selection_mode_changed)
+ self.bind_property(
+ 'search-mode-allowed', self._headerbar, 'search-mode-allowed')
self.bind_property(
'selected-items-count', self._headerbar, 'selected-items-count')
self.bind_property(
@@ -303,7 +306,7 @@ class Window(Gtk.ApplicationWindow):
# Open search bar on Ctrl + F
if (keyval == Gdk.KEY_f
and not self.views[View.PLAYLIST].rename_active
- and self._headerbar.props.state != HeaderBar.State.SEARCH):
+ and self.props.search_mode_allowed):
search_enabled = self._searchbar.props.search_mode_enabled
self._searchbar.props.search_mode_enabled = not search_enabled
# Play / Pause on Ctrl + SPACE
@@ -387,7 +390,7 @@ class Window(Gtk.ApplicationWindow):
and (modifiers == shift_mask
or modifiers == 0)
and not self.views[View.PLAYLIST].rename_active
- and self._headerbar.props.state != HeaderBar.State.SEARCH):
+ and self.props.search_mode_allowed):
self._searchbar.props.search_mode_enabled = True
@log
@@ -444,10 +447,13 @@ class Window(Gtk.ApplicationWindow):
@log
def _on_search_state_changed(self, klass, data):
+ search_state = self._searchbar.props.search_state
+ self.props.search_mode_allowed = (search_state != Search.State.CHILD)
+
# Get back to the view before the search if curr_view has not already
# been changed by a keyboard shortcut.
search_views = [self.views[View.SEARCH], self.views[View.EMPTY]]
- if (self._searchbar.props.search_state == Search.State.NONE
+ if (search_state == Search.State.NONE
and self.curr_view in search_views):
self._stack.set_visible_child(
self.views[View.SEARCH].previous_view)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]