Skip to content

command chaining functionality in config #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Housekeeping
  • Loading branch information
harindu95 committed Sep 16, 2017
commit f4064c3e4af8cd0ecbfccd62f99c6ecb9387b31f
32 changes: 12 additions & 20 deletions quicktile/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def decorate(func):
return func
return decorate

def checkCommand(self, command,winman,*args,**kwargs):
def check_command(self, command, winman, *args, **kwargs):
""" check if the command is valid and execute it"""
Copy link
Owner

Choose a reason for hiding this comment

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

The name check_command implies that it won't execute the command if it does exist. (A view supported by the docstring saying "check ... and execute it".)

Please either leave this as call or rename it to try_call.

# type: (str, WindowManager, *Any, **Any) -> bool
cmd = self.commands.get(command, None)

Expand All @@ -190,11 +191,11 @@ def call(self, command, winman, *args, **kwargs):
if ',' in command:
cmds = [i.strip() for i in command.split(',')]
for cmd in cmds:
success = self.checkCommand(cmd, winman, *args, **kwargs)
success = self.check_command(cmd, winman, *args, **kwargs)
else:
return self.checkCommand(command,winman,*args,**kwargs)
return self.check_command(command, winman, *args, **kwargs)

return success
return success


#: The instance of L{CommandRegistry} to be used in 99.9% of use cases.
Expand Down Expand Up @@ -354,26 +355,17 @@ 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('WithBorder', True)
@commands.add('borderless', False)
Copy link
Owner

Choose a reason for hiding this comment

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

The use of capitals rather than dashes to indicate word boundaries in WithBorder is inconsistent with the naming convention for the rest of the commands.

Also, using borderless implies that bordered isn't a toggle.

Please change these to bordered-set and bordered-unset so there's no ambiguity and their naming is consistent if I decide to generalize the naming pattern to all of the toggles. (eg. maximize-set and maximize-unset)

Copy link
Author

Choose a reason for hiding this comment

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

Yeah. I wasn't sure about how to name it considering some options were capitalized while some were not.

Copy link
Owner

Choose a reason for hiding this comment

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

There shouldn't be any. I certainly don't see any capitals in the output of quicktile --show-actions on my end.

Copy link
Author

Choose a reason for hiding this comment

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

mmm not the actions. But some of the [general ] config are capitalized while some are not. Since I was considering adding "boderless" as a general state, I guess it kind of bled through on my end.

@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