From: W. Trevor King Date: Sat, 31 Jul 2010 11:55:38 +0000 (-0400) Subject: Fix postprocess_get_curve in the case that nothing in the playlist panel is selected X-Git-Url: http://git.tremily.us/?p=hooke.git;a=commitdiff_plain;h=a544e3ea354f62cb451d41bab69be9b8ff19b35b Fix postprocess_get_curve in the case that nothing in the playlist panel is selected --- diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index d5086cf..231b054 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -305,7 +305,7 @@ class HookeFrame (wx.Frame): pp = getattr( self, '_postprocess_%s' % command.name.replace(' ', '_'), self._postprocess_text) - pp(command=command, results=results) + pp(command=command, args=args, results=results) return results def _handle_request(self, msg): @@ -335,7 +335,7 @@ class HookeFrame (wx.Frame): # Command-specific postprocessing - def _postprocess_text(self, command, results): + def _postprocess_text(self, command, args, results): """Print the string representation of the results to the Results window. This is similar to :class:`~hooke.ui.commandline.DoCommand`'s @@ -348,42 +348,45 @@ class HookeFrame (wx.Frame): self._c['output'].write(result.__class__.__name__+'\n') self._c['output'].write(str(result).rstrip()+'\n') - def _postprocess_load_playlist(self, command, results): + def _postprocess_load_playlist(self, command, args, results): """Update `self` to show the playlist. """ if not isinstance(results[-1], Success): self._postprocess_text(command, results) assert len(results) == 2, results playlist = results[0] - print playlist self._c['playlists']._c['tree'].add_playlist(playlist) - def _postprocess_get_playlist(self, command, results): + def _postprocess_get_playlist(self, command, args, results): if not isinstance(results[-1], Success): self._postprocess_text(command, results) assert len(results) == 2, results playlist = results[0] - print playlist self._c['playlists']._c['tree'].update_playlist(playlist) - def _postprocess_get_curve(self, command, results): + def _postprocess_get_curve(self, command, args, results): """Update `self` to show the curve. """ if not isinstance(results[-1], Success): self._postprocess_text(command, results) assert len(results) == 2, results curve = results[0] - playlist = self._c['playlists']._c['tree'].get_selected_playlist() - if playlist != None: # TODO: fix once we have hooke.plugin.playlists - self._c['playlists']._c['tree'].set_selected_curve( - playlist, curve) + if args.get('curve', None) == None: + # the command defaults to the current curve of the current playlist + results = self.execute_command( + command=self._command_by_name('get playlist')) + playlist = results[0] + else: + raise NotImplementedError() + self._c['playlists']._c['tree'].set_selected_curve( + playlist, curve) - def _postprocess_next_curve(self, command, results): + def _postprocess_next_curve(self, command, args, results): """No-op. Only call 'next curve' via `self._next_curve()`. """ pass - def _postprocess_previous_curve(self, command, results): + def _postprocess_previous_curve(self, command, args, results): """No-op. Only call 'previous curve' via `self._previous_curve()`. """ pass