[gnome-music] Get back to the right view/widget with search deactivation when in Albums view
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Get back to the right view/widget with search deactivation when in Albums view
- Date: Mon, 14 Sep 2015 08:51:29 +0000 (UTC)
commit be592822e9f5e628bcd3ffced3a999d3cebcc5a4
Author: Hapoofesgeli <Hapoofesgeli openmailbox org>
Date: Thu Sep 10 11:58:13 2015 +0430
Get back to the right view/widget with search deactivation when in Albums view
https://bugzilla.gnome.org/show_bug.cgi?id=754836
gnomemusic/toolbar.py | 14 +++++++++++++-
gnomemusic/view.py | 23 ++++++++++++++++++-----
gnomemusic/window.py | 14 +++++++++-----
3 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index 86cdb36..baa1920 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -82,6 +82,7 @@ class Toolbar(GObject.GObject):
self.header_bar.pack_end(self._cancel_button)
self.header_bar.pack_end(self._search_button)
self._back_button.connect('clicked', self.on_back_button_clicked)
+ self._window = self.header_bar.get_parent()
@log
def reset_header_title(self):
@@ -129,9 +130,20 @@ class Toolbar(GObject.GObject):
@log
def on_back_button_clicked(self, widget):
+ self._window = self.header_bar.get_parent()
+ visible_child = self._window.curr_view.get_visible_child()
+
view = self._stack_switcher.get_stack().get_visible_child()
view._back_button_clicked(view)
- self.set_state(ToolbarState.MAIN)
+
+ if not ((self._window.curr_view == self._window.views[4] or
+ self._window.curr_view == self._window.views[5]) and
+ visible_child != self._window.curr_view._grid):
+ self.set_state(ToolbarState.MAIN)
+ else:
+ self._window.views[0].update_title()
+ self._search_button.set_visible(True)
+
@log
def set_state(self, state, btn=None):
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 106861c..8fc375c 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -355,17 +355,22 @@ class Albums(ViewContainer):
except TypeError:
return
title = self.model.get_value(_iter, 2)
- artist = self.model.get_value(_iter, 3)
+ self._artist = self.model.get_value(_iter, 3)
item = self.model.get_value(_iter, 5)
- self._albumWidget.update(artist, title, item,
+ self._albumWidget.update(self._artist, title, item,
self.header_bar, self.selection_toolbar)
self.header_bar.set_state(ToolbarState.CHILD_VIEW)
- escaped_title = albumArtCache.get_media_title(item)
- self.header_bar.header_bar.set_title(escaped_title)
- self.header_bar.header_bar.sub_title = artist
+ self._escaped_title = albumArtCache.get_media_title(item)
+ self.header_bar.header_bar.set_title(self._escaped_title)
+ self.header_bar.header_bar.sub_title = self._artist
self.set_visible_child(self._albumWidget)
@log
+ def update_title(self):
+ self.header_bar.header_bar.set_title(self._escaped_title)
+ self.header_bar.header_bar.sub_title = self._artist
+
+ @log
def populate(self):
if grilo.tracker:
self.window._init_loading_notification()
@@ -1308,6 +1313,7 @@ class EmptySearch(ViewContainer):
def __init__(self, window, player):
ViewContainer.__init__(self, 'emptysearch', None, window, Gd.MainViewType.LIST)
self._artistAlbumsWidget = None
+ self._albumWidget = None
self.player = player
builder = Gtk.Builder()
@@ -1325,6 +1331,9 @@ class EmptySearch(ViewContainer):
if self.get_visible_child() == self._artistAlbumsWidget:
self._artistAlbumsWidget.destroy()
self._artistAlbumsWidget = None
+ elif self.get_visible_child() == self._grid:
+ self.window.views[0].set_visible_child(self.window.views[0]._grid)
+ self.window.toolbar.set_state(ToolbarState.CHILD_VIEW)
self.set_visible_child(self._grid)
@@ -1382,8 +1391,12 @@ class Search(ViewContainer):
if self.get_visible_child() == self._artistAlbumsWidget:
self._artistAlbumsWidget.destroy()
self._artistAlbumsWidget = None
+ elif self.get_visible_child() == self._grid:
+ self.window.views[0].set_visible_child(self.window.views[0]._grid)
+ self.window.toolbar.set_state(ToolbarState.CHILD_VIEW)
self.set_visible_child(self._grid)
+
@log
def _on_item_activated(self, widget, id, path):
if self.star_handler.star_renderer_click:
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index aab541b..1072d33 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -425,7 +425,7 @@ class Window(Gtk.ApplicationWindow):
self.curr_view = stack.get_visible_child()
# Switch to all albums view when we're clicking Albums
- if self.curr_view == self.views[0]:
+ if self.curr_view == self.views[0] and not (self.prev_view == self.views[4] or self.prev_view ==
self.views[5]):
self.curr_view.set_visible_child(self.curr_view._grid)
# Slide out sidebar on switching to Artists or Playlists view
@@ -451,10 +451,14 @@ class Window(Gtk.ApplicationWindow):
self.toolbar.searchbar.show_bar(button.get_active(),
self.curr_view != self.views[4])
if (not button.get_active() and
- (self.curr_view == self.views[4] or self.curr_view == self.views[5]) and
- self.toolbar._state == ToolbarState.MAIN):
- # We should get back to the view before the search
- self._stack.set_visible_child(self.views[4].previous_view)
+ (self.curr_view == self.views[4] or self.curr_view == self.views[5])):
+ if self.toolbar._state == ToolbarState.MAIN:
+ # We should get back to the view before the search
+ self._stack.set_visible_child(self.views[4].previous_view)
+ elif (self.views[4].previous_view == self.views[0] and
+ self.curr_view.get_visible_child() != self.curr_view._albumWidget):
+ self._stack.set_visible_child(self.views[0])
+
if self.toolbar._selectionMode:
self.toolbar.set_selection_mode(False)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]