[gnome-color-manager: 56/80] Add a dummy sensor type for debugging



commit ab58dc5a0b1a5e0adca46ad7b6a480d3c16d6acb
Author: Richard Hughes <richard hughsie com>
Date:   Sat Jul 17 23:37:54 2010 +0100

    Add a dummy sensor type for debugging

 libcolor-glib/Makefile.am        |    2 +
 libcolor-glib/gcm-sensor-dummy.c |  112 ++++++++++++++++++++++++++++++++++++++
 libcolor-glib/gcm-sensor-dummy.h |   57 +++++++++++++++++++
 3 files changed, 171 insertions(+), 0 deletions(-)
---
diff --git a/libcolor-glib/Makefile.am b/libcolor-glib/Makefile.am
index eebd019..4389993 100644
--- a/libcolor-glib/Makefile.am
+++ b/libcolor-glib/Makefile.am
@@ -47,6 +47,8 @@ libcolor_glib_la_SOURCES =					\
 	gcm-sensor.h						\
 	gcm-sensor-huey.c					\
 	gcm-sensor-huey.h					\
+	gcm-sensor-dummy.c					\
+	gcm-sensor-dummy.h					\
 	gcm-ddc-client.c					\
 	gcm-ddc-client.h					\
 	gcm-ddc-device.c					\
diff --git a/libcolor-glib/gcm-sensor-dummy.c b/libcolor-glib/gcm-sensor-dummy.c
new file mode 100644
index 0000000..1032251
--- /dev/null
+++ b/libcolor-glib/gcm-sensor-dummy.c
@@ -0,0 +1,112 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/**
+ * SECTION:gcm-sensor-dummy
+ * @short_description: functionality to talk to a dummy colorimeter.
+ *
+ * This object contains all the low level logic for imaginary hardware.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+
+#include "gcm-sensor-dummy.h"
+
+G_DEFINE_TYPE (GcmSensorDummy, gcm_sensor_dummy, GCM_TYPE_SENSOR)
+
+/**
+ * gcm_sensor_dummy_get_ambient:
+ **/
+static gboolean
+gcm_sensor_dummy_get_ambient (GcmSensor *sensor, gdouble *value, GError **error)
+{
+	*value = 17.0f;
+	return TRUE;
+}
+
+/**
+ * gcm_sensor_dummy_set_leds:
+ **/
+static gboolean
+gcm_sensor_dummy_set_leds (GcmSensor *sensor, guint8 value, GError **error)
+{
+	return TRUE;
+}
+
+/**
+ * gcm_sensor_dummy_sample:
+ **/
+static gboolean
+gcm_sensor_dummy_sample (GcmSensor *sensor, GcmColorXYZ *value, GError **error)
+{
+	value->X = 17.0f;
+	value->Y = 18.0f;
+	value->Z = 19.0f;
+	return TRUE;
+}
+
+/**
+ * gcm_sensor_dummy_startup:
+ **/
+static gboolean
+gcm_sensor_dummy_startup (GcmSensor *sensor, GError **error)
+{
+	return TRUE;
+}
+
+/**
+ * gcm_sensor_dummy_class_init:
+ **/
+static void
+gcm_sensor_dummy_class_init (GcmSensorDummyClass *klass)
+{
+	GcmSensorClass *parent_class = GCM_SENSOR_CLASS (klass);
+
+	/* setup klass links */
+	parent_class->get_ambient = gcm_sensor_dummy_get_ambient;
+	parent_class->set_leds = gcm_sensor_dummy_set_leds;
+	parent_class->sample = gcm_sensor_dummy_sample;
+	parent_class->startup = gcm_sensor_dummy_startup;
+}
+
+/**
+ * gcm_sensor_dummy_init:
+ **/
+static void
+gcm_sensor_dummy_init (GcmSensorDummy *sensor)
+{
+}
+
+/**
+ * gcm_sensor_dummy_new:
+ *
+ * Return value: a new #GcmSensor object.
+ **/
+GcmSensor *
+gcm_sensor_dummy_new (void)
+{
+	GcmSensorDummy *sensor;
+	sensor = g_object_new (GCM_TYPE_SENSOR_DUMMY, NULL);
+	return GCM_SENSOR (sensor);
+}
+
diff --git a/libcolor-glib/gcm-sensor-dummy.h b/libcolor-glib/gcm-sensor-dummy.h
new file mode 100644
index 0000000..67acaef
--- /dev/null
+++ b/libcolor-glib/gcm-sensor-dummy.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef __GCM_SENSOR_DUMMY_H
+#define __GCM_SENSOR_DUMMY_H
+
+#include <glib-object.h>
+
+#include "gcm-sensor.h"
+
+G_BEGIN_DECLS
+
+#define GCM_TYPE_SENSOR_DUMMY		(gcm_sensor_dummy_get_type ())
+#define GCM_SENSOR_DUMMY(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GCM_TYPE_SENSOR_DUMMY, GcmSensorDummy))
+#define GCM_SENSOR_DUMMY_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GCM_TYPE_SENSOR_DUMMY, GcmSensorDummyClass))
+#define GCM_IS_SENSOR_DUMMY(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GCM_TYPE_SENSOR_DUMMY))
+#define GCM_IS_SENSOR_DUMMY_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GCM_TYPE_SENSOR_DUMMY))
+#define GCM_SENSOR_DUMMY_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GCM_TYPE_SENSOR_DUMMY, GcmSensorDummyClass))
+
+typedef struct _GcmSensorDummy		GcmSensorDummy;
+typedef struct _GcmSensorDummyClass	GcmSensorDummyClass;
+
+struct _GcmSensorDummy
+{
+	 GcmSensor		 parent;
+};
+
+struct _GcmSensorDummyClass
+{
+	GcmSensorClass	parent_class;
+};
+
+GType		 gcm_sensor_dummy_get_type		 (void);
+GcmSensor	*gcm_sensor_dummy_new			 (void);
+
+G_END_DECLS
+
+#endif /* __GCM_SENSOR_DUMMY_H */
+



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