Commit Graph

57881 Commits

Author SHA1 Message Date
Benjamin Otte
136d6a1ae8 doc tools: Create AccelLabel image without using GtkAccelGroup 2019-05-15 17:20:52 -03:00
Benjamin Otte
40a26c2e8c 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-05-15 17:20:51 -03:00
Benjamin Otte
8ef6e2fc8e testgtk: Port keyval example to shortcut controllers 2019-05-15 17:20:51 -03:00
Benjamin Otte
7996b5b355 gtk-demo: Redo builder example to use shortcuts
Now that shortcuts and controllers are supported by GtkBuilder, demo
how all of that works.
2019-05-15 17:20:51 -03:00
Benjamin Otte
c319da4de0 shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2019-05-15 17:20:51 -03:00
Benjamin Otte
4939c3be90 shortcutaction: INtegrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2019-05-15 17:20:51 -03:00
Benjamin Otte
66fca6dfcc shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2019-05-15 17:20:50 -03:00
Benjamin Otte
276e761515 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-05-15 17:20:50 -03:00
Benjamin Otte
94d09e2a74 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2019-05-15 17:20:50 -03:00
Benjamin Otte
643936d5d5 accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2019-05-15 17:20:50 -03:00
Benjamin Otte
ab0eea1859 shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2019-05-15 17:20:50 -03:00
Benjamin Otte
d3674f6375 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-05-15 17:20:49 -03:00
Benjamin Otte
e434fdcf4d gdk: Make gdk_keyval_name() return a const char
The string is const, so return it like that.
2019-05-15 17:20:49 -03:00
Benjamin Otte
432a4b844a shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2019-05-15 17:20:49 -03:00
Benjamin Otte
f1c108e21a 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-05-15 17:20:49 -03:00
Benjamin Otte
87004c3a6c 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-05-15 17:20:49 -03:00
Benjamin Otte
e8cd1d140b shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2019-05-15 17:20:48 -03:00
Benjamin Otte
a262c38a79 gtk-demo: Port the sliding puzzle demo to shortcuts 2019-05-15 17:20:48 -03:00
Benjamin Otte
f2caa676a9 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-05-15 17:20:48 -03:00
Benjamin Otte
8391c87c6d 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-05-15 17:20:48 -03:00
Benjamin Otte
1f413ef061 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2019-05-15 17:20:48 -03:00
Benjamin Otte
3685e52254 gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2019-05-15 17:20:47 -03:00
Benjamin Otte
a4c9f37b32 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.
2019-05-15 17:20:47 -03:00
Benjamin Otte
38c8cfe917 menushell: Remove old mnemonic handling
It's not used anymore.

This was also the last user of GtkMnemonicHash, so delete that one, too.
2019-05-15 17:20:47 -03:00
Benjamin Otte
3839d41d44 window: Remove all old mnemonic handling API 2019-05-15 17:20:47 -03:00
Benjamin Otte
2ee29b1538 menu: Implement GtkShortcutManager
And make sure to activate mnemonics without Alt
2019-05-15 17:20:46 -03:00
Benjamin Otte
787220507d shortcutmanager: Add
This adds an interface for taking care of shortcut controllers with
managed scope.

GtkRoot requires this interface, where it's also used for global
controllers and to ensure that managed scope always finds a parent that
is a shortcut manager.

No widget that isn't a root implements the interface yet.
2019-05-15 17:20:46 -03:00
Benjamin Otte
6e164b6c82 label: Implement mnemonics using shortcuts 2019-05-15 17:20:46 -03:00
Benjamin Otte
171505b823 shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
2019-05-15 17:20:46 -03:00
Benjamin Otte
85c5585c63 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.
2019-05-15 17:20:45 -03:00
Benjamin Otte
2f29b14bec window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2019-05-15 17:20:45 -03:00
Benjamin Otte
1db44a0af2 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).
2019-05-15 17:20:45 -03:00
Benjamin Otte
1d106ea36b gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
2019-05-15 17:20:45 -03:00
Benjamin Otte
35222a40f8 gtk-demo: Add a dumb demo for shortcut triggers 2019-05-15 17:20:45 -03:00
Benjamin Otte
6ceaa17597 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.
2019-05-15 17:20:44 -03:00
Benjamin Otte
a554a5cb93 shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
2019-05-15 17:20:44 -03:00
Benjamin Otte
852953121d accelgroup: Add gtk_accel_group_print_label() 2019-05-15 17:20:44 -03:00
Benjamin Otte
291d7f9897 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.
2019-05-15 17:20:44 -03:00
Benjamin Otte
d73be336d0 accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
2019-05-15 17:20:44 -03:00
Benjamin Otte
09af271445 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2019-05-15 17:20:43 -03:00
Georges Basile Stavracas Neto
811a2ea698 eventcontrollerkey: Remove binding handling 2019-05-15 17:20:43 -03:00
Georges Basile Stavracas Neto
e0723d74e6 passwordentry: Remove unused header 2019-05-15 17:20:43 -03:00
Benjamin Otte
e3ead985e4 accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
2019-05-15 17:20:43 -03:00
Benjamin Otte
cf4c4e0465 treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
2019-05-15 17:20:43 -03:00
Benjamin Otte
ee815e0cf5 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.
2019-05-15 17:20:42 -03:00
Benjamin Otte
16fd077867 iconview: Port bindings to use shortcuts 2019-05-15 17:20:42 -03:00
Benjamin Otte
2c25375663 infobar: Port bindings to use shortcuts 2019-05-15 17:20:42 -03:00
Benjamin Otte
c340a18b0f label: Port bindings to use shortcuts 2019-05-15 17:20:41 -03:00
Benjamin Otte
f164fe371c listbox: Port bindings to use shortcuts 2019-05-15 17:20:41 -03:00
Benjamin Otte
533200a016 menubar: Port bindings to use shortcuts 2019-05-15 17:20:41 -03:00