[gnome-music/wip/jfelder/simplify-player-model: 3/5] player: Remove field parameter from set_playlist
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/simplify-player-model: 3/5] player: Remove field parameter from set_playlist
- Date: Sun, 4 Mar 2018 22:52:02 +0000 (UTC)
commit dfc5db6f059b371dd85f3bda3a6b872a47e47918
Author: Jean Felder <jean felder gmail com>
Date: Thu Feb 15 16:49:31 2018 +0100
player: Remove field parameter from set_playlist
This parameter is unecessary as it is always equal to 5.
Rename playlistField attribute to playlist_field.
Use playlist_field in artistalbumwidget.
gnomemusic/mpris.py | 19 +++++++++----------
gnomemusic/player.py | 18 ++++++++----------
gnomemusic/views/playlistview.py | 11 +++++------
gnomemusic/views/searchview.py | 2 +-
gnomemusic/views/songsview.py | 2 +-
gnomemusic/widgets/albumwidget.py | 8 ++++----
gnomemusic/widgets/artistalbumwidget.py | 4 ++--
7 files changed, 30 insertions(+), 34 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index a282b2af..4781274a 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -350,7 +350,7 @@ class MediaPlayer2Service(Server):
@log
def _get_media_from_id(self, track_id):
for track in self.player.playlist:
- media = track[self.player.playlistField]
+ media = track[self.player.playlist_field]
if track_id == self._get_media_id(media):
return media
return None
@@ -358,7 +358,7 @@ class MediaPlayer2Service(Server):
@log
def _get_track_list(self):
if self.player.playlist:
- return [self._get_media_id(track[self.player.playlistField])
+ return [self._get_media_id(track[self.player.playlist_field])
for track in self.player.playlist]
else:
return []
@@ -463,7 +463,7 @@ class MediaPlayer2Service(Server):
if self.first_song_handler:
model.disconnect(self.first_song_handler)
self.first_song_handler = 0
- self.player.set_playlist('Songs', None, model, iter_, 5)
+ self.player.set_playlist('Songs', None, model, iter_)
self.player.set_playing(True)
@log
@@ -496,7 +496,7 @@ class MediaPlayer2Service(Server):
def _on_playlist_modified(self, path=None, _iter=None, data=None):
if self.player.currentTrack and self.player.currentTrack.valid():
path = self.player.currentTrack.get_path()
- currentTrack = self.player.playlist[path][self.player.playlistField]
+ currentTrack = self.player.playlist[path][self.player.playlist_field]
track_list = self._get_track_list()
self.TrackListReplaced(track_list, self._get_media_id(currentTrack))
self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
@@ -591,13 +591,12 @@ class MediaPlayer2Service(Server):
def GoTo(self, track_id):
for track in self.player.playlist:
- media = track[self.player.playlistField]
+ media = track[self.player.playlist_field]
if track_id == self._get_media_id(media):
- self.player.set_playlist(self.player.playlistType,
- self.player.playlistId,
- self.player.playlist,
- track.iter,
- self.player.playlistField)
+ self.player.set_playlist(
+ self.player.playlistType, self.player.playlistId,
+ self.player.playlist, track.iter)
+
self.player.play()
return
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index cc6e7bf2..d64c2a29 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -107,7 +107,7 @@ class Player(GObject.GObject):
self.playlist = None
self.playlistType = None
self.playlistId = None
- self.playlistField = None
+ self.playlist_field = 5
self.currentTrack = None
self._current_track_uri = None
self._missingPluginMessages = []
@@ -593,7 +593,7 @@ class Player(GObject.GObject):
if self.currentTrack and self.currentTrack.valid():
currentTrack = self.playlist.get_iter(self.currentTrack.get_path())
- uri = self.playlist[currentTrack][self.playlistField].get_url()
+ uri = self.playlist[currentTrack][self.playlist_field].get_url()
self._current_track_uri = uri
self.emit('playlist-item-changed', self.playlist, currentTrack)
self.emit('current-changed')
@@ -622,15 +622,15 @@ class Player(GObject.GObject):
return
_iter = self.playlist.get_iter(self.nextTrack.get_path())
- status = self.playlist.get_value(_iter, self.discovery_status_field)
- nextSong = self.playlist.get_value(_iter, self.playlistField)
- url = self.playlist.get_value(_iter, 5).get_url()
+ status = self.playlist[_iter][self.discovery_status_field]
+ next_song = self.playlist[_iter][self.playlist_field]
+ url = next_song.get_url()
# Skip remote songs discovery
if url.startswith('http://') or url.startswith('https://'):
return False
elif status == DiscoveryStatus.PENDING:
- self.discover_item(nextSong, self._on_next_item_validated, _iter)
+ self.discover_item(next_song, self._on_next_item_validated, _iter)
elif status == DiscoveryStatus.FAILED:
GLib.idle_add(self._validate_next_track)
@@ -722,8 +722,7 @@ class Player(GObject.GObject):
# FIXME: set the discovery field to 11 to be safe, but for some
# models it is 12.
@log
- def set_playlist(self, type, id, model, iter, field,
- discovery_status_field=11):
+ def set_playlist(self, type, id, model, iter, discovery_status_field=11):
old_playlist = self.playlist
if old_playlist != model:
self.playlist = model
@@ -735,7 +734,6 @@ class Player(GObject.GObject):
self.playlistType = type
self.playlistId = id
self.currentTrack = Gtk.TreeRowReference.new(model, model.get_path(iter))
- self.playlistField = field
self.discovery_status_field = discovery_status_field
if old_playlist != model:
@@ -1054,7 +1052,7 @@ class Player(GObject.GObject):
currentTrack = self.playlist.get_iter(self.currentTrack.get_path())
if self.playlist.get_value(currentTrack, self.discovery_status_field) == DiscoveryStatus.FAILED:
return None
- return self.playlist.get_value(currentTrack, self.playlistField)
+ return self.playlist[currentTrack][self.playlist_field]
class MissingCodecsDialog(Gtk.MessageDialog):
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index acc1e371..8c6e3b08 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -349,7 +349,7 @@ class PlaylistView(BaseView):
if self.model[_iter][8] != self._error_icon_name:
self.player.set_playlist(
'Playlist', self._current_playlist.get_id(), self.model,
- _iter, 5, 11)
+ _iter)
self.player.set_playing(True)
# 'row-activated' signal is emitted before 'drag-begin' signal.
@@ -417,7 +417,7 @@ class PlaylistView(BaseView):
self._iter_to_clean = new_iter
self.player.set_playlist(
'Playlist', self._current_playlist.get_id(), self.model,
- new_iter, 5, 11)
+ new_iter)
first_pos = min(new_pos, prev_pos)
last_pos = max(new_pos, prev_pos)
@@ -819,8 +819,8 @@ class PlaylistView(BaseView):
self._iter_to_clean = None
self._update_model(self.player, model, next_iter)
- self.player.set_playlist('Playlist', playlist.get_id(),
- model, next_iter, 5, 11)
+ self.player.set_playlist(
+ 'Playlist', playlist.get_id(), model, next_iter)
self.player.set_playing(True)
# Update songs count
@@ -840,8 +840,7 @@ class PlaylistView(BaseView):
and self._row_is_playing(playlist, row)):
self._iter_to_clean = row.iter
self.player.set_playlist(
- 'Playlist', playlist.get_id(), self.model, row.iter, 5,
- 11)
+ 'Playlist', playlist.get_id(), self.model, row.iter)
return
@log
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 21eab0d4..e5ffb34b 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -143,7 +143,7 @@ class SearchView(BaseView):
if self.model[_iter][12] != DiscoveryStatus.FAILED:
c_iter = self._songs_model.convert_child_iter_to_iter(_iter)[1]
self.player.set_playlist(
- 'Search Results', None, self._songs_model, c_iter, 5, 12)
+ 'Search Results', None, self._songs_model, c_iter, 12)
self.player.set_playing(True)
else: # Headers
if self._view.get_generic_view().row_expanded(path):
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index dfcd71a3..a09109a8 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -94,7 +94,7 @@ class SongsView(BaseView):
return
if self.model[itr][8] != self._error_icon_name:
- self.player.set_playlist('Songs', None, self.model, itr, 5, 11)
+ self.player.set_playlist('Songs', None, self.model, itr)
self.player.set_playing(True)
@log
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 97aaaa1d..76717d68 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -242,8 +242,8 @@ class AlbumWidget(Gtk.EventBox):
return
self._player.stop()
- self._player.set_playlist('Album', self._album, song_widget.model,
- song_widget.itr, 5, 11)
+ self._player.set_playlist(
+ 'Album', self._album, song_widget.model, song_widget.itr)
self._player.set_playing(True)
return True
@@ -293,7 +293,7 @@ class AlbumWidget(Gtk.EventBox):
if (playlist != self._model):
return True
- current_song = playlist[current_iter][5]
+ current_song = playlist[current_iter][player.playlist_field]
self._duration = 0
@@ -301,7 +301,7 @@ class AlbumWidget(Gtk.EventBox):
_iter = playlist.get_iter_first()
while _iter:
- song = playlist[_iter][5]
+ song = playlist[_iter][player.playlist_field]
song_widget = song.song_widget
self._duration += song.get_duration()
escaped_title = GLib.markup_escape_text(
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index c26af1e8..f679671c 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -163,8 +163,8 @@ class ArtistAlbumWidget(Gtk.Box):
return
self._player.stop()
- self._player.set_playlist('Artist', self._artist, song_widget.model,
- song_widget.itr, 5, 11)
+ self._player.set_playlist(
+ 'Artist', self._artist, song_widget.model, song_widget.itr)
self._player.set_playing(True)
return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]