[gnome-control-center/wip/carlosg/ekr-loves-27qhd: 2/4] wacom: Cater for multiple pads in the CcWacomPage
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/carlosg/ekr-loves-27qhd: 2/4] wacom: Cater for multiple pads in the CcWacomPage
- Date: Thu, 5 Dec 2019 16:48:30 +0000 (UTC)
commit e6565be69408eb8458a89b5fbc2f9ff480812fdd
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Dec 5 15:36:03 2019 +0100
wacom: Cater for multiple pads in the CcWacomPage
We don't need to track them much specifically, as we delegate pad
button mapping UI on GNOME Shell. It is however possible to have
tablets with 0 to N pads (upper bound within sanity = 2), so we
must at least reflect that in the "Map Buttons..." button visibility.
This distinction is most important for the combination of EKR plus
Cintiq 27QHD, as this is a pad-less tablet, for which we wouldn't
usually show the "Map buttons..." action.
https://gitlab.gnome.org/GNOME/gnome-control-center/issues/415
panels/wacom/cc-wacom-page.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index c037ff88b..54ff2e39c 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -68,7 +68,7 @@ struct _CcWacomPage
CcWacomPanel *panel;
CcWacomDevice *stylus;
- CcWacomDevice *pad;
+ GList *pads;
GtkBuilder *builder;
GtkWidget *nav;
GtkWidget *notebook;
@@ -376,15 +376,17 @@ static void
setup_button_mapping (CcWacomPage *page)
{
GDesktopPadButtonAction action;
+ CcWacomDevice *pad;
GtkWidget *list_box;
guint i, n_buttons;
GSettings *settings;
list_box = MWID ("shortcuts_list");
- n_buttons = cc_wacom_device_get_num_buttons (page->pad);
+ pad = page->pads->data;
+ n_buttons = cc_wacom_device_get_num_buttons (pad);
for (i = 0; i < n_buttons; i++) {
- settings = cc_wacom_device_get_button_settings (page->pad, i);
+ settings = cc_wacom_device_get_button_settings (pad, i);
if (!settings)
continue;
@@ -470,7 +472,9 @@ set_osd_visibility (CcWacomPage *page)
const gchar *device_path;
proxy = cc_wacom_panel_get_gsd_wacom_bus_proxy (page->panel);
- gsd_device = cc_wacom_device_get_device (page->pad);
+
+ /* Pick the first device, the OSD may change later between them */
+ gsd_device = cc_wacom_device_get_device (page->pads->data);
device_path = gsd_device_get_device_file (gsd_device);
@@ -720,7 +724,8 @@ cc_wacom_page_dispose (GObject *object)
g_clear_pointer (&self->dialog, gtk_widget_destroy);
g_clear_object (&self->builder);
g_clear_object (&self->header_group);
- g_clear_object (&self->pad);
+ g_list_free_full (self->pads, g_object_unref);
+ self->pads = NULL;
self->panel = NULL;
@@ -916,7 +921,7 @@ set_page_layout (CcWacomPage *page,
static void
update_pad_availability (CcWacomPage *page)
{
- gtk_widget_set_visible (WID ("map-buttons-button"), page->pad != NULL);
+ gtk_widget_set_visible (WID ("map-buttons-button"), page->pads != NULL);
}
static void
@@ -938,7 +943,7 @@ check_add_pad (CcWacomPage *page,
return;
}
- g_set_object (&page->pad, wacom_device);
+ page->pads = g_list_prepend (page->pads, wacom_device);
update_pad_availability (page);
}
@@ -946,11 +951,19 @@ static void
check_remove_pad (CcWacomPage *page,
GsdDevice *gsd_device)
{
+ GList *l;
+
if ((gsd_device_get_device_type (gsd_device) & GSD_DEVICE_TYPE_PAD) == 0)
return;
- if (page->pad && cc_wacom_device_get_device (page->pad) == gsd_device)
- page->pad = NULL;
+ for (l = page->pads; l; l = l->next) {
+ CcWacomDevice *wacom_device = l->data;
+ if (cc_wacom_device_get_device (wacom_device) == gsd_device) {
+ page->pads = g_list_delete_link (page->pads, l);
+ g_object_unref (wacom_device);
+ }
+ }
+
update_pad_availability (page);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]