diff --git a/quicktile/__main__.py b/quicktile/__main__.py index 09d2385..5ec27bd 100644 --- a/quicktile/__main__.py +++ b/quicktile/__main__.py @@ -311,7 +311,7 @@ def main(): # type: () -> None winman.screen.force_update() for arg in args: - commands.commands.call(arg, winman) + commands.commands.call_multiple(arg, winman) while gtk.events_pending(): # pylint: disable=no-member gtk.main_iteration() # pylint: disable=no-member elif not opts.show_args and not opts.show_binds: diff --git a/quicktile/commands.py b/quicktile/commands.py index 1b8163c..c4b0501 100644 --- a/quicktile/commands.py +++ b/quicktile/commands.py @@ -169,7 +169,7 @@ def decorate(func): def call(self, command, winman, *args, **kwargs): # type: (str, WindowManager, *Any, **Any) -> bool - """Resolve a textual positioning command and execute it.""" + """Check if the command is valid and execute it.""" cmd = self.commands.get(command, None) if cmd: @@ -183,6 +183,21 @@ def call(self, command, winman, *args, **kwargs): logging.error("Unrecognized command: %s", command) return False + def call_multiple(self, command, winman, *args, **kwargs): + # type: (str, WindowManager, *Any, **Any) -> bool + """Resolve a textual positioning command and execute it. + Accepts a comma seperated string as the command.""" + cmds = [] #type: List[str] + success = True + if ',' in command: + cmds = [i.strip() for i in command.split(',')] + for cmd in cmds: + success = self.call(cmd, winman, *args, **kwargs) + else: + return self.call(command, winman, *args, **kwargs) + + return success + #: The instance of L{CommandRegistry} to be used in 99.9% of use cases. commands = CommandRegistry() @@ -341,12 +356,17 @@ def move_to_position(winman, # type: WindowManager winman.reposition(win, result, use_rect, gravity=gravity, geometry_mask=gravity_mask) +@commands.add('bordered-set', True) +@commands.add('bordered-unset', False) @commands.add('bordered') -def toggle_decorated(winman, win, state): # pylint: disable=unused-argument - # type: (WindowManager, wnck.Window, Any) -> None +def toggle_decorated(winman, win, state, decoration=None): # pylint: disable=unused-argument + # type: (WindowManager, wnck.Window, Any, Optional[bool]) -> None """Toggle window decoration state on the active window.""" win = gtk.gdk.window_foreign_new(win.get_xid()) - win.set_decorations(not win.get_decorations()) + if decoration is not None: + win.set_decorations(decoration) + else: + win.set_decorations(not win.get_decorations()) @commands.add('show-desktop', windowless=True) def toggle_desktop(winman, win, state): # pylint: disable=unused-argument diff --git a/quicktile/dbus_api.py b/quicktile/dbus_api.py index fa4580b..f4b0130 100644 --- a/quicktile/dbus_api.py +++ b/quicktile/dbus_api.py @@ -39,8 +39,8 @@ def doCommand(self, command): # type: (str) -> bool """Execute a QuickTile tiling command @todo 1.0.0: Expose a proper, introspectable D-Bus API""" - return self.commands.call(command, self.winman) - # FIXME: self.commands.call always returns None + return self.commands.call_multiple(command, self.winman) + # FIXME: self.commands.call_multiple always returns None def init(commands, # type: CommandRegistry winman # type: WindowManager diff --git a/quicktile/keybinder.py b/quicktile/keybinder.py index 6670ca6..3f08fb3 100644 --- a/quicktile/keybinder.py +++ b/quicktile/keybinder.py @@ -222,7 +222,7 @@ def init(modmask, # type: Optional[str] def call(func=func): """Closure to resolve `func` and call it on a `WindowManager` instance""" - commands.call(func, winman) + commands.call_multiple(func, winman) keybinder.bind(modmask + key, call) return keybinder