[gnome-color-manager/colord] Neuter a lot of GcmDeviceXrandr, pending its future removal



commit 069909d731f0f2cf3712ed63b1d3de1550ad0524
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jan 17 14:38:31 2011 +0000

    Neuter a lot of GcmDeviceXrandr, pending its future removal

 src/Makefile.am         |    2 -
 src/cc-color-panel.c    |   18 +---
 src/gcm-calibrate.c     |    5 +-
 src/gcm-device-xrandr.c |  254 +++--------------------------------------------
 src/gcm-device-xrandr.h |   69 -------------
 src/gcm-session.c       |   15 +--
 src/gcm-x11-output.c    |   94 ++++++++++++++++--
 src/gcm-x11-output.h    |    5 +
 8 files changed, 120 insertions(+), 342 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 7231e7b..922f26d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,8 +60,6 @@ libgcmshared_a_SOURCES =				\
 	gcm-debug.h					\
 	gcm-device.c					\
 	gcm-device.h					\
-	gcm-device-xrandr.c				\
-	gcm-device-xrandr.h				\
 	gcm-dmi.c					\
 	gcm-dmi.h					\
 	gcm-edid.c					\
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index 6b2f526..b0e9bf6 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -34,7 +34,6 @@
 #include "gcm-calibrate-argyll.h"
 #include "gcm-cie-widget.h"
 #include "gcm-sensor-client.h"
-#include "gcm-device-xrandr.h"
 #include "gcm-exif.h"
 #include "gcm-profile.h"
 #include "gcm-profile-store.h"
@@ -249,7 +248,7 @@ cc_color_panel_calibrate_display (CcColorPanel *panel, GcmCalibrate *calibrate)
 	}
 
 	/* clear any VCGT */
-	ret = gcm_device_xrandr_reset (GCM_DEVICE_XRANDR (panel->priv->current_device), &error);
+//	ret = gcm_device_xrandr_reset (GCM_DEVICE_XRANDR (panel->priv->current_device), &error);
 	if (!ret) {
 		g_warning ("failed to reset so we can calibrate: %s", error->message);
 		g_error_free (error);
@@ -938,7 +937,7 @@ cc_color_panel_profile_remove_cb (GtkWidget *widget, CcColorPanel *panel)
 	GtkTreeSelection *selection;
 	GtkTreeModel *model;
 	gboolean ret;
-	const gchar *device_md5;
+	const gchar *device_md5 = NULL;
 	GcmProfile *profile = NULL;
 	GError *error = NULL;
 
@@ -959,7 +958,7 @@ cc_color_panel_profile_remove_cb (GtkWidget *widget, CcColorPanel *panel)
 	 * removed, then assume there was something wrong with the profile
 	 * and don't do this again on next session start */
 	if (gcm_device_get_kind (panel->priv->current_device) == CD_DEVICE_KIND_DISPLAY) {
-		device_md5 = gcm_device_xrandr_get_edid_md5 (GCM_DEVICE_XRANDR (panel->priv->current_device));
+//		device_md5 = gcm_device_xrandr_get_edid_md5 (GCM_DEVICE_XRANDR (panel->priv->current_device));
 		if (g_strstr_len (gcm_profile_get_filename (profile), -1, device_md5) != NULL) {
 			g_debug ("removed an auto-profile, so disabling add for device");
 			gcm_device_set_use_edid_profile (panel->priv->current_device, FALSE);
@@ -1340,7 +1339,7 @@ cc_color_panel_set_calibrate_button_sensitivity (CcColorPanel *panel)
 		}
 
 		/* are we not XRandR 1.3 compat */
-		ret = gcm_device_xrandr_get_xrandr13 (GCM_DEVICE_XRANDR (panel->priv->current_device));
+//		ret = gcm_device_xrandr_get_xrandr13 (GCM_DEVICE_XRANDR (panel->priv->current_device));
 		if (!ret) {
 			/* TRANSLATORS: this is when the button is insensitive */
 			tooltip = _("Cannot create profile: The display driver does not support XRandR 1.3");
@@ -1433,7 +1432,7 @@ cc_color_panel_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcColor
 	if (kind == CD_DEVICE_KIND_DISPLAY) {
 		ret = gcm_device_get_connected (panel->priv->current_device);
 		if (ret) {
-			ret = gcm_device_xrandr_get_xrandr13 (GCM_DEVICE_XRANDR (panel->priv->current_device));
+//			ret = gcm_device_xrandr_get_xrandr13 (GCM_DEVICE_XRANDR (panel->priv->current_device));
 			if (!ret) {
                                 widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "label_problems"));
 				/* TRANSLATORS: Some shitty binary drivers do not support per-head gamma controls.
@@ -1567,12 +1566,6 @@ cc_color_panel_add_device_xrandr (CcColorPanel *panel, GcmDevice *device)
 	gboolean connected;
 	GError *error = NULL;
 
-	/* sanity check */
-	if (!GCM_IS_DEVICE_XRANDR (device)) {
-		g_warning ("not a xrandr device");
-		goto out;
-	}
-
 	/* italic for non-connected devices */
 	connected = gcm_device_get_connected (device);
 	title_tmp = gcm_device_get_title (device);
@@ -1610,7 +1603,6 @@ cc_color_panel_add_device_xrandr (CcColorPanel *panel, GcmDevice *device)
 			    GCM_DEVICES_COLUMN_SORT, sort,
 			    GCM_DEVICES_COLUMN_TITLE, title,
 			    GCM_DEVICES_COLUMN_ICON, "video-display", -1);
-out:
 	g_free (sort);
 	g_free (title);
 }
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index b7255d6..913f486 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -34,7 +34,6 @@
 #include "gcm-calibrate.h"
 #include "gcm-color.h"
 #include "gcm-dmi.h"
-#include "gcm-device-xrandr.h"
 #include "gcm-utils.h"
 #include "gcm-brightness.h"
 #include "gcm-sensor-client.h"
@@ -325,7 +324,7 @@ gcm_calibrate_set_from_device (GcmCalibrate *calibrate, GcmDevice *device, GErro
 
 	/* if we're a laptop, maybe use the dmi data instead */
 	if (kind == CD_DEVICE_KIND_DISPLAY) {
-		native_device = gcm_device_xrandr_get_native_device (GCM_DEVICE_XRANDR (device));
+//		native_device = gcm_device_xrandr_get_native_device (GCM_DEVICE_XRANDR (device));
 		lcd_internal = gcm_utils_output_is_lcd_internal (native_device);
 		if (lcd_internal) {
 			model = gcm_dmi_get_name (priv->dmi);
@@ -347,7 +346,7 @@ gcm_calibrate_set_from_device (GcmCalibrate *calibrate, GcmDevice *device, GErro
 
 	/* display specific properties */
 	if (kind == CD_DEVICE_KIND_DISPLAY) {
-		native_device = gcm_device_xrandr_get_native_device (GCM_DEVICE_XRANDR (device));
+//		native_device = gcm_device_xrandr_get_native_device (GCM_DEVICE_XRANDR (device));
 		if (native_device == NULL) {
 			g_set_error (error,
 				     GCM_CALIBRATE_ERROR,
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index dbcb7a4..747b023 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -19,11 +19,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "config.h"
+gboolean	 gcm_device_xrandr_set_from_output	(GcmDevice		*device,
+							 GcmX11Output		*output,
+							 GError			**error);
+void		 gcm_device_xrandr_set_remove_atom	(GcmDeviceXrandr	*device_xrandr,
+							 gboolean		 remove_atom);
+const gchar	*gcm_device_xrandr_get_native_device	(GcmDeviceXrandr	*device_xrandr);
+const gchar	*gcm_device_xrandr_get_eisa_id		(GcmDeviceXrandr	*device_xrandr);
+const gchar	*gcm_device_xrandr_get_edid_md5		(GcmDeviceXrandr	*device_xrandr);
+gboolean	 gcm_device_xrandr_get_xrandr13		(GcmDeviceXrandr	*device_xrandr);
+gboolean	 gcm_device_xrandr_is_primary		(GcmDeviceXrandr	*device_xrandr);
+gboolean	 gcm_device_xrandr_reset		(GcmDeviceXrandr	*device_xrandr,
+							 GError			**error);
 
-#include <glib-object.h>
-#include <glib/gi18n.h>
-#include <math.h>
 #include <X11/extensions/Xrandr.h>
 #include <gdk/gdkx.h>
 
@@ -36,10 +44,6 @@
 #include "gcm-x11-output.h"
 #include "gcm-x11-screen.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:
  *
@@ -53,22 +57,11 @@ struct _GcmDeviceXrandrPrivate
 	guint				 gamma_size;
 	GcmEdid				*edid;
 	GcmDmi				*dmi;
-	GSettings			*settings;
 	GcmX11Screen			*screen;
 	gboolean			 remove_atom;
 	gboolean			 randr_13;
 };
 
-enum {
-	PROP_0,
-	PROP_NATIVE_DEVICE,
-	PROP_EISA_ID,
-	PROP_EDID_MD5,
-	PROP_LAST
-};
-
-G_DEFINE_TYPE (GcmDeviceXrandr, gcm_device_xrandr, GCM_TYPE_DEVICE)
-
 #define GCM_ICC_PROFILE_IN_X_VERSION_MAJOR	0
 #define GCM_ICC_PROFILE_IN_X_VERSION_MINOR	3
 
@@ -297,86 +290,6 @@ out:
 }
 
 /**
- * gcm_device_xrandr_get_xrandr13:
- * @device_xrandr: a valid #GcmDeviceXrandr instance
- *
- * Return value: %TRUE if the display supports XRandr 1.3;
- **/
-gboolean
-gcm_device_xrandr_get_xrandr13 (GcmDeviceXrandr *device_xrandr)
-{
-	return device_xrandr->priv->randr_13;
-}
-
-/**
- * gcm_device_xrandr_apply_for_output:
- *
- * Return value: %TRUE for success;
- **/
-static gboolean
-gcm_device_xrandr_apply_for_output (GcmDeviceXrandr *device_xrandr, GcmX11Output *output, GcmClut *clut, GError **error)
-{
-	gboolean ret = TRUE;
-	GPtrArray *array = NULL;
-	guint16 *red = NULL;
-	guint16 *green = NULL;
-	guint16 *blue = NULL;
-	guint i;
-	GcmClutData *data;
-
-	/* get data */
-	array = gcm_clut_get_array (clut);
-	if (array == NULL) {
-		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "failed to get CLUT data");
-		goto out;
-	}
-
-	/* no length? */
-	if (array->len == 0) {
-		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "no data in the CLUT array");
-		goto out;
-	}
-
-	/* convert to a type X understands */
-	red = g_new (guint16, array->len);
-	green = g_new (guint16, array->len);
-	blue = g_new (guint16, array->len);
-	for (i=0; i<array->len; i++) {
-		data = g_ptr_array_index (array, i);
-		red[i] = data->red;
-		green[i] = data->green;
-		blue[i] = data->blue;
-	}
-
-	/* send to LUT */
-	ret = gcm_x11_output_set_gamma (output, array->len, red, green, blue, error);
-	if (!ret)
-		goto out;
-out:
-	g_free (red);
-	g_free (green);
-	g_free (blue);
-	if (array != NULL)
-		g_ptr_array_unref (array);
-	return ret;
-}
-
-/**
- * gcm_device_xrandr_set_remove_atom:
- *
- * This is set to FALSE at login time when we are sure there are going to be
- * no atoms previously set that have to be removed.
- **/
-void
-gcm_device_xrandr_set_remove_atom (GcmDeviceXrandr *device_xrandr, gboolean remove_atom)
-{
-	g_return_if_fail (GCM_IS_DEVICE_XRANDR (device_xrandr));
-	device_xrandr->priv->remove_atom = remove_atom;
-}
-
-/**
  * gcm_device_xrandr_generate_profile:
  **/
 static GcmProfile *
@@ -447,31 +360,6 @@ out:
 }
 
 /**
- * gcm_device_xrandr_is_primary:
- *
- * Return value: %TRUE is the monitor is left-most
- **/
-gboolean
-gcm_device_xrandr_is_primary (GcmDeviceXrandr *device_xrandr)
-{
-	guint x, y;
-	gboolean ret = FALSE;
-	GcmX11Output *output;
-
-	/* check we have an output */
-	output = gcm_x11_screen_get_output_by_name (device_xrandr->priv->screen,
-						    device_xrandr->priv->native_device, NULL);
-	if (output == NULL)
-		goto out;
-
-	/* is the monitor our primary monitor */
-	gcm_x11_output_get_position (output, &x, &y);
-	ret = (x == 0 && y == 0);
-out:
-	return ret;
-}
-
-/**
  * gcm_device_xrandr_reset:
  *
  * Clears any VCGT table, so we're ready for profiling
@@ -518,7 +406,7 @@ gcm_device_xrandr_reset (GcmDeviceXrandr *device_xrandr, GError **error)
 		      NULL);
 
 	/* actually set the gamma */
-	ret = gcm_device_xrandr_apply_for_output (device_xrandr, output, clut, error);
+	ret = gcm_x11_output_set_gamma_from_clut (output, clut, error);
 	if (!ret)
 		goto out;
 out:
@@ -596,10 +484,7 @@ gcm_device_xrandr_apply (GcmDevice *device, GError **error)
 	priv->gamma_size = gcm_x11_output_get_gamma_size (output);
 	size = priv->gamma_size;
 
-	/* only set the CLUT if we're not seting the atom */
-	use_global = g_settings_get_boolean (priv->settings, GCM_SETTINGS_GLOBAL_DISPLAY_CORRECTION);
-	if (use_global && profile != NULL)
-		clut = gcm_profile_generate_vcgt (profile, size);
+	clut = gcm_profile_generate_vcgt (profile, size);
 
 	/* create dummy CLUT if we failed */
 	if (clut == NULL) {
@@ -622,7 +507,7 @@ gcm_device_xrandr_apply (GcmDevice *device, GError **error)
 	}
 
 	/* actually set the gamma */
-	ret = gcm_device_xrandr_apply_for_output (device_xrandr, output, clut, error);
+	ret = gcm_x11_output_set_gamma_from_clut (output, clut, error);
 	if (!ret)
 		goto out;
 
@@ -630,9 +515,7 @@ gcm_device_xrandr_apply (GcmDevice *device, GError **error)
 	gcm_x11_output_get_position (output, &x, &y);
 	leftmost_screen = (x == 0 && y == 0);
 
-	/* either remove the atoms or set them */
-	use_atom = g_settings_get_boolean (priv->settings, GCM_SETTINGS_SET_ICC_PROFILE_ATOM);
-	if (!use_atom || profile == NULL) {
+	if (profile == NULL) {
 
 		/* at login we don't need to remove any previously set options */
 		if (!priv->remove_atom)
@@ -687,95 +570,6 @@ out:
 }
 
 /**
- * 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;
-	case PROP_EISA_ID:
-		g_value_set_string (value, priv->eisa_id);
-		break;
-	case PROP_EDID_MD5:
-		g_value_set_string (value, priv->edid_md5);
-		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);
-	GcmDeviceClass *device_class = GCM_DEVICE_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;
-
-	device_class->apply = gcm_device_xrandr_apply;
-	device_class->generate_profile = gcm_device_xrandr_generate_profile;
-
-	/**
-	 * 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);
-
-	/**
-	 * GcmDeviceXrandr:eisa-id:
-	 */
-	pspec = g_param_spec_string ("eisa-id", NULL, NULL,
-				     NULL,
-				     G_PARAM_READABLE);
-	g_object_class_install_property (object_class, PROP_EISA_ID, pspec);
-
-	/**
-	 * GcmDeviceXrandr:edid-md5:
-	 */
-	pspec = g_param_spec_string ("edid-md", NULL, NULL,
-				     NULL,
-				     G_PARAM_READABLE);
-	g_object_class_install_property (object_class, PROP_EDID_MD5, pspec);
-
-	g_type_class_add_private (klass, sizeof (GcmDeviceXrandrPrivate));
-}
-
-/**
  * gcm_device_xrandr_init:
  **/
 static void
@@ -789,7 +583,6 @@ gcm_device_xrandr_init (GcmDeviceXrandr *device_xrandr)
 	device_xrandr->priv->gamma_size = 0;
 	device_xrandr->priv->edid = gcm_edid_new ();
 	device_xrandr->priv->dmi = gcm_dmi_new ();
-	device_xrandr->priv->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
 	device_xrandr->priv->screen = gcm_x11_screen_new ();
 }
 
@@ -807,22 +600,7 @@ gcm_device_xrandr_finalize (GObject *object)
 	g_free (priv->edid_md5);
 	g_object_unref (priv->edid);
 	g_object_unref (priv->dmi);
-	g_object_unref (priv->settings);
 	g_object_unref (priv->screen);
 
 	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-session.c b/src/gcm-session.c
index d4e2403..c35a152 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -28,12 +28,13 @@
 #include <colord.h>
 #include <libnotify/notify.h>
 
-#include "gcm-device-xrandr.h"
-#include "gcm-exif.h"
+#include "gcm-debug.h"
 #include "gcm-device.h"
-#include "gcm-utils.h"
+#include "gcm-exif.h"
 #include "gcm-profile-store.h"
-#include "gcm-debug.h"
+#include "gcm-utils.h"
+#include "gcm-x11-output.h"
+#include "gcm-x11-screen.h"
 
 static GMainLoop *loop = NULL;
 static GSettings *settings = NULL;
@@ -333,11 +334,7 @@ gcm_session_get_profiles_for_device (const gchar *device_id_with_prefix, GError
 		device = g_ptr_array_index (array_devices, i);
 
 		/* get the id for this device */
-		if (use_native_device && GCM_IS_DEVICE_XRANDR (device)) {
-			device_id_tmp = gcm_device_xrandr_get_native_device (GCM_DEVICE_XRANDR (device));
-		} else {
-			device_id_tmp = gcm_device_get_id (device);
-		}
+		device_id_tmp = gcm_device_get_id (device);
 
 		/* wrong kind of device */
 		if (device_id_tmp == NULL)
diff --git a/src/gcm-x11-output.c b/src/gcm-x11-output.c
index 023aeda..0b25b31 100644
--- a/src/gcm-x11-output.c
+++ b/src/gcm-x11-output.c
@@ -362,7 +362,10 @@ out:
  * Return value: %TRUE for success.
  **/
 gboolean
-gcm_x11_output_get_edid_data (GcmX11Output *output, guint8 **data, gsize *length, GError **error)
+gcm_x11_output_get_edid_data (GcmX11Output *output,
+			      guint8 **data,
+			      gsize *length,
+			      GError **error)
 {
 	Atom edid_atom;
 	guint8 *result;
@@ -410,7 +413,12 @@ out:
  * Return value: %TRUE for success.
  **/
 gboolean
-gcm_x11_output_set_gamma (GcmX11Output *output, guint length, guint16 *red, guint16 *green, guint16 *blue, GError **error)
+gcm_x11_output_set_gamma (GcmX11Output *output,
+			  guint length,
+			  guint16 *red,
+			  guint16 *green,
+			  guint16 *blue,
+			  GError **error)
 {
 	guint copy_size;
 	XRRCrtcGamma *gamma;
@@ -450,6 +458,64 @@ gcm_x11_output_set_gamma (GcmX11Output *output, guint length, guint16 *red, guin
 }
 
 /**
+ * gcm_x11_output_set_gamma_from_clut:
+ **/
+gboolean
+gcm_x11_output_set_gamma_from_clut (GcmX11Output *output,
+				    GcmClut *clut,
+				    GError **error)
+{
+	gboolean ret = TRUE;
+	GPtrArray *array = NULL;
+	guint16 *red = NULL;
+	guint16 *green = NULL;
+	guint16 *blue = NULL;
+	guint i;
+	GcmClutData *data;
+
+	/* get data */
+	array = gcm_clut_get_array (clut);
+	if (array == NULL) {
+		ret = FALSE;
+		g_set_error_literal (error, 1, 0,
+				     "failed to get CLUT data");
+		goto out;
+	}
+
+	/* no length? */
+	if (array->len == 0) {
+		ret = FALSE;
+		g_set_error_literal (error, 1, 0,
+				     "no data in the CLUT array");
+		goto out;
+	}
+
+	/* convert to a type X understands */
+	red = g_new (guint16, array->len);
+	green = g_new (guint16, array->len);
+	blue = g_new (guint16, array->len);
+	for (i=0; i<array->len; i++) {
+		data = g_ptr_array_index (array, i);
+		red[i] = data->red;
+		green[i] = data->green;
+		blue[i] = data->blue;
+	}
+
+	/* send to LUT */
+	ret = gcm_x11_output_set_gamma (output, array->len,
+					red, green, blue, error);
+	if (!ret)
+		goto out;
+out:
+	g_free (red);
+	g_free (green);
+	g_free (blue);
+	if (array != NULL)
+		g_ptr_array_unref (array);
+	return ret;
+}
+
+/**
  * gcm_x11_output_get_gamma:
  * @output: a valid %GcmX11Output instance
  * @length: the returned data arrays size, or %NULL.
@@ -463,7 +529,12 @@ gcm_x11_output_set_gamma (GcmX11Output *output, guint length, guint16 *red, guin
  * Return value: %TRUE for success.
  **/
 gboolean
-gcm_x11_output_get_gamma (GcmX11Output *output, guint *length, guint16 **red, guint16 **green, guint16 **blue, GError **error)
+gcm_x11_output_get_gamma (GcmX11Output *output,
+			  guint *length,
+			  guint16 **red,
+			  guint16 **green,
+			  guint16 **blue,
+			  GError **error)
 {
 	guint copy_size;
 	guint16 *r, *g, *b;
@@ -516,7 +587,10 @@ gcm_x11_output_get_gamma (GcmX11Output *output, guint *length, guint16 **red, gu
  * Return value: %TRUE for success.
  **/
 gboolean
-gcm_x11_output_get_profile_data (GcmX11Output *output, guint8 **data, gsize *length, GError **error)
+gcm_x11_output_get_profile_data (GcmX11Output *output,
+				 guint8 **data,
+				 gsize *length,
+				 GError **error)
 {
 	gboolean ret = FALSE;
 	gchar *data_tmp = NULL;
@@ -543,17 +617,19 @@ gcm_x11_output_get_profile_data (GcmX11Output *output, guint8 **data, gsize *len
 
 	/* did the call fail */
 	if (rc != Success) {
-		g_set_error (error, 1, 0, "failed to get icc profile atom with rc %i", rc);
+		g_set_error (error, 1, 0,
+			     "failed to get icc profile atom with rc %i", rc);
 		goto out;
 	}
 
 	/* was nothing found */
 	if (nitems == 0) {
-		g_set_error (error, 1, 0, "icc profile atom has not been set");
+		g_set_error (error, 1, 0,
+			     "icc profile atom has not been set");
 		goto out;
 	}
 
-	/* allocate the data using Glib, rather than asking the user to use XFree */
+	/* allocate the data using Glib */
 	*data = g_new0 (guint8, nitems);
 	memcpy (*data, data_tmp, nitems);
 
@@ -580,7 +656,9 @@ out:
  * Return value: %TRUE for success.
  **/
 gboolean
-gcm_x11_output_set_profile (GcmX11Output *output, const gchar *filename, GError **error)
+gcm_x11_output_set_profile (GcmX11Output *output,
+			    const gchar *filename,
+			    GError **error)
 {
 	gboolean ret;
 	gchar *data = NULL;
diff --git a/src/gcm-x11-output.h b/src/gcm-x11-output.h
index bc54e0c..7338c75 100644
--- a/src/gcm-x11-output.h
+++ b/src/gcm-x11-output.h
@@ -24,6 +24,8 @@
 
 #include <glib-object.h>
 
+#include "gcm-clut.h"
+
 G_BEGIN_DECLS
 
 #define GCM_TYPE_X11_OUTPUT		(gcm_x11_output_get_type ())
@@ -94,6 +96,9 @@ gboolean	 gcm_x11_output_set_gamma		(GcmX11Output		*output,
 							 guint16		*green,
 							 guint16		*blue,
 							 GError			**error);
+gboolean	 gcm_x11_output_set_gamma_from_clut	(GcmX11Output		*output,
+							 GcmClut		*clut,
+							 GError			**error);
 gboolean	 gcm_x11_output_get_edid_data		(GcmX11Output		*output,
 							 guint8			**data,
 							 gsize			*length,



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