padcontroller: Port to new API model

This commit is contained in:
Benjamin Otte 2018-03-10 19:10:35 +01:00 committed by Carlos Garnacho
parent 4f3058f195
commit c5f12a7326
3 changed files with 10 additions and 14 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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