[gnome-music/wip/jfelder/searchview-new-style: 11/15] 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: 11/15] window: Restore previous view when leaving search
- Date: Mon, 5 Aug 2019 19:59:50 +0000 (UTC)
commit cad11e8bd3722ebcba77cb65856609d28f182bb3
Author: Jean Felder <jfelder src gnome org>
Date: Sun Aug 4 03:12:57 2019 +0200
window: Restore previous view when leaving search
Also, remove previous_view variable in SearchView by moving the logic
to Window.
search_mode_active property needs to be changed after the
visible_child has been changed to prevent restoring the previous view.
gnomemusic/views/searchview.py | 6 ++----
gnomemusic/window.py | 10 +++++++---
2 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 009eae06..45082d52 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -113,8 +113,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",
@@ -241,9 +239,9 @@ class SearchView(Gtk.Stack):
self._headerbar.props.state = HeaderBar.State.SEARCH
self._headerbar.props.title = corealbum.props.title
self._headerbar.props.subtitle = corealbum.props.artist
- self.props.search_mode_active = False
self.set_visible_child(self._album_widget)
+ self.props.search_mode_active = False
@Gtk.Template.Callback()
def _on_artist_activated(self, widget, child, user_data=None):
@@ -263,9 +261,9 @@ class SearchView(Gtk.Stack):
self._headerbar.props.state = HeaderBar.State.SEARCH
self._headerbar.props.title = coreartist.props.artist
self._headerbar.props.subtitle = None
- self.props.search_mode_active = False
self.set_visible_child(self._artist_albums_widget)
+ self.props.search_mode_active = False
def _select_all(self, value):
with self._model.freeze_notify():
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 8b096f55..582356a4 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
@@ -418,7 +419,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
@@ -451,11 +455,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]