Commit Graph

62024 Commits

Author SHA1 Message Date
Benjamin Otte
43c0ea676d filechooser: Trigger the location popup via bindings
Simplifies code quite a bit.
2020-03-25 23:14:44 -04:00
Benjamin Otte
bb4fbe3d8f accels: Remove GtkAccelGroup 2020-03-25 23:14:44 -04:00
Benjamin Otte
7c4d8d49b6 testmenubutton: Don't create a GtkAccelGroup
It's unused.
2020-03-25 23:14:28 -04:00
Benjamin Otte
cac39526a9 testsuite: Remove GtkAccelGroup usage 2020-03-25 23:14:28 -04:00
Benjamin Otte
4c45410d43 widget: Remove gtk_widget_add_accelerator()
People should use shortcut controllers instead (global, capture).

A side effect of this is that GtkAccelLabel now lost its method to
magically look up accelerators to display. Somebody needs to add that
back later.
2020-03-25 23:14:28 -04:00
Benjamin Otte
8e9218df03 doc tools: Create AccelLabel image without using GtkAccelGroup 2020-03-25 23:14:28 -04:00
Emmanuele Bassi
541c478eeb testgtk: Port keyval example to shortcut controllers 2020-03-25 23:14:28 -04:00
Benjamin Otte
78e3e42042 shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2020-03-25 23:14:28 -04:00
Benjamin Otte
33045c3e0b shortcutaction: Integrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2020-03-25 23:14:28 -04:00
Benjamin Otte
7974751e24 shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2020-03-25 23:14:28 -04:00
Benjamin Otte
daa7d9072d 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.
2020-03-25 23:14:28 -04:00
Benjamin Otte
90a34312d4 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2020-03-25 23:14:28 -04:00
Benjamin Otte
580863b112 accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2020-03-25 23:14:28 -04:00
Benjamin Otte
fb6a8f5fc1 shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2020-03-25 23:14:28 -04:00
Matthias Clasen
c2e2e2993b shortcutmanager: Use list models 2020-03-25 23:14:28 -04:00
Matthias Clasen
5763514ab8 shortcutcontroller: Use a list model for shortcuts 2020-03-25 23:14:28 -04:00
Benjamin Otte
4c5d8547be shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2020-03-25 23:14:27 -04:00
Matthias Clasen
34987c0b5c widget: Only create a controller if we have shortcuts
No point in creating objects that just hold empty lists.
2020-03-25 23:14:27 -04:00
Benjamin Otte
3cd4eb0310 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.
2020-03-25 23:14:27 -04:00
Benjamin Otte
a1e9ae5259 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.
2020-03-25 23:14:27 -04:00
Benjamin Otte
e738a4d129 shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2020-03-25 23:14:27 -04:00
Benjamin Otte
1ec950d14a gtk-demo: Port the sliding puzzle demo to shortcuts 2020-03-25 23:14:27 -04:00
Benjamin Otte
92e20deca1 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.
2020-03-25 23:14:27 -04:00
Benjamin Otte
cd0332aad5 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
2020-03-25 23:14:27 -04:00
Benjamin Otte
cdd33bbee6 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
bca1f6b64f gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-25 23:14:27 -04:00
Benjamin Otte
9b99b89807 gtk: Remove accel paths
It's an outdated technology now that everybody is using GActionGroups.

If somebody wanted to support changeable shortcuts, they'd need to
reintroduce it in another way.
2020-03-25 23:14:27 -04:00
Benjamin Otte
62f96bfda6 Remove GtkMnemonicHash
It's not used anymore.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
2c62cde780 window: Remove all old mnemonic handling API 2020-03-25 23:14:27 -04:00
Emmanuele Bassi
aab10ea43b Add GtkShortcutManager
This adds an interface for taking care of shortcut controllers with
managed scope.

Only GtkWindow currently implements this interface, so we need to ensure
that we check if any top-level widget we reach is a shortcuts manager
before we call into it.
2020-03-25 23:14:27 -04:00
Benjamin Otte
9428807c57 label: Implement mnemonics using shortcuts 2020-03-25 23:14:27 -04:00
Benjamin Otte
21e6e4c026 shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
2020-03-25 23:14:27 -04:00
Benjamin Otte
bde4cbe377 shortcuttrigger: Add support for mnemonics
Mnemonics need to be triggered with help from the controllers (who
determine the modifiers). Support for that has been added, too.

Mnemonics do not use this yet though.
2020-03-25 23:14:27 -04:00
Benjamin Otte
0b7e74318b window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2020-03-25 23:14:27 -04:00
Benjamin Otte
e398f63bf6 window: Get rid of public APIs that shouldn't be
Event controllers should have replaced all of them.
And if they haven't, apps need to fix their code (I'm
looking at you Gimp).
2020-03-25 23:14:27 -04:00
Benjamin Otte
2244eeb727 gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
2020-03-25 23:14:27 -04:00
Benjamin Otte
c3af47f5d9 gtk-demo: Add a dumb demo for shortcut triggers 2020-03-25 23:14:27 -04:00
Benjamin Otte
730154df7d shortcutcontroller: Add GtkShortcutScope
Allow setting the scope for a controller. The scope determines at what
point in event propagation the shortcuts will be activated.

Local scope is the usual activation, global scope means that the root
widget activates the shortcuts - ie they are activated at the very
start of event propagation (for global capture events) or the very end
(for global bubble events).
Managed scope so far is unimplemented.

This is supposed to be used to replace accelerators and mnemonics.
2020-03-25 23:14:27 -04:00
Benjamin Otte
2309e1dd38 shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
2020-03-25 23:14:27 -04:00
Benjamin Otte
90c7f4608a accelgroup: Add gtk_accel_group_print_label() 2020-03-25 23:14:27 -04:00
Benjamin Otte
66102dacf1 accellabel: Move gtk_accelerator_get_label() code
The function lives in gtkaccelgroup.c, so there's no need to have that
call a private function in another source file. Instead, make that
other source file call gtk_accelerator_get_label() instead.
2020-03-25 23:14:27 -04:00
Benjamin Otte
d84b60e5f9 accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
2020-03-25 23:14:27 -04:00
Benjamin Otte
9a03c8b4d8 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
f02521c502 Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
2020-03-25 22:36:03 -04:00
Matthias Clasen
c1247a7993 popover: Add keynav keybindings
The shortcut controllers are limited to same-native,
so we need to duplicate the Tab and arrow key bindings
for focus handling, as well as the Enter bindings for
activation.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi
b2a747b4d4 popovermenu: Port to shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
c1ee2fd54a accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
2020-03-25 22:36:03 -04:00
Benjamin Otte
4c7b00fd20 treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
2020-03-25 22:36:03 -04:00
Benjamin Otte
3fba7f9dce combobox: Redo key event forwarding hack
Instead of manualling invoking bindings, we now reorder event
controllers inside the treemenu, so that shortcuts run before the event
forwarding.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi
7ca4a94768 widget: Add private accessor to event controllers 2020-03-25 22:36:03 -04:00