Skip to content
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

Add support for a second keybind per action #870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rcalixte
Copy link
Contributor

@rcalixte rcalixte commented Jan 11, 2024

Modifying code:

  • terminatorlib/config.py
  • terminatorlib/keybindings.py
  • terminatorlib/plugin.py
  • terminatorlib/preferences.glade
  • terminatorlib/prefseditor.py
  • terminatorlib/terminal_popup_menu.py
  • terminatorlib/window.py

Modifying tests:

  • tests/test_prefseditor_keybindings.py

Closes #371

NOTES

  • This can be expanded to three bindings per action if needed but I thought two would be sufficient.
  • Whitespace was cleaned up in the modified files in addition to addenda below.

ADDENDA

  • Added missing parameters to base definitions
  • Removed unnecessary parentheses from return and del statements
  • Changed comparisons from == True to is True (unsure if test conditions were meant to be truthy or not)
  • Formatted regular strings that could be f-strings
  • Various other code quality cleanups

cc @mattrose This will probably be easier to review with whitespace changes hidden. For the translation files, I just ran both scripts to pick up the new strings. I've tested this locally off of the master branch as well. For configs in the "old"/current format, there are config parsing warnings at startup (only visible if you launch from a terminal), but nothing visible otherwise to the user and nothing that impacts usability. Once any setting is modified, the new format for bindings will be written to the config and the warnings won't be seen again. So users who don't make any settings changes after upgrading won't see anything change in their experience. For the context menu, I opted to show the first binding found only, in the event more than one binding is configured for an action. A warning dialog is also shown if there is an attempt to set an existing binding to a new action or the same action twice. Feel free to let me know if any additional changes are needed in order to get this merged and released.

Question:
Should the workflows be updated for python 3.10 and 3.11? They are currently 3.8 and 3.9. I tested 3.10 and 3.11 on my local fork without issue so it should be safe to make that change. (Adding 3.12 would require working around the removal of packages like setuptools and I reason that isn't on the roadmap yet which is why I excluded it.)

(Side note: I'd only recently learned about Terminator and it's literally been the biggest boon for my productivity of late, immediately becoming my default on every machine. Thanks to you and the team for resurrecting and maintaining it!)

@rcalixte rcalixte force-pushed the multiple_keybinds branch 13 times, most recently from e392cfb to 961b5a0 Compare January 13, 2024 00:08
@mattrose
Copy link
Member

Wow, there's a lot here, I'll take a look as soon as I can.

@rcalixte rcalixte force-pushed the multiple_keybinds branch 9 times, most recently from bf09d79 to 4f5fba1 Compare February 11, 2024 21:01
@rcalixte rcalixte force-pushed the multiple_keybinds branch 3 times, most recently from 06228fa to f191937 Compare February 16, 2024 18:13
@mattrose
Copy link
Member

So, there's so much here that it's impossible for me to do a review. 70,000 changes is way too big for a code review. The idea is good, but it looks like you went through it with a code formatter or linter that made a bunch of irrelevant changes. That's fine as it is, but it makes it impossible for me to easily review the changes that are necessary to the feature, and the output of the linter. Also, the doc changes should probably be done in a separate PR as well, so that we can more easily tease those out.

If you could make another PR with just the changes that are necessary to implement the feature, I could definitely review that and merge it in, with some work, but as it is, I can't really review or merge this PR.

@rcalixte
Copy link
Contributor Author

If you could make another PR with just the changes that are necessary to implement the feature, I could definitely review that and merge it in, with some work, but as it is, I can't really review or merge this PR.

I mentioned that it would be easier to review with GitHub's whitespace option for that reason. The line change count is also largely due to the modified translation files due to the changed strings. I can pull those and the PR should be easier to review but I do think proper translation support should be implemented at some point in time.

@rcalixte
Copy link
Contributor Author

Question:
Should the workflows be updated for python 3.10 and 3.11? They are currently 3.8 and 3.9. I tested 3.10 and 3.11 on my local fork without issue so it should be safe to make that change. (Adding 3.12 would require working around the removal of packages like setuptools and I reason that isn't on the roadmap yet which is why I excluded it.)

Should I open the PRs for this too? We could add 3.10 and 3.11 while dropping 3.8. (I don't know of any distros that ship 3.8 and an updated terminator package.)

keyboard shortcuts.

"""

import re
from gi.repository import Gtk, Gdk
from gi.repository import Gdk
Copy link
Member

@mattrose mattrose Feb 18, 2024

Choose a reason for hiding this comment

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

Why remove GTK here? Is it necessary?

Copy link
Contributor Author

@rcalixte rcalixte Feb 18, 2024

Choose a reason for hiding this comment

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

It's an unused import here. There was one call that was commented out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we remove the comment too?

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather keep code cleanup changes separate from feature or bugfix changes. It means when I go back theough the history I can tell exactly what changes did what. This is the point I was trying to get across with my earlier comment. There's too much going on in this commit. The stuff may be good to include in another PR, but in a PR that is just supposed to implement a feature, the code should just reflect what is necessary to implement that feature. I definitely welcome bugfixes and code cleanup PRs, just not mixed in with feature implementation PRs

Copy link
Member

@mattrose mattrose left a comment

Choose a reason for hiding this comment

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

I'd rather keep code cleanup changes separate from feature or bugfix changes. It means when I go back theough the history I can tell exactly what changes did what. This is the point I was trying to get across with my earlier comment. There's too much going on in this commit. The stuff may be good to include in another PR, but in a PR that is just supposed to implement a feature, the code should just reflect what is necessary to implement that feature. I definitely welcome bugfixes and code cleanup PRs, just not mixed in with feature implementation PRs

@@ -91,7 +95,7 @@ def reload(self):
self._lookup[mask][keyval] = action
self._masks |= mask

def _parsebinding(self, binding):
Copy link
Member

Choose a reason for hiding this comment

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

Why change this method name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The underscore kept it as an internal method. This affected the tests from being able to access the method.

@@ -103,27 +107,25 @@ def _parsebinding(self, binding):
raise KeymapError('No key found')
keyval = Gdk.keyval_from_name(key)
if keyval == 0:
raise KeymapError("Key '%s' is unrecognised" % key)
raise KeymapError(f"Key '{key}' is unrecognised")
Copy link
Member

Choose a reason for hiding this comment

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

Why are you changing this string formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

F-strings have been preferred since Python 3.6 went GA.

@@ -103,27 +107,25 @@ def _parsebinding(self, binding):
raise KeymapError('No key found')
keyval = Gdk.keyval_from_name(key)
if keyval == 0:
raise KeymapError("Key '%s' is unrecognised" % key)
Copy link
Member

Choose a reason for hiding this comment

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

Why are you changing this string formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

F-strings have been preferred since Python 3.6 went GA.

return (keyval, mask)

def _lookup_modifier(self, modifier):
"""Map modifier names to gtk values"""
try:
return self.modifiers[modifier.lower()]
except KeyError:
raise KeymapError("Unhandled modifier '<%s>'" % modifier)
except KeyError as exc:
Copy link
Member

Choose a reason for hiding this comment

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

Why are you changing this string formatting?

keyboard shortcuts.

"""

import re
from gi.repository import Gtk, Gdk
from gi.repository import Gdk
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather keep code cleanup changes separate from feature or bugfix changes. It means when I go back theough the history I can tell exactly what changes did what. This is the point I was trying to get across with my earlier comment. There's too much going on in this commit. The stuff may be good to include in another PR, but in a PR that is just supposed to implement a feature, the code should just reflect what is necessary to implement that feature. I definitely welcome bugfixes and code cleanup PRs, just not mixed in with feature implementation PRs

Modifying code:
 - terminatorlib/config.py
 - terminatorlib/keybindings.py
 - terminatorlib/plugin.py
 - terminatorlib/preferences.glade
 - terminatorlib/prefseditor.py
 - terminatorlib/terminal_popup_menu.py
 - terminatorlib/window.py

Modifying test:
 - tests/test_prefseditor_keybindings.py

Closes gnome-terminator#371
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Keybinds for one Action
2 participants