Commit Graph

58734 Commits

Author SHA1 Message Date
Matthias Clasen
1cbb2099a2 text: Stop using keybinding signals internally
We can just call the class handlers.
2019-06-24 22:40:29 +00:00
Matthias Clasen
7ed27ef574 text: Convert bindings to actions 2019-06-24 22:40:29 +00:00
Matthias Clasen
9039d0b0c1 text: Add more actions
These will let us port more bindings to actions.
2019-06-24 22:40:29 +00:00
Matthias Clasen
00e68fcae2 widget: Unset propagation limits for shortcut managers
These controllers are meant to be global and
thus should be able to react to events that are
getting routed to open popovers. This makes
shortcuts in open popover menus work.
2019-06-24 22:40:29 +00:00
Matthias Clasen
9038b7a8c5 widget_factory: Stop using GtkApplication for accels
We want to replace the accels APIs in GtkApplication
with shortcut controllers.
2019-06-24 22:40:29 +00:00
Matthias Clasen
0a7f5f1be1 text: Convert bindings from signals to actions
With this change, the context menu picks up the
accels for the actions. The conversion is not
complete, since we don't have actions for all
bindings yet.
2019-06-24 22:40:29 +00:00
Matthias Clasen
70597de0a5 widget: Pass shortcuts to the action muxer
Send the shortcuts used by shortcut managers
and the per-class shortcuts to the action muxer
for associating accels with actions. The
action muxer has existing machinery for propagating
accels to the UI.
2019-06-24 22:40:29 +00:00
Matthias Clasen
75b19169cf action muxer: Support injecting shortcuts
Give the action muxer an api to add list models
of shortcuts to draw accels from.
2019-06-24 22:40:29 +00:00
Matthias Clasen
390ba974df model button: Drop accel lookup hack
We were just cutting through to the application
at map time in a last-ditch effort to find
an accel to display. Drop that and just rely on
the menu tracker to give us the right thing.
2019-06-24 22:40:29 +00:00
Matthias Clasen
d9167fc8d6 model button: Stop parsing accels
The new shortcuts machinery gives us formatted
strings, so just use them as-is without parsing
and reformatting.
2019-06-24 22:40:29 +00:00
Matthias Clasen
d000bed15f popover menu: Make mnemonics visible
For menus, mnemonics trigger without pressing Alt,
and the expectation is that we show them whenever
keynav is happening. Reinstate this behavior for
popover menus.
2019-06-24 22:40:29 +00:00
Matthias Clasen
b1ac7b667c popover menu: Implement shortcut manager
And make mnemonics trigger without Alt,
like we already do for GtkMenu.
2019-06-24 22:40:29 +00:00
Matthias Clasen
b89dee2f56 shortcut controller: Factor out a helper
No need to have the same code in multiple places.
2019-06-24 22:40:29 +00:00
Matthias Clasen
0f75f33857 Implement group cycling
When more than one shortcut can trigger,
activate them non-exclusively, round-robin.
2019-06-24 22:40:29 +00:00
Matthias Clasen
f41931f527 label: Remove mnemonics when unmapped
We never want mnemonics to trigger when the user
can't see them, so remove them from the shortcuts
manager.
2019-06-24 22:40:29 +00:00
Matthias Clasen
fa8ffa6d6c Set names on shortcut controllers 2019-06-24 22:40:29 +00:00
Matthias Clasen
b2be6db1ed inspector: Show owners for shortcuts
This is somewhat preliminary, but it helps
debugging shortcuts. It suffers from not having
the right list model apis to do this.

Eventually, this should become a link to the
object details.
2019-06-24 22:40:29 +00:00
Matthias Clasen
949afa598a inspector: Add a quick shortcuts page
This shows the shortcuts for a GtkShortcutController
object.
2019-06-24 22:40:29 +00:00
Matthias Clasen
56bc921586 inspector: Show shortcut actions and triggers
Show these in the property details for
GtkShortcut objects.
2019-06-24 22:40:29 +00:00
Matthias Clasen
d0509d5afc shortcut controller: Make model readable
We want to show the shortcuts in the inspector,
so we need to be able to get at the model.
2019-06-24 22:40:29 +00:00
Matthias Clasen
a9c0548179 window: Use gtk_widget_class_bind_action
Use gtk_widget_class_bind_action for default.activate.
2019-06-24 22:40:29 +00:00
Matthias Clasen
79c5398690 Add gtk_widget_class_bind_action
Similar to gtk_widget_class_add_binding_signal,
but triggers an action.
2019-06-24 22:40:29 +00:00
Georges Basile Stavracas Neto
26d310fb07 shortcutcontroller: Unref shortcut proper
g_list_model_get_item() is transfer full, so we need to
unref everything that is acquired through it.
2019-06-24 22:40:29 +00:00
Georges Basile Stavracas Neto
1787bf5471 shortcuttrigger: Filter a few modifiers out
Copying the code from GtkKeyHash, filter out X11 modifiers and
Caps Lock from events. Unfortunately, legacy X11 modifiers can
be present even when running full Wayland, due to XKB.
2019-06-24 22:40:29 +00:00
Benjamin Otte
2ace9aef5f filechooser: Trigger the location popup via bindings
Simplifies code quite a bit.
2019-06-24 22:40:29 +00:00
Benjamin Otte
b46e7f1108 filechooser: Remove outdated hack
In GTK2, the filechooser was using a Paned, so switching between sidebar
and files list with the arrow keys didn't work (the slider would be
selected instead). So in
https://bugzilla.gnome.org/show_bug.cgi?id=161489 a crude hack was added
to make this possible.

Over the years the filechooser code has changed so that it now would do
this by default, yet the hack had been retained.
2019-06-24 22:40:29 +00:00
Benjamin Otte
cedb413600 accels: Remove GtkAccelGroup 2019-06-24 22:40:29 +00:00
Benjamin Otte
f0b41b181d testmenubutton: Don't create a GtkAccelGroup
It's unused.
2019-06-24 22:40:29 +00:00
Benjamin Otte
9c46eb4398 testsuite: Remove GtkAccelGroup usage 2019-06-24 22:40:29 +00:00
Benjamin Otte
2aa9c0ddc1 doc tools: Create AccelLabel image without using GtkAccelGroup 2019-06-24 22:40:29 +00:00
Benjamin Otte
ba9fc7aead widget: Remove gtk_widget_add_accelerator()
People should use shortcut controllers instead (global, capture).

A side effect of this is that GtkMenuItem (or rather: GtkAccelLabel) now
lost its method to magically look up accelerators to display. Somebody
needs to add that back later.
2019-06-24 22:40:29 +00:00
Benjamin Otte
0a77a4a264 testgtk: Port keyval example to shortcut controllers 2019-06-24 22:40:29 +00:00
Benjamin Otte
0b21d6a01c gtk-demo: Redo builder example to use shortcuts
Now that shortcuts and controllers are supported by GtkBuilder, demo
how all of that works.
2019-06-24 22:40:29 +00:00
Benjamin Otte
21e4f5353b shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2019-06-24 22:40:29 +00:00
Benjamin Otte
16583da221 shortcutaction: Integrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2019-06-24 22:40:29 +00:00
Benjamin Otte
ee88c6863e shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2019-06-24 22:40:29 +00:00
Benjamin Otte
112a8d1037 application: Replace accelerator handling with shortcuts
API remains the same, but activation is now done via a
shortcutcontroller.

The code uses a controller with global scope so that the shortcuts are
managed with all the other global shortcuts.
2019-06-24 22:40:29 +00:00
Benjamin Otte
28a1e44833 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2019-06-24 22:40:29 +00:00
Benjamin Otte
d273fb63ec accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2019-06-24 22:40:29 +00:00
Benjamin Otte
4ac2f95688 shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2019-06-24 22:40:28 +00:00
Benjamin Otte
d38791473a shortcuts: Mananage managed shortcuts with a custom model
Reduce the amount of special casing by using a ListModel for global and
managed shortcuts, too.

This way, the ListModel API will work for the ShortcutController in the
GtkShortcutManager and GtkRoot.

The only special case remaining is shortcut activation, which needs to
pass the right widget to the controller in the global/managed case.
2019-06-24 22:40:28 +00:00
Benjamin Otte
c5b2bb06be gdk: Make gdk_keyval_name() return a const char
The string is const, so return it like that.
2019-06-24 22:40:28 +00:00
Benjamin Otte
6a75fdf732 shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2019-06-24 22:40:28 +00:00
Benjamin Otte
dd1b65d522 widget: Keep keybindings as a GListStore
This way, we can use shortcut_controller_new_for_model() and avoid all
the special casing about run_class.
2019-06-24 22:40:28 +00:00
Benjamin Otte
40264629f7 shortcutcontroller: Add gtk_shortcut_controller_new_for_model()
This is mainly for internal use, but I can't see a reason to not have it
public for people who want to maintain their own lists.

I'm sure gnome-builder will never ever find a way to misuse it.
2019-06-24 22:40:28 +00:00
Benjamin Otte
740fe4f7ce shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2019-06-24 22:40:28 +00:00
Benjamin Otte
7fffbccbde gtk-demo: Port the sliding puzzle demo to shortcuts 2019-06-24 22:40:28 +00:00
Benjamin Otte
10ff0bc959 shortcut: Change the API for creating shortcuts
When creating shortcuts, there almost always are a trigger and an action
available for use. So make gtk_shortcut_new() take those as arguments.

Also add gtk_shortcut_new_with_arguments() so people can easily pass
those in, too.
2019-06-24 22:40:28 +00:00
Benjamin Otte
c336ebdaae shortcut: Add GtkShortcutAction
Similar to GtkShortcutTrigger, GtkShortCutAction provides all the
different ways to activate a shortcut.

So far, these different ways are supported:
- do nothing
- Call a user-provided callback
- Call gtk_widget_activate()
- Call gtk_widget_mnemonic_activate()
- Emit an action signal
- Activate an action from the widget's action muxer
- Activate a GAction
2019-06-24 22:40:28 +00:00
Benjamin Otte
4d6d5d3fe5 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2019-06-24 22:40:28 +00:00