Handle broadcast_playlist_loaded.
[euphoria.git] / lib / playlist.rb
index b8b6406019d0c034b350d7b63bd1f988b425ca7e..9406a5b52ccb7734167a2bf9e8a554aa7a2df58b 100644 (file)
@@ -12,7 +12,7 @@ class Playlist < Array
                @eet = nil
                @container = nil
 
-               @xmms.playlist.entries.notifier { |res| push(*res.value) }
+               query_contents
 
                @xmms.playlist.current_pos.notifier do |res|
                        begin
@@ -31,15 +31,18 @@ class Playlist < Array
                        current_item.hilighted = true
                end
 
+               @xmms.broadcast_playlist_loaded.
+                       notifier(&method(:on_playlist_loaded))
+
                @xmms.broadcast_playlist_changed.notifier do |res|
                        case res.value[:type]
-                               when Xmms::Result::PLAYLIST_CHANGED_ADD
+                               when Xmms::Playlist::ADD
                                        self << res.value[:id]
-                               when Xmms::Result::PLAYLIST_CHANGED_REMOVE
+                               when Xmms::Playlist::REMOVE
                                        # the daemon sends the position of the song, not the
                                        # unique mlib id
                                        delete(self[res.value[:position]])
-                               when Xmms::Result::PLAYLIST_CHANGED_CLEAR
+                               when Xmms::Playlist::CLEAR
                                        clear
                        end
                end
@@ -192,4 +195,15 @@ class Playlist < Array
 
                @ee.shaped = !@edje.data("shaped").nil?
        end
+
+       def query_contents
+               @xmms.playlist.entries.notifier do |res|
+                       push(*res.value)
+               end
+       end
+
+       def on_playlist_loaded(res)
+               clear
+               query_contents
+       end
 end