[mutter/wip/tablet-protocol-v2: 63/70] wayland: Add getters for the current feedback strings in MetaWaylandTabletPad
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/tablet-protocol-v2: 63/70] wayland: Add getters for the current feedback strings in MetaWaylandTabletPad
- Date: Wed, 22 Jun 2016 17:38:39 +0000 (UTC)
commit 1fe744994a232ac707fa600e7b579e0ffabc0693
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jun 22 19:00:15 2016 +0200
wayland: Add getters for the current feedback strings in MetaWaylandTabletPad
Each of the buttons/rings/strips may have one such feedback string, this API
makes is meant to make lookups consistent.
src/wayland/meta-wayland-tablet-pad.c | 65 +++++++++++++++++++++++++++++++++
src/wayland/meta-wayland-tablet-pad.h | 4 ++
2 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-tablet-pad.c b/src/wayland/meta-wayland-tablet-pad.c
index 875c886..cc111a0 100644
--- a/src/wayland/meta-wayland-tablet-pad.c
+++ b/src/wayland/meta-wayland-tablet-pad.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include <wayland-server.h>
#include "tablet-unstable-v2-server-protocol.h"
@@ -433,3 +434,67 @@ meta_wayland_tablet_pad_update (MetaWaylandTabletPad *pad,
break;
}
}
+
+static gchar *
+meta_wayland_tablet_pad_label_mode_switch_button (MetaWaylandTabletPad *pad,
+ guint button)
+{
+ MetaWaylandTabletPadGroup *group;
+ GList *l;
+
+ for (l = pad->groups; l; l = l->next)
+ {
+ group = l->data;
+
+ if (meta_wayland_tablet_pad_group_is_mode_switch_button (group, button))
+ return g_strdup_printf (_("Mode Switch: Mode %d"), group->current_mode + 1);
+ }
+
+ return NULL;
+}
+
+gchar *
+meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad,
+ MetaPadActionType type,
+ guint action)
+{
+ const gchar *label = NULL;
+ gchar *mode_label;
+
+ switch (type)
+ {
+ case META_PAD_ACTION_BUTTON:
+ mode_label = meta_wayland_tablet_pad_label_mode_switch_button (pad, action);
+ if (mode_label)
+ return mode_label;
+
+ label = g_hash_table_lookup (pad->feedback, GUINT_TO_POINTER (action));
+ break;
+ case META_PAD_ACTION_RING:
+ {
+ MetaWaylandTabletPadGroup *group;
+ MetaWaylandTabletPadRing *ring;
+
+ /* FIXME: Assuming each group gets 1 */
+ group = g_list_nth_data (pad->groups, action);
+ ring = g_list_nth_data (group->rings, 1);
+ if (ring)
+ label = ring->feedback;
+ break;
+ }
+ case META_PAD_ACTION_STRIP:
+ {
+ MetaWaylandTabletPadGroup *group;
+ MetaWaylandTabletPadStrip *strip;
+
+ /* FIXME: Assuming each group gets 1 */
+ group = g_list_nth_data (pad->groups, action);
+ strip = g_list_nth_data (group->strips, 1);
+ if (strip)
+ label = strip->feedback;
+ break;
+ }
+ }
+
+ return g_strdup (label);
+}
diff --git a/src/wayland/meta-wayland-tablet-pad.h b/src/wayland/meta-wayland-tablet-pad.h
index a627226..72a66ec 100644
--- a/src/wayland/meta-wayland-tablet-pad.h
+++ b/src/wayland/meta-wayland-tablet-pad.h
@@ -73,4 +73,8 @@ gboolean meta_wayland_tablet_pad_handle_event (MetaWaylandTabletPad *
void meta_wayland_tablet_pad_set_focus (MetaWaylandTabletPad *pad,
MetaWaylandSurface *surface);
+gchar * meta_wayland_tablet_pad_get_label (MetaWaylandTabletPad *pad,
+ MetaPadActionType type,
+ guint action);
+
#endif /* META_WAYLAND_TABLET_PAD_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]