Commit da7fa8df authored by Jean Felder's avatar Jean Felder Committed by Jean Felder

player: Simplify song-changed signal

Now that "current_song_index" is exposed as property, it does not need
to be transmitted when the "song-changed" signal is emitted.
parent ec529590
Pipeline #84868 passed with stages
in 7 minutes and 27 seconds
......@@ -449,7 +449,7 @@ class MediaPlayer2Service(Server):
return (True, (path, playlist_name, ""))
@log
def _on_current_song_changed(self, player, position):
def _on_current_song_changed(self, player):
self._update_songs_list()
if self.player.props.repeat_mode == RepeatMode.SONG:
self.Seeked(0)
......
......@@ -544,7 +544,7 @@ class Player(GObject.GObject):
__gsignals__ = {
'playlist-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
'seek-finished': (GObject.SignalFlags.RUN_FIRST, None, (float,)),
'song-changed': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
'song-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
'song-validated': (GObject.SignalFlags.RUN_FIRST, None, (int, int)),
}
......@@ -623,7 +623,7 @@ class Player(GObject.GObject):
self._gst_player.props.url = song.get_url()
self.emit('song-changed', self.props.current_song_index)
self.emit('song-changed')
@log
def _on_eos(self, klass):
......
......@@ -245,11 +245,10 @@ class PlaylistView(BaseView):
cell.set_visible(False)
@log
def _update_model(self, player, position):
def _update_model(self, player):
"""Updates model when the song changes
:param Player player: The main player object
:param int position: current song position
"""
if self._current_playlist is None:
return
......@@ -260,7 +259,8 @@ class PlaylistView(BaseView):
PlayerPlaylist.Type.PLAYLIST, self._current_playlist.get_id()):
return False
iter_ = self.model.get_iter_from_string(str(position))
index = self.player.props.current_song_index
iter_ = self.model.get_iter_from_string(str(index))
self.model[iter_][10] = True
path = self.model.get_path(iter_)
self._view.scroll_to_cell(path, None, False, 0., 0.)
......
......@@ -229,18 +229,18 @@ class SongsView(BaseView):
self.props.selected_items_count = len(self.get_selected_songs())
@log
def _update_model(self, player, position):
def _update_model(self, player):
"""Updates model when the song changes
:param Player player: The main player object
:param int position: current song position
"""
if self._iter_to_clean:
self.model[self._iter_to_clean][10] = False
if not player.playing_playlist(PlayerPlaylist.Type.SONGS, None):
return False
iter_ = self.model.get_iter_from_string(str(position))
index = self.player.props.current_song_index
iter_ = self.model.get_iter_from_string(str(index))
self.model[iter_][10] = True
path = self.model.get_path(iter_)
self._view.scroll_to_cell(path, None, False, 0., 0.)
......
......@@ -226,11 +226,10 @@ class AlbumWidget(Gtk.EventBox):
self._update_model(self._player)
@log
def _update_model(self, player, position=None):
def _update_model(self, player):
"""Updates model when the song changes
:param Player player: The main player object
:param int position: current song position
"""
if not player.playing_playlist(
PlayerPlaylist.Type.ALBUM, self._album_name):
......
......@@ -137,11 +137,10 @@ class ArtistAlbumsWidget(Gtk.Box):
widget.connect('songs-loaded', self._on_album_displayed)
@log
def _update_model(self, player, position):
def _update_model(self, player):
"""Updates model when the song changes
:param Player player: The main player object
:param int position: current song position
"""
if not player.playing_playlist(
PlayerPlaylist.Type.ARTIST, self._artist):
......
......@@ -172,11 +172,10 @@ class PlayerToolbar(Gtk.ActionBar):
self._prev_button.props.sensitive = self._player.props.has_previous
@log
def _update_view(self, player, position):
def _update_view(self, player):
"""Updates model when the song changes
:param Player player: The main player object
:param int position: current song position
"""
current_song = player.props.current_song
self._duration_label.set_label(
......
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