mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
padcontroller: Port to new API model
This commit is contained in:
parent
4f3058f195
commit
c5f12a7326
@ -581,8 +581,7 @@ init_pad_controller (GtkWidget *window,
|
||||
gint i;
|
||||
|
||||
action_group = g_simple_action_group_new ();
|
||||
pad_controller = gtk_pad_controller_new (GTK_WINDOW (window),
|
||||
G_ACTION_GROUP (action_group),
|
||||
pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
|
||||
@ -607,8 +606,7 @@ init_pad_controller (GtkWidget *window,
|
||||
|
||||
gtk_pad_controller_set_action_entries (pad_controller, pad_actions,
|
||||
G_N_ELEMENTS (pad_actions));
|
||||
g_object_set_data_full (G_OBJECT (window), "pad-controller",
|
||||
pad_controller, g_object_unref);
|
||||
gtk_widget_add_controller (window, GTK_EVENT_CONTROLLER (pad_controller));
|
||||
|
||||
g_object_unref (action_group);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
||||
* g_signal_connect (action, "activate", on_invert_selection_activated, NULL);
|
||||
* g_action_map_add_action (G_ACTION_MAP (action_group), action);
|
||||
* …
|
||||
* pad_controller = gtk_pad_controller_new (window, action_group, NULL);
|
||||
* pad_controller = gtk_pad_controller_new (action_group, NULL);
|
||||
* ]|
|
||||
*
|
||||
* The actions belonging to rings/strips will be activated with a parameter
|
||||
@ -387,35 +387,34 @@ gtk_pad_controller_init (GtkPadController *controller)
|
||||
|
||||
/**
|
||||
* gtk_pad_controller_new:
|
||||
* @window: a #GtkWindow
|
||||
* @group: #GActionGroup to trigger actions from
|
||||
* @pad: (nullable): A %GDK_SOURCE_TABLET_PAD device, or %NULL to handle all pads
|
||||
*
|
||||
* Creates a new #GtkPadController that will associate events from @pad to
|
||||
* actions. A %NULL pad may be provided so the controller manages all pad devices
|
||||
* generically, it is discouraged to mix #GtkPadController objects with %NULL
|
||||
* and non-%NULL @pad argument on the same @window, as execution order is not
|
||||
* guaranteed.
|
||||
* and non-%NULL @pad argument on the same toplevel window, as execution order
|
||||
* is not guaranteed.
|
||||
*
|
||||
* The #GtkPadController is created with no mapped actions. In order to map pad
|
||||
* events to actions, use gtk_pad_controller_set_action_entries() or
|
||||
* gtk_pad_controller_set_action().
|
||||
*
|
||||
* Be aware that pad events will only be delivered to #GtkWindows, so adding a pad
|
||||
* controller to any other type of widget will not have an effect.
|
||||
*
|
||||
* Returns: A newly created #GtkPadController
|
||||
**/
|
||||
GtkPadController *
|
||||
gtk_pad_controller_new (GtkWindow *window,
|
||||
GActionGroup *group,
|
||||
gtk_pad_controller_new (GActionGroup *group,
|
||||
GdkDevice *pad)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
|
||||
g_return_val_if_fail (G_IS_ACTION_GROUP (group), NULL);
|
||||
g_return_val_if_fail (!pad || GDK_IS_DEVICE (pad), NULL);
|
||||
g_return_val_if_fail (!pad || gdk_device_get_source (pad) == GDK_SOURCE_TABLET_PAD, NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_PAD_CONTROLLER,
|
||||
"propagation-phase", GTK_PHASE_CAPTURE,
|
||||
"widget", window,
|
||||
"action-group", group,
|
||||
"pad", pad,
|
||||
NULL);
|
||||
|
@ -78,8 +78,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_pad_controller_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkPadController *gtk_pad_controller_new (GtkWindow *window,
|
||||
GActionGroup *group,
|
||||
GtkPadController *gtk_pad_controller_new (GActionGroup *group,
|
||||
GdkDevice *pad);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
Loading…
Reference in New Issue
Block a user