Skip to content

Commit

Permalink
command chaining functionality in config
Browse files Browse the repository at this point in the history
  • Loading branch information
harindu95 committed Sep 16, 2017
1 parent dac1e1a commit c1aeaaf
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions quicktile/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ def decorate(func):
return func
return decorate

def call(self, command, winman, *args, **kwargs):
def checkCommand(self, command,winman,*args,**kwargs):
# type: (str, WindowManager, *Any, **Any) -> bool
"""Resolve a textual positioning command and execute it."""
cmd = self.commands.get(command, None)

if cmd:
Expand All @@ -183,6 +182,20 @@ def call(self, command, winman, *args, **kwargs):
logging.error("Unrecognized command: %s", command)
return False

def call(self, command, winman, *args, **kwargs):
# type: (str, WindowManager, *Any, **Any) -> bool
"""Resolve a textual positioning command and execute it."""
cmds = []
success = True
if ',' in command:
cmds = [i.strip() for i in command.split(',')]
for cmd in cmds:
success = self.checkCommand(cmd, winman, *args, **kwargs)
else:
return self.checkCommand(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,6 +354,20 @@ def move_to_position(winman, # type: WindowManager
winman.reposition(win, result, use_rect, gravity=gravity,
geometry_mask=gravity_mask)

@commands.add('WithBorder')
def add_decoration(winman, win, state): # pylint: disable=unused-argument
# type: (WindowManager, wnck.Window, Any) -> None
"""Add window decoration on the active window."""
win = gtk.gdk.window_foreign_new(win.get_xid())
win.set_decorations(True)

@commands.add('borderless')
def remove_decoration(winman, win, state): # pylint: disable=unused-argument
# type: (WindowManager, wnck.Window, Any) -> None
"""Remove window decoration on the active window."""
win = gtk.gdk.window_foreign_new(win.get_xid())
win.set_decorations(False)

@commands.add('bordered')
def toggle_decorated(winman, win, state): # pylint: disable=unused-argument
# type: (WindowManager, wnck.Window, Any) -> None
Expand Down

0 comments on commit c1aeaaf

Please sign in to comment.