[gnome-control-center/wip/carlosg/ekr] wacom: Show distinct entries for Wacom Express Key Remote
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/carlosg/ekr] wacom: Show distinct entries for Wacom Express Key Remote
- Date: Fri, 12 Aug 2022 10:57:32 +0000 (UTC)
commit 7bca23aeacb3e84729355e109aa284959b1fa4cd
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Aug 12 12:32:38 2022 +0200
wacom: Show distinct entries for Wacom Express Key Remote
If you did not know the Wacom Express Key Remote (or EKR for short),
let me introduce it to you:
https://estore.wacom.com/media/catalog/product/cache/fb4143a007ae6439deba9b18afd745f2/a/c/ack-411050_main_2.jpg
This is a hand-sized standalone pad device, meant to be used together
with drawing tablets, providing additional buttons and a touch sensitive
ring that can be mapped to actions and keypresses.
These pads were so far handled in GNOME, but in a very subtle manner.
As the EKR is implicitly paired to a tablet, it was possible to map
EKR buttons from the paired tablet once the pad OSD UI from GNOME
Shell was shown.
As this device basically just needs a "Map buttons" action to
configure it, it just didn't sit well in the older Settings UI,
it would get a separate page with just a lone button in there. So
its support has been kind of an easter egg so far.
But the new UI can indeed accomodate better a device that is neither
tablet nor stylus, and has few options. This commit adds the EKR
as a separate AdwPreferencesGroup.
panels/wacom/cc-wacom-ekr-page.c | 195 ++++++++++++++++++++++++++++++++++++++
panels/wacom/cc-wacom-ekr-page.h | 34 +++++++
panels/wacom/cc-wacom-ekr-page.ui | 32 +++++++
panels/wacom/cc-wacom-panel.c | 30 +++++-
panels/wacom/meson.build | 3 +-
panels/wacom/wacom.gresource.xml | 1 +
6 files changed, 291 insertions(+), 4 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-ekr-page.c b/panels/wacom/cc-wacom-ekr-page.c
new file mode 100644
index 000000000..fb2f3e32f
--- /dev/null
+++ b/panels/wacom/cc-wacom-ekr-page.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright © 2022 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Carlos Garnacho <carlosg gnome org>
+ */
+
+#include "config.h"
+
+#include "cc-wacom-ekr-page.h"
+#include "cc-wacom-panel.h"
+
+struct _CcWacomEkrPage
+{
+ GtkBox parent_instance;
+ GtkWidget *ekr_section;
+ GtkWidget *ekr_icon;
+ GtkWidget *ekr_map_buttons;
+ CcWacomPanel *panel;
+ CcWacomDevice *device;
+};
+
+enum {
+ PROP_0,
+ PROP_PANEL,
+ PROP_DEVICE,
+ N_PROPS,
+};
+
+static GParamSpec *props[N_PROPS] = { 0, };
+
+G_DEFINE_TYPE (CcWacomEkrPage, cc_wacom_ekr_page, GTK_TYPE_BOX)
+
+static void
+set_osd_visibility_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer data)
+{
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GVariant) result = NULL;
+
+ result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
+
+ if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Error invoking pad button mapping OSK: %s\n", error->message);
+}
+
+static void
+set_osd_visibility (CcWacomEkrPage *page)
+{
+ GDBusProxy *proxy;
+ GsdDevice *gsd_device;
+ const gchar *device_path;
+
+ proxy = cc_wacom_panel_get_gsd_wacom_bus_proxy (page->panel);
+
+ if (proxy == NULL) {
+ g_warning ("Wacom D-Bus interface is not available");
+ return;
+ }
+
+ gsd_device = cc_wacom_device_get_device (page->device);
+ device_path = gsd_device_get_device_file (gsd_device);
+
+ g_dbus_proxy_call (proxy,
+ "Show",
+ g_variant_new ("(ob)", device_path, TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ set_osd_visibility_cb,
+ page);
+}
+
+static void
+on_map_buttons_activated (CcWacomEkrPage *self)
+{
+ set_osd_visibility (self);
+}
+
+static void
+cc_wacom_ekr_page_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ CcWacomEkrPage *page = CC_WACOM_EKR_PAGE (object);
+
+ switch (prop_id) {
+ case PROP_PANEL:
+ g_value_set_object (value, page->panel);
+ break;
+ case PROP_DEVICE:
+ g_value_set_object (value, page->device);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+cc_wacom_ekr_page_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CcWacomEkrPage *page = CC_WACOM_EKR_PAGE (object);
+
+ switch (prop_id) {
+ case PROP_PANEL:
+ page->panel = g_value_get_object (value);
+ break;
+ case PROP_DEVICE:
+ page->device = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+cc_wacom_ekr_page_constructed (GObject *object)
+{
+ CcWacomEkrPage *page = CC_WACOM_EKR_PAGE (object);
+
+ G_OBJECT_CLASS (cc_wacom_ekr_page_parent_class)->constructed (object);
+
+ adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (page->ekr_section),
+ cc_wacom_device_get_name (page->device));
+}
+
+static void
+cc_wacom_ekr_page_class_init (CcWacomEkrPageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = cc_wacom_ekr_page_get_property;
+ object_class->set_property = cc_wacom_ekr_page_set_property;
+ object_class->constructed = cc_wacom_ekr_page_constructed;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/wacom/cc-wacom-ekr-page.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, CcWacomEkrPage, ekr_section);
+ gtk_widget_class_bind_template_child (widget_class, CcWacomEkrPage, ekr_icon);
+ gtk_widget_class_bind_template_child (widget_class, CcWacomEkrPage, ekr_map_buttons);
+
+ gtk_widget_class_bind_template_callback (widget_class, on_map_buttons_activated);
+
+ props[PROP_PANEL] = g_param_spec_object ("panel",
+ "panel",
+ "panel",
+ CC_TYPE_WACOM_PANEL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY);
+
+ props[PROP_DEVICE] = g_param_spec_object ("device",
+ "device",
+ "device",
+ CC_TYPE_WACOM_DEVICE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (object_class, N_PROPS, props);
+}
+
+static void
+cc_wacom_ekr_page_init (CcWacomEkrPage *page)
+{
+ gtk_widget_init_template (GTK_WIDGET (page));
+}
+
+GtkWidget *
+cc_wacom_ekr_page_new (CcWacomPanel *panel,
+ CcWacomDevice *ekr)
+{
+ return g_object_new (CC_TYPE_WACOM_EKR_PAGE,
+ "panel", panel,
+ "device", ekr,
+ NULL);
+}
diff --git a/panels/wacom/cc-wacom-ekr-page.h b/panels/wacom/cc-wacom-ekr-page.h
new file mode 100644
index 000000000..f8944a195
--- /dev/null
+++ b/panels/wacom/cc-wacom-ekr-page.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2022 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Carlos Garnacho <carlosg gnome org>
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+#include "cc-wacom-panel.h"
+#include "cc-wacom-device.h"
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_WACOM_EKR_PAGE (cc_wacom_ekr_page_get_type ())
+G_DECLARE_FINAL_TYPE (CcWacomEkrPage, cc_wacom_ekr_page, CC, WACOM_EKR_PAGE, GtkBox)
+
+GtkWidget * cc_wacom_ekr_page_new (CcWacomPanel *panel,
+ CcWacomDevice *stylus);
+
+G_END_DECLS
diff --git a/panels/wacom/cc-wacom-ekr-page.ui b/panels/wacom/cc-wacom-ekr-page.ui
new file mode 100644
index 000000000..1d1e403b7
--- /dev/null
+++ b/panels/wacom/cc-wacom-ekr-page.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="CcWacomEkrPage" parent="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">24</property>
+ <child>
+ <object class="AdwPreferencesGroup" id="ekr_section">
+ <property name="description" translatable="yes"
+ comments="translators: this is a drawing tablet pad, i.e. a collection of buttons and
knobs">External pad device</property>
+ <property name="header-suffix">
+ <object class="GtkPicture" id="ekr_icon">
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="file">resource:///org/gnome/control-center/wacom/wacom-tablet.svg</property>
+ </object>
+ </property>
+ <child>
+ <object class="AdwActionRow" id="ekr_map_buttons">
+ <property name="title" translatable="yes">Map Buttons</property>
+ <property name="activatable">True</property>
+ <signal name="activated" handler="on_map_buttons_activated" object="CcWacomEkrPage"
swapped="yes" />
+ <child type="suffix">
+ <object class="GtkImage">
+ <property name="icon-name">go-next-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 05592f3ea..9b50c7b36 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -29,6 +29,7 @@
#include "shell/cc-debug.h"
#include "cc-wacom-panel.h"
#include "cc-wacom-page.h"
+#include "cc-wacom-ekr-page.h"
#include "cc-wacom-stylus-page.h"
#include "cc-wacom-resources.h"
#include "cc-drawing-area.h"
@@ -39,6 +40,9 @@
#include <gdk/wayland/gdkwayland.h>
#endif
+#define EKR_VENDOR "056a"
+#define EKR_PRODUCT "0331"
+
struct _CcWacomPanel
{
CcPanel parent_instance;
@@ -546,6 +550,7 @@ add_known_device (CcWacomPanel *self,
GsdDeviceType device_type;
g_autoptr(GList) tools = NULL;
GtkWidget *page;
+ gboolean is_ekr = FALSE;
GList *l;
device_type = gsd_device_get_device_type (gsd_device);
@@ -554,12 +559,27 @@ add_known_device (CcWacomPanel *self,
return;
if ((device_type &
- (GSD_DEVICE_TYPE_PAD |
- GSD_DEVICE_TYPE_TOUCHSCREEN |
+ (GSD_DEVICE_TYPE_TOUCHSCREEN |
GSD_DEVICE_TYPE_TOUCHPAD)) != 0) {
return;
}
+ if ((device_type & GSD_DEVICE_TYPE_PAD) != 0) {
+ const char *vendor, *product;
+
+ gsd_device_get_device_ids (gsd_device, &vendor, &product);
+ is_ekr = (g_strcmp0 (vendor, EKR_VENDOR) == 0 &&
+ g_strcmp0 (product, EKR_PRODUCT) == 0);
+
+ /* Express key remote is an special case, as it is an
+ * external pad device, we want to distinctly show it
+ * in the list. Other pads are mounted on a tablet, which
+ * get their own entries.
+ */
+ if (!is_ekr)
+ return;
+ }
+
device = cc_wacom_device_new (gsd_device);
if (!device)
return;
@@ -572,7 +592,11 @@ add_known_device (CcWacomPanel *self,
add_stylus (self, l->data);
}
- page = cc_wacom_page_new (self, device);
+ if (is_ekr)
+ page = cc_wacom_ekr_page_new (self, device);
+ else
+ page = cc_wacom_page_new (self, device);
+
gtk_box_append (GTK_BOX (self->tablets), page);
g_hash_table_insert (self->pages, device, page);
}
diff --git a/panels/wacom/meson.build b/panels/wacom/meson.build
index 019b64fcf..f65a3db66 100644
--- a/panels/wacom/meson.build
+++ b/panels/wacom/meson.build
@@ -70,7 +70,8 @@ common_sources += wacom_gresource
sources = common_sources + files(
'cc-' + cappletname + '-panel.c',
- 'cc-drawing-area.c'
+ 'cc-drawing-area.c',
+ 'cc-wacom-ekr-page.c',
)
deps += libdevice_dep
diff --git a/panels/wacom/wacom.gresource.xml b/panels/wacom/wacom.gresource.xml
index ce133b751..1aa4df297 100644
--- a/panels/wacom/wacom.gresource.xml
+++ b/panels/wacom/wacom.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/control-center/wacom">
<file preprocess="xml-stripblanks">cc-wacom-panel.ui</file>
<file preprocess="xml-stripblanks">cc-wacom-page.ui</file>
+ <file preprocess="xml-stripblanks">cc-wacom-ekr-page.ui</file>
<file preprocess="xml-stripblanks">cc-wacom-stylus-page.ui</file>
<file preprocess="xml-stripblanks">button-mapping.ui</file>
<file preprocess="xml-stripblanks">calibrator/calibrator.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]