[gnome-music/wip/jfelder/search-selection-reset: 6/11] window: Do not expose headerbar's search button
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/search-selection-reset: 6/11] window: Do not expose headerbar's search button
- Date: Wed, 3 Apr 2019 19:29:48 +0000 (UTC)
commit 61ab4eefc62b6e64d455722f03a42d733afcda16
Author: Jean Felder <jfelder src gnome org>
Date: Wed Feb 27 08:59:40 2019 +0100
window: Do not expose headerbar's search button
With the introduction of search-mode-enabled and state properties from
the previous commits, it is now possible to directly listen to
search-mode-enabled changes.
gnomemusic/window.py | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 598fc7b0..d3cd1055 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -184,10 +184,9 @@ class Window(Gtk.ApplicationWindow):
self._box.pack_start(selection_toolbar, False, False, 0)
self.add(self._box)
- self._headerbar._search_button.connect(
- 'toggled', self._on_search_toggled)
selection_toolbar.connect(
'add-to-playlist', self._on_add_to_playlist)
+ self._search.connect("notify::state", self._on_search_state_changed)
self._headerbar.props.state = HeaderBar.State.MAIN
self._headerbar.show()
@@ -459,22 +458,13 @@ class Window(Gtk.ApplicationWindow):
self._stack.set_visible_child(self.views[view_enum])
@log
- def _on_search_toggled(self, button, data=None):
- if (not button.get_active()
- and (self.curr_view == self.views[View.SEARCH]
- or self.curr_view == self.views[View.EMPTY])):
- child = self.curr_view.get_visible_child()
- if self._headerbar.props.state == HeaderBar.State.MAIN:
- # We should get back to the view before the search
- self._stack.set_visible_child(
- self.views[View.SEARCH].previous_view)
- elif (self.views[View.SEARCH].previous_view == self.views[View.ALBUM]
- and child != self.curr_view._album_widget
- and child != self.curr_view._artist_albums_widget):
- self._stack.set_visible_child(self.views[View.ALBUM])
-
- if self.props.selection_mode:
- self.props.selection_mode = False
+ def _on_search_state_changed(self, klass, param):
+ if (self._search.props.state != Search.State.NONE
+ or not self.views[View.SEARCH].previous_view):
+ return
+
+ # Get back to the view before the search
+ self._stack.set_visible_child(self.views[View.SEARCH].previous_view)
@log
def _switch_back_from_childview(self, klass=None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]