[gnome-music/wip/mschraal/window-template: 8/10] 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: 8/10] playertoolbar: Make player argument a property
- Date: Mon, 27 May 2019 09:21:09 +0000 (UTC)
commit 0bc4fe0a212cb62062c5e624f891679a32cfd7e0
Author: Marinus Schraal <mschraal gnome org>
Date: Sun May 5 00:20:38 2019 +0200
playertoolbar: Make player argument a property
gnomemusic/widgets/playertoolbar.py | 32 ++++++++++++++++++++++++++++----
gnomemusic/window.py | 3 ++-
2 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index c0ee9f83..89209588 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -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
+ 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):
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 3b94e687..9ce4bcf4 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -148,7 +148,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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]