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 shortcuts list #5251
base: master
Are you sure you want to change the base?
Add shortcuts list #5251
Conversation
I think the shortcut list should be generated from the Actions list on runtime. |
fe65998
to
8e90502
Compare
That makes sense for the menu shortcuts, which are associated to actions. There are cons as well. In particular, we can't handtune the titles of the shortcuts and have to take the labels defined in
Instead of defining the shortcuts in The shortcuts from the "texteditor shortcuts" section and "other shortcuts" section are not associated to actions though. |
This sounds like the best solution to me, if we can manage to get it to work.
I think shortcuts define by hand (e.g. in XournalView::onKeyPressEvent() or TextEditor::onKeyPressEvent()) should be refactored into Actions indeed -- or just straped to the existing actions with same shortcut (e.g. |
The Gtk example app bloatpad actually uses the |
8e90502
to
0004f28
Compare
0004f28
to
7e7a8cf
Compare
I got the From the docs
See Is there a reason why we don't use GResources for other UI elements (glade files, icons)? They are packed into the executable, which makes loading those UI elements more efficient, since it's already in memory. |
We are most likely not using "new" functions of gtk because it simply did not exist at the time the code was written. Xournalpp was originally a gtk2 and pre c++11 application. This is also why we don't have reconfigurable shortcuts. We needed the step @bhennion took to move to GTK. Even though those changes only replaced gtk2 idioms with gtk3 idioms. Anything that modernises our codebase is welcome. |
I don't think that different actions should be merged with the action being executed depending on whether some widget is active or not. |
Why?
An GioAction is a low level abstraction which splits the functionality from the actual implementation. Therefore, I would suggest, to actually handle all (general) actions we have with GioActions. This might even mean, that several Actions might trigger the same action handler. For example, we have an insert-text action, which is only valid for specific text insertions, but the strg+c action triggers the same when a text field is selected: strg-action -> insert-text -> handler. |
7e7a8cf
to
20601ae
Compare
Agreed, my proposal was naive. The point is that two GAction's can have the same accelerator as long as they are not in the same GActionMap. In this |
How is this implemented in Gtk 3? Looks like in Gtk 4, one can
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller),
gtk_shortcut_new (gtk_keyval_trigger_new (key, modifier),
gtk_named_action_new ("prefix.action-name")));
Compare In Gtk 3 it seems that
|
I tested this in python in Gtk4: app.zip Yes, the same shortcut can be used for different actions when they are added to different widgets. In case one of the widgets is a child of the other one, the action for the child is activated.
Accelerators added via In the case of plus it should be possible to activate different actions depending on which widget is focused. If text is entered, the dummy text widget should have focus, otherwise a different widget contained in the main window. |
Addresses #5218 (reply in thread)
The shortcuts list is displayed by activating menu
Help > Shortcuts
. There are three sections:I'm not sure the icons are needed, since they are part of Gtk. However I only see the image missing icon when I don't include the icons on Ubuntu 23.10.
To generate the
shortcuts.glade
file I took my earlier blueprint file, compiled it to a Gtk 4.ui
file and made the necessary changes so it works with Gtk3. Glade doesn't support ShortcutsWindow, so theshortcuts.glade
file cannot actually be edited there.<Control>
with<Meta>
for MacOS for menu Shortcuts. -> Achieved by replacing accelerators by actions