[gnome-color-manager: 5/18] Add functionality for a device to generate it's own internal profile
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager: 5/18] Add functionality for a device to generate it's own internal profile
- Date: Fri, 8 Oct 2010 16:08:35 +0000 (UTC)
commit 4631abe3efc77d6ab32336f2736fad06b5359cde
Author: Richard Hughes <richard hughsie com>
Date: Fri Oct 8 11:32:39 2010 +0100
Add functionality for a device to generate it's own internal profile
src/gcm-device-xrandr.c | 35 +++++++++++++++++++++++++++++++++++
src/gcm-device.c | 22 ++++++++++++++++++++++
src/gcm-device.h | 8 ++++++++
3 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index d4dcde1..9e40484 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -390,6 +390,40 @@ gcm_device_xrandr_get_config_data (GcmDevice *device)
}
/**
+ * gcm_device_xrandr_generate_profile:
+ **/
+static GcmProfile *
+gcm_device_xrandr_generate_profile (GcmDevice *device, GError **error)
+{
+ const gchar *data;
+ GcmProfile *profile;
+ GcmDeviceXrandr *device_xrandr = GCM_DEVICE_XRANDR (device);
+ GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
+
+ /* create new profile */
+ profile = gcm_profile_new ();
+ gcm_profile_set_colorspace (profile, 0);
+ gcm_profile_set_copyright (profile, "No copyright");
+ gcm_profile_set_description (profile, "Automatically generated profile for EDID");
+ gcm_profile_set_kind (profile, GCM_PROFILE_KIND_DISPLAY_DEVICE);
+
+ /* get manufacturer */
+ data = gcm_edid_get_vendor_name (priv->edid);
+ if (data == NULL)
+ data = "Unknown vendor";
+ gcm_profile_set_manufacturer (profile, data);
+
+ /* get model */
+ data = gcm_edid_get_monitor_name (priv->edid);
+ if (data == NULL)
+ data = "Unknown monitor";
+ gcm_profile_set_model (profile, data);
+
+ /* TODO: generate a profile from the chroma data */
+ return profile;
+}
+
+/**
* gcm_device_xrandr_is_primary:
*
* Return value: %TRUE is the monitor is left-most
@@ -631,6 +665,7 @@ gcm_device_xrandr_class_init (GcmDeviceXrandrClass *klass)
device_class->apply = gcm_device_xrandr_apply;
device_class->get_config_data = gcm_device_xrandr_get_config_data;
+ device_class->generate_profile = gcm_device_xrandr_generate_profile;
/**
* GcmDeviceXrandr:native-device:
diff --git a/src/gcm-device.c b/src/gcm-device.c
index 479b3cb..e2934d3 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -923,6 +923,28 @@ out:
}
/**
+ * gcm_device_generate_profile:
+ **/
+GcmProfile *
+gcm_device_generate_profile (GcmDevice *device, GError **error)
+{
+ GcmProfile *profile = NULL;
+ GcmDeviceClass *klass = GCM_DEVICE_GET_CLASS (device);
+
+ /* no support */
+ if (klass->generate_profile == NULL) {
+ g_set_error (error, GCM_DEVICE_ERROR, GCM_DEVICE_ERROR_NO_SUPPPORT,
+ "no klass support for %s", device->priv->id);
+ goto out;
+ }
+
+ /* run the callback */
+ profile = klass->generate_profile (device, error);
+out:
+ return profile;
+}
+
+/**
* gcm_device_get_property:
**/
static void
diff --git a/src/gcm-device.h b/src/gcm-device.h
index 2a79888..cc3bdfd 100644
--- a/src/gcm-device.h
+++ b/src/gcm-device.h
@@ -36,6 +36,10 @@ G_BEGIN_DECLS
#define GCM_IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GCM_TYPE_DEVICE))
#define GCM_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GCM_TYPE_DEVICE, GcmDeviceClass))
+#define GCM_DEVICE_ERROR 1
+#define GCM_DEVICE_ERROR_INTERNAL 0
+#define GCM_DEVICE_ERROR_NO_SUPPPORT 0
+
typedef struct _GcmDevicePrivate GcmDevicePrivate;
typedef struct _GcmDevice GcmDevice;
typedef struct _GcmDeviceClass GcmDeviceClass;
@@ -52,6 +56,8 @@ struct _GcmDeviceClass
void (*changed) (GcmDevice *device);
gboolean (*apply) (GcmDevice *device,
GError **error);
+ GcmProfile *(*generate_profile) (GcmDevice *device,
+ GError **error);
gchar *(*get_config_data) (GcmDevice *device);
/* padding for future expansion */
void (*_gcm_reserved1) (void);
@@ -68,6 +74,8 @@ gboolean gcm_device_save (GcmDevice *device,
GError **error);
gboolean gcm_device_apply (GcmDevice *device,
GError **error);
+GcmProfile *gcm_device_generate_profile (GcmDevice *device,
+ GError **error);
/* accessors */
GcmDeviceKind gcm_device_get_kind (GcmDevice *device);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]