[gnome-music] mpris: Use Songs view if has no playlist
- From: Arnel A. Borja <arnelborja src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] mpris: Use Songs view if has no playlist
- Date: Mon, 2 Sep 2013 16:17:59 +0000 (UTC)
commit 227ec60c768f91f003fbdce349c6cf90dcc2bfce
Author: Arnel A. Borja <arnelborja src gnome org>
Date: Sun Sep 1 22:43:13 2013 +0800
mpris: Use Songs view if has no playlist
Select Songs view as playlist if there's none and Play is called.
https://bugzilla.gnome.org/show_bug.cgi?id=705855
gnomemusic/mpris.py | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 68d294f..dfcae49 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -48,6 +48,7 @@ class MediaPlayer2Service(dbus.service.Object):
self.player.connect('volume-changed', self._on_volume_changed)
self.player.connect('prev-next-invalidated', self._on_prev_next_invalidated)
self.player.connect('seeked', self._on_seeked)
+ self.first_song_handler = 0
def _get_playback_status(self):
state = self.player.get_playback_status()
@@ -147,6 +148,13 @@ class MediaPlayer2Service(dbus.service.Object):
},
[])
+ def _play_first_song(self, model, path, iter_, data=None):
+ if self.first_song_handler:
+ model.disconnect(self.first_song_handler)
+ self.first_song_handler = 0
+ self.player.set_playlist('Songs', None, model, iter_, 5)
+ self.player.set_playing(True)
+
def _on_seeked(self, player, position, data=None):
self.Seeked(position)
@@ -180,7 +188,17 @@ class MediaPlayer2Service(dbus.service.Object):
@dbus.service.method(dbus_interface=MEDIA_PLAYER2_PLAYER_IFACE)
def Play(self):
- self.player.set_playing(True)
+ if self.player.playlist is not None:
+ self.player.set_playing(True)
+ elif self.first_song_handler == 0:
+ window = self.app.get_active_window()
+ window._stack.set_visible_child(window.views[2])
+ model = window.views[2]._model
+ if model.iter_n_children(None):
+ _iter = model.get_iter_first()
+ self._play_first_song(model, model.get_path(_iter), _iter)
+ else:
+ self.first_song_handler = model.connect('row-inserted', self._play_first_song)
@dbus.service.method(dbus_interface=MEDIA_PLAYER2_PLAYER_IFACE,
in_signature='x')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]