Keep Playlist._loaded up to date on Curve.unload() calls.
[hooke.git] / hooke / plugin / playlist.py
index 36993017a4344113c9a61c6261c190eef021ffe7..43978b5669f7eba4f58fbb43241fa2dbb6090309 100644 (file)
@@ -38,7 +38,7 @@ class PlaylistPlugin (Builtin):
         self._commands = [
             NextCommand(self), PreviousCommand(self), JumpCommand(self),
             GetCommand(self), IndexCommand(self), CurveListCommand(self),
-            SaveCommand(self), LoadCommand(self),
+            NameCommand(self), SaveCommand(self), LoadCommand(self),
             AddCommand(self), AddGlobCommand(self),
             RemoveCommand(self), ApplyCommand(self),
             FilterCommand(self),
@@ -210,6 +210,26 @@ class CurveListCommand (PlaylistCommand):
        outqueue.put(list(self._playlist(hooke, params)))
 
 
+class NameCommand (PlaylistCommand):
+    """(Re)name a playlist.
+    """
+    def __init__(self, plugin):
+        super(NameCommand, self).__init__(
+            name='name playlist',
+            arguments=[
+                Argument(name='name', type='string', optional=False,
+                         help="""
+Name for the playlist.
+""".strip()),
+                ],
+            help=self.__doc__, plugin=plugin)
+
+    def _run(self, hooke, inqueue, outqueue, params):
+       p = self._playlist(hooke, params)
+        p.name = params['name']
+        outqueue.put(p)
+
+
 class SaveCommand (PlaylistCommand):
     """Save a playlist.
     """
@@ -250,7 +270,7 @@ Drivers for loading curves.
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
-        p = load(path=params['input'], drivers=params['drivers'])
+        p = load(path=params['input'], drivers=params['drivers'], hooke=hooke)
         self._set_playlist(hooke, params, p)
        outqueue.put(p)
 
@@ -365,7 +385,7 @@ Evaluate the applied command stack immediately.
                 for command in params['commands']:
                     curve.command_stack.append(command)
                 curve.set_hooke(hooke)
-                curve.unload()
+                p.unload(curve)
 
     def __setup_params(self, hooke, params):
         if params['commands'] == None: