[gnome-music/wip/jfelder/selection-misc-cleanups: 2/20] artistsview: Reselect the current artist when leaving selection-mode
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/selection-misc-cleanups: 2/20] artistsview: Reselect the current artist when leaving selection-mode
- Date: Tue, 14 Jan 2020 14:51:57 +0000 (UTC)
commit 215c2d32ae402ef451a94af12550a7c4d3b633ba
Author: Jean Felder <jfelder src gnome org>
Date: Thu Jan 9 20:42:46 2020 +0100
artistsview: Reselect the current artist when leaving selection-mode
gnomemusic/views/artistsview.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 05afb8b9..7b4f204f 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -61,6 +61,8 @@ class ArtistsView(BaseView):
self._application = application
self._artists = {}
+ self._selected_artist = None
+
self._window = application.props.window
self._coremodel = application.props.coremodel
self._model = self._coremodel.props.artists_sort
@@ -152,6 +154,9 @@ class ArtistsView(BaseView):
row.props.selected = not row.props.selected
return
+ selected_row = self._sidebar.get_selected_row()
+ self._selected_artist = selected_row.props.coreartist
+
# Prepare a new artist_albums_widget here
coreartist = row.props.coreartist
if coreartist.props.artist in self._loaded_artists:
@@ -195,6 +200,18 @@ class ArtistsView(BaseView):
self._sidebar.props.selection_mode = Gtk.SelectionMode.NONE
else:
self._sidebar.props.selection_mode = Gtk.SelectionMode.SINGLE
+ selected_row = self._sidebar.get_row_at_index(0)
+ if selected_row is None:
+ self._selected_artist = None
+ return
+
+ for row in self._sidebar:
+ if row.props.coreartist == self._selected_artist:
+ selected_row = row
+ break
+
+ self._sidebar.select_row(selected_row)
+ self._selected_artist = None
@log
def _toggle_all_selection(self, selected):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]