[gnome-music/wip/jfelder/mpris-cleanup: 5/24] 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-cleanup: 5/24] mpris: Group MPRIS playlist creation logic into one method
- Date: Sun, 7 Apr 2019 21:46:39 +0000 (UTC)
commit d92530462f316b1be7fc0865bd4f65f2129ce4f8
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 01574b38..744241c5 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -396,6 +396,12 @@ class MPRIS(DBusInterface):
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.playlists:
@@ -432,9 +438,8 @@ class MPRIS(DBusInterface):
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, position):
@@ -666,17 +671,16 @@ class MPRIS(DBusInterface):
if order != 'Alphabetical':
return []
- playlists = [(self._get_playlist_dbus_path(playlist),
- utils.get_media_title(playlist), '')
- for playlist in self.playlists]
+ mpris_playlists = [self._get_mpris_playlist_from_playlist(playlist)
+ for playlist in self.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]