X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fui%2Fgui%2Finterface.py;fp=hooke%2Fui%2Fgui%2Finterface.py;h=3ea863153415616c4b859bd1f895cc658decf378;hp=2c58923c8698455ce69346bb24859d651dd3f296;hb=26b91a633c6264f2fb11cbb7a418894dbdce4759;hpb=52d826ba83665e8afedfd8450a3ebb9f669df09f diff --git a/hooke/ui/gui/interface.py b/hooke/ui/gui/interface.py index 2c58923..3ea8631 100644 --- a/hooke/ui/gui/interface.py +++ b/hooke/ui/gui/interface.py @@ -130,10 +130,8 @@ class HookeFrame (wx.Frame): # defaultFilter=self.gui.config['folders-filter-index']), 'left'), (panel.PANELS['playlist']( callbacks={ - 'delete_playlist':self._on_user_delete_playlist, - '_delete_playlist':self._on_delete_playlist, - 'delete_curve':self._on_user_delete_curve, - '_delete_curve':self._on_delete_curve, + '_delete_playlist':self._delete_playlist, + '_delete_curve':self._delete_curve, '_on_set_selected_playlist':self._on_set_selected_playlist, '_on_set_selected_curve':self._on_set_selected_curve, }, @@ -221,9 +219,9 @@ class HookeFrame (wx.Frame): callbacks={ 'next': self._next_curve, 'previous': self._previous_curve, + 'delete': self._delete_curve, }, - parent=self, - style=wx.TB_FLAT | wx.TB_NODIVIDER) + parent=self) self._c['manager'].AddPane( self._c['navigation bar'], aui.AuiPaneInfo().Name('Navigation').Caption('Navigation' @@ -238,6 +236,7 @@ class HookeFrame (wx.Frame): self.Bind(wx.EVT_SIZE, self._on_size) self.Bind(wx.EVT_CLOSE, self._on_close) self.Bind(aui.EVT_AUI_PANE_CLOSE, self._on_pane_close) + self.Bind(wx.EVT_CHAR_HOOK, self._on_key) return # TODO: cleanup treeCtrl = self._c['folders'].GetTreeCtrl() @@ -259,6 +258,7 @@ class HookeFrame (wx.Frame): def _on_close(self, *args): self.log.info('closing GUI framework') + # apply changes self._set_config('main height', self.GetSize().GetHeight()) self._set_config('main left', self.GetPosition()[0]) @@ -271,6 +271,16 @@ class HookeFrame (wx.Frame): def _on_erase_background(self, event): event.Skip() + def _on_key(self, event): + code = event.GetKeyCode() + if code == wx.WXK_RIGHT: + self._next_curve() + elif code == wx.WXK_LEFT: + self._previous_curve() + elif code == wx.WXK_DELETE or code == wx.WXK_BACK: + self._delete_curve() + else: + event.Skip() # Panel utility functions @@ -520,6 +530,11 @@ class HookeFrame (wx.Frame): self.execute_command( command=self._command_by_name('get playlist')) + def _postprocess_delete_curve(self, command, args={}, results=[]): + """No-op. Only call 'delete curve' via `self._delete_curve()`. + """ + pass + def _update_curve(self, command, args={}, results=[]): """Update the curve, since the available columns may have changed. """ @@ -594,22 +609,11 @@ class HookeFrame (wx.Frame): # Playlist panel interface - def _on_user_delete_playlist(self, _class, method, playlist): - pass - - def _on_delete_playlist(self, _class, method, playlist): - if hasattr(playlist, 'path') and playlist.path != None: - os.remove(playlist.path) - - def _on_user_delete_curve(self, _class, method, playlist, curve): - pass - - def _on_delete_curve(self, _class, method, playlist, curve): - index = playlist.index(curve) - results = self.execute_command( - command=self._command_by_name('remove curve from playlist'), - args={'index': index}) - #os.remove(curve.path) + def _delete_playlist(self, _class, method, playlist): + #if hasattr(playlist, 'path') and playlist.path != None: + # os.remove(playlist.path) + # TODO: remove playlist from underlying hooke instance and call ._c['playlist'].delete_playlist() + # possibly rename this method to _postprocess_delete_playlist... pass def _on_set_selected_playlist(self, _class, method, playlist): @@ -675,6 +679,18 @@ class HookeFrame (wx.Frame): self.execute_command( command=self._command_by_name('get curve')) + def _delete_curve(self, *args, **kwargs): + cmd_kwargs = {} + playlist = kwargs.get('playlist', None) + curve = kwargs.get('curve', None) + if playlist is not None and curve is not None: + cmd_kwargs['index'] = playlist.index(curve) + results = self.execute_command( + command=self._command_by_name('remove curve from playlist'), + args=cmd_kwargs) + if isinstance(results[-1], Success): + results = self.execute_command( + command=self._command_by_name('get playlist')) # Panel display handling