[gnome-music/wip/jfelder/selection-misc-cleanups: 3/9] baseview: Do not change selection-mode if the view is not visible
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/selection-misc-cleanups: 3/9] baseview: Do not change selection-mode if the view is not visible
- Date: Thu, 9 Jan 2020 19:49:00 +0000 (UTC)
commit f7733c7c604ac909b79d99fc5fdb4c7554951da9
Author: Jean Felder <jfelder src gnome org>
Date: Thu Jan 9 15:55:53 2020 +0100
baseview: Do not change selection-mode if the view is not visible
A user can only select songs, albums or artists in the visible view.
gnomemusic/views/baseview.py | 19 ++++++++++++-------
gnomemusic/views/playlistsview.py | 2 +-
2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index 08b9d26f..3aa19219 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -66,12 +66,12 @@ class BaseView(Gtk.Stack):
self.add(self._grid)
self.show_all()
- self._selection_mode_id = self.connect(
- "notify::selection-mode", self._on_selection_mode_changed)
-
self.bind_property(
- 'selection-mode', self._window, 'selection-mode',
- GObject.BindingFlags.BIDIRECTIONAL)
+ "selection-mode", self._window, "selection-mode",
+ GObject.BindingFlags.DEFAULT)
+
+ self._selection_mode_id = self._window.connect(
+ "notify::selection-mode", self._on_selection_mode_changed)
@log
def _setup_view(self):
@@ -80,6 +80,11 @@ class BaseView(Gtk.Stack):
@log
def _on_selection_mode_changed(self, widget, data=None):
- if (self.get_parent().get_visible_child() == self
- and not self.props.selection_mode):
+ selection_mode = self._window.props.selection_mode
+ if (selection_mode == self.props.selection_mode
+ or self.get_parent().get_visible_child() != self):
+ return
+
+ self.props.selection_mode = selection_mode
+ if self.props.selection_mode is False:
self.unselect_all()
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index 3a272670..ec3d2541 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -97,7 +97,7 @@ class PlaylistsView(BaseView):
"notify::active-playlist", self._on_active_playlist_changed)
# Selection is only possible from the context menu
- self.disconnect(self._selection_mode_id)
+ self._window.disconnect(self._selection_mode_id)
self.show_all()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]