[gnome-music/wip/jfelder/lastfm-ui-v1: 34/35] Initialize Last.fm scrobbler in application



commit 1abe459f15592eeca4153cb50a69e5129a6c5ebd
Author: Jean Felder <jfelder src gnome org>
Date:   Sat Jan 4 16:43:40 2020 +0100

    Initialize Last.fm scrobbler in application

 gnomemusic/application.py | 11 +++++++++++
 gnomemusic/player.py      |  3 +--
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index e49607fe..cec31d2c 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -42,6 +42,7 @@ from gnomemusic.inhibitsuspend import InhibitSuspend
 from gnomemusic.mpris import MPRIS
 from gnomemusic.pauseonsuspend import PauseOnSuspend
 from gnomemusic.player import Player
+from gnomemusic.scrobbler import LastFmScrobbler
 from gnomemusic.widgets.aboutdialog import AboutDialog
 from gnomemusic.window import Window
 
@@ -67,6 +68,7 @@ class Application(Gtk.Application):
         self._coremodel = CoreModel(self)
 
         self._settings = Gio.Settings.new('org.gnome.Music')
+        self._lastfm_scrobbler = LastFmScrobbler(self)
         self._player = Player(self)
 
         InhibitSuspend(self)
@@ -120,6 +122,15 @@ class Application(Gtk.Application):
         """
         return self._coreselection
 
+    @GObject.Property(type=LastFmScrobbler, flags=GObject.ParamFlags.READABLE)
+    def lastfm_scrobbler(self):
+        """Get Last.fm scrobbler.
+
+        :returns: Last.fm scrobbler
+        :rtype: LastFmScrobbler
+        """
+        return self._lastfm_scrobbler
+
     @GObject.Property(type=Window, flags=GObject.ParamFlags.READABLE)
     def window(self):
         """Get main window.
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 79d0c075..a2af87e9 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -35,7 +35,6 @@ from gi._gi import pygobject_new_full
 from gnomemusic import log
 from gnomemusic.coresong import CoreSong
 from gnomemusic.gstplayer import GstPlayer, Playback
-from gnomemusic.scrobbler import LastFmScrobbler
 from gnomemusic.widgets.songwidget import SongWidget
 
 
@@ -401,7 +400,7 @@ class Player(GObject.GObject):
         self._gst_player.bind_property(
             'state', self, 'state', GObject.BindingFlags.SYNC_CREATE)
 
-        self._lastfm = LastFmScrobbler(application)
+        self._lastfm = application.props.lastfm_scrobbler
 
     @GObject.Property(
         type=bool, default=False, flags=GObject.ParamFlags.READABLE)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]