Fix postprocess_get_curve in the case that nothing in the playlist panel is selected
authorW. Trevor King <wking@drexel.edu>
Sat, 31 Jul 2010 11:55:38 +0000 (07:55 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 31 Jul 2010 11:55:38 +0000 (07:55 -0400)
hooke/ui/gui/__init__.py

index d5086cfffa6ddd201207e039824ec94662d6268e..231b0544359a62e507ea891198e72e5f38fb0a22 100644 (file)
@@ -305,7 +305,7 @@ class HookeFrame (wx.Frame):
         pp = getattr(\r
             self, '_postprocess_%s' % command.name.replace(' ', '_'),\r
             self._postprocess_text)\r
-        pp(command=command, results=results)\r
+        pp(command=command, args=args, results=results)\r
         return results\r
 \r
     def _handle_request(self, msg):\r
@@ -335,7 +335,7 @@ class HookeFrame (wx.Frame):
 \r
     # Command-specific postprocessing\r
 \r
-    def _postprocess_text(self, command, results):\r
+    def _postprocess_text(self, command, args, results):\r
         """Print the string representation of the results to the Results window.\r
 \r
         This is similar to :class:`~hooke.ui.commandline.DoCommand`'s\r
@@ -348,42 +348,45 @@ class HookeFrame (wx.Frame):
                 self._c['output'].write(result.__class__.__name__+'\n')\r
             self._c['output'].write(str(result).rstrip()+'\n')\r
 \r
-    def _postprocess_load_playlist(self, command, results):\r
+    def _postprocess_load_playlist(self, command, args, results):\r
         """Update `self` to show the playlist.\r
         """\r
         if not isinstance(results[-1], Success):\r
             self._postprocess_text(command, results)\r
         assert len(results) == 2, results\r
         playlist = results[0]\r
-        print playlist\r
         self._c['playlists']._c['tree'].add_playlist(playlist)\r
 \r
-    def _postprocess_get_playlist(self, command, results):\r
+    def _postprocess_get_playlist(self, command, args, results):\r
         if not isinstance(results[-1], Success):\r
             self._postprocess_text(command, results)\r
         assert len(results) == 2, results\r
         playlist = results[0]\r
-        print playlist\r
         self._c['playlists']._c['tree'].update_playlist(playlist)\r
 \r
-    def _postprocess_get_curve(self, command, results):\r
+    def _postprocess_get_curve(self, command, args, results):\r
         """Update `self` to show the curve.\r
         """\r
         if not isinstance(results[-1], Success):\r
             self._postprocess_text(command, results)\r
         assert len(results) == 2, results\r
         curve = results[0]\r
-        playlist = self._c['playlists']._c['tree'].get_selected_playlist()\r
-        if playlist != None:  # TODO: fix once we have hooke.plugin.playlists\r
-            self._c['playlists']._c['tree'].set_selected_curve(\r
-                playlist, curve)\r
+        if args.get('curve', None) == None:\r
+            # the command defaults to the current curve of the current playlist\r
+            results = self.execute_command(\r
+                command=self._command_by_name('get playlist'))\r
+            playlist = results[0]\r
+        else:\r
+            raise NotImplementedError()\r
+        self._c['playlists']._c['tree'].set_selected_curve(\r
+            playlist, curve)\r
 \r
-    def _postprocess_next_curve(self, command, results):\r
+    def _postprocess_next_curve(self, command, args, results):\r
         """No-op.  Only call 'next curve' via `self._next_curve()`.\r
         """\r
         pass\r
 \r
-    def _postprocess_previous_curve(self, command, results):\r
+    def _postprocess_previous_curve(self, command, args, results):\r
         """No-op.  Only call 'previous curve' via `self._previous_curve()`.\r
         """\r
         pass\r