[gnome-music/wip/jfelder/mpris-limit-songs: 1/3] player: Define has_songs property



commit 17295fd217f1b67da1d5c2a199778433e50236d8
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Sep 13 23:54:21 2018 +0200

    player: Define has_songs property
    
    This simplifies mpris Play method.

 gnomemusic/mpris.py  | 2 +-
 gnomemusic/player.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index dce483de..b103c50c 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -538,7 +538,7 @@ class MediaPlayer2Service(Server):
         self.player.stop()
 
     def Play(self):
-        if self.player.get_songs():
+        if self.player.props.has_songs:
             self.player.play()
         elif self.first_song_handler == 0:
             window = self.app.get_active_window()
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index c26cb20f..644a6ee2 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -852,6 +852,12 @@ class Player(GObject.GObject):
         self._player.volume = rate
         self.emit('volume-changed')
 
+    @GObject.Property(
+        type=bool, default=False, flags=GObject.ParamFlags.READABLE)
+    def has_songs(self):
+        """Check if the playlist has songs"""
+        return self._playlist.props.current_song is not None
+
     @log
     def get_songs(self):
         return self._playlist.get_songs()


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