Matthias Clasen [Thu, 26 Mar 2020 03:40:22 +0000 (03:40 +0000)]
Merge branch 'wip/matthiasc/shortcut-4' into 'master'
Shortcuts
See merge request GNOME/gtk!1569
Matthias Clasen [Thu, 26 Mar 2020 02:30:15 +0000 (22:30 -0400)]
Some documentation fixes
Matthias Clasen [Wed, 25 Mar 2020 21:13:37 +0000 (17:13 -0400)]
shortcutmanager: Add some more docs
Matthias Clasen [Tue, 24 Mar 2020 21:01:18 +0000 (17:01 -0400)]
shortcuttrigger: Some documentation fixups
Matthias Clasen [Tue, 24 Mar 2020 20:57:27 +0000 (16:57 -0400)]
shortcutaction: Some documentation fixups
Matthias Clasen [Tue, 24 Mar 2020 20:29:47 +0000 (16:29 -0400)]
shortcutcontroller: Expand the docs
Matthias Clasen [Tue, 24 Mar 2020 20:11:07 +0000 (16:11 -0400)]
docs: Update the overview input chapter
Update the wording around events to reflect current
usage, and add information about shortcuts and the
shortcut controller.
Matthias Clasen [Tue, 24 Mar 2020 16:45:12 +0000 (12:45 -0400)]
popovermenu: Show mnemonics on keynav
This is the expected behavior for menus.
Matthias Clasen [Tue, 24 Mar 2020 16:45:43 +0000 (12:45 -0400)]
popover: Implement auto mnemonics
Unfortunately, this involves copying a bunch of
code from gtkwindow.c. The only difference here
is that we add a private method to turn this off,
which will be used by GtkPopoverMenu to implement
its own auto mnemonics.
Matthias Clasen [Tue, 24 Mar 2020 16:44:08 +0000 (12:44 -0400)]
label: Respect GtkPopover::mnemonics-visible
When inside a popover, look to the popover for
whether to show mnemonics or not.
Matthias Clasen [Tue, 24 Mar 2020 16:29:26 +0000 (12:29 -0400)]
popover: Add a mnemonics-visible property
This will be handled separately for popovers, so we
need our own property for it.
Matthias Clasen [Tue, 24 Mar 2020 15:54:17 +0000 (11:54 -0400)]
label: Disconnect visible mnemonics in popovers
The controller handling mnemonics is limited to same-native,
so showing mnemonics in other natives.
Matthias Clasen [Tue, 24 Mar 2020 05:07:09 +0000 (01:07 -0400)]
modelbutton: Install accels when inside a popover
When a model button in a popover displays a shortcut,
it is probably from the global shortcut controllers,
and will not work inside the popover, since that is
a different native. Install a shortcut using the same
trigger that just activates the model button. This
shortcut will end up in the managed shortcut controller
of the popover.
Matthias Clasen [Tue, 24 Mar 2020 04:00:43 +0000 (00:00 -0400)]
popovermenu: Make mnemonics work without Alt
This is expected menu behavior.
Matthias Clasen [Tue, 24 Mar 2020 03:04:53 +0000 (23:04 -0400)]
shortcutcontroller: Inject accels into the action muxer
This is the way model button pic up accels for their actions.
Matthias Clasen [Tue, 24 Mar 2020 03:04:06 +0000 (23:04 -0400)]
popover: Implement GtkShortcutManager
This makes mnemonics work in popovers.
Matthias Clasen [Tue, 24 Mar 2020 03:03:29 +0000 (23:03 -0400)]
modelbutton: Make activatable
This is expected of button-like widgets, and is necessary
to make keynav in popover menus work as expected.
Matthias Clasen [Mon, 23 Mar 2020 18:46:20 +0000 (14:46 -0400)]
modelbutton: Remove accel poking
Stop manually poking GtkApplication for accels.
GtkApplication already feeds them into the action
muxer machinery, so that is where will get them.
Emmanuele Bassi [Fri, 20 Mar 2020 15:19:45 +0000 (15:19 +0000)]
Turn GtkShortcutAction into a GObject
Just like we did for GtkShortcutTrigger.
This allows language bindings to properly deal with all the actions.
Emmanuele Bassi [Thu, 19 Mar 2020 15:57:02 +0000 (15:57 +0000)]
Turn GtkShortcutTrigger into an object
The lightweight inheritance mechanism used for GtkShortcutTrigger is not
going to be usable by bindings, because boxed types cannot have derived
types.
We could use GTypeInstance and derive everything from that, like
GParamSpec, but in the end shortcuts are not really a performance
critical paths, unlike CSS values or render nodes.
Emmanuele Bassi [Thu, 19 Mar 2020 15:53:35 +0000 (15:53 +0000)]
Add definition macro for internal types
GTK defines various types that are meant to be derivable only within GTK
itself, and "final" from the perspective of consumers of the GTK API.
The existing macros defined by GObject, such as G_DECLARE_FINAL_TYPE and
G_DECLARE_DERIVABLE_TYPE, lack this functionality.
While we wait for GObject to get this kind of macro, we should define
our own.
Matthias Clasen [Mon, 23 Mar 2020 12:37:01 +0000 (08:37 -0400)]
widget: Remove some leftover accel group plumbing
The ::can-activate-accel and ::accel-closures-changed signals
are not used anymore, remove them.
Matthias Clasen [Mon, 23 Mar 2020 00:58:35 +0000 (20:58 -0400)]
shortcutcontroller: Only activate shortcuts of visible widgets
Our shortcuts are like mnemonics in this respect - they only
activate when the widget is viewable.
Matthias Clasen [Sun, 22 Mar 2020 20:15:36 +0000 (16:15 -0400)]
Drop GtkKeyHash
Matthias Clasen [Sun, 22 Mar 2020 20:14:55 +0000 (16:14 -0400)]
window: Remove GtkKeyHash remnants
It is not used anymore.
Matthias Clasen [Sun, 22 Mar 2020 20:08:11 +0000 (16:08 -0400)]
Drop the keyhash test
GtkKeyHash is going away.
Matthias Clasen [Sun, 22 Mar 2020 16:55:49 +0000 (12:55 -0400)]
shortcutcontroller: Implement mnemonic cycling
Make GtkShortcutController collect matching shortcuts
in the same way GtkKeyHash did (accept fuzzy matches
if we don't have any exact matches), and cycle among
the matches if we have multiple.
Matthias Clasen [Sun, 22 Mar 2020 13:54:15 +0000 (09:54 -0400)]
shortcuttrigger: Do elaborate matching for key events
Copy the logic from GtkKeyHash for matching key events
to shortcuts.
Adapt shortcuts test to work with the better matching,
by creating more complete key events.
Matthias Clasen [Sun, 22 Mar 2020 13:16:57 +0000 (09:16 -0400)]
shortcuttrigger: Introduce partial matches
Allow GtkShortcutTrigger to return partial matches.
Currently, no triggers produce such results, and
GtkShortcutController treats partial matches like
exact ones.
Matthias Clasen [Fri, 20 Mar 2020 03:58:59 +0000 (23:58 -0400)]
Add tests for shortcut actions
Matthias Clasen [Fri, 20 Mar 2020 02:41:59 +0000 (22:41 -0400)]
Add a test for shortcut triggers
Matthias Clasen [Thu, 19 Mar 2020 04:56:46 +0000 (00:56 -0400)]
widget: Drop the ::popup-menu signal
This is now done in widgets which have context
menus.
Matthias Clasen [Thu, 19 Mar 2020 04:52:05 +0000 (00:52 -0400)]
placesview: Stop using ::popup-menu
This signal is going away.
Matthias Clasen [Thu, 19 Mar 2020 04:07:45 +0000 (00:07 -0400)]
filechooser: Stop using ::popup-menu
This signal is going away.
Matthias Clasen [Thu, 19 Mar 2020 02:56:53 +0000 (22:56 -0400)]
mountoperation: Stop using ::popup-menu
We can just use a shortcut controller directly.
Matthias Clasen [Thu, 19 Mar 2020 02:40:13 +0000 (22:40 -0400)]
gtk-demo: Stop emitting ::popup-menu
The signal was not used anyway, in the font explorer demo.
Matthias Clasen [Thu, 19 Mar 2020 02:36:31 +0000 (22:36 -0400)]
colorchooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
Matthias Clasen [Thu, 19 Mar 2020 01:57:51 +0000 (21:57 -0400)]
range: Remove ::popup-menu emission
This signal is going away, and having context menus
on sliders is not really a thing anyway.
Matthias Clasen [Thu, 19 Mar 2020 01:55:08 +0000 (21:55 -0400)]
scrollbar: Remove :popup-menu forwarding
This signal is going away.
Matthias Clasen [Wed, 18 Mar 2020 20:52:52 +0000 (16:52 -0400)]
emojichooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
Matthias Clasen [Mon, 16 Mar 2020 02:25:09 +0000 (22:25 -0400)]
Use an action for the context menu keybinding
The ::popup-menu signal is going away.
Matthias Clasen [Mon, 16 Mar 2020 02:10:39 +0000 (22:10 -0400)]
Print mnemonic triggers clearly
Matthias Clasen [Mon, 16 Mar 2020 00:48:31 +0000 (20:48 -0400)]
inspector: Show shortcuts
At a tab that lists the shortcuts contained in a
GtkShortcutController.
Benjamin Otte [Sun, 26 Aug 2018 16:39:51 +0000 (18:39 +0200)]
filechooser: Trigger the location popup via bindings
Simplifies code quite a bit.
Benjamin Otte [Fri, 24 Aug 2018 06:46:54 +0000 (08:46 +0200)]
accels: Remove GtkAccelGroup
Benjamin Otte [Fri, 24 Aug 2018 05:41:28 +0000 (07:41 +0200)]
testmenubutton: Don't create a GtkAccelGroup
It's unused.
Benjamin Otte [Fri, 24 Aug 2018 05:40:49 +0000 (07:40 +0200)]
testsuite: Remove GtkAccelGroup usage
Benjamin Otte [Fri, 24 Aug 2018 05:34:23 +0000 (07:34 +0200)]
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.
Benjamin Otte [Fri, 24 Aug 2018 05:38:44 +0000 (07:38 +0200)]
doc tools: Create AccelLabel image without using GtkAccelGroup
Emmanuele Bassi [Thu, 6 Feb 2020 16:55:34 +0000 (16:55 +0000)]
testgtk: Port keyval example to shortcut controllers
Benjamin Otte [Fri, 24 Aug 2018 05:00:12 +0000 (07:00 +0200)]
shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
Benjamin Otte [Fri, 24 Aug 2018 04:58:44 +0000 (06:58 +0200)]
shortcutaction: Integrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
Benjamin Otte [Thu, 23 Aug 2018 19:07:36 +0000 (21:07 +0200)]
shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
Benjamin Otte [Wed, 22 Aug 2018 23:23:24 +0000 (01:23 +0200)]
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.
Benjamin Otte [Mon, 20 Aug 2018 22:44:47 +0000 (00:44 +0200)]
accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
Benjamin Otte [Mon, 20 Aug 2018 17:45:51 +0000 (19:45 +0200)]
accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
Benjamin Otte [Mon, 20 Aug 2018 07:18:59 +0000 (09:18 +0200)]
shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
Matthias Clasen [Wed, 25 Mar 2020 21:28:34 +0000 (17:28 -0400)]
shortcutmanager: Use list models
Matthias Clasen [Wed, 25 Mar 2020 21:28:01 +0000 (17:28 -0400)]
shortcutcontroller: Use a list model for shortcuts
Benjamin Otte [Mon, 20 Aug 2018 02:45:10 +0000 (04:45 +0200)]
shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
Matthias Clasen [Sun, 15 Mar 2020 22:24:52 +0000 (18:24 -0400)]
widget: Only create a controller if we have shortcuts
No point in creating objects that just hold empty lists.
Benjamin Otte [Mon, 20 Aug 2018 02:18:28 +0000 (04:18 +0200)]
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.
Benjamin Otte [Sun, 19 Aug 2018 05:12:00 +0000 (07:12 +0200)]
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.
Benjamin Otte [Sun, 19 Aug 2018 04:26:50 +0000 (06:26 +0200)]
shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
Benjamin Otte [Sat, 18 Aug 2018 18:01:27 +0000 (20:01 +0200)]
gtk-demo: Port the sliding puzzle demo to shortcuts
Benjamin Otte [Sat, 18 Aug 2018 18:01:43 +0000 (20:01 +0200)]
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.
Benjamin Otte [Sat, 18 Aug 2018 05:32:11 +0000 (07:32 +0200)]
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
Benjamin Otte [Fri, 17 Aug 2018 04:43:27 +0000 (06:43 +0200)]
accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
Emmanuele Bassi [Thu, 6 Feb 2020 16:02:44 +0000 (16:02 +0000)]
gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
Benjamin Otte [Fri, 17 Aug 2018 03:07:32 +0000 (05:07 +0200)]
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.
Benjamin Otte [Thu, 16 Aug 2018 05:55:49 +0000 (07:55 +0200)]
Remove GtkMnemonicHash
It's not used anymore.
Emmanuele Bassi [Thu, 6 Feb 2020 15:54:57 +0000 (15:54 +0000)]
window: Remove all old mnemonic handling API
Emmanuele Bassi [Thu, 6 Feb 2020 15:43:55 +0000 (15:43 +0000)]
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.
Benjamin Otte [Thu, 16 Aug 2018 03:43:37 +0000 (05:43 +0200)]
label: Implement mnemonics using shortcuts
Benjamin Otte [Thu, 16 Aug 2018 03:18:01 +0000 (05:18 +0200)]
shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
Benjamin Otte [Thu, 16 Aug 2018 01:59:24 +0000 (03:59 +0200)]
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.
Benjamin Otte [Wed, 15 Aug 2018 04:43:31 +0000 (06:43 +0200)]
window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
Benjamin Otte [Wed, 15 Aug 2018 04:19:52 +0000 (06:19 +0200)]
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).
Benjamin Otte [Wed, 15 Aug 2018 03:50:28 +0000 (05:50 +0200)]
gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
Benjamin Otte [Sat, 11 Aug 2018 23:40:03 +0000 (01:40 +0200)]
gtk-demo: Add a dumb demo for shortcut triggers
Benjamin Otte [Mon, 13 Aug 2018 14:02:27 +0000 (16:02 +0200)]
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.
Benjamin Otte [Mon, 13 Aug 2018 03:45:12 +0000 (05:45 +0200)]
shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
Benjamin Otte [Mon, 13 Aug 2018 03:19:05 +0000 (05:19 +0200)]
accelgroup: Add gtk_accel_group_print_label()
Benjamin Otte [Mon, 13 Aug 2018 02:59:49 +0000 (04:59 +0200)]
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.
Benjamin Otte [Mon, 13 Aug 2018 02:51:03 +0000 (04:51 +0200)]
accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
Benjamin Otte [Sun, 12 Aug 2018 20:07:27 +0000 (22:07 +0200)]
gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
Emmanuele Bassi [Thu, 6 Feb 2020 15:01:18 +0000 (15:01 +0000)]
Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
Matthias Clasen [Tue, 17 Mar 2020 21:24:09 +0000 (17:24 -0400)]
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.
Emmanuele Bassi [Thu, 6 Feb 2020 15:00:31 +0000 (15:00 +0000)]
popovermenu: Port to shortcuts
Benjamin Otte [Sun, 12 Aug 2018 23:52:04 +0000 (01:52 +0200)]
accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
Benjamin Otte [Sun, 12 Aug 2018 19:32:42 +0000 (21:32 +0200)]
treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
Benjamin Otte [Sun, 12 Aug 2018 19:15:37 +0000 (21:15 +0200)]
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.
Emmanuele Bassi [Thu, 6 Feb 2020 14:21:10 +0000 (14:21 +0000)]
widget: Add private accessor to event controllers
Benjamin Otte [Sun, 12 Aug 2018 15:07:23 +0000 (17:07 +0200)]
iconview: Port bindings to use shortcuts
Benjamin Otte [Sun, 12 Aug 2018 14:57:37 +0000 (16:57 +0200)]
infobar: Port bindings to use shortcuts
Benjamin Otte [Sun, 12 Aug 2018 14:55:43 +0000 (16:55 +0200)]
label: Port bindings to use shortcuts
Benjamin Otte [Sun, 12 Aug 2018 14:47:58 +0000 (16:47 +0200)]
listbox: Port bindings to use shortcuts
Benjamin Otte [Sun, 12 Aug 2018 14:05:45 +0000 (16:05 +0200)]
notebook: Port bindings to use shortcuts
Benjamin Otte [Sun, 12 Aug 2018 13:53:45 +0000 (15:53 +0200)]
scale: Port bindings to use shortcuts
Benjamin Otte [Sun, 12 Aug 2018 13:50:45 +0000 (15:50 +0200)]
scalebutton: Port bindings to use shortcuts