[gnome-settings-daemon] wacom: Create fake devices from database



commit 7a6d8c36523da86d0c4c84f846bf1ef60b7b899f
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Dec 12 16:57:27 2011 +0000

    wacom: Create fake devices from database
    
    Instead of keeping a load of data ourselves.

 plugins/wacom/gsd-wacom-device.c |  105 ++++++++++----------------------------
 plugins/wacom/gsd-wacom-device.h |    6 +--
 2 files changed, 28 insertions(+), 83 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index a0baf15..9ea02eb 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -610,82 +610,52 @@ gsd_wacom_device_type_to_string (GsdWacomDeviceType type)
 GsdWacomDevice *
 gsd_wacom_device_create_fake (GsdWacomDeviceType  type,
 			      const char         *name,
-			      const char         *tool_name,
-			      gboolean            reversible,
-			      gboolean            is_screen_tablet,
-			      const char         *icon_name,
-			      guint               num_styli)
+			      const char         *tool_name)
 {
-	/* FIXME Look in libwacom's database instead */
-#if 0
 	GsdWacomDevice *device;
 	GsdWacomDevicePrivate *priv;
-	guint i;
+	WacomDevice *wacom_device;
 
 	device = GSD_WACOM_DEVICE (g_object_new (GSD_TYPE_WACOM_DEVICE, NULL));
 
+	if (db == NULL)
+		db = libwacom_database_new ();
+
 	priv = device->priv;
 	priv->type = type;
-	priv->name = g_strdup (name);
 	priv->tool_name = g_strdup (tool_name);
-	priv->reversible = reversible;
-	priv->is_screen_tablet = is_screen_tablet;
-	priv->icon_name = g_strdup (icon_name);
-	priv->wacom_settings = g_settings_new (SETTINGS_WACOM_DIR);
-
-	for (i = 0; i < num_styli ; i++) {
-		GsdWacomStylus *stylus;
-		GSettings *settings;
-
-		if (device->priv->type == WACOM_TYPE_STYLUS) {
-			settings = g_settings_new (SETTINGS_WACOM_DIR "." SETTINGS_STYLUS_DIR);
-			stylus = gsd_wacom_stylus_new (device, settings, _("Stylus"), "wacom-stylus");
-		} else {
-			settings = g_settings_new (SETTINGS_WACOM_DIR "." SETTINGS_ERASER_DIR);
-			stylus = gsd_wacom_stylus_new (device, settings, "Eraser XXX", NULL);
-		}
-		device->priv->styli = g_list_append (device->priv->styli, stylus);
-	}
+	wacom_device = libwacom_new_from_name (db, name, NULL);
+	gsd_wacom_device_update_from_db (device, wacom_device, name);
+	libwacom_destroy (wacom_device);
 
 	return device;
-#endif
-	return NULL;
 }
 
 GList *
 gsd_wacom_device_create_fake_cintiq (void)
 {
+#if 0
 	GsdWacomDevice *device;
 	GList *devices;
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_STYLUS,
 					       "Wacom Cintiq 21UX2",
-					       "Wacom Cintiq 21UX2 stylus",
-					       TRUE,
-					       TRUE,
-					       "wacom-tablet-cintiq",
-					       1);
+					       "Wacom Cintiq 21UX2 stylus");
 	devices = g_list_prepend (NULL, device);
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_ERASER,
 					       "Wacom Cintiq 21UX2",
-					       "Wacom Cintiq 21UX2 eraser",
-					       TRUE,
-					       TRUE,
-					       "wacom-tablet-cintiq",
-					       1);
+					       "Wacom Cintiq 21UX2 eraser");
 	devices = g_list_prepend (devices, device);
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_PAD,
 					       "Wacom Cintiq 21UX2",
-					       "Wacom Cintiq 21UX2 pad",
-					       TRUE,
-					       TRUE,
-					       "wacom-tablet-cintiq",
-					       0);
+					       "Wacom Cintiq 21UX2 pad");
 	devices = g_list_prepend (devices, device);
 
 	return devices;
+#endif
+	return NULL;
 }
 
 GList *
@@ -695,39 +665,23 @@ gsd_wacom_device_create_fake_bt (void)
 	GList *devices;
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_STYLUS,
-					       "WACOM Pen Tablet",
-					       "WACOM Pen Tablet stylus",
-					       FALSE,
-					       FALSE,
-					       "wacom-tablet",
-					       1);
+					       "Graphire Wireless",
+					       "Graphire Wireless stylus");
 	devices = g_list_prepend (NULL, device);
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_ERASER,
-					       "WACOM Pen Tablet",
-					       "WACOM Pen Tablet eraser",
-					       FALSE,
-					       FALSE,
-					       "wacom-tablet",
-					       1);
+					       "Graphire Wireless",
+					       "Graphire Wireless eraser");
 	devices = g_list_prepend (devices, device);
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_PAD,
-					       "WACOM Pen Tablet",
-					       "WACOM Pen Tablet pad",
-					       FALSE,
-					       FALSE,
-					       "wacom-tablet",
-					       0);
+					       "Graphire Wireless",
+					       "Graphire Wireless pad");
 	devices = g_list_prepend (devices, device);
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_CURSOR,
-					       "WACOM Pen Tablet",
-					       "WACOM Pen Tablet cursor",
-					       FALSE,
-					       FALSE,
-					       "wacom-tablet",
-					       0);
+					       "Graphire Wireless",
+					       "Graphire Wireless cursor");
 	devices = g_list_prepend (devices, device);
 
 	return devices;
@@ -736,26 +690,21 @@ gsd_wacom_device_create_fake_bt (void)
 GList *
 gsd_wacom_device_create_fake_x201 (void)
 {
+#if 0
 	GsdWacomDevice *device;
 	GList *devices;
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_STYLUS,
 					       "Serial Wacom Tablet WACf004",
-					       "Serial Wacom Tablet WACf004 stylus",
-					       FALSE,
-					       TRUE,
-					       "wacom-tablet-pc",
-					       1);
+					       "Serial Wacom Tablet WACf004 stylus");
 	devices = g_list_prepend (NULL, device);
 
 	device = gsd_wacom_device_create_fake (WACOM_TYPE_ERASER,
 					       "Serial Wacom Tablet WACf004",
-					       "Serial Wacom Tablet WACf004 eraser",
-					       FALSE,
-					       TRUE,
-					       "wacom-tablet-pc",
-					       1);
+					       "Serial Wacom Tablet WACf004 eraser");
 	devices = g_list_prepend (devices, device);
 
 	return devices;
+#endif
+	return NULL;
 }
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index d3701a8..ecea0ae 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -99,11 +99,7 @@ const char     * gsd_wacom_device_type_to_string   (GsdWacomDeviceType type);
 /* Helper and debug functions */
 GsdWacomDevice * gsd_wacom_device_create_fake (GsdWacomDeviceType  type,
 					       const char         *name,
-					       const char         *tool_name,
-					       gboolean            reversible,
-					       gboolean            is_screen_tablet,
-					       const char         *icon_name,
-					       guint               num_styli);
+					       const char         *tool_name);
 
 GList * gsd_wacom_device_create_fake_cintiq   (void);
 GList * gsd_wacom_device_create_fake_bt       (void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]