Commit 6aca5425 authored by Jean Felder's avatar Jean Felder

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.
parent 031c577e
......@@ -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
......
......@@ -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:
......@@ -1056,7 +1054,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):
......
......@@ -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
......
......@@ -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):
......
......@@ -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
......
......@@ -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(
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment