[gnome-control-center] wacom: Add functions to create fake devices



commit 05546dd3ffa130e1c7961b8671c9150f129d3d34
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 25 16:09:13 2011 +0000

    wacom: Add functions to create fake devices

 panels/wacom/gsd-wacom-device.c |   77 +++++++++++++++++++++++++++++++++++++++
 panels/wacom/gsd-wacom-device.h |   11 ++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/panels/wacom/gsd-wacom-device.c b/panels/wacom/gsd-wacom-device.c
index c3f8b26..e1fdf27 100644
--- a/panels/wacom/gsd-wacom-device.c
+++ b/panels/wacom/gsd-wacom-device.c
@@ -509,3 +509,80 @@ gsd_wacom_device_type_to_string (GsdWacomDeviceType type)
 		return "Unknown 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)
+{
+	GsdWacomDevice *device;
+	GsdWacomDevicePrivate *priv;
+	guint i;
+
+	device = GSD_WACOM_DEVICE (g_object_new (GSD_TYPE_WACOM_DEVICE, NULL));
+
+	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);
+	}
+
+	return device;
+}
+
+GList *
+gsd_wacom_device_create_fake_cintiq (void)
+{
+	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);
+	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);
+	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",
+					       1);
+	devices = g_list_prepend (devices, device);
+
+	return devices;
+}
diff --git a/panels/wacom/gsd-wacom-device.h b/panels/wacom/gsd-wacom-device.h
index 420e709..59ce70e 100644
--- a/panels/wacom/gsd-wacom-device.h
+++ b/panels/wacom/gsd-wacom-device.h
@@ -96,6 +96,17 @@ GSettings      * gsd_wacom_device_get_settings     (GsdWacomDevice *device);
 GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
 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);
+
+GList * gsd_wacom_device_create_fake_cintiq   (void);
+
 G_END_DECLS
 
 #endif /* __GSD_WACOM_DEVICE_MANAGER_H */



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