Added CommandStack.explicit_user_call to distinguish user- from UI-generated calls.
[hooke.git] / hooke / ui / gui / __init__.py
index c96e78c3436c5fcdc2e38b4cf01aaf855b48351a..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,
@@ -300,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
@@ -337,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):