[gnome-music/wip/jfelder/mpris-playlists-cleanup: 8/9] mpris: Group MPRIS playlist creation logic into one method
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-playlists-cleanup: 8/9] mpris: Group MPRIS playlist creation logic into one method
- Date: Thu, 30 May 2019 15:26:02 +0000 (UTC)
commit f94050d5c3a09ed9e3051a81934c7e07bf13ffbc
Author: Jean Felder <jfelder src gnome org>
Date: Thu Apr 4 14:08:37 2019 +0200
mpris: Group MPRIS playlist creation logic into one method
MPRIS playlists are a data structure describing a playlist. It
consists of a unique identifier (path), a name, and an icon.
In GNOME Music case, icon are always empty.
gnomemusic/mpris.py | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 896f6c1b..7433dcca 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -389,6 +389,12 @@ class MediaPlayer2Service(Server):
return playlist
return None
+ @log
+ def _get_mpris_playlist_from_playlist(self, playlist):
+ playlist_name = utils.get_media_title(playlist)
+ path = self._get_playlist_dbus_path(playlist)
+ return (path, playlist_name, "")
+
@log
def _get_playlist_from_id(self, playlist_id):
for playlist in self._stored_playlists:
@@ -424,9 +430,8 @@ class MediaPlayer2Service(Server):
return (False, ("/", "", ""))
playlist = self._get_playlist_from_id(self.player.get_playlist_id())
- playlist_name = utils.get_media_title(playlist)
- path = self._get_playlist_dbus_path(playlist)
- return (True, (path, playlist_name, ""))
+ mpris_playlist = self._get_mpris_playlist_from_playlist(playlist)
+ return (True, mpris_playlist)
@log
def _on_current_song_changed(self, player):
@@ -653,17 +658,16 @@ class MediaPlayer2Service(Server):
if order != 'Alphabetical':
return []
- playlists = [(self._get_playlist_dbus_path(playlist),
- utils.get_media_title(playlist), '')
- for playlist in self._stored_playlists]
+ mpris_playlists = [self._get_mpris_playlist_from_playlist(playlist)
+ for playlist in self._stored_playlists]
if not reverse:
- return playlists[index:index + max_count]
+ return mpris_playlists[index:index + max_count]
first_index = index - 1
if first_index < 0:
first_index = None
- return playlists[index + max_count - 1:first_index:-1]
+ return mpris_playlists[index + max_count - 1:first_index:-1]
def PlaylistChanged(self, playlist):
self.con.emit_signal(None,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]