diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2015-03-13 13:11:10 -0400 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2015-04-01 11:15:29 +0200 |
commit | 66cb45bdad214ef9ce6db7316fb13a8417b28647 (patch) | |
tree | 91fff6233807787c363a715902510b1419abe430 | |
parent | 28574f0386d5db06ee421bb990f4c5c5b3f12373 (diff) | |
download | gnome-control-center-66cb45bdad214ef9ce6db7316fb13a8417b28647.tar.gz |
wacom: do not bail out if the tablet doesn't have an eraser
Tablets have not always an eraser (most of the generic tablets like Huion,
UC-Logic, etc... don't). We should not reject such tablets.
Commit 54849a9 (wacom: Only the stylus and eraser tools need to exist)
mentioned that we were not sure about eraser, and I think we should not
assume one either.
To do so, we simply ignore the eraser xinput node and rely on
libwacom to actually provide the eraser information.
If the stylus does not have the eraser tip, we may fall in the
LAYOUT_OTHER case. We have a picture of a generic Wacom pen with an
eraser, and the leaders linking the widget to the picture are scrambled.
To prevent that, gray out the eraser pressure slider so that we do not
break the layout.
https://bugzilla.gnome.org/show_bug.cgi?id=746117
-rw-r--r-- | panels/wacom/cc-wacom-page.c | 24 | ||||
-rw-r--r-- | panels/wacom/cc-wacom-page.h | 2 | ||||
-rw-r--r-- | panels/wacom/cc-wacom-panel.c | 14 | ||||
-rw-r--r-- | panels/wacom/cc-wacom-stylus-page.c | 42 | ||||
-rw-r--r-- | panels/wacom/cc-wacom-stylus-page.h | 3 | ||||
-rw-r--r-- | panels/wacom/test-wacom.c | 2 |
6 files changed, 38 insertions, 49 deletions
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c index 2f7fc422a..812d673d3 100644 --- a/panels/wacom/cc-wacom-page.c +++ b/panels/wacom/cc-wacom-page.c @@ -61,7 +61,7 @@ enum { struct _CcWacomPagePrivate { CcWacomPanel *panel; - GsdWacomDevice *stylus, *eraser, *pad; + GsdWacomDevice *stylus, *pad; GtkBuilder *builder; GtkWidget *nav; GtkWidget *notebook; @@ -826,7 +826,7 @@ add_styli (CcWacomPage *page) styli = gsd_wacom_device_list_styli (priv->stylus); for (l = styli; l; l = l->next) { - GsdWacomStylus *stylus, *eraser; + GsdWacomStylus *stylus; GtkWidget *page; stylus = l->data; @@ -834,15 +834,7 @@ add_styli (CcWacomPage *page) if (gsd_wacom_stylus_get_stylus_type (stylus) == WACOM_STYLUS_TYPE_PUCK) continue; - if (gsd_wacom_stylus_get_has_eraser (stylus)) { - GsdWacomDeviceType type; - type = gsd_wacom_stylus_get_stylus_type (stylus); - eraser = gsd_wacom_device_get_stylus_for_type (priv->eraser, type); - } else { - eraser = NULL; - } - - page = cc_wacom_stylus_page_new (stylus, eraser); + page = cc_wacom_stylus_page_new (stylus); cc_wacom_stylus_page_set_navigation (CC_WACOM_STYLUS_PAGE (page), GTK_NOTEBOOK (priv->notebook)); gtk_widget_show (page); gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, NULL); @@ -964,7 +956,6 @@ update_tablet_ui (CcWacomPage *page, gboolean cc_wacom_page_update_tools (CcWacomPage *page, GsdWacomDevice *stylus, - GsdWacomDevice *eraser, GsdWacomDevice *pad) { CcWacomPagePrivate *priv; @@ -975,12 +966,11 @@ cc_wacom_page_update_tools (CcWacomPage *page, layout = get_layout_type (stylus); priv = page->priv; - changed = (priv->stylus != stylus || priv->eraser != eraser || priv->pad != pad); + changed = (priv->stylus != stylus || priv->pad != pad); if (!changed) return FALSE; priv->stylus = stylus; - priv->eraser = eraser; priv->pad = pad; update_tablet_ui (CC_WACOM_PAGE (page), layout); @@ -991,7 +981,6 @@ cc_wacom_page_update_tools (CcWacomPage *page, GtkWidget * cc_wacom_page_new (CcWacomPanel *panel, GsdWacomDevice *stylus, - GsdWacomDevice *eraser, GsdWacomDevice *pad) { CcWacomPage *page; @@ -1000,9 +989,6 @@ cc_wacom_page_new (CcWacomPanel *panel, g_return_val_if_fail (GSD_IS_WACOM_DEVICE (stylus), NULL); g_return_val_if_fail (gsd_wacom_device_get_device_type (stylus) == WACOM_TYPE_STYLUS, NULL); - g_return_val_if_fail (GSD_IS_WACOM_DEVICE (eraser), NULL); - g_return_val_if_fail (gsd_wacom_device_get_device_type (eraser) == WACOM_TYPE_ERASER, NULL); - if (pad != NULL) g_return_val_if_fail (gsd_wacom_device_get_device_type (pad) == WACOM_TYPE_PAD, NULL); @@ -1011,7 +997,7 @@ cc_wacom_page_new (CcWacomPanel *panel, priv = page->priv; priv->panel = panel; - cc_wacom_page_update_tools (page, stylus, eraser, pad); + cc_wacom_page_update_tools (page, stylus, pad); /* FIXME move this to construct */ priv->wacom_settings = gsd_wacom_device_get_settings (stylus); diff --git a/panels/wacom/cc-wacom-page.h b/panels/wacom/cc-wacom-page.h index 9c9cbdef6..9cb24f326 100644 --- a/panels/wacom/cc-wacom-page.h +++ b/panels/wacom/cc-wacom-page.h @@ -70,12 +70,10 @@ GType cc_wacom_page_get_type (void) G_GNUC_CONST; GtkWidget * cc_wacom_page_new (CcWacomPanel *panel, GsdWacomDevice *stylus, - GsdWacomDevice *eraser, GsdWacomDevice *pad); gboolean cc_wacom_page_update_tools (CcWacomPage *page, GsdWacomDevice *stylus, - GsdWacomDevice *eraser, GsdWacomDevice *pad); void cc_wacom_page_set_navigation (CcWacomPage *page, diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c index a8122bbef..b3bab89f5 100644 --- a/panels/wacom/cc-wacom-panel.c +++ b/panels/wacom/cc-wacom-panel.c @@ -54,7 +54,6 @@ struct _CcWacomPanelPrivate typedef struct { const char *name; GsdWacomDevice *stylus; - GsdWacomDevice *eraser; GsdWacomDevice *pad; } Tablet; @@ -298,12 +297,10 @@ update_current_page (CcWacomPanel *self) case WACOM_TYPE_STYLUS: tablet->stylus = device; break; - case WACOM_TYPE_ERASER: - tablet->eraser = device; - break; case WACOM_TYPE_PAD: tablet->pad = device; break; + case WACOM_TYPE_ERASER: default: /* Nothing */ ; @@ -319,8 +316,7 @@ update_current_page (CcWacomPanel *self) GtkWidget *page; tablet = l->data; - if (tablet->stylus == NULL || - tablet->eraser == NULL) { + if (tablet->stylus == NULL) { page = g_hash_table_lookup (priv->pages, tablet->name); if (page != NULL) { remove_page (GTK_NOTEBOOK (priv->notebook), page); @@ -330,10 +326,10 @@ update_current_page (CcWacomPanel *self) } continue; } - /* this code is called once the stylus + eraser were set up, but the pad does not exist yet */ + /* this code is called once the stylus is set up, but the pad does not exist yet */ page = g_hash_table_lookup (priv->pages, tablet->name); if (page == NULL) { - page = cc_wacom_page_new (self, tablet->stylus, tablet->eraser, tablet->pad); + page = cc_wacom_page_new (self, tablet->stylus, tablet->pad); cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK (priv->notebook), TRUE); gtk_widget_show (page); gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, NULL); @@ -341,7 +337,7 @@ update_current_page (CcWacomPanel *self) changed = TRUE; } else { - cc_wacom_page_update_tools (CC_WACOM_PAGE (page), tablet->stylus, tablet->eraser, tablet->pad); + cc_wacom_page_update_tools (CC_WACOM_PAGE (page), tablet->stylus, tablet->pad); } } g_list_free (tablets); diff --git a/panels/wacom/cc-wacom-stylus-page.c b/panels/wacom/cc-wacom-stylus-page.c index fe7e05948..d3eeddf9d 100644 --- a/panels/wacom/cc-wacom-stylus-page.c +++ b/panels/wacom/cc-wacom-stylus-page.c @@ -38,7 +38,7 @@ G_DEFINE_TYPE (CcWacomStylusPage, cc_wacom_stylus_page, GTK_TYPE_BOX) struct _CcWacomStylusPagePrivate { - GsdWacomStylus *stylus, *eraser; + GsdWacomStylus *stylus; GtkBuilder *builder; GtkWidget *nav; GSettings *stylus_settings, *eraser_settings; @@ -353,9 +353,10 @@ set_icon_name (CcWacomStylusPage *page, /* Different types of layout for the stylus config */ enum { - LAYOUT_NORMAL, /* eraser, 2 buttons, tip */ - LAYOUT_INKING, /* tip */ - LAYOUT_AIRBRUSH, /* eraser, 1 button, tip */ + LAYOUT_NORMAL, /* eraser, 2 buttons, tip */ + LAYOUT_INKING, /* tip */ + LAYOUT_AIRBRUSH, /* eraser, 1 button, tip */ + LAYOUT_GENERIC_2_BUTTONS_NO_ERASER, /* 2 buttons, tip, no eraser */ LAYOUT_OTHER }; @@ -417,6 +418,12 @@ update_stylus_ui (CcWacomStylusPage *page, gtk_container_child_set (CWID ("stylus-controls-grid"), WID ("box-tip-feel"), "top_attach", 2, NULL); + break; + case LAYOUT_GENERIC_2_BUTTONS_NO_ERASER: + /* Gray out eraser until we have a proper picture */ + gtk_widget_set_sensitive (WID ("eraser-box"), FALSE); + gtk_widget_set_sensitive (WID ("label-eraser-feel"), FALSE); + break; case LAYOUT_OTHER: /* We already warn about it in cc_wacom_stylus_page_new () */ break; @@ -424,13 +431,13 @@ update_stylus_ui (CcWacomStylusPage *page, } GtkWidget * -cc_wacom_stylus_page_new (GsdWacomStylus *stylus, - GsdWacomStylus *eraser) +cc_wacom_stylus_page_new (GsdWacomStylus *stylus) { CcWacomStylusPage *page; CcWacomStylusPagePrivate *priv; int num_buttons; int layout; + int has_eraser; g_return_val_if_fail (GSD_IS_WACOM_STYLUS (stylus), NULL); @@ -438,26 +445,28 @@ cc_wacom_stylus_page_new (GsdWacomStylus *stylus, priv = page->priv; priv->stylus = stylus; - priv->eraser = eraser; /* Icon */ set_icon_name (page, "image-stylus", gsd_wacom_stylus_get_icon_name (stylus)); /* Settings */ priv->stylus_settings = gsd_wacom_stylus_get_settings (stylus); - if (eraser != NULL) - priv->eraser_settings = gsd_wacom_stylus_get_settings (eraser); + has_eraser = gsd_wacom_stylus_get_has_eraser (stylus); + if (has_eraser) + priv->eraser_settings = gsd_wacom_stylus_get_settings (stylus); /* Stylus name */ gtk_label_set_text (GTK_LABEL (WID ("label-stylus")), gsd_wacom_stylus_get_name (stylus)); num_buttons = gsd_wacom_stylus_get_num_buttons (stylus); - if (num_buttons == 0 && eraser == NULL) + if (num_buttons == 0 && !has_eraser) layout = LAYOUT_INKING; - else if (num_buttons == 2 && eraser != NULL) + else if (num_buttons == 2 && has_eraser) layout = LAYOUT_NORMAL; - else if (num_buttons == 1 && eraser != NULL) + else if (num_buttons == 1 && has_eraser) layout = LAYOUT_AIRBRUSH; + else if (num_buttons == 2 && !has_eraser) + layout = LAYOUT_GENERIC_2_BUTTONS_NO_ERASER; else { layout = LAYOUT_OTHER; if (num_buttons == 0) @@ -465,11 +474,12 @@ cc_wacom_stylus_page_new (GsdWacomStylus *stylus, else if (num_buttons == 1) remove_button (priv); - if (eraser == NULL) - remove_eraser (priv); + /* Gray out eraser if not available */ + gtk_widget_set_sensitive (WID ("eraser-box"), has_eraser); + gtk_widget_set_sensitive (WID ("label-eraser-feel"), has_eraser); g_warning ("The layout of this page is not known, %d buttons, %s eraser", - num_buttons, eraser ? "with" : "without"); + num_buttons, has_eraser ? "with" : "without"); } update_stylus_ui (page, layout); @@ -480,7 +490,7 @@ cc_wacom_stylus_page_new (GsdWacomStylus *stylus, set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-bottombutton")), priv->stylus_settings, 2); set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-tip-feel")), priv->stylus_settings); - if (eraser != NULL) + if (has_eraser) set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-eraser-feel")), priv->eraser_settings); g_object_set (G_OBJECT (page), "margin-top", 16, NULL); diff --git a/panels/wacom/cc-wacom-stylus-page.h b/panels/wacom/cc-wacom-stylus-page.h index dc19f86b0..7941351cd 100644 --- a/panels/wacom/cc-wacom-stylus-page.h +++ b/panels/wacom/cc-wacom-stylus-page.h @@ -67,8 +67,7 @@ struct _CcWacomStylusPageClass GType cc_wacom_stylus_page_get_type (void) G_GNUC_CONST; -GtkWidget * cc_wacom_stylus_page_new (GsdWacomStylus *stylus, - GsdWacomStylus *eraser); +GtkWidget * cc_wacom_stylus_page_new (GsdWacomStylus *stylus); GsdWacomStylus * cc_wacom_stylus_page_get_stylus (CcWacomStylusPage *page); diff --git a/panels/wacom/test-wacom.c b/panels/wacom/test-wacom.c index 2da02fba4..5ad657bb7 100644 --- a/panels/wacom/test-wacom.c +++ b/panels/wacom/test-wacom.c @@ -54,7 +54,7 @@ add_page (GList *devices, } g_list_free (devices); - widget = cc_wacom_page_new (NULL, stylus, eraser, pad); + widget = cc_wacom_page_new (NULL, stylus, pad); cc_wacom_page_set_navigation (CC_WACOM_PAGE (widget), GTK_NOTEBOOK (notebook), FALSE); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, NULL); gtk_widget_show (widget); |