Commit 19b6bc57 authored by Marinus Schraal's avatar Marinus Schraal

playertoolbar: Make player argument a property

parent bd471da1
......@@ -28,7 +28,7 @@ from gi.repository import GObject, Gtk
from gnomemusic import log
from gnomemusic.albumartcache import Art
from gnomemusic.gstplayer import Playback
from gnomemusic.player import RepeatMode
from gnomemusic.player import Player, RepeatMode
from gnomemusic.widgets.coverstack import CoverStack # noqa: F401
from gnomemusic.widgets.smoothscale import SmoothScale # noqa: F401
from gnomemusic.widgets.twolinetip import TwoLineTip
......@@ -66,24 +66,48 @@ class PlayerToolbar(Gtk.ActionBar):
return '<PlayerToolbar>'
@log
def __init__(self, player):
def __init__(self):
super().__init__()
self._player = player
self._progress_scale.props.player = self._player
self._player = None
self._cover_stack.props.size = Art.Size.XSMALL
self._cover_stack.connect('updated', self._on_cover_stack_updated)
self._tooltip = TwoLineTip()
self._sync_repeat_image()
# FIXME: This is a workaround for not being able to pass the player
# object via init when using Gtk.Builder.
@GObject.Property(type=Player, default=None)
def player(self):
"""The GstPlayer object used
:return: player object
:rtype: GstPlayer
"""
return self._player
@player.setter
def player(self, player):
"""Set the GstPlayer object used
:param GstPlayer player: The GstPlayer to use
"""
if (player is None
or (self._player is not None
and self._player != player)):
return
self._player = player
self._progress_scale.props.player = self._player
self._player.connect('song-changed', self._update_view)
self._player.connect(
'notify::repeat-mode', self._on_repeat_mode_changed)
self._player.connect('notify::state', self._sync_playing)
self._sync_repeat_image()
@Gtk.Template.Callback()
@log
def _on_progress_value_changed(self, progress_scale):
......
......@@ -142,7 +142,8 @@ class Window(Gtk.ApplicationWindow):
"state", self._searchbar, "search-state",
GObject.BindingFlags.SYNC_CREATE)
self._player_toolbar = PlayerToolbar(self._player)
self._player_toolbar = PlayerToolbar()
self._player_toolbar.props.player = self._player
self.views = [None] * len(View)
......
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