Repository navigation
Conversation
… menu The terminal context menu shows the configured keybinding next to most of its entries (Copy, Paste, Split, Open Tab, Close...), because they are built through TerminalPopupMenu.menu_item(). The "Zoom terminal", "Maximize terminal" and "Restore all terminals" entries were still built with a plain Gtk.MenuItem, so users had no way to discover from the menu that Ctrl+Shift+Z and Ctrl+Shift+X do the same thing as these entries. Build those three entries through menu_item() as well, so they display the scaled_zoom and toggle_zoom shortcuts. Both bindings restore the layout when a terminal is zoomed, so "Restore all terminals" shows toggle_zoom, or scaled_zoom when toggle_zoom is unbound. Add tests covering menu_item() for the two zoom actions. Signed-off-by: Riccardo Ravaioli <rravaioli@nvidia.com>
TerminalPopupMenu.menu_item() built the accelerator shown next to a menu
entry by hand: it recognised only <Shift>, <Control>/<Primary> and <Alt>,
and took the key from the last character of the binding, falling back to
the entry's mnemonic letter. A binding such as "<Control>F5" was shown as
Ctrl+Z on "Zoom terminal" while the key handler honoured F5, and a
binding on <Super> was not shown at all.
Let Gtk.accelerator_parse() do the parsing: it handles the modifiers and
key names used in the keybindings section, and yields no key for a
binding it cannot parse, in which case the entry is shown without a
shortcut instead of with a wrong one.
While at it, read the keybindings table with get_item('keybindings')
instead of passing the action name as the profile argument, and treat
"", None and "None" alike as unbound.
Signed-off-by: Riccardo Ravaioli <rravaioli@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two problems with the shortcuts shown in the terminal context menu:
Gtk.MenuItem, unlike Copy, Paste, Split, Open Tab or Close, which go throughTerminalPopupMenu.menu_item()and show their keybinding. From the menu alone there is no way to find out thatCtrl+Shift+ZandCtrl+Shift+Xdo the same thing as these entries.menu_item()parses the binding by hand: it recognises only<Shift>,<Control>/<Primary>and<Alt>, takes the key from the last character of the binding and otherwise falls back to the entry's mnemonic letter. A custom binding like<Control>F5is therefore shown asCtrl+Zon "Zoom terminal" (the key handler honours F5 just fine), and a<Super>binding is not shown at all.What this PR does:
menu_item(), so they show thescaled_zoomandtoggle_zoombindings; "Restore all terminals" showstoggle_zoom, orscaled_zoomwhentoggle_zoomis unbound (both restore the layout)Gtk.accelerator_parse(), which handles the modifiers and key names used in the[keybindings]section; a binding GTK cannot parse yields an entry without shortcut rather than a wrong oneget_item('keybindings')instead of passing the action name as the profile argument, and treats"",Noneand"None"alike as unboundmenu_item()intests/test_terminal_popup_menu.pyThe tests run as part of the existing pytest suite (
xvfb-run -a pytest-3, same as CI).