Ran update_copyright.py.
[hooke.git] / hooke / ui / gui / panel / playlist.py
index c50da0bd1449763fdffb075464285b6ccfdb9e81..f355e6d0038943a774e3778bf00beb8d09d67826 100644 (file)
@@ -1,5 +1,5 @@
-# Copyright (C) 2010 Massimo Sandal <devicerandom@gmail.com>
-#                    W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2011 Massimo Sandal <devicerandom@gmail.com>
+#                         W. Trevor King <wking@drexel.edu>
 #
 # This file is part of Hooke.
 #
@@ -334,6 +334,36 @@ class Tree (wx.TreeCtrl):
         """Absorb changed `.index()`, etc.
         """
         self._playlists[playlist.name] = playlist
+        cnames = []
+        for curve in playlist:
+            if (playlist.name, curve.name) not in self._id_for_name:
+                self._add_curve(playlist.name, curve)
+            cnames.append(curve.name)
+        dc = self._callbacks['delete_curve']
+        _dc = self._callbacks['_delete_curve']
+        self._callbacks['delete_curve'] = None
+        self._callbacks['_delete_curve'] = None
+        for name in self._id_for_name.keys():
+            if not self._is_curve(name):
+                continue
+            pname,cname = name
+            if pname != playlist.name:
+                continue
+            if cname not in cnames:
+                self.delete_curve(playlist.name, cname)
+        self._callbacks['delete_curve'] = dc
+        self._callbacks['_delete_curve'] = _dc
+
+    def is_playlist_loaded(self, playlist):
+        """Return `True` if `playlist` is loaded, `False` otherwise.
+        """
+        return self.is_playlist_name_loaded(playlist.name)
+
+    def is_playlist_name_loaded(self, name):
+        """Return `True` if a playlist named `name` is loaded, `False`
+        otherwise.
+        """
+        return name in self._playlists
 
 
 class Playlist (Panel, wx.Panel):
@@ -359,8 +389,8 @@ class Playlist (Panel, wx.Panel):
         # Following DRY and the LoD.
         for attribute_name in dir(self._c['tree']):
             if (attribute_name.startswith('_')
-                or 'playlist' not in attribute_name
-                or 'curve' not in attribute_name):
+                or ('playlist' not in attribute_name
+                    and 'curve' not in attribute_name)):
                 continue  # not an attribute we're interested in
             attr = getattr(self._c['tree'], attribute_name)
             if hasattr(attr, '__call__'):  # attr is a function / method