[gnome-color-manager] trivial: Remove gcm_device_new() -- we should never create devices without backing types



commit 9263fdeaff3a0ce937f7c233bd24487f344e9908
Author: Richard Hughes <richard hughsie com>
Date:   Tue Feb 9 12:17:55 2010 +0000

    trivial: Remove gcm_device_new() -- we should never create devices without backing types

 src/gcm-client.c |   22 ++++++++++++++++++----
 src/gcm-device.c |   13 -------------
 src/gcm-device.h |    1 -
 3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index bfe3229..751c682 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -578,12 +578,26 @@ gcm_client_add_unconnected_device (GcmClient *client, GKeyFile *keyfile, const g
 		goto out;
 	type_text = g_key_file_get_string (keyfile, id, "type", NULL);
 	type = gcm_device_type_enum_from_string (type_text);
+	if (type == GCM_DEVICE_TYPE_ENUM_UNKNOWN)
+		goto out;
 
-	/* create device */
-	if (type == GCM_DEVICE_TYPE_ENUM_DISPLAY)
+	/* create device or specified type */
+	if (type == GCM_DEVICE_TYPE_ENUM_DISPLAY) {
 		device = gcm_device_xrandr_new ();
-	else
-		device = gcm_device_new ();
+	} else if (type == GCM_DEVICE_TYPE_ENUM_PRINTER) {
+		device = gcm_device_cups_new ();
+	} else if (type == GCM_DEVICE_TYPE_ENUM_CAMERA) {
+		/* FIXME: use GPhoto? */
+		device = gcm_device_udev_new ();
+	} else if (type == GCM_DEVICE_TYPE_ENUM_SCANNER) {
+		/* FIXME: use SANE? */
+		device = gcm_device_udev_new ();
+	} else {
+		egg_warning ("device type internal error");
+		goto out;
+	}
+
+	/* create device */
 	g_object_set (device,
 		      "type", type,
 		      "id", id,
diff --git a/src/gcm-device.c b/src/gcm-device.c
index 104235a..7a2c78a 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -671,19 +671,6 @@ gcm_device_finalize (GObject *object)
 	G_OBJECT_CLASS (gcm_device_parent_class)->finalize (object);
 }
 
-/**
- * gcm_device_new:
- *
- * Return value: a new GcmDevice object.
- **/
-GcmDevice *
-gcm_device_new (void)
-{
-	GcmDevice *device;
-	device = g_object_new (GCM_TYPE_DEVICE, NULL);
-	return GCM_DEVICE (device);
-}
-
 /***************************************************************************
  ***                          MAKE CHECK TESTS                           ***
  ***************************************************************************/
diff --git a/src/gcm-device.h b/src/gcm-device.h
index b8a52a7..8600a4e 100644
--- a/src/gcm-device.h
+++ b/src/gcm-device.h
@@ -55,7 +55,6 @@ struct _GcmDeviceClass
 };
 
 GType		 gcm_device_get_type		  	(void);
-GcmDevice	*gcm_device_new				(void);
 const gchar	*gcm_device_get_id			(GcmDevice		*device);
 gboolean	 gcm_device_load			(GcmDevice		*device,
 							 GError			**error);



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