[gnome-color-manager] trivial: Split out the device-specific data into thier own subclasses



commit fef658109f2d662a8fd4ead88513ba97f24d2c90
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 4 14:31:51 2010 +0000

    trivial: Split out the device-specific data into thier own subclasses

 src/Makefile.am         |    6 ++
 src/gcm-client.c        |   11 ++-
 src/gcm-dbus.c          |    2 +-
 src/gcm-device-cups.c   |  162 +++++++++++++++++++++++++++++++++++++++++++++++
 src/gcm-device-cups.h   |   59 +++++++++++++++++
 src/gcm-device-sysfs.c  |  160 ++++++++++++++++++++++++++++++++++++++++++++++
 src/gcm-device-sysfs.h  |   59 +++++++++++++++++
 src/gcm-device-xrandr.c |  160 ++++++++++++++++++++++++++++++++++++++++++++++
 src/gcm-device-xrandr.h |   59 +++++++++++++++++
 src/gcm-device.c        |   44 +------------
 src/gcm-prefs.c         |    2 +-
 src/gcm-utils.c         |    2 +-
 12 files changed, 678 insertions(+), 48 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6d998ce..84bf635 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,6 +51,12 @@ libgcmshared_a_SOURCES =				\
 	gcm-color-device.h				\
 	gcm-device.c					\
 	gcm-device.h					\
+	gcm-device-xrandr.c				\
+	gcm-device-xrandr.h				\
+	gcm-device-sysfs.c				\
+	gcm-device-sysfs.h				\
+	gcm-device-cups.c				\
+	gcm-device-cups.h				\
 	gcm-cie-widget.c				\
 	gcm-cie-widget.h				\
 	gcm-trc-widget.c				\
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 8e28993..86c39ac 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -36,6 +36,9 @@
 #include <math.h>
 
 #include "gcm-client.h"
+#include "gcm-device-xrandr.h"
+#include "gcm-device-sysfs.h"
+#include "gcm-device-cups.h"
 #include "gcm-screen.h"
 #include "gcm-utils.h"
 #include "gcm-edid.h"
@@ -228,7 +231,7 @@ gcm_client_gudev_add_type (GcmClient *client, GUdevDevice *udev_device, GcmDevic
 	sysfs_path = g_udev_device_get_sysfs_path (udev_device);
 
 	/* create device */
-	device = gcm_device_new ();
+	device = gcm_device_sysfs_new ();
 	manufacturer = g_strdup (g_udev_device_get_property (udev_device, "ID_VENDOR"));
 	model = g_strdup (g_udev_device_get_property (udev_device, "ID_MODEL"));
 	serial = g_strdup (g_udev_device_get_property (udev_device, "ID_SERIAL"));
@@ -255,7 +258,7 @@ gcm_client_gudev_add_type (GcmClient *client, GUdevDevice *udev_device, GcmDevic
 		      "model", model,
 		      "manufacturer", manufacturer,
 		      "title", title,
-		      "native-device-sysfs", sysfs_path,
+		      "native-device", sysfs_path,
 		      NULL);
 
 	/* load the device */
@@ -710,7 +713,7 @@ gcm_client_xrandr_add (GcmClient *client, GnomeRROutput *output)
 	}
 
 	/* add new device */
-	device = gcm_device_new ();
+	device = gcm_device_xrandr_new ();
 	title = gcm_client_get_output_name (client, output);
 	g_object_set (device,
 		      "type", GCM_DEVICE_TYPE_ENUM_DISPLAY,
@@ -720,7 +723,7 @@ gcm_client_xrandr_add (GcmClient *client, GnomeRROutput *output)
 		      "model", model,
 		      "manufacturer", manufacturer,
 		      "title", title,
-		      "native-device-xrandr", output_name,
+		      "native-device", output_name,
 		      NULL);
 
 	/* load the device */
diff --git a/src/gcm-dbus.c b/src/gcm-dbus.c
index 0b576a4..b8e3d5a 100644
--- a/src/gcm-dbus.c
+++ b/src/gcm-dbus.c
@@ -184,7 +184,7 @@ gcm_dbus_get_profiles_for_device_internal (GcmDbus *dbus, const gchar *sysfs_pat
 
 		/* get the native path of this device */
 		g_object_get (device,
-			      "native-device-sysfs", &sysfs_path_tmp,
+			      "native-device", &sysfs_path_tmp,
 			      NULL);
 
 		/* wrong type of device */
diff --git a/src/gcm-device-cups.c b/src/gcm-device-cups.c
new file mode 100644
index 0000000..bcf3fa8
--- /dev/null
+++ b/src/gcm-device-cups.c
@@ -0,0 +1,162 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <cups/cups.h>
+#include <cups/ppd.h>
+
+#include "gcm-device-cups.h"
+
+#include "egg-debug.h"
+
+static void     gcm_device_cups_finalize	(GObject     *object);
+
+#define GCM_DEVICE_CUPS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_DEVICE_CUPS, GcmDeviceCupsPrivate))
+
+/**
+ * GcmDeviceCupsPrivate:
+ *
+ * Private #GcmDeviceCups data
+ **/
+struct _GcmDeviceCupsPrivate
+{
+	gchar				*native_device;
+};
+
+enum {
+	PROP_0,
+	PROP_NATIVE_DEVICE,
+	PROP_LAST
+};
+
+G_DEFINE_TYPE (GcmDeviceCups, gcm_device_cups, GCM_TYPE_DEVICE)
+
+/**
+ * gcm_device_cups_set_from_instance:
+ **/
+gboolean
+gcm_device_cups_set_from_instance (GcmDevice *device, gpointer instance, GError **error)
+{
+	return TRUE;
+}
+
+/**
+ * gcm_device_cups_get_property:
+ **/
+static void
+gcm_device_cups_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+	GcmDeviceCups *device_cups = GCM_DEVICE_CUPS (object);
+	GcmDeviceCupsPrivate *priv = device_cups->priv;
+
+	switch (prop_id) {
+	case PROP_NATIVE_DEVICE:
+		g_value_set_string (value, priv->native_device);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gcm_device_cups_set_property:
+ **/
+static void
+gcm_device_cups_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+	GcmDeviceCups *device_cups = GCM_DEVICE_CUPS (object);
+	GcmDeviceCupsPrivate *priv = device_cups->priv;
+
+	switch (prop_id) {
+	case PROP_NATIVE_DEVICE:
+		g_free (priv->native_device);
+		priv->native_device = g_strdup (g_value_get_string (value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gcm_device_cups_class_init:
+ **/
+static void
+gcm_device_cups_class_init (GcmDeviceCupsClass *klass)
+{
+	GParamSpec *pspec;
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gcm_device_cups_finalize;
+	object_class->get_property = gcm_device_cups_get_property;
+	object_class->set_property = gcm_device_cups_set_property;
+
+
+	/**
+	 * GcmDeviceCups:native-device:
+	 */
+	pspec = g_param_spec_string ("native-device", NULL, NULL,
+				     NULL,
+				     G_PARAM_READWRITE);
+	g_object_class_install_property (object_class, PROP_NATIVE_DEVICE, pspec);
+
+	g_type_class_add_private (klass, sizeof (GcmDeviceCupsPrivate));
+}
+
+/**
+ * gcm_device_cups_init:
+ **/
+static void
+gcm_device_cups_init (GcmDeviceCups *device_cups)
+{
+	device_cups->priv = GCM_DEVICE_CUPS_GET_PRIVATE (device_cups);
+	device_cups->priv->native_device = NULL;
+}
+
+/**
+ * gcm_device_cups_finalize:
+ **/
+static void
+gcm_device_cups_finalize (GObject *object)
+{
+	GcmDeviceCups *device_cups = GCM_DEVICE_CUPS (object);
+	GcmDeviceCupsPrivate *priv = device_cups->priv;
+
+	g_free (priv->native_device);
+
+	G_OBJECT_CLASS (gcm_device_cups_parent_class)->finalize (object);
+}
+
+/**
+ * gcm_device_cups_new:
+ *
+ * Return value: a new #GcmDevice object.
+ **/
+GcmDevice *
+gcm_device_cups_new (void)
+{
+	GcmDevice *device;
+	device = g_object_new (GCM_TYPE_DEVICE_CUPS, NULL);
+	return GCM_DEVICE (device);
+}
+
diff --git a/src/gcm-device-cups.h b/src/gcm-device-cups.h
new file mode 100644
index 0000000..573d19b
--- /dev/null
+++ b/src/gcm-device-cups.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GCM_DEVICE_CUPS_H
+#define __GCM_DEVICE_CUPS_H
+
+#include <glib-object.h>
+
+#include "gcm-device.h"
+
+G_BEGIN_DECLS
+
+#define GCM_TYPE_DEVICE_CUPS		(gcm_device_cups_get_type ())
+#define GCM_DEVICE_CUPS(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GCM_TYPE_DEVICE_CUPS, GcmDeviceCups))
+#define GCM_IS_DEVICE_CUPS(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GCM_TYPE_DEVICE_CUPS))
+
+typedef struct _GcmDeviceCupsPrivate	GcmDeviceCupsPrivate;
+typedef struct _GcmDeviceCups		GcmDeviceCups;
+typedef struct _GcmDeviceCupsClass	GcmDeviceCupsClass;
+
+struct _GcmDeviceCups
+{
+	 GcmDevice			 parent;
+	 GcmDeviceCupsPrivate		*priv;
+};
+
+struct _GcmDeviceCupsClass
+{
+	GcmDeviceClass	parent_class;
+};
+
+GType		 gcm_device_cups_get_type		  	(void);
+GcmDevice	*gcm_device_cups_new				(void);
+gboolean	 gcm_device_cups_set_from_instance		(GcmDevice	*device,
+								 gpointer	 instance,
+								 GError		**error);
+
+G_END_DECLS
+
+#endif /* __GCM_DEVICE_CUPS_H */
+
diff --git a/src/gcm-device-sysfs.c b/src/gcm-device-sysfs.c
new file mode 100644
index 0000000..0cb77bc
--- /dev/null
+++ b/src/gcm-device-sysfs.c
@@ -0,0 +1,160 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+
+#include "gcm-device-sysfs.h"
+
+#include "egg-debug.h"
+
+static void     gcm_device_sysfs_finalize	(GObject     *object);
+
+#define GCM_DEVICE_SYSFS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_DEVICE_SYSFS, GcmDeviceSysfsPrivate))
+
+/**
+ * GcmDeviceSysfsPrivate:
+ *
+ * Private #GcmDeviceSysfs data
+ **/
+struct _GcmDeviceSysfsPrivate
+{
+	gchar				*native_device;
+};
+
+enum {
+	PROP_0,
+	PROP_NATIVE_DEVICE,
+	PROP_LAST
+};
+
+G_DEFINE_TYPE (GcmDeviceSysfs, gcm_device_sysfs, GCM_TYPE_DEVICE)
+
+/**
+ * gcm_device_sysfs_set_from_instance:
+ **/
+gboolean
+gcm_device_sysfs_set_from_instance (GcmDevice *device, gpointer instance, GError **error)
+{
+	return TRUE;
+}
+
+/**
+ * gcm_device_sysfs_get_property:
+ **/
+static void
+gcm_device_sysfs_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+	GcmDeviceSysfs *device_sysfs = GCM_DEVICE_SYSFS (object);
+	GcmDeviceSysfsPrivate *priv = device_sysfs->priv;
+
+	switch (prop_id) {
+	case PROP_NATIVE_DEVICE:
+		g_value_set_string (value, priv->native_device);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gcm_device_sysfs_set_property:
+ **/
+static void
+gcm_device_sysfs_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+	GcmDeviceSysfs *device_sysfs = GCM_DEVICE_SYSFS (object);
+	GcmDeviceSysfsPrivate *priv = device_sysfs->priv;
+
+	switch (prop_id) {
+	case PROP_NATIVE_DEVICE:
+		g_free (priv->native_device);
+		priv->native_device = g_strdup (g_value_get_string (value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gcm_device_sysfs_class_init:
+ **/
+static void
+gcm_device_sysfs_class_init (GcmDeviceSysfsClass *klass)
+{
+	GParamSpec *pspec;
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gcm_device_sysfs_finalize;
+	object_class->get_property = gcm_device_sysfs_get_property;
+	object_class->set_property = gcm_device_sysfs_set_property;
+
+
+	/**
+	 * GcmDeviceSysfs:native-device:
+	 */
+	pspec = g_param_spec_string ("native-device", NULL, NULL,
+				     NULL,
+				     G_PARAM_READWRITE);
+	g_object_class_install_property (object_class, PROP_NATIVE_DEVICE, pspec);
+
+	g_type_class_add_private (klass, sizeof (GcmDeviceSysfsPrivate));
+}
+
+/**
+ * gcm_device_sysfs_init:
+ **/
+static void
+gcm_device_sysfs_init (GcmDeviceSysfs *device_sysfs)
+{
+	device_sysfs->priv = GCM_DEVICE_SYSFS_GET_PRIVATE (device_sysfs);
+	device_sysfs->priv->native_device = NULL;
+}
+
+/**
+ * gcm_device_sysfs_finalize:
+ **/
+static void
+gcm_device_sysfs_finalize (GObject *object)
+{
+	GcmDeviceSysfs *device_sysfs = GCM_DEVICE_SYSFS (object);
+	GcmDeviceSysfsPrivate *priv = device_sysfs->priv;
+
+	g_free (priv->native_device);
+
+	G_OBJECT_CLASS (gcm_device_sysfs_parent_class)->finalize (object);
+}
+
+/**
+ * gcm_device_sysfs_new:
+ *
+ * Return value: a new #GcmDevice object.
+ **/
+GcmDevice *
+gcm_device_sysfs_new (void)
+{
+	GcmDevice *device;
+	device = g_object_new (GCM_TYPE_DEVICE_SYSFS, NULL);
+	return GCM_DEVICE (device);
+}
+
diff --git a/src/gcm-device-sysfs.h b/src/gcm-device-sysfs.h
new file mode 100644
index 0000000..1545ed7
--- /dev/null
+++ b/src/gcm-device-sysfs.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GCM_DEVICE_SYSFS_H
+#define __GCM_DEVICE_SYSFS_H
+
+#include <glib-object.h>
+
+#include "gcm-device.h"
+
+G_BEGIN_DECLS
+
+#define GCM_TYPE_DEVICE_SYSFS		(gcm_device_sysfs_get_type ())
+#define GCM_DEVICE_SYSFS(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GCM_TYPE_DEVICE_SYSFS, GcmDeviceSysfs))
+#define GCM_IS_DEVICE_SYSFS(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GCM_TYPE_DEVICE_SYSFS))
+
+typedef struct _GcmDeviceSysfsPrivate	GcmDeviceSysfsPrivate;
+typedef struct _GcmDeviceSysfs		GcmDeviceSysfs;
+typedef struct _GcmDeviceSysfsClass	GcmDeviceSysfsClass;
+
+struct _GcmDeviceSysfs
+{
+	 GcmDevice			 parent;
+	 GcmDeviceSysfsPrivate		*priv;
+};
+
+struct _GcmDeviceSysfsClass
+{
+	GcmDeviceClass	parent_class;
+};
+
+GType		 gcm_device_sysfs_get_type		  	(void);
+GcmDevice	*gcm_device_sysfs_new				(void);
+gboolean	 gcm_device_sysfs_set_from_instance		(GcmDevice	*device,
+								 gpointer	 instance,
+								 GError		**error);
+
+G_END_DECLS
+
+#endif /* __GCM_DEVICE_SYSFS_H */
+
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
new file mode 100644
index 0000000..80fcbdc
--- /dev/null
+++ b/src/gcm-device-xrandr.c
@@ -0,0 +1,160 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+
+#include "gcm-device-xrandr.h"
+
+#include "egg-debug.h"
+
+static void     gcm_device_xrandr_finalize	(GObject     *object);
+
+#define GCM_DEVICE_XRANDR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_DEVICE_XRANDR, GcmDeviceXrandrPrivate))
+
+/**
+ * GcmDeviceXrandrPrivate:
+ *
+ * Private #GcmDeviceXrandr data
+ **/
+struct _GcmDeviceXrandrPrivate
+{
+	gchar				*native_device;
+};
+
+enum {
+	PROP_0,
+	PROP_NATIVE_DEVICE,
+	PROP_LAST
+};
+
+G_DEFINE_TYPE (GcmDeviceXrandr, gcm_device_xrandr, GCM_TYPE_DEVICE)
+
+/**
+ * gcm_device_xrandr_set_from_instance:
+ **/
+gboolean
+gcm_device_xrandr_set_from_instance (GcmDevice *device, gpointer instance, GError **error)
+{
+	return TRUE;
+}
+
+/**
+ * gcm_device_xrandr_get_property:
+ **/
+static void
+gcm_device_xrandr_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+	GcmDeviceXrandr *device_xrandr = GCM_DEVICE_XRANDR (object);
+	GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
+
+	switch (prop_id) {
+	case PROP_NATIVE_DEVICE:
+		g_value_set_string (value, priv->native_device);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gcm_device_xrandr_set_property:
+ **/
+static void
+gcm_device_xrandr_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+	GcmDeviceXrandr *device_xrandr = GCM_DEVICE_XRANDR (object);
+	GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
+
+	switch (prop_id) {
+	case PROP_NATIVE_DEVICE:
+		g_free (priv->native_device);
+		priv->native_device = g_strdup (g_value_get_string (value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gcm_device_xrandr_class_init:
+ **/
+static void
+gcm_device_xrandr_class_init (GcmDeviceXrandrClass *klass)
+{
+	GParamSpec *pspec;
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gcm_device_xrandr_finalize;
+	object_class->get_property = gcm_device_xrandr_get_property;
+	object_class->set_property = gcm_device_xrandr_set_property;
+
+
+	/**
+	 * GcmDeviceXrandr:native-device:
+	 */
+	pspec = g_param_spec_string ("native-device", NULL, NULL,
+				     NULL,
+				     G_PARAM_READWRITE);
+	g_object_class_install_property (object_class, PROP_NATIVE_DEVICE, pspec);
+
+	g_type_class_add_private (klass, sizeof (GcmDeviceXrandrPrivate));
+}
+
+/**
+ * gcm_device_xrandr_init:
+ **/
+static void
+gcm_device_xrandr_init (GcmDeviceXrandr *device_xrandr)
+{
+	device_xrandr->priv = GCM_DEVICE_XRANDR_GET_PRIVATE (device_xrandr);
+	device_xrandr->priv->native_device = NULL;
+}
+
+/**
+ * gcm_device_xrandr_finalize:
+ **/
+static void
+gcm_device_xrandr_finalize (GObject *object)
+{
+	GcmDeviceXrandr *device_xrandr = GCM_DEVICE_XRANDR (object);
+	GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
+
+	g_free (priv->native_device);
+
+	G_OBJECT_CLASS (gcm_device_xrandr_parent_class)->finalize (object);
+}
+
+/**
+ * gcm_device_xrandr_new:
+ *
+ * Return value: a new #GcmDevice object.
+ **/
+GcmDevice *
+gcm_device_xrandr_new (void)
+{
+	GcmDevice *device;
+	device = g_object_new (GCM_TYPE_DEVICE_XRANDR, NULL);
+	return GCM_DEVICE (device);
+}
+
diff --git a/src/gcm-device-xrandr.h b/src/gcm-device-xrandr.h
new file mode 100644
index 0000000..f681b7b
--- /dev/null
+++ b/src/gcm-device-xrandr.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GCM_DEVICE_XRANDR_H
+#define __GCM_DEVICE_XRANDR_H
+
+#include <glib-object.h>
+
+#include "gcm-device.h"
+
+G_BEGIN_DECLS
+
+#define GCM_TYPE_DEVICE_XRANDR		(gcm_device_xrandr_get_type ())
+#define GCM_DEVICE_XRANDR(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GCM_TYPE_DEVICE_XRANDR, GcmDeviceXrandr))
+#define GCM_IS_DEVICE_XRANDR(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GCM_TYPE_DEVICE_XRANDR))
+
+typedef struct _GcmDeviceXrandrPrivate	GcmDeviceXrandrPrivate;
+typedef struct _GcmDeviceXrandr		GcmDeviceXrandr;
+typedef struct _GcmDeviceXrandrClass	GcmDeviceXrandrClass;
+
+struct _GcmDeviceXrandr
+{
+	 GcmDevice			 parent;
+	 GcmDeviceXrandrPrivate		*priv;
+};
+
+struct _GcmDeviceXrandrClass
+{
+	GcmDeviceClass	parent_class;
+};
+
+GType		 gcm_device_xrandr_get_type		  	(void);
+GcmDevice	*gcm_device_xrandr_new				(void);
+gboolean	 gcm_device_xrandr_set_from_instance		(GcmDevice	*device,
+								 gpointer	 instance,
+								 GError		**error);
+
+G_END_DECLS
+
+#endif /* __GCM_DEVICE_XRANDR_H */
+
diff --git a/src/gcm-device.c b/src/gcm-device.c
index d7e07b0..1bc876d 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -29,10 +29,7 @@
 #include "config.h"
 
 #include <glib-object.h>
-#include <math.h>
-#include <gio/gio.h>
 #include <gconf/gconf-client.h>
-#include <libgnomeui/gnome-rr.h>
 
 #include "gcm-device.h"
 #include "gcm-profile.h"
@@ -64,8 +61,6 @@ struct _GcmDevicePrivate
 	gchar				*profile_filename;
 	gchar				*title;
 	GConfClient			*gconf_client;
-	gchar				*native_device_xrandr;
-	gchar				*native_device_sysfs;
 };
 
 enum {
@@ -82,7 +77,6 @@ enum {
 	PROP_CONTRAST,
 	PROP_PROFILE_FILENAME,
 	PROP_TITLE,
-	PROP_NATIVE_DEVICE_XRANDR,
 	PROP_NATIVE_DEVICE_SYSFS,
 	PROP_LAST
 };
@@ -440,12 +434,6 @@ gcm_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
 	case PROP_TITLE:
 		g_value_set_string (value, priv->title);
 		break;
-	case PROP_NATIVE_DEVICE_XRANDR:
-		g_value_set_string (value, priv->native_device_xrandr);
-		break;
-	case PROP_NATIVE_DEVICE_SYSFS:
-		g_value_set_string (value, priv->native_device_sysfs);
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -504,14 +492,6 @@ gcm_device_set_property (GObject *object, guint prop_id, const GValue *value, GP
 	case PROP_CONTRAST:
 		priv->contrast = g_value_get_float (value);
 		break;
-	case PROP_NATIVE_DEVICE_XRANDR:
-		g_free (priv->native_device_xrandr);
-		priv->native_device_xrandr = g_strdup (g_value_get_string (value));
-		break;
-	case PROP_NATIVE_DEVICE_SYSFS:
-		g_free (priv->native_device_sysfs);
-		priv->native_device_sysfs = g_strdup (g_value_get_string (value));
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -626,22 +606,6 @@ gcm_device_class_init (GcmDeviceClass *klass)
 				     G_PARAM_READWRITE);
 	g_object_class_install_property (object_class, PROP_TITLE, pspec);
 
-	/**
-	 * GcmDevice:native-device-xrandr:
-	 */
-	pspec = g_param_spec_string ("native-device-xrandr", NULL, NULL,
-				     NULL,
-				     G_PARAM_READWRITE);
-	g_object_class_install_property (object_class, PROP_NATIVE_DEVICE_XRANDR, pspec);
-
-	/**
-	 * GcmDevice:native-device-sysfs:
-	 */
-	pspec = g_param_spec_string ("native-device-sysfs", NULL, NULL,
-				     NULL,
-				     G_PARAM_READWRITE);
-	g_object_class_install_property (object_class, PROP_NATIVE_DEVICE_SYSFS, pspec);
-
 	g_type_class_add_private (klass, sizeof (GcmDevicePrivate));
 }
 
@@ -659,8 +623,6 @@ gcm_device_init (GcmDevice *device)
 	device->priv->serial = NULL;
 	device->priv->manufacturer = NULL;
 	device->priv->model = NULL;
-	device->priv->native_device_xrandr = NULL;
-	device->priv->native_device_sysfs = NULL;
 	device->priv->profile_filename = NULL;
 	device->priv->gconf_client = gconf_client_get_default ();
 	device->priv->gamma = gconf_client_get_float (device->priv->gconf_client, GCM_SETTINGS_DEFAULT_GAMMA, &error);
@@ -688,8 +650,6 @@ gcm_device_finalize (GObject *object)
 	g_free (priv->serial);
 	g_free (priv->manufacturer);
 	g_free (priv->model);
-	g_free (priv->native_device_xrandr);
-	g_free (priv->native_device_sysfs);
 	g_object_unref (priv->gconf_client);
 
 	G_OBJECT_CLASS (gcm_device_parent_class)->finalize (object);
@@ -714,6 +674,8 @@ gcm_device_new (void)
 #ifdef EGG_TEST
 #include "egg-test.h"
 
+#include "gcm-device-sysfs.h"
+
 void
 gcm_device_test (EggTest *test)
 {
@@ -731,7 +693,7 @@ gcm_device_test (EggTest *test)
 
 	/************************************************************/
 	egg_test_title (test, "get a device object");
-	device = gcm_device_new ();
+	device = gcm_device_sysfs_new ();
 	egg_test_assert (test, device != NULL);
 
 	/************************************************************/
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index d9ff8bf..d9f6bd4 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -320,7 +320,7 @@ gcm_prefs_calibrate_display (GcmCalibrate *calibrate)
 
 	/* get the device */
 	g_object_get (current_device,
-		      "native-device-xrandr", &output_name,
+		      "native-device", &output_name,
 		      "serial", &basename,
 		      "manufacturer", &manufacturer,
 		      "model", &model,
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 78a9e90..524e998 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -418,7 +418,7 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
 		      "gamma", &gamma,
 		      "brightness", &brightness,
 		      "contrast", &contrast,
-		      "native-device-xrandr", &output_name,
+		      "native-device", &output_name,
 		      NULL);
 
 	/* do no set the gamma for non-display types */



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