[gnome-control-center/gnome-3-4] wacom: update the UI if a new tool comes in
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-4] wacom: update the UI if a new tool comes in
- Date: Fri, 25 May 2012 10:52:47 +0000 (UTC)
commit 5598edc4708276137e4d91c25aa7e9e24f607951
Author: Peter Hutterer <peter hutterer who-t net>
Date: Thu Apr 12 15:29:36 2012 +0200
wacom: update the UI if a new tool comes in
The device_added_cb is called once for each tool added. The wacom driver
hotplugs tools in the order stylus, eraser, cursor, pad.
update_current_page will add a new page once a tablet has stylus and
eraser, before cursor and pad exist. priv->pad is thus always NULL,
causing, cc_wacom_page's update_tablet_ui to remove the "Map Buttons..."
button for any device.
Change the code to update the tool list for every new tool we get,
merely triggering the visibility of the button instead of destroying it
completely.
https://bugzilla.gnome.org/show_bug.cgi?id=672691
panels/wacom/cc-wacom-page.c | 80 +++++++++++++++++++++++++++++-----------
panels/wacom/cc-wacom-page.h | 5 +++
panels/wacom/cc-wacom-panel.c | 11 +++---
3 files changed, 69 insertions(+), 27 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index f8c1910..a0cff9a 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -96,6 +96,32 @@ enum {
MODE_RELATIVE, /* stylus + eraser relative */
};
+/* Different types of layout for the tablet config */
+enum {
+ LAYOUT_NORMAL, /* tracking mode, button mapping */
+ LAYOUT_REVERSIBLE, /* tracking mode, button mapping, left-hand orientation */
+ LAYOUT_SCREEN /* button mapping, calibration, display resolution */
+};
+
+static void
+update_tablet_ui (CcWacomPage *page,
+ int layout);
+
+static int
+get_layout_type (GsdWacomDevice *device)
+{
+ int layout;
+
+ if (gsd_wacom_device_is_screen_tablet (device))
+ layout = LAYOUT_SCREEN;
+ else if (gsd_wacom_device_reversible (device))
+ layout = LAYOUT_REVERSIBLE;
+ else
+ layout = LAYOUT_NORMAL;
+
+ return layout;
+}
+
static void
set_calibration (gint *cal,
gsize ncal,
@@ -665,11 +691,14 @@ display_mapping_dialog_closed (GtkDialog *dialog,
CcWacomPage *page)
{
CcWacomPagePrivate *priv;
+ int layout;
priv = page->priv;
gtk_widget_destroy (priv->dialog);
priv->dialog = NULL;
priv->mapping = NULL;
+ layout = get_layout_type (priv->stylus);
+ update_tablet_ui (page, layout);
}
static void
@@ -990,13 +1019,6 @@ stylus_changed (GsdWacomDevice *device,
gsd_wacom_stylus_get_name (stylus));
}
-/* Different types of layout for the tablet config */
-enum {
- LAYOUT_NORMAL, /* tracking mode, button mapping */
- LAYOUT_REVERSIBLE, /* tracking mode, button mapping, left-hand orientation */
- LAYOUT_SCREEN /* button mapping, calibration, display resolution */
-};
-
static void
remove_left_handed (CcWacomPagePrivate *priv)
{
@@ -1059,6 +1081,33 @@ update_tablet_ui (CcWacomPage *page,
}
}
+gboolean
+cc_wacom_page_update_tools (CcWacomPage *page,
+ GsdWacomDevice *stylus,
+ GsdWacomDevice *eraser,
+ GsdWacomDevice *pad)
+{
+ CcWacomPagePrivate *priv;
+ int layout;
+ gboolean changed;
+
+ /* Type of layout */
+ layout = get_layout_type (stylus);
+
+ priv = page->priv;
+ changed = (priv->stylus != stylus || priv->eraser != eraser || priv->pad != pad);
+ if (!changed)
+ return FALSE;
+
+ priv->stylus = stylus;
+ priv->eraser = eraser;
+ priv->pad = pad;
+
+ update_tablet_ui (CC_WACOM_PAGE (page), layout);
+
+ return TRUE;
+}
+
GtkWidget *
cc_wacom_page_new (CcWacomPanel *panel,
GsdWacomDevice *stylus,
@@ -1067,7 +1116,6 @@ cc_wacom_page_new (CcWacomPanel *panel,
{
CcWacomPage *page;
CcWacomPagePrivate *priv;
- int layout;
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);
@@ -1081,10 +1129,8 @@ cc_wacom_page_new (CcWacomPanel *panel,
page = g_object_new (CC_TYPE_WACOM_PAGE, NULL);
priv = page->priv;
- priv->panel = panel;
- priv->stylus = stylus;
- priv->eraser = eraser;
- priv->pad = pad;
+
+ cc_wacom_page_update_tools (page, stylus, eraser, pad);
/* FIXME move this to construct */
priv->wacom_settings = gsd_wacom_device_get_settings (stylus);
@@ -1093,16 +1139,6 @@ cc_wacom_page_new (CcWacomPanel *panel,
/* Tablet name */
gtk_label_set_text (GTK_LABEL (WID ("label-tabletmodel")), gsd_wacom_device_get_name (stylus));
- /* Type of layout */
- if (gsd_wacom_device_is_screen_tablet (stylus))
- layout = LAYOUT_SCREEN;
- else if (gsd_wacom_device_reversible (stylus))
- layout = LAYOUT_REVERSIBLE;
- else
- layout = LAYOUT_NORMAL;
-
- update_tablet_ui (page, layout);
-
/* Left-handedness */
if (gsd_wacom_device_reversible (stylus))
set_left_handed_from_gsettings (page);
diff --git a/panels/wacom/cc-wacom-page.h b/panels/wacom/cc-wacom-page.h
index 7b8fc2d..12c520e 100644
--- a/panels/wacom/cc-wacom-page.h
+++ b/panels/wacom/cc-wacom-page.h
@@ -74,6 +74,11 @@ GtkWidget * cc_wacom_page_new (CcWacomPanel *panel,
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,
GtkNotebook *notebook,
gboolean ignore_first_page);
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 1cfdd5a..087d1b6 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -200,12 +200,11 @@ update_current_page (CcWacomPanel *self)
tablets = g_hash_table_get_values (ht);
for (l = tablets; l; l = l->next) {
Tablet *tablet;
+ GtkWidget *page;
tablet = l->data;
if (tablet->stylus == NULL ||
tablet->eraser == NULL) {
- GtkWidget *page;
-
page = g_hash_table_lookup (priv->pages, tablet->name);
if (page != NULL) {
remove_page (GTK_NOTEBOOK (priv->notebook), page);
@@ -215,9 +214,9 @@ update_current_page (CcWacomPanel *self)
}
continue;
}
-
- if (g_hash_table_lookup (priv->pages, tablet->name) == NULL) {
- GtkWidget *page;
+ /* this code is called once the stylus + eraser were 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);
cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK (priv->notebook), TRUE);
gtk_widget_show (page);
@@ -225,6 +224,8 @@ update_current_page (CcWacomPanel *self)
g_hash_table_insert (priv->pages, g_strdup (tablet->name), page);
changed = TRUE;
+ } else {
+ cc_wacom_page_update_tools (CC_WACOM_PAGE (page), tablet->stylus, tablet->eraser, tablet->pad);
}
}
g_list_free (tablets);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]