-
Notifications
You must be signed in to change notification settings - Fork 87
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
c1aeaaf
f4064c3
8d0d0e9
76e97dc
cdf7ea0
f4894f2
7d4400a
f90de3d
4d47975
418185a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,9 +167,9 @@ def decorate(func): | |
| return func | ||
| return decorate | ||
|
|
||
| def call(self, command, winman, *args, **kwargs): | ||
| def check_command(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.""" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! That's done. |
||
| cmd = self.commands.get(command, None) | ||
|
|
||
| if cmd: | ||
|
|
@@ -183,6 +183,20 @@ def call(self, command, winman, *args, **kwargs): | |
| logging.error("Unrecognized command: %s", command) | ||
| return False | ||
|
|
||
| def call(self, command, winman, *args, **kwargs): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no expectation that a completely unadorned name like Please rename this to something like
|
||
| # type: (str, WindowManager, *Any, **Any) -> bool | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll probably need another day or two. If I'm seeing |
||
| """Resolve a textual positioning command and execute it.""" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this docstring to make it clear that the method accepts a comma-separated list of commands. |
||
| cmds = [] | ||
| success = True | ||
| if ',' in command: | ||
| cmds = [i.strip() for i in command.split(',')] | ||
| for cmd in cmds: | ||
| success = self.check_command(cmd, winman, *args, **kwargs) | ||
| else: | ||
| return self.check_command(command, winman, *args, **kwargs) | ||
|
|
||
| return success | ||
|
|
||
|
|
||
| #: The instance of L{CommandRegistry} to be used in 99.9% of use cases. | ||
| commands = CommandRegistry() | ||
|
|
@@ -341,12 +355,17 @@ def move_to_position(winman, # type: WindowManager | |
| winman.reposition(win, result, use_rect, gravity=gravity, | ||
| geometry_mask=gravity_mask) | ||
|
|
||
| @commands.add('WithBorder', True) | ||
| @commands.add('borderless', False) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of capitals rather than dashes to indicate word boundaries in Also, using Please change these to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name
check_commandimplies 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
callor rename it totry_call.