[gnome-color-manager] trivial: add GcmDeviceVirtual which is a virtual device not tied to any hardware
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: add GcmDeviceVirtual which is a virtual device not tied to any hardware
- Date: Wed, 24 Feb 2010 10:25:38 +0000 (UTC)
commit 110f689a44af5cf4dded22cf58de29c83b81abdf
Author: Richard Hughes <richard hughsie com>
Date: Wed Feb 24 09:50:06 2010 +0000
trivial: add GcmDeviceVirtual which is a virtual device not tied to any hardware
src/Makefile.am | 2 +
src/gcm-device-virtual.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++
src/gcm-device-virtual.h | 60 ++++++++++++++++++++++++++++
3 files changed, 161 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index adc8310..bece432 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,6 +63,8 @@ libgcmshared_a_SOURCES = \
gcm-device-cups.h \
gcm-device-sane.c \
gcm-device-sane.h \
+ gcm-device-virtual.c \
+ gcm-device-virtual.h \
gcm-cie-widget.c \
gcm-cie-widget.h \
gcm-trc-widget.c \
diff --git a/src/gcm-device-virtual.c b/src/gcm-device-virtual.c
new file mode 100644
index 0000000..8f41142
--- /dev/null
+++ b/src/gcm-device-virtual.c
@@ -0,0 +1,99 @@
+/* -*- 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 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-virtual.h"
+#include "gcm-enum.h"
+#include "gcm-utils.h"
+
+#include "egg-debug.h"
+
+#define GCM_DEVICE_VIRTUAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_DEVICE_VIRTUAL, GcmDeviceVirtualPrivate))
+
+G_DEFINE_TYPE (GcmDeviceVirtual, gcm_device_virtual, GCM_TYPE_DEVICE)
+
+/**
+ * gcm_device_virtual_create_from_params:
+ **/
+gboolean
+gcm_device_virtual_create_from_params (GcmDeviceVirtual *device_virtual,
+ GcmDeviceTypeEnum device_type,
+ const gchar *model,
+ const gchar *manufacturer,
+ GcmColorspaceEnum colorspace)
+{
+ gchar *id;
+ gchar *title;
+
+ /* make some stuff up */
+ title = g_strdup_printf ("%s - %s", model, manufacturer);
+ id = g_strdup_printf ("%s_%s", model, manufacturer);
+ gcm_utils_alphanum_lcase (id);
+
+ /* create the device */
+ egg_debug ("adding %s '%s'", id, title);
+ g_object_set (device_virtual,
+ "connected", FALSE,
+ "type", device_type,
+ "id", id,
+ "manufacturer", manufacturer,
+ "model", model,
+ "title", title,
+ "colorspace", colorspace,
+ "virtual", TRUE,
+ NULL);
+ g_free (id);
+ g_free (title);
+ return TRUE;
+}
+
+/**
+ * gcm_device_virtual_class_init:
+ **/
+static void
+gcm_device_virtual_class_init (GcmDeviceVirtualClass *klass)
+{
+}
+
+/**
+ * gcm_device_virtual_init:
+ **/
+static void
+gcm_device_virtual_init (GcmDeviceVirtual *device_virtual)
+{
+}
+
+/**
+ * gcm_device_virtual_new:
+ *
+ * Return value: a new #GcmDevice object.
+ **/
+GcmDevice *
+gcm_device_virtual_new (void)
+{
+ GcmDevice *device;
+ device = g_object_new (GCM_TYPE_DEVICE_VIRTUAL, NULL);
+ return GCM_DEVICE (device);
+}
+
diff --git a/src/gcm-device-virtual.h b/src/gcm-device-virtual.h
new file mode 100644
index 0000000..8f8d39c
--- /dev/null
+++ b/src/gcm-device-virtual.h
@@ -0,0 +1,60 @@
+/* -*- 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_VIRTUAL_H
+#define __GCM_DEVICE_VIRTUAL_H
+
+#include <glib-object.h>
+
+#include "gcm-device.h"
+#include "gcm-enum.h"
+
+G_BEGIN_DECLS
+
+#define GCM_TYPE_DEVICE_VIRTUAL (gcm_device_virtual_get_type ())
+#define GCM_DEVICE_VIRTUAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GCM_TYPE_DEVICE_VIRTUAL, GcmDeviceVirtual))
+#define GCM_IS_DEVICE_VIRTUAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GCM_TYPE_DEVICE_VIRTUAL))
+
+typedef struct _GcmDeviceVirtual GcmDeviceVirtual;
+typedef struct _GcmDeviceVirtualClass GcmDeviceVirtualClass;
+
+struct _GcmDeviceVirtual
+{
+ GcmDevice parent;
+};
+
+struct _GcmDeviceVirtualClass
+{
+ GcmDeviceClass parent_class;
+};
+
+GType gcm_device_virtual_get_type (void);
+GcmDevice *gcm_device_virtual_new (void);
+gboolean gcm_device_virtual_create_from_params (GcmDeviceVirtual *device_virtual,
+ GcmDeviceTypeEnum device_type,
+ const gchar *model,
+ const gchar *manufacturer,
+ GcmColorspaceEnum colorspace);
+
+G_END_DECLS
+
+#endif /* __GCM_DEVICE_VIRTUAL_H */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]