[gnome-music/wip/mschraal/playlists-fixes: 6/6] coremodel: Unify player model property binding
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/playlists-fixes: 6/6] coremodel: Unify player model property binding
- Date: Sun, 1 Mar 2020 21:15:16 +0000 (UTC)
commit 89605f8e6776606769efc19adf5a62f7e05ac228
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Mar 1 21:55:00 2020 +0100
coremodel: Unify player model property binding
Every playlist type was binding the state and validation properties
seperately. Unify this in one function.
gnomemusic/coremodel.py | 49 ++++++++++++++-----------------------------------
1 file changed, 14 insertions(+), 35 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index c4033421..01ef0759 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -231,6 +231,16 @@ class CoreModel(GObject.GObject):
self.emit("playlist-loaded", playlist_type)
return
+ def bind_song_properties(model_song, player_song):
+ model_song.bind_property(
+ "state", player_song, "state",
+ GObject.BindingFlags.BIDIRECTIONAL
+ | GObject.BindingFlags.SYNC_CREATE)
+ model_song.bind_property(
+ "validation", player_song, "validation",
+ GObject.BindingFlags.BIDIRECTIONAL
+ | GObject.BindingFlags.SYNC_CREATE)
+
def _on_items_changed(model, position, removed, added):
songs_list = []
if added > 0:
@@ -239,15 +249,7 @@ class CoreModel(GObject.GObject):
song = CoreSong(
coresong.props.media, self._coreselection,
self.props.grilo)
-
- coresong.bind_property(
- "state", song, "state",
- GObject.BindingFlags.SYNC_CREATE)
- coresong.bind_property(
- "validation", song, "validation",
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
-
+ bind_song_properties(coresong, song)
songs_list.append(song)
self._playlist_model.splice(position, removed, songs_list)
@@ -282,16 +284,8 @@ class CoreModel(GObject.GObject):
song = CoreSong(
model_song.props.media, self._coreselection,
self.props.grilo)
-
+ bind_song_properties(model_song, song)
songs_added.append(song)
- model_song.bind_property(
- "state", song, "state",
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
- model_song.bind_property(
- "validation", song, "validation",
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
elif playlist_type == PlayerPlaylist.Type.ARTIST:
proxy_model = Gio.ListStore.new(Gio.ListModel)
@@ -308,15 +302,8 @@ class CoreModel(GObject.GObject):
song = CoreSong(
model_song.props.media, self._coreselection,
self.props.grilo)
-
+ bind_song_properties(model_song, song)
songs_added.append(song)
- song.bind_property(
- "state", model_song, "state",
- GObject.BindingFlags.SYNC_CREATE)
- model_song.bind_property(
- "validation", song, "validation",
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
elif playlist_type == PlayerPlaylist.Type.SONGS:
self._current_playlist_model = self._songliststore.props.model
@@ -340,17 +327,9 @@ class CoreModel(GObject.GObject):
song = CoreSong(
model_song.props.media, self._coreselection,
self.props.grilo)
-
+ bind_song_properties(model_song, song)
songs_added.append(song)
- song.bind_property(
- "state", model_song, "state",
- GObject.BindingFlags.SYNC_CREATE)
- model_song.bind_property(
- "validation", song, "validation",
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
-
self._playlist_model.splice(
0, self._playlist_model.get_n_items(), songs_added)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]