Flesh out HookeFrame._on_set_selected_playlist with 'jump to playlist' call
authorW. Trevor King <wking@drexel.edu>
Tue, 3 Aug 2010 01:29:57 +0000 (21:29 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 3 Aug 2010 01:29:57 +0000 (21:29 -0400)
hooke/ui/gui/__init__.py
hooke/ui/gui/panel/playlist.py

index c3a9f45a94c3314109b5b43c7609bdbca6cbcb2b..c7409fbb6a9d410a8dcf3707acc3b3a92029946d 100644 (file)
@@ -711,16 +711,27 @@ class HookeFrame (wx.Frame):
         os.remove(curve.path)
 
     def _on_set_selected_playlist(self, _class, method, playlist):
-        """TODO: playlists plugin with `jump to playlist`.
+        """Call the `jump to playlist` command.
         """
-        pass
+        results = self.execute_command(
+            command=self._command_by_name('playlists'))
+        if not isinstance(results[-1], Success):
+            return
+        assert len(results) == 2, results
+        playlists = results[0]
+        matching = [p for p in playlists if p.name == playlist.name]
+        assert len(matching) == 1, matching
+        index = playlists.index(matching[0])
+        results = self.execute_command(
+            command=self._command_by_name('jump to playlist'),
+            args={'index':index})
 
     def _on_set_selected_curve(self, _class, method, playlist, curve):
         """Call the `jump to curve` command.
 
         TODO: playlists plugin.
         """
-        # TODO: jump to playlist, get playlist
+        self._on_set_selected_playlist(_class, method, playlist)
         index = playlist.index(curve)
         results = self.execute_command(
             command=self._command_by_name('jump to curve'),
index f5c840fd52c1b30dcbd91a1d6fdfb5b7f8a9481f..ddfedb11bf3f2a78cfb14c4eeb0025a9632aff87 100644 (file)
@@ -302,9 +302,12 @@ class Tree (wx.TreeCtrl):
             self._on_set_selected_playlist(name)
 
     def _on_set_selected_playlist(self, name):
+        self.log.debug('playlist tree selecting playlist %s' % name)
         in_callback(self, self._playlists[name])
 
     def _on_set_selected_curve(self, playlist_name, name):
+        self.log.debug('playlist tree selecting curve %s in %s'
+                       % (name, playlist_name))
         playlist = self._playlists[playlist_name]
         curve = None
         for i,c in enumerate(playlist):