[gnome-settings-daemon] wacom: Split device listing function



commit 989acf8b7cd3a01de301f7ccf23cdacc7441f901
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 25 15:57:40 2011 +0000

    wacom: Split device listing function

 plugins/wacom/list-wacom.c |   42 ++++++++++++++++++++++++++++++------------
 1 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/plugins/wacom/list-wacom.c b/plugins/wacom/list-wacom.c
index aa61a4c..d707b7f 100644
--- a/plugins/wacom/list-wacom.c
+++ b/plugins/wacom/list-wacom.c
@@ -46,23 +46,16 @@ get_loc (GSettings *settings)
 #define BOOL_AS_STR(x) (x ? "yes" : "no")
 
 static void
-list_actual_devices (void)
+list_devices (GList *devices)
 {
-	GdkDeviceManager *mgr;
-	GList *list, *l;
-
-	mgr = gdk_display_get_device_manager (gdk_display_get_default ());
+	GList *l;
 
-	list = gdk_device_manager_list_devices (mgr, GDK_DEVICE_TYPE_SLAVE);
-	for (l = list; l ; l = l->next) {
+	for (l = devices; l ; l = l->next) {
 		GsdWacomDevice *device;
 		char *loc;
 
-		device = gsd_wacom_device_new (l->data);
-		if (gsd_wacom_device_get_device_type (device) == WACOM_TYPE_INVALID) {
-			g_object_unref (device);
-			continue;
-		}
+		device = l->data;
+
 		g_message ("*** Device '%s' (type: %s)",
 			   gsd_wacom_device_get_name (device),
 			   gsd_wacom_device_type_to_string (gsd_wacom_device_get_device_type (device)));
@@ -92,7 +85,32 @@ list_actual_devices (void)
 		}
 		g_object_unref (device);
 	}
+	g_list_free (devices);
+}
+
+static void
+list_actual_devices (void)
+{
+	GdkDeviceManager *mgr;
+	GList *list, *l, *devices;
+
+	mgr = gdk_display_get_device_manager (gdk_display_get_default ());
+
+	list = gdk_device_manager_list_devices (mgr, GDK_DEVICE_TYPE_SLAVE);
+	devices = NULL;
+	for (l = list; l ; l = l->next) {
+		GsdWacomDevice *device;
+
+		device = gsd_wacom_device_new (l->data);
+		if (gsd_wacom_device_get_device_type (device) == WACOM_TYPE_INVALID) {
+			g_object_unref (device);
+			continue;
+		}
+		devices = g_list_prepend (devices, device);
+	}
 	g_list_free (list);
+
+	list_devices (devices);
 }
 
 int main (int argc, char **argv)



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