[gnome-music/wip/jfelder/mpris-cleanup: 10/29] 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: 10/29] mpris: Group MPRIS playlist creation logic into one method
- Date: Mon, 8 Apr 2019 16:28:36 +0000 (UTC)
commit 18b0a7f8ad6a17cf23ba775b6cc19ddd6e8707ba
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 eb7fb832..b585118f 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -403,6 +403,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:
@@ -439,9 +445,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):
@@ -670,17 +675,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]