[gnome-music/wip/mschraal/window-template: 4/5] playertoolbar: Make player argument a property
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/window-template: 4/5] playertoolbar: Make player argument a property
- Date: Wed, 12 Sep 2018 11:54:50 +0000 (UTC)
commit e02338d26c93801566a0b04db0d76da6a5647ba1
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Sep 9 12:46:32 2018 +0200
playertoolbar: Make player argument a property
gnomemusic/widgets/playertoolbar.py | 30 ++++++++++++++++++++++++++----
gnomemusic/window.py | 4 +++-
2 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 5508013e..8950fd41 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -66,18 +66,40 @@ class PlayerToolbar(Gtk.ActionBar):
return '<PlayerToolbar>'
@log
- def __init__(self, player):
+ def __init__(self):
super().__init__()
- self._player = player
- self._progress_scale.player = self._player.get_gst_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
+ 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.player = self._player.get_gst_player()
self._player.connect('clock-tick', self._on_clock_tick)
self._player.connect('song-changed', self._update_view)
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index a9150e11..89eae11b 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -130,7 +130,9 @@ class Window(Gtk.ApplicationWindow):
def _setup_view(self):
self._headerbar = HeaderBar()
- self._player_toolbar = PlayerToolbar(self._player)
+ self._player_toolbar = PlayerToolbar()
+ self._player_toolbar.props.player = self._player
+
self.views = [None] * len(View)
self._headerbar.bind_property(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]