Added CommandStack.explicit_user_call to distinguish user- from UI-generated calls.
[hooke.git] / hooke / ui / gui / __init__.py
index 048764e97f6a1c204c24a0948fe6b7ee3bc0aa9f..1cdeb05ef69ca31d1046fdc1f1ee9500d3b141f5 100644 (file)
@@ -165,7 +165,7 @@ class HookeFrame (wx.Frame):
                     commands=self.commands,
                     selected=self.gui.config['selected command'],
                     callbacks={
-                        'execute': self.execute_command,
+                        'execute': self.explicit_execute_command,
                         'select_plugin': self.select_plugin,
                         'select_command': self.select_command,
 #                        'selection_changed': self.panelProperties.select(self, method, command),  #SelectedTreeItem = selected_item,
@@ -244,7 +244,6 @@ 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(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self._on_notebook_page_close)
 
         return # TODO: cleanup
         treeCtrl = self._c['folders'].GetTreeCtrl()
@@ -301,8 +300,14 @@ class HookeFrame (wx.Frame):
             raise Exception('Multiple commands named "%s"' % name)
         return cs[0]
 
+    def explicit_execute_command(self, _class=None, method=None,
+                                 command=None, args=None):
+        return self.execute_command(
+            _class=_class, method=method, command=command, args=args,
+            explicit_user_call=True)
+
     def execute_command(self, _class=None, method=None,
-                        command=None, args=None):
+                        command=None, args=None, explicit_user_call=False):
         if args == None:
             args = {}
         if ('property editor' in self._c
@@ -338,7 +343,11 @@ class HookeFrame (wx.Frame):
                     if len(args[arg.name]) == 0:
                         args[arg.name] = arg.default
         cm = CommandMessage(command.name, args)
-        self.gui._submit_command(cm, self.inqueue)
+        self.gui._submit_command(
+            cm, self.inqueue, explicit_user_call=explicit_user_call)
+        # TODO: skip responses for commands that were captured by the
+        # command stack.  We'd need to poll on each request, remember
+        # capture state, or add a flag to the response...
         return self._handle_response(command_message=cm)
 
     def _handle_response(self, command_message):
@@ -567,6 +576,9 @@ class HookeFrame (wx.Frame):
 
         self._set_config('selected command', command.name)
 
+    def select_plugin(self, _class=None, method=None, plugin=None):
+        pass
+
 
 
     # Folders panel interface