Commit Graph

34566 Commits

Author SHA1 Message Date
Matthias Clasen
fc0b0b14a8 label: Respect GtkPopover::mnemonics-visible
When inside a popover, look to the popover for
whether to show mnemonics or not.
2020-03-25 23:14:45 -04:00
Matthias Clasen
2de4fc3ec0 popover: Add a mnemonics-visible property
This will be handled separately for popovers, so we
need our own property for it.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b2ac42e576 label: Disconnect visible mnemonics in popovers
The controller handling mnemonics is limited to same-native,
so showing mnemonics in other natives.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b19d4b9006 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.
2020-03-25 23:14:45 -04:00
Matthias Clasen
2c28a0713d popovermenu: Make mnemonics work without Alt
This is expected menu behavior.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b423f974db shortcutcontroller: Inject accels into the action muxer
This is the way model button pic up accels for their actions.
2020-03-25 23:14:45 -04:00
Matthias Clasen
4a430820bd popover: Implement GtkShortcutManager
This makes mnemonics work in popovers.
2020-03-25 23:14:45 -04:00
Matthias Clasen
5153cdc01d modelbutton: Make activatable
This is expected of button-like widgets, and is necessary
to make keynav in popover menus work as expected.
2020-03-25 23:14:45 -04:00
Matthias Clasen
1db5382c6d 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.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi
6e8c78714d Turn GtkShortcutAction into a GObject
Just like we did for GtkShortcutTrigger.

This allows language bindings to properly deal with all the actions.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi
457b6657bb 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.
2020-03-25 23:14:45 -04:00
Matthias Clasen
5ea45bf57d widget: Remove some leftover accel group plumbing
The ::can-activate-accel and ::accel-closures-changed signals
are not used anymore, remove them.
2020-03-25 23:14:45 -04:00
Matthias Clasen
4e978d6b7a shortcutcontroller: Only activate shortcuts of visible widgets
Our shortcuts are like mnemonics in this respect - they only
activate when the widget is viewable.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b4722b43a1 Drop GtkKeyHash 2020-03-25 23:14:45 -04:00
Matthias Clasen
fd95cc56b1 window: Remove GtkKeyHash remnants
It is not used anymore.
2020-03-25 23:14:45 -04:00
Matthias Clasen
35332eb3b0 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.
2020-03-25 23:14:45 -04:00
Matthias Clasen
586e7749d5 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.
2020-03-25 23:14:45 -04:00
Matthias Clasen
904835d4b1 shortcuttrigger: Introduce partial matches
Allow GtkShortcutTrigger to return partial matches.
Currently, no triggers produce such results, and
GtkShortcutController treats partial matches like
exact ones.
2020-03-25 23:14:45 -04:00
Matthias Clasen
9cce474106 widget: Drop the ::popup-menu signal
This is now done in widgets which have context
menus.
2020-03-25 23:14:45 -04:00
Matthias Clasen
9d84996fea placesview: Stop using ::popup-menu
This signal is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen
c2d77a1f37 filechooser: Stop using ::popup-menu
This signal is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen
54a0037c45 mountoperation: Stop using ::popup-menu
We can just use a shortcut controller directly.
2020-03-25 23:14:45 -04:00
Matthias Clasen
844801580f colorchooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-25 23:14:44 -04:00
Matthias Clasen
28b05eea67 range: Remove ::popup-menu emission
This signal is going away, and having context menus
on sliders is not really a thing anyway.
2020-03-25 23:14:44 -04:00
Matthias Clasen
ca1d4322a2 scrollbar: Remove :popup-menu forwarding
This signal is going away.
2020-03-25 23:14:44 -04:00
Matthias Clasen
c94ec4a204 emojichooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-25 23:14:44 -04:00
Matthias Clasen
778d884f70 Use an action for the context menu keybinding
The ::popup-menu signal is going away.
2020-03-25 23:14:44 -04:00
Matthias Clasen
e8be45fabc Print mnemonic triggers clearly 2020-03-25 23:14:44 -04:00
Matthias Clasen
c90b0581dd inspector: Show shortcuts
At a tab that lists the shortcuts contained in a
GtkShortcutController.
2020-03-25 23:14:44 -04:00
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
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
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
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