[gnome-music] view: Add method to play a playlist in Playlists view
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] view: Add method to play a playlist in Playlists view
- Date: Tue, 18 Nov 2014 11:39:07 +0000 (UTC)
commit d5aff13e48c1be312a5d494df1d301614246d911
Author: Arnel Borja <arnelborja src gnome org>
Date: Sun Nov 16 22:34:16 2014 +0800
view: Add method to play a playlist in Playlists view
https://bugzilla.gnome.org/show_bug.cgi?id=729309
gnomemusic/view.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 12668de..cd2a1ea 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -784,6 +784,10 @@ class Artists (ViewContainer):
class Playlist(ViewContainer):
+ __gsignals__ = {
+ 'playlists-loaded': (GObject.SIGNAL_RUN_FIRST, None, ()),
+ 'playlist-songs-loaded': (GObject.SIGNAL_RUN_FIRST, None, ()),
+ }
@log
def __init__(self, window, player):
@@ -982,6 +986,7 @@ class Playlist(ViewContainer):
@log
def _add_playlist_item_to_model(self, item):
if not item:
+ self.emit('playlists-loaded')
return
_iter = self.playlists_model.insert_with_valuesv(
-1,
@@ -1005,6 +1010,47 @@ class Playlist(ViewContainer):
self.player.set_playing(True)
@log
+ def activate_playlist(self, playlist_id):
+ def find_and_activate_playlist():
+ for playlist in self.playlists_model:
+ if playlist[5].get_id() == playlist_id:
+ selection = self.playlists_sidebar.get_generic_view().get_selection()
+ if selection.iter_is_selected(playlist.iter):
+ self._on_play_activate(None)
+ else:
+ selection.select_iter(playlist.iter)
+ handler = 0
+
+ def songs_loaded_callback(view):
+ self.disconnect(handler)
+ self._on_play_activate(None)
+
+ handler = self.connect('playlist-songs-loaded', songs_loaded_callback)
+ self.playlists_sidebar.emit('item-activated', '0', playlist.path)
+
+ return
+
+ if self._init:
+ find_and_activate_playlist()
+ else:
+ handler = 0
+
+ def playlists_loaded_callback(view):
+ self.disconnect(handler)
+ def_handler = 0
+
+ def songs_loaded_callback(view):
+ self.disconnect(def_handler)
+ find_and_activate_playlist()
+
+ # Skip load of default playlist
+ def_handler = self.connect('playlist-songs-loaded', songs_loaded_callback)
+
+ handler = self.connect('playlists-loaded', playlists_loaded_callback)
+
+ self._populate()
+
+ @log
def _on_playlist_activated(self, widget, item_id, path):
_iter = self.playlists_model.get_iter(path)
playlist_name = self.playlists_model.get_value(_iter, 2)
@@ -1027,6 +1073,7 @@ class Playlist(ViewContainer):
self.view.set_model(self._model)
self.songs_count = self._model.iter_n_children(None)
self._update_songs_count()
+ self.emit('playlist-songs-loaded')
else:
self._model = Gtk.ListStore(
GObject.TYPE_STRING,
@@ -1053,6 +1100,7 @@ class Playlist(ViewContainer):
@log
def _add_item_to_model(self, item, model):
if not item:
+ self.emit('playlist-songs-loaded')
return
self._offset += 1
title = albumArtCache.get_media_title(item)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]