Commit Graph

55629 Commits

Author SHA1 Message Date
Benjamin Otte
aa849bb538 shortcutaction: INtegrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2018-08-25 08:09:09 +02:00
Benjamin Otte
c914d4c5ca shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2018-08-25 08:09:09 +02:00
Benjamin Otte
4536987569 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.
2018-08-25 08:09:09 +02:00
Benjamin Otte
e05009fa1d accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2018-08-25 08:09:09 +02:00
Benjamin Otte
9b1d9749a4 accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2018-08-25 08:09:09 +02:00
Benjamin Otte
cd8e2cd7ce shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2018-08-25 08:09:09 +02:00
Benjamin Otte
87667730af 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.
2018-08-25 08:09:09 +02:00
Benjamin Otte
40c2d27004 gdk: Make gdk_keyval_name() return a const char
The string is const, so return it like that.
2018-08-24 08:55:44 +02:00
Benjamin Otte
86b905679d shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2018-08-24 08:55:44 +02:00
Benjamin Otte
098d968da0 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
eb54453318 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
39140a8741 shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2018-08-24 08:55:44 +02:00
Benjamin Otte
a3172243b5 gtk-demo: Port the sliding puzzle demo to shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
d66d0268e5 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
22f9dc86bf 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
2018-08-24 08:55:44 +02:00
Benjamin Otte
74338af685 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2018-08-24 08:55:44 +02:00
Benjamin Otte
4195b4dfa1 gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2018-08-24 08:55:44 +02:00
Benjamin Otte
5e89acb4de 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
0a893b203a menushell: Remove old mnemonic handling
It's not used anymore.

This was also the last user of GtkMnemonicHash, so delete that one, too.
2018-08-24 08:55:44 +02:00
Benjamin Otte
4f2570d9b6 window: Remove all old mnemonic handling API 2018-08-24 08:55:44 +02:00
Benjamin Otte
57f9eed05f menu: Implement GtkShortcutManager
And make sure to activate mnemonics without Alt
2018-08-24 08:55:44 +02:00
Benjamin Otte
d50be09253 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
37bb5de03b label: Implement mnemonics using shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
26ab1e68ab shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
2018-08-24 08:55:44 +02:00
Benjamin Otte
7cbcee1514 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
78b6268ac3 window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2018-08-24 08:55:44 +02:00
Benjamin Otte
8e428e9b85 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).
2018-08-24 08:55:44 +02:00
Benjamin Otte
77e75f40a7 gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
2018-08-24 08:55:44 +02:00
Benjamin Otte
19eee860de gtk-demo: Add a dumb demo for shortcut triggers 2018-08-24 08:55:44 +02:00
Benjamin Otte
12a4531f71 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
3065ff7908 shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
2018-08-24 08:55:44 +02:00
Benjamin Otte
4b7df0fe84 accelgroup: Add gtk_accel_group_print_label() 2018-08-24 08:55:44 +02:00
Benjamin Otte
34736ab97e 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
4682f706fa accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
2018-08-24 08:55:44 +02:00
Benjamin Otte
4b3172d047 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2018-08-24 08:55:44 +02:00
Benjamin Otte
be341be1ac accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
2018-08-24 08:55:44 +02:00
Benjamin Otte
56f9b96fe6 treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
2018-08-24 08:55:44 +02:00
Benjamin Otte
4aac701b42 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.
2018-08-24 08:55:44 +02:00
Benjamin Otte
caf309d81b eventcontrollerkey: Remove unused header 2018-08-24 08:55:44 +02:00
Benjamin Otte
d80e651623 iconview: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
fb6cdbc1f1 infobar: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
66476bbd23 label: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
853c9b3c4c listbox: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
37c4b5209d menubar: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
893bd45c1f menu: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
06ed2e0356 menushell: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
ebf15560f0 notebook: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
dcfa355d0a scale: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
474494d82c scalebutton: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00
Benjamin Otte
c73be5c405 scrolledwindow: Port bindings to use shortcuts 2018-08-24 08:55:44 +02:00