Commit Graph

2349 Commits

Author SHA1 Message Date
Matthias Clasen
3419d9c04f gtk: Drop gtk_widget_get_modifier_mask
This is not used anymore.
2020-04-06 16:32:03 -04:00
Matthias Clasen
234a21905c gtk: Stop using keymap apis
Stop using most keymap apis in GTK. Only a few calls
related to virtual modifiers are left.
2020-04-06 01:40:49 -04:00
Timm Bäder
785b33f169 widget: Return an array from list_controllers
Minimize the GList usage throughout the code base.
2020-03-29 15:32:54 +02: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
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
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
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
Matthias Clasen
c2e2e2993b shortcutmanager: Use list models 2020-03-25 23:14:28 -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
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
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
Benjamin Otte
9b99b89807 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.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
aab10ea43b 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-25 23:14:27 -04:00
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
Emmanuele Bassi
7ca4a94768 widget: Add private accessor to event controllers 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
Benjamin Otte
6d418134ee widget: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Emmanuele Bassi
17eef48835 Allow installing bindings bound to actions
This is just convenience code around GtkShortcut, just like bindings for
signal emission and callback invocation.
2020-03-25 22:36:03 -04:00
Benjamin Otte
d4bba7de88 shortcut: Add gtk_shortcut_set_callback()
... and gtk_widget_class_add_binding() to go with it.

This allows shortcuts to invoke manually added callbacks.
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
Christian Hergert
b5b836668a muxer: force muxer dispoal as part of widget dispose
We need to cleanup state here immediately so that we do not potentially
access the g_class private data after it been finalized. This ensures that
the borrowed reference is dropped by the muxer.
2020-03-25 14:02:59 -07:00
Christian Hergert
ccac404f28 widget: fix class private data usage to be _init() safe
Before this commit, adding GtkWidgetAction to class private data would
require copying the actions to each subclass as they were built or
modified. This was convenient in that it is a sort of "copy on write"
semantic.

However, due to the way that GTypeInstance works with base _init()
functions, the "g_class" pointer in GTypeInstance is updated as each
_init() function is called. That means you cannot access the subclasses
class private data, but only the parent class private data.

If instead we use a singly linked list of GtkWidgetAction, each subclass
has their own "head" yet all subclasses share the tail of the
GtkWidgetAction chain.

This creates one bit of complexity though. You need a stable way to know
which "bit" is the "enabled" bit of the action so we can track enabled
GAction state. That is easily solved by calculating the distance to the
end of the chain for a given action so that base classes sort ahead of
subclasses. Since the parent class always knows its parent's actions, the
position is stable.

A new dynamic bitarray helper also helps us avoid allocations in all the
current cases (up to 64 actions per widget) and dynamically switches to
malloc if that is to ever be exceeded.
2020-03-20 11:17:56 -07:00
Christian Hergert
6822dce8fb widget: move class private data to gtkwidgetprivate.h
We want access to the private data from the action muxer so we can just
move the structures to the gtkwidgetprivate.h header. Alternatively we
could create accessors, but given that we'll probably need to use this
in other areas, seems reasonable to just put it there.
2020-03-20 11:17:56 -07:00
Carlos Garnacho
0f73e83f44 gtkwindow: Remove internal popover API
This was only used by text handles, and not anymore.
2020-03-20 15:52:19 +01: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
Matthias Clasen
c8fd6407a8 widget: Drop the ::popup-menu signal
This is now done in widgets which have context
menus.
2020-03-19 00:56:46 -04:00
Matthias Clasen
f7021e80a7 Only create a class shortcut controller if we have shortcuts
No point in creating objects that just hold empty lists.
2020-03-18 23:00:51 -04:00
Matthias Clasen
3e7d49a8d3 widget: Name the controllers 2020-03-18 23:00:51 -04:00
Matthias Clasen
ad69899a9d Move shortcut manager initialization code
It is just too ugly to use quarks across multiple
source files, so add a private helper function that
attaches the controllers.
2020-03-18 23:00:51 -04:00
Benjamin Otte
17d9ba362c 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-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
4a4bfa0766 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-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
b28da74e90 gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-18 23:00:51 -04:00
Benjamin Otte
ba3882de83 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.
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
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
Emmanuele Bassi
56595e7529 widget: Add private accessor to event controllers 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
Benjamin Otte
ac31979805 widget: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Emmanuele Bassi
d75fd59ddf Allow installing bindings bound to actions
This is just convenience code around GtkShortcut, just like bindings for
signal emission and callback invocation.
2020-03-18 23:00:49 -04:00
Benjamin Otte
b18f9da807 shortcut: Add gtk_shortcut_set_callback()
... and gtk_widget_class_add_binding() to go with it.

This allows shortcuts to invoke manually added callbacks.
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