Skip to content

Removes duplicated entries from Layers Menu#1404

Closed
pedropaulosuzuki wants to merge 3 commits into
PintaProject:masterfrom
pedropaulosuzuki:patch-2
Closed

Removes duplicated entries from Layers Menu#1404
pedropaulosuzuki wants to merge 3 commits into
PintaProject:masterfrom
pedropaulosuzuki:patch-2

Conversation

@pedropaulosuzuki

Copy link
Copy Markdown
Contributor

Removes "Add New Layer", "Delete Layer", "Duplicate Layer" and "Merge Layer Down" from Layers Menu, as it is already present on the Layers Panel. Also adds the shortcuts to the respective buttons in the Layers Panel (on hover), making them more discoverable.

Partially fixes #1386

Removes "Add New Layer", "Delete Layer", "Duplicate Layer" and "Merge Layer Down" from Layers Menu, as it is already present on the Layers Panel. Also adds the shortcuts to the respective buttons in the Layers Panel (on hover), making them more discoverable.

Partially fixes #1386
@pedropaulosuzuki

Copy link
Copy Markdown
Contributor Author

Only problem is the keyboard shortcuts don't get translated on the hover effect as they were to the menu. I didn't want to hardcode because Primary might not be Ctrl (I believe in MacOS it is the Super key?). @cameronwhite, any ideas?

Keyboard shortcut appears as "<Primary><Shift>N" instead of Ctrl + Shift + N

@pedropaulosuzuki

Copy link
Copy Markdown
Contributor Author

I'd also suggest using <Primary><Shift>Up and <Primary><Shift>Down for moving layers up and down, if the shortcut is not taken already somewhere. Keeps it consistent with <Primary><Shift>N, <Primary><Shift>Delete and <Primary><Shift>D.

Also, as every other shortcut related to the layers is <Primary><Shift>Something, maybe changing <Primary>M to <Primary><Shift>M might not be a bad idea. It's one more key press, but the consistency might pay off.

Maybe even <Primary><Shift>R for Rotate/Pan/Zoom Layer (or maybe <Primary><Shift>T, T being for Transform)?

Restores shortcuts and removes the correct menu entries
@cameronwhite

Copy link
Copy Markdown
Member

I'd avoid adding the shortcut text in the command's label - this would start appearing for translators (which gets annoying especially if the shortcut ever changes), and also duplicates it.

I think we could handle this more generically when toolbar buttons are created from a Gtk.Action, by appending the shortcut to the button's label when constructing the tooltip

TooltipText = action.Tooltip ?? action.Label,

To get the shortcut, though, I think you'd need to call Gtk.Application.GetAccelsForAction() . If it returns something like <Primary><Shift><T> you'd need to run it through AcceleratorGetLabel() similar to this:

return Gtk.Functions.AcceleratorGetLabel (key, mods);

@pedropaulosuzuki

Copy link
Copy Markdown
Contributor Author

I think we could handle this more generically when toolbar buttons are created from a Gtk.Action, by appending the shortcut to the button's label when constructing the tooltip

TooltipText = action.Tooltip ?? action.Label,

The problem is RegisterActions runs after LayerActions, so the shortcuts are not set yet when the labels are being created.

To get the shortcut, though, I think you'd need to call Gtk.Application.GetAccelsForAction() . If it returns something like <Primary><Shift><T> you'd need to run it through AcceleratorGetLabel() similar to this:

return Gtk.Functions.AcceleratorGetLabel (key, mods);

We would also need CreateToolBarItem to get access to the Gtk.Application instance in order to call GetAccelsForAction().

Maybe we could refactor Command to take an optional shortcut for an action and then assign it at creation time? Makes more sense to me and would be better integrated overall, also avoiding verbosity.

@pedropaulosuzuki

pedropaulosuzuki commented May 3, 2025

Copy link
Copy Markdown
Contributor Author

I'll just close this MR and open a new one just removing the menu entries. We can work on the refactor showing keyboard shortcuts on a future MR. Opening an issue (#1408) for now.

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.

[UI] Remove "Layers" from hamburger menu

2 participants