def _make_action(self): """ Generates and returns Action instance """ entName = self.builder.get_object("entName") cbMacroType = self.builder.get_object("cbMacroType") pars = [x[0] for x in self.actions] if len(pars) == 0: # No action is actually set action = NoAction() elif cbMacroType.get_active() == 2: # Cycle pars = filter(lambda a: not isinstance(a, SleepAction), pars) action = Cycle(*pars) elif cbMacroType.get_active() == 1: # Repeating macro action = Macro(*pars) action.repeat = True elif len(pars) == 1: # Only one action action = pars[0] else: # Macro action = Macro(*pars) if entName.get_text().strip() != "": action.name = entName.get_text().strip() return action
def apply_keys(self, *a): """ Common part of on_*key_grabbed """ cbToggle = self.builder.get_object("cbToggle") keys = list(sorted(self.keys, key=ButtonsComponent.modifiers_first)) action = ButtonAction(keys[0]) if len(keys) > 1: actions = [ButtonAction(k) for k in keys] action = MultiAction(*actions) if cbToggle.get_active(): action = Cycle(PressAction(action), ReleaseAction(action)) self.editor.set_action(action)