Commit Graph

23 Commits

Author SHA1 Message Date
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
9a03c8b4d8 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2020-03-25 23:14:27 -04:00
Benjamin Otte
58e8f2332d shortcutcontroller: Add gtk_shortcut_controller_add_shortcut()
... and gtk_shortcut_controller_remove_shortcut().
2020-03-25 22:36:03 -04:00
Benjamin Otte
376dc4d169 shortcutcontroller: Add private API for running class shortcuts
We don't want regular users to be able to run class shortcuts in their
controllers, so we have to special case that.
2020-03-25 22:36:03 -04:00
Matthias Clasen
6d452f1eb8 shortcut: Add GtkShortcutTrigger
Triggers are meant to describe how to trigger a shortcut.
So far only a keyval + modifiers trigger exists.
2020-03-25 22:36:03 -04:00
Benjamin Otte
0eb1228902 widget: Add gtk_widget_class_add_shortcut()
This allows adding shortcuts as a replacement for keybindings.
2020-03-25 22:36:03 -04:00
Benjamin Otte
a232107122 shortcutcontroller: Introduce
This is a very barebones controller that currently does nothing but
activate the binding signals. Yay.

And because we have bindings on every widget (Yes, a GtkGrid has a
keybinding - 2 in fact), we need that controller everywhere.
2020-03-25 22:36:03 -04:00
Matthias Clasen
31db615885 Revert "Merge branch 'disable-window-test' into 'master'"
This reverts commit 3ac4c76b18, reversing
changes made to 6ec96d2e98.
2020-03-19 18:03:16 -04:00
Benjamin Otte
29ced09dc4 shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2020-03-18 23:00:51 -04:00
Benjamin Otte
0c81698911 shortcuts: Mananage managed shortcuts with a custom model
Reduce the amount of special casing by using a list model
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.
2020-03-18 23:00:51 -04:00
Benjamin Otte
3b595f5720 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-18 23:00:51 -04:00
Benjamin Otte
d14807b93d 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-18 23:00:51 -04:00
Benjamin Otte
538a1a0461 shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2020-03-18 23:00:51 -04:00
Benjamin Otte
e6d0560a82 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
2020-03-18 23:00:51 -04:00
Emmanuele Bassi
09400b6bfe 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-18 23:00:50 -04:00
Benjamin Otte
ef40f22632 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-18 23:00:50 -04:00
Benjamin Otte
d4127fe0d4 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-18 23:00:50 -04:00
Benjamin Otte
fb99f834e6 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2020-03-18 23:00:50 -04:00
Benjamin Otte
5ade831cd1 shortcutcontroller: Add gtk_shortcut_controller_add_shortcut()
... and gtk_shortcut_controller_remove_shortcut().
2020-03-18 23:00:50 -04:00
Benjamin Otte
3b8a4340da shortcutcontroller: Add private API for running class shortcuts
We don't want regular users to be able to run class shortcuts in their
controllers, so we have to special case that.
2020-03-18 23:00:49 -04:00
Matthias Clasen
78f9940ddc shortcut: Add GtkShortcutTrigger
Triggers are meant to describe how to trigger a shortcut.
So far only a keyval + modifiers trigger exists.
2020-03-18 23:00:49 -04:00
Benjamin Otte
e19b49f5aa widget: Add gtk_widget_class_add_shortcut()
This allows adding shortcuts as a replacement for keybindings.
2020-03-18 23:00:49 -04:00
Benjamin Otte
5c6be5c0cd shortcutcontroller: Introduce
This is a very barebones controller that currently does nothing but
activate the binding signals. Yay.

And because we have bindings on every widget (Yes, a GtkGrid has a
keybinding - 2 in fact), we need that controller everywhere.
2020-03-18 23:00:49 -04:00