[gnome-music/wip/jfelder/searchview-new-style: 5/5] window: Restore previous view when leaving search
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/searchview-new-style: 5/5] window: Restore previous view when leaving search
- Date: Sun, 4 Aug 2019 01:37:50 +0000 (UTC)
commit 76008b73674ea4c6f02e87ca0bff849ee9c04a33
Author: Jean Felder <jfelder src gnome org>
Date: Sun Aug 4 03:12:57 2019 +0200
window: Restore previous view when leaving search
gnomemusic/views/searchview.py | 2 --
gnomemusic/window.py | 10 +++++++---
2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 70ff5d8a..08852f63 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -117,8 +117,6 @@ class SearchView(Gtk.Stack):
'selection-mode', self._window, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL)
- self.previous_view = None
-
self._album_widget = AlbumWidget(player, self)
self._album_widget.bind_property(
"selection-mode", self, "selection-mode",
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 69f0c0b6..0116dd92 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -95,6 +95,7 @@ class Window(Gtk.ApplicationWindow):
self.prev_view = None
self.curr_view = None
+ self._view_before_search = None
self._player = app.props.player
@@ -417,7 +418,10 @@ class Window(Gtk.ApplicationWindow):
# Disable search mode when switching view
search_views = [self.views[View.EMPTY], self.views[View.SEARCH]]
- if (self.curr_view not in search_views
+ if (self.curr_view in search_views
+ and self.prev_view not in search_views):
+ self._view_before_search = self.prev_view
+ elif (self.curr_view not in search_views
and self._search.props.search_mode_active is True):
self._search.props.search_mode_active = False
@@ -450,11 +454,11 @@ class Window(Gtk.ApplicationWindow):
@log
def _on_search_state_changed(self, klass, param):
if (self._search.props.state != Search.State.NONE
- or not self.views[View.SEARCH].previous_view):
+ or not self._view_before_search):
return
# Get back to the view before the search
- self._stack.set_visible_child(self.views[View.SEARCH].previous_view)
+ self._stack.set_visible_child(self._view_before_search)
@log
def _switch_back_from_childview(self, klass=None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]