[gtk+/wip/wayland-tablet-v2: 40/41] GtkPadController: Make ring/strip actions be activated with the axis value
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/wayland-tablet-v2: 40/41] GtkPadController: Make ring/strip actions be activated with the axis value
- Date: Tue, 23 Aug 2016 18:34:39 +0000 (UTC)
commit 2833214d4524b179886eb9304b798bd51dce518a
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Aug 23 20:16:02 2016 +0200
GtkPadController: Make ring/strip actions be activated with the axis value
This way these axes may be used in detail by the implementors of pad GActions.
gtk/gtkpadcontroller.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkpadcontroller.c b/gtk/gtkpadcontroller.c
index df54d5d..e44d047 100644
--- a/gtk/gtkpadcontroller.c
+++ b/gtk/gtkpadcontroller.c
@@ -61,6 +61,10 @@
* …
* pad_controller = gtk_pad_controller_new (window, action_group, NULL);
* ]|
+ *
+ * The actions belonging to rings/strips will be activated with a parameter
+ * of type %G_VARIANT_TYPE_DOUBLE bearing the value of the given axis, it
+ * is recommended that those are made stateful and accepting this #GVariantType.
*/
#include "config.h"
@@ -155,6 +159,16 @@ gtk_pad_controller_activate_action (GtkPadController *controller,
}
static void
+gtk_pad_controller_activate_action_with_axis (GtkPadController *controller,
+ const GtkPadActionEntry *entry,
+ gdouble value)
+{
+ g_action_group_activate_action (controller->action_group,
+ entry->action_name,
+ g_variant_new_double (value));
+}
+
+static void
gtk_pad_controller_handle_mode_switch (GtkPadController *controller,
GdkDevice *pad,
guint group,
@@ -253,7 +267,16 @@ gtk_pad_controller_handle_event (GtkEventController *controller,
if (!entry)
return GDK_EVENT_PROPAGATE;
- gtk_pad_controller_activate_action (pad_controller, entry);
+ if (event->type == GDK_PAD_RING ||
+ event->type == GDK_PAD_STRIP)
+ {
+ gtk_pad_controller_activate_action_with_axis (pad_controller, entry,
+ event->pad_axis.value);
+ }
+ else
+ {
+ gtk_pad_controller_activate_action (pad_controller, entry);
+ }
return GDK_EVENT_STOP;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]