Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quicktile/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 23 additions & 3 deletions quicktile/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def decorate(func):
return decorate

def call(self, command, winman, *args, **kwargs):
"""Check if the command is valid and execute it."""
# type: (str, WindowManager, *Any, **Any) -> bool
"""Resolve a textual positioning command and execute it."""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssokolow@monolith quicktile [master] % ./run_tests.sh 
[...]
quicktile/commands.py:172: error: misplaced type annotation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! That's done.

cmd = self.commands.get(command, None)

if cmd:
Expand All @@ -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 list as the command."""
cmds = []
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()
Expand Down Expand Up @@ -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
def toggle_decorated(winman, win, state, decoration=None): # pylint: disable=unused-argument
# type: (WindowManager, wnck.Window, Any) -> 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
Expand Down
4 changes: 2 additions & 2 deletions quicktile/dbus_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion quicktile/keybinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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