[gnome-color-manager: 61/80] trivial: move GcmClut, GcmProfile and GcmXyz to libcolor-glib



commit 4d48676a999c1d4e3b4da9ffed9c6b5a5c712307
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jul 18 12:36:28 2010 +0100

    trivial: move GcmClut, GcmProfile and GcmXyz to libcolor-glib

 libcolor-glib/Makefile.am            |   13 ++-
 {src => libcolor-glib}/gcm-clut.c    |    9 +--
 {src => libcolor-glib}/gcm-clut.h    |    0
 {src => libcolor-glib}/gcm-enum.c    |   19 ----
 {src => libcolor-glib}/gcm-enum.h    |    3 +-
 {src => libcolor-glib}/gcm-profile.c |   48 ++++++++-
 {src => libcolor-glib}/gcm-profile.h |    0
 libcolor-glib/gcm-self-test.c        |  198 +++++++++++++++++++++++++++++++++-
 {src => libcolor-glib}/gcm-xyz.c     |    0
 {src => libcolor-glib}/gcm-xyz.h     |    0
 libcolor-glib/libcolor-glib.h        |    4 +
 libcolor-glib/libcolor-glib.pc.in    |    2 +-
 po/POTFILES.in                       |    3 +-
 src/Makefile.am                      |   25 +----
 src/cc-color-panel.c                 |    1 +
 src/gcm-device-xrandr.c              |    1 +
 src/gcm-self-test.c                  |  193 ---------------------------------
 src/gcm-utils.c                      |   54 +++-------
 src/gcm-utils.h                      |    3 +-
 19 files changed, 285 insertions(+), 291 deletions(-)
---
diff --git a/libcolor-glib/Makefile.am b/libcolor-glib/Makefile.am
index 6d651d4..b614ed5 100644
--- a/libcolor-glib/Makefile.am
+++ b/libcolor-glib/Makefile.am
@@ -7,6 +7,7 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
 
 INCLUDES = \
 	$(GLIB_CFLAGS)						\
+	$(LCMS_CFLAGS)						\
 	$(USB_CFLAGS)						\
 	-I$(top_srcdir)/libcolor-glib				\
 	-I$(top_builddir)/libcolor-glib				\
@@ -37,7 +38,8 @@ libcolor_glib_include_HEADERS =					\
 	gcm-sensor-huey.h					\
 	gcm-sensor.h						\
 	gcm-edid.h						\
-	gcm-tables.h						\
+	gcm-enum.h						\
+	gcm-profile.h						\
 	gcm-version.h						\
 	$(NULL)
 
@@ -57,6 +59,10 @@ libcolor_glib_la_SOURCES =					\
 	gcm-tables.h						\
 	gcm-edid.c						\
 	gcm-edid.h						\
+	gcm-profile.c						\
+	gcm-profile.h						\
+	gcm-clut.c						\
+	gcm-clut.h						\
 	gcm-ddc-client.c					\
 	gcm-ddc-client.h					\
 	gcm-ddc-device.c					\
@@ -65,11 +71,16 @@ libcolor_glib_la_SOURCES =					\
 	gcm-ddc-control.h					\
 	gcm-ddc-common.c					\
 	gcm-ddc-common.h					\
+	gcm-enum.c						\
+	gcm-enum.h						\
+	gcm-xyz.c						\
+	gcm-xyz.h						\
 	gcm-version.h						\
 	$(NULL)
 
 libcolor_glib_la_LIBADD =					\
 	$(USB_LIBS)						\
+	$(LCMS_LIBS)						\
 	$(GLIB_LIBS)						\
 	-lm
 
diff --git a/src/gcm-clut.c b/libcolor-glib/gcm-clut.c
similarity index 96%
rename from src/gcm-clut.c
rename to libcolor-glib/gcm-clut.c
index 7436678..86f2003 100644
--- a/src/gcm-clut.c
+++ b/libcolor-glib/gcm-clut.c
@@ -34,7 +34,7 @@
 #include <gio/gio.h>
 
 #include "gcm-clut.h"
-#include "gcm-utils.h"
+//#include "gcm-utils.h"
 
 #include "egg-debug.h"
 
@@ -54,7 +54,6 @@ struct _GcmClutPrivate
 	gdouble				 gamma;
 	gdouble				 brightness;
 	gdouble				 contrast;
-	GSettings			*settings;
 };
 
 enum {
@@ -332,10 +331,7 @@ gcm_clut_init (GcmClut *clut)
 {
 	clut->priv = GCM_CLUT_GET_PRIVATE (clut);
 	clut->priv->array = g_ptr_array_new_with_free_func (g_free);
-	clut->priv->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
-	clut->priv->gamma = g_settings_get_double (clut->priv->settings, GCM_SETTINGS_DEFAULT_GAMMA);
-	if (clut->priv->gamma < 0.01)
-		clut->priv->gamma = 1.0f;
+	clut->priv->gamma = 1.0;
 	clut->priv->brightness = 0.0f;
 	clut->priv->contrast = 100.f;
 }
@@ -350,7 +346,6 @@ gcm_clut_finalize (GObject *object)
 	GcmClutPrivate *priv = clut->priv;
 
 	g_ptr_array_unref (priv->array);
-	g_object_unref (clut->priv->settings);
 
 	G_OBJECT_CLASS (gcm_clut_parent_class)->finalize (object);
 }
diff --git a/src/gcm-clut.h b/libcolor-glib/gcm-clut.h
similarity index 100%
rename from src/gcm-clut.h
rename to libcolor-glib/gcm-clut.h
diff --git a/src/gcm-enum.c b/libcolor-glib/gcm-enum.c
similarity index 91%
rename from src/gcm-enum.c
rename to libcolor-glib/gcm-enum.c
index e6c3930..fa4f83d 100644
--- a/src/gcm-enum.c
+++ b/libcolor-glib/gcm-enum.c
@@ -21,8 +21,6 @@
 
 #include "config.h"
 
-#include <glib/gi18n.h>
-
 #include "gcm-enum.h"
 
 /**
@@ -135,23 +133,6 @@ gcm_colorspace_to_string (GcmColorspace colorspace)
 }
 
 /**
- * gcm_colorspace_to_localised_string:
- **/
-const gchar *
-gcm_colorspace_to_localised_string (GcmColorspace colorspace)
-{
-	if (colorspace == GCM_COLORSPACE_RGB) {
-		/* TRANSLATORS: this is the colorspace, e.g. red, green, blue */
-		return _("RGB");
-	}
-	if (colorspace == GCM_COLORSPACE_CMYK) {
-		/* TRANSLATORS: this is the colorspace, e.g. cyan, magenta, yellow, black */
-		return _("CMYK");
-	}
-	return NULL;
-}
-
-/**
  * gcm_colorspace_from_string:
  **/
 GcmColorspace
diff --git a/src/gcm-enum.h b/libcolor-glib/gcm-enum.h
similarity index 96%
rename from src/gcm-enum.h
rename to libcolor-glib/gcm-enum.h
index fff75f4..920abc6 100644
--- a/src/gcm-enum.h
+++ b/libcolor-glib/gcm-enum.h
@@ -22,7 +22,7 @@
 #ifndef __GCM_ENUM_H
 #define __GCM_ENUM_H
 
-#include <glib/gi18n.h>
+#include <glib-object.h>
 
 typedef enum {
 	GCM_INTENT_UNKNOWN,
@@ -74,7 +74,6 @@ const gchar	*gcm_intent_to_string			(GcmIntent		 intent);
 GcmProfileKind	 gcm_profile_kind_from_string		(const gchar		*profile_kind);
 const gchar	*gcm_profile_kind_to_string		(GcmProfileKind		 profile_kind);
 const gchar	*gcm_colorspace_to_string		(GcmColorspace		 colorspace);
-const gchar	*gcm_colorspace_to_localised_string	(GcmColorspace	 colorspace);
 GcmColorspace	 gcm_colorspace_from_string		(const gchar		*colorspace);
 GcmDeviceKind	 gcm_device_kind_from_string		(const gchar		*kind);
 const gchar	*gcm_device_kind_to_string		(GcmDeviceKind		 kind);
diff --git a/src/gcm-profile.c b/libcolor-glib/gcm-profile.c
similarity index 97%
rename from src/gcm-profile.c
rename to libcolor-glib/gcm-profile.c
index a32f2b6..afee80e 100644
--- a/src/gcm-profile.c
+++ b/libcolor-glib/gcm-profile.c
@@ -37,7 +37,7 @@
 #include "egg-debug.h"
 
 #include "gcm-profile.h"
-#include "gcm-utils.h"
+//#include "gcm-utils.h"
 #include "gcm-xyz.h"
 
 static void     gcm_profile_finalize	(GObject     *object);
@@ -115,6 +115,30 @@ gcm_profile_get_description (GcmProfile *profile)
 	return profile->priv->description;
 }
 
+
+/**
+ * gcm_profile_ensure_printable:
+ **/
+static void
+gcm_profile_ensure_printable (gchar *text)
+{
+	guint i;
+	guint idx = 0;
+
+	g_return_if_fail (text != NULL);
+
+	for (i=0; text[i] != '\0'; i++) {
+		if (g_ascii_isalnum (text[i]) ||
+		    g_ascii_ispunct (text[i]) ||
+		    text[i] == ' ')
+			text[idx++] = text[i];
+	}
+	text[idx] = '\0';
+
+	/* broken profiles have _ instead of spaces */
+	g_strdelimit (text, "_", ' ');
+}
+
 /**
  * gcm_profile_set_description:
  **/
@@ -128,7 +152,7 @@ gcm_profile_set_description (GcmProfile *profile, const gchar *description)
 	priv->description = g_strdup (description);
 
 	if (priv->description != NULL)
-		gcm_utils_ensure_printable (priv->description);
+		gcm_profile_ensure_printable (priv->description);
 
 	/* there's nothing sensible to display */
 	if (priv->description == NULL || priv->description[0] == '\0') {
@@ -245,7 +269,7 @@ gcm_profile_set_copyright (GcmProfile *profile, const gchar *copyright)
 	g_free (priv->copyright);
 	priv->copyright = g_strdup (copyright);
 	if (priv->copyright != NULL)
-		gcm_utils_ensure_printable (priv->copyright);
+		gcm_profile_ensure_printable (priv->copyright);
 	g_object_notify (G_OBJECT (profile), "copyright");
 }
 
@@ -272,7 +296,7 @@ gcm_profile_set_model (GcmProfile *profile, const gchar *model)
 	g_free (priv->model);
 	priv->model = g_strdup (model);
 	if (priv->model != NULL)
-		gcm_utils_ensure_printable (priv->model);
+		gcm_profile_ensure_printable (priv->model);
 	g_object_notify (G_OBJECT (profile), "model");
 }
 
@@ -299,7 +323,7 @@ gcm_profile_set_manufacturer (GcmProfile *profile, const gchar *manufacturer)
 	g_free (priv->manufacturer);
 	priv->manufacturer = g_strdup (manufacturer);
 	if (priv->manufacturer != NULL)
-		gcm_utils_ensure_printable (priv->manufacturer);
+		gcm_profile_ensure_printable (priv->manufacturer);
 	g_object_notify (G_OBJECT (profile), "manufacturer");
 }
 
@@ -460,6 +484,20 @@ gcm_profile_get_can_delete (GcmProfile *profile)
 }
 
 /**
+ * gcm_utils_format_date_time:
+ **/
+static gchar *
+gcm_utils_format_date_time (const struct tm *created)
+{
+	gchar buffer[256];
+
+	/* TRANSLATORS: this is the profile creation date strftime format */
+	strftime (buffer, sizeof(buffer), _("%B %e %Y, %I:%M:%S %p"), created);
+
+	return g_strdup (g_strchug (buffer));
+}
+
+/**
  * gcm_profile_parse_data:
  **/
 gboolean
diff --git a/src/gcm-profile.h b/libcolor-glib/gcm-profile.h
similarity index 100%
rename from src/gcm-profile.h
rename to libcolor-glib/gcm-profile.h
diff --git a/libcolor-glib/gcm-self-test.c b/libcolor-glib/gcm-self-test.c
index c581f03..9eda46c 100644
--- a/libcolor-glib/gcm-self-test.c
+++ b/libcolor-glib/gcm-self-test.c
@@ -22,6 +22,7 @@
 #include "config.h"
 
 #include <glib-object.h>
+#include <math.h>
 
 #include "gcm-common.h"
 #include "gcm-sensor-dummy.h"
@@ -29,6 +30,9 @@
 #include "gcm-ddc-device.h"
 #include "gcm-edid.h"
 #include "gcm-tables.h"
+#include "gcm-profile.h"
+#include "gcm-clut.h"
+#include "gcm-xyz.h"
 
 static void
 gcm_test_common_func (void)
@@ -291,6 +295,193 @@ gcm_test_tables_func (void)
 	g_object_unref (tables);
 }
 
+
+static void
+gcm_test_profile_func (void)
+{
+	GcmProfile *profile;
+	GFile *file;
+	GcmClut *clut;
+	gboolean ret;
+	GError *error = NULL;
+	GcmXyz *xyz;
+
+	/* bluish test */
+	profile = gcm_profile_new ();
+	file = g_file_new_for_path (TESTDATADIR "/bluish.icc");
+	ret = gcm_profile_parse (profile, file, &error);
+	g_assert_no_error (error);
+	g_assert (ret);
+	g_object_unref (file);
+
+	/* get CLUT */
+	clut = gcm_profile_generate_vcgt (profile, 256);
+	g_assert (clut != NULL);
+	g_assert_cmpint (gcm_clut_get_size (clut), ==, 256);
+
+	g_assert_cmpstr (gcm_profile_get_copyright (profile), ==, "Copyright (c) 1998 Hewlett-Packard Company");
+	g_assert_cmpstr (gcm_profile_get_manufacturer (profile), ==, "IEC http://www.iec.ch";);
+	g_assert_cmpstr (gcm_profile_get_model (profile), ==, "IEC 61966-2.1 Default RGB colour space - sRGB");
+	g_assert_cmpstr (gcm_profile_get_datetime (profile), ==, "February  9 1998, 06:49:00 AM");
+	g_assert_cmpstr (gcm_profile_get_description (profile), ==, "Blueish Test");
+	g_assert_cmpstr (gcm_profile_get_checksum (profile), ==, "8e2aed5dac6f8b5d8da75610a65b7f27");
+	g_assert_cmpint (gcm_profile_get_kind (profile), ==, GCM_PROFILE_KIND_DISPLAY_DEVICE);
+	g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, GCM_COLORSPACE_RGB);
+	g_assert (gcm_profile_get_has_vcgt (profile));
+
+	/* get extra data */
+	g_object_get (profile,
+		      "red", &xyz,
+		      NULL);
+	g_assert_cmpfloat (fabs (gcm_xyz_get_x (xyz) - 0.648454), <, 0.01);
+
+	g_object_unref (xyz);
+	g_object_unref (clut);
+	g_object_unref (profile);
+
+	/* Adobe test */
+	profile = gcm_profile_new ();
+	file = g_file_new_for_path (TESTDATADIR "/AdobeGammaTest.icm");
+	ret = gcm_profile_parse (profile, file, &error);
+	g_assert_no_error (error);
+	g_assert (ret);
+	g_object_unref (file);
+
+	g_assert_cmpstr (gcm_profile_get_copyright (profile), ==, "Copyright (c) 1998 Hewlett-Packard Company Modified using Adobe Gamma");
+	g_assert_cmpstr (gcm_profile_get_manufacturer (profile), ==, "IEC http://www.iec.ch";);
+	g_assert_cmpstr (gcm_profile_get_model (profile), ==, "IEC 61966-2.1 Default RGB colour space - sRGB");
+	g_assert_cmpstr (gcm_profile_get_datetime (profile), ==, "August 16 2005, 09:49:54 PM");
+	g_assert_cmpstr (gcm_profile_get_description (profile), ==, "ADOBEGAMMA-Test");
+	g_assert_cmpstr (gcm_profile_get_checksum (profile), ==, "bd847723f676e2b846daaf6759330624");
+	g_assert_cmpint (gcm_profile_get_kind (profile), ==, GCM_PROFILE_KIND_DISPLAY_DEVICE);
+	g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, GCM_COLORSPACE_RGB);
+	g_assert (gcm_profile_get_has_vcgt (profile));
+
+	g_object_unref (profile);
+}
+
+
+static void
+gcm_test_clut_func (void)
+{
+	GcmClut *clut;
+	GPtrArray *array;
+	const GcmClutData *data;
+
+	clut = gcm_clut_new ();
+	g_assert (clut != NULL);
+
+	/* set some initial properties */
+	g_object_set (clut,
+		      "size", 3,
+		      "contrast", 100.0f,
+		      "brightness", 0.0f,
+		      NULL);
+
+	array = gcm_clut_get_array (clut);
+	g_assert_cmpint (array->len, ==, 3);
+
+	data = g_ptr_array_index (array, 0);
+	g_assert_cmpint (data->red, ==, 0);
+	g_assert_cmpint (data->green, ==, 0);
+	g_assert_cmpint (data->blue, ==, 0);
+
+	data = g_ptr_array_index (array, 1);
+	g_assert_cmpint (data->red, ==, 32767);
+	g_assert_cmpint (data->green, ==, 32767);
+	g_assert_cmpint (data->blue, ==, 32767);
+
+	data = g_ptr_array_index (array, 2);
+	g_assert_cmpint (data->red, ==, 65535);
+	g_assert_cmpint (data->green, ==, 65535);
+	g_assert_cmpint (data->blue, ==, 65535);
+
+	g_ptr_array_unref (array);
+
+	/* set some initial properties */
+	g_object_set (clut,
+		      "contrast", 99.0f,
+		      "brightness", 0.0f,
+		      NULL);
+
+	array = gcm_clut_get_array (clut);
+	g_assert_cmpint (array->len, ==, 3);
+
+	data = g_ptr_array_index (array, 0);
+	g_assert_cmpint (data->red, ==, 0);
+	g_assert_cmpint (data->green, ==, 0);
+	g_assert_cmpint (data->blue, ==, 0);
+	data = g_ptr_array_index (array, 1);
+	g_assert_cmpint (data->red, ==, 32439);
+	g_assert_cmpint (data->green, ==, 32439);
+	g_assert_cmpint (data->blue, ==, 32439);
+	data = g_ptr_array_index (array, 2);
+	g_assert_cmpint (data->red, ==, 64879);
+	g_assert_cmpint (data->green, ==, 64879);
+	g_assert_cmpint (data->blue, ==, 64879);
+
+	g_ptr_array_unref (array);
+
+	/* set some initial properties */
+	g_object_set (clut,
+		      "contrast", 100.0f,
+		      "brightness", 1.0f,
+		      NULL);
+
+	array = gcm_clut_get_array (clut);
+	g_assert_cmpint (array->len, ==, 3);
+
+	data = g_ptr_array_index (array, 0);
+	g_assert_cmpint (data->red, ==, 655);
+	g_assert_cmpint (data->green, ==, 655);
+	g_assert_cmpint (data->blue, ==, 655);
+	data = g_ptr_array_index (array, 1);
+	g_assert_cmpint (data->red, ==, 33094);
+	g_assert_cmpint (data->green, ==, 33094);
+	g_assert_cmpint (data->blue, ==, 33094);
+	data = g_ptr_array_index (array, 2);
+	g_assert_cmpint (data->red, ==, 65535);
+	g_assert_cmpint (data->green, ==, 65535);
+	g_assert_cmpint (data->blue, ==, 65535);
+
+	g_ptr_array_unref (array);
+
+	g_object_unref (clut);
+}
+
+
+static void
+gcm_test_xyz_func (void)
+{
+	GcmXyz *xyz;
+	gdouble value;
+
+	xyz = gcm_xyz_new ();
+	g_assert (xyz != NULL);
+
+	/* nothing set */
+	value = gcm_xyz_get_x (xyz);
+	g_assert_cmpfloat (fabs (value - 0.0f), <, 0.001f);
+
+	/* set dummy values */
+	g_object_set (xyz,
+		      "cie-x", 0.125,
+		      "cie-y", 0.25,
+		      "cie-z", 0.5,
+		      NULL);
+
+	value = gcm_xyz_get_x (xyz);
+	g_assert_cmpfloat (fabs (value - 0.142857143f), <, 0.001f);
+
+	value = gcm_xyz_get_y (xyz);
+	g_assert_cmpfloat (fabs (value - 0.285714286f), <, 0.001f);
+
+	value = gcm_xyz_get_z (xyz);
+	g_assert_cmpfloat (fabs (value - 0.571428571f), <, 0.001f);
+
+	g_object_unref (xyz);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -303,8 +494,11 @@ main (int argc, char **argv)
 	g_test_add_func ("/libcolor-glib/ddc-device", gcm_test_ddc_device_func);
 	g_test_add_func ("/libcolor-glib/ddc-client", gcm_test_ddc_client_func);
 	g_test_add_func ("/libcolor-glib/sensor", gcm_test_sensor_func);
-	g_test_add_func ("/color/edid", gcm_test_edid_func);
-	g_test_add_func ("/color/tables", gcm_test_tables_func);
+	g_test_add_func ("/libcolor-glib/edid", gcm_test_edid_func);
+	g_test_add_func ("/libcolor-glib/tables", gcm_test_tables_func);
+	g_test_add_func ("/libcolor-glib/profile", gcm_test_profile_func);
+	g_test_add_func ("/libcolor-glib/clut", gcm_test_clut_func);
+	g_test_add_func ("/libcolor-glib/xyz", gcm_test_xyz_func);
 
 	return g_test_run ();
 }
diff --git a/src/gcm-xyz.c b/libcolor-glib/gcm-xyz.c
similarity index 100%
rename from src/gcm-xyz.c
rename to libcolor-glib/gcm-xyz.c
diff --git a/src/gcm-xyz.h b/libcolor-glib/gcm-xyz.h
similarity index 100%
rename from src/gcm-xyz.h
rename to libcolor-glib/gcm-xyz.h
diff --git a/libcolor-glib/libcolor-glib.h b/libcolor-glib/libcolor-glib.h
index 75a2b04..351f642 100644
--- a/libcolor-glib/libcolor-glib.h
+++ b/libcolor-glib/libcolor-glib.h
@@ -36,6 +36,10 @@
 #include <gcm-sensor.h>
 #include <gcm-sensor-huey.h>
 #include <gcm-sensor-dummy.h>
+#include <gcm-edid.h>
+#include <gcm-profile.h>
+#include <gcm-enum.h>
+#include <gcm-clut.h>
 
 #undef __GCM_H_INSIDE__
 
diff --git a/libcolor-glib/libcolor-glib.pc.in b/libcolor-glib/libcolor-glib.pc.in
index 0fa719b..3c0b029 100644
--- a/libcolor-glib/libcolor-glib.pc.in
+++ b/libcolor-glib/libcolor-glib.pc.in
@@ -7,6 +7,6 @@ Name: libcolor-glib
 Description: libcolor-glib is a userspace color library.
 Version: @VERSION@
 Requires.private: gthread-2.0
-Requires: glib-2.0, gobject-2.0, libusb-1.0
+Requires: glib-2.0, gobject-2.0, libusb-1.0 lcms2
 Libs: -L${libdir} -llibcolor-glib
 Cflags: -I${includedir}/libcolor-glib
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d7ec61c..4e08590 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -17,16 +17,15 @@ src/gcm-colorimeter.c
 src/gcm-device-xrandr.c
 src/gcm-dump-edid.c
 src/gcm-dump-profile.c
-src/gcm-enum.c
 src/gcm-fix-profile.c
 src/gcm-import.c
 src/gcm-inspect.c
 src/gcm-install-system-wide.c
 src/gcm-picker.c
 src/gcm-viewer.c
-src/gcm-profile.c
 src/gcm-session.c
 src/gcm-utils.c
+libcolor-glib/gcm-profile.c
 [type: gettext/glade]data/gcm-calibrate.ui
 [type: gettext/glade]data/gcm-picker.ui
 [type: gettext/glade]data/gcm-prefs.ui
diff --git a/src/Makefile.am b/src/Makefile.am
index 3ce91d6..accafd7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,6 @@ INCLUDES =						\
 	$(GTK_CFLAGS)					\
 	$(GNOMEDESKTOP_CFLAGS)				\
 	$(VTE_CFLAGS)					\
-	$(LCMS_CFLAGS)					\
 	$(XORG_CFLAGS)					\
 	$(CUPS_CFLAGS)					\
 	$(SANE_CFLAGS)					\
@@ -44,18 +43,12 @@ libgcmshared_a_SOURCES =				\
 	gcm-image.h					\
 	gcm-screen.c					\
 	gcm-screen.h					\
-	gcm-xyz.c					\
-	gcm-xyz.h					\
 	gcm-exif.c					\
 	gcm-exif.h					\
 	gcm-print.c					\
 	gcm-print.h					\
 	gcm-utils.c					\
 	gcm-utils.h					\
-	gcm-enum.c					\
-	gcm-enum.h					\
-	gcm-clut.c					\
-	gcm-clut.h					\
 	gcm-dmi.c					\
 	gcm-dmi.h					\
 	gcm-xserver.c					\
@@ -82,8 +75,6 @@ libgcmshared_a_SOURCES =				\
 	gcm-gamma-widget.h				\
 	gcm-profile-store.c				\
 	gcm-profile-store.h				\
-	gcm-profile.c					\
-	gcm-profile.h					\
 	gcm-calibrate.c					\
 	gcm-calibrate.h					\
 	gcm-calibrate-argyll.c				\
@@ -146,7 +137,6 @@ gcm_dump_edid_LDADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
@@ -166,7 +156,6 @@ gcm_dump_profile_LDADD =				\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
@@ -183,10 +172,10 @@ gcm_fix_profile_SOURCES =				\
 gcm_fix_profile_LDADD =					\
 	$(GLIB_LIBS)					\
 	$(X11_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
 	$(CUPS_LIBS)					\
+	$(LCMS_LIBS)					\
 	-lm
 
 gcm_fix_profile_CFLAGS =				\
@@ -201,11 +190,11 @@ gcm_inspect_LDADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
 	$(CUPS_LIBS)					\
+	$(COLOR_GLIB_LIBS)				\
 	-lm
 
 gcm_inspect_CFLAGS =					\
@@ -220,7 +209,6 @@ gcm_apply_LDADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
@@ -240,11 +228,11 @@ gcm_import_LDADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
 	$(CUPS_LIBS)					\
+	$(COLOR_GLIB_LIBS)				\
 	-lm
 
 gcm_import_CFLAGS =					\
@@ -262,13 +250,13 @@ gcm_viewer_LDADD =					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(VTE_LIBS)					\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
 	$(CUPS_LIBS)					\
 	$(TIFF_LIBS)					\
 	$(EXIF_LIBS)					\
+	$(COLOR_GLIB_LIBS)				\
 	-lm
 
 gcm_viewer_CFLAGS =					\
@@ -284,7 +272,6 @@ gcm_picker_LDADD =					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(VTE_LIBS)					\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
@@ -307,7 +294,6 @@ gcm_session_LDADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(TIFF_LIBS)					\
@@ -334,7 +320,6 @@ libcolor_la_LIBADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(TIFF_LIBS)					\
@@ -377,13 +362,13 @@ gcm_self_test_LDADD =					\
 	$(X11_LIBS)					\
 	$(GNOMEDESKTOP_LIBS)				\
 	$(GUDEV_LIBS)					\
-	$(LCMS_LIBS)					\
 	$(XORG_LIBS)					\
 	$(GTK_LIBS)					\
 	$(SANE_LIBS)					\
 	$(CUPS_LIBS)					\
 	$(TIFF_LIBS)					\
 	$(EXIF_LIBS)					\
+	$(COLOR_GLIB_LIBS)				\
 	-lm
 
 gcm_self_test_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS_C)
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index abc4dcf..4a6081c 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index b17e07a..b7457df 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -22,6 +22,7 @@
 #include "config.h"
 
 #include <glib-object.h>
+#include <glib/gi18n.h>
 #include <math.h>
 #include <libgnomeui/gnome-rr.h>
 #include <X11/extensions/Xrandr.h>
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 502d037..e9dab4e 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -29,7 +29,6 @@
 #include "gcm-calibrate-manual.h"
 #include "gcm-cie-widget.h"
 #include "gcm-client.h"
-#include "gcm-clut.h"
 #include "gcm-device.h"
 #include "gcm-device-udev.h"
 #include "gcm-device-xrandr.h"
@@ -270,94 +269,6 @@ gcm_test_cie_widget_func (void)
 	g_object_unref (blue);
 }
 
-static void
-gcm_test_clut_func (void)
-{
-	GcmClut *clut;
-	GPtrArray *array;
-	const GcmClutData *data;
-
-	clut = gcm_clut_new ();
-	g_assert (clut != NULL);
-
-	/* set some initial properties */
-	g_object_set (clut,
-		      "size", 3,
-		      "contrast", 100.0f,
-		      "brightness", 0.0f,
-		      NULL);
-
-	array = gcm_clut_get_array (clut);
-	g_assert_cmpint (array->len, ==, 3);
-
-	data = g_ptr_array_index (array, 0);
-	g_assert_cmpint (data->red, ==, 0);
-	g_assert_cmpint (data->green, ==, 0);
-	g_assert_cmpint (data->blue, ==, 0);
-
-	data = g_ptr_array_index (array, 1);
-	g_assert_cmpint (data->red, ==, 32767);
-	g_assert_cmpint (data->green, ==, 32767);
-	g_assert_cmpint (data->blue, ==, 32767);
-
-	data = g_ptr_array_index (array, 2);
-	g_assert_cmpint (data->red, ==, 65535);
-	g_assert_cmpint (data->green, ==, 65535);
-	g_assert_cmpint (data->blue, ==, 65535);
-
-	g_ptr_array_unref (array);
-
-	/* set some initial properties */
-	g_object_set (clut,
-		      "contrast", 99.0f,
-		      "brightness", 0.0f,
-		      NULL);
-
-	array = gcm_clut_get_array (clut);
-	g_assert_cmpint (array->len, ==, 3);
-
-	data = g_ptr_array_index (array, 0);
-	g_assert_cmpint (data->red, ==, 0);
-	g_assert_cmpint (data->green, ==, 0);
-	g_assert_cmpint (data->blue, ==, 0);
-	data = g_ptr_array_index (array, 1);
-	g_assert_cmpint (data->red, ==, 32439);
-	g_assert_cmpint (data->green, ==, 32439);
-	g_assert_cmpint (data->blue, ==, 32439);
-	data = g_ptr_array_index (array, 2);
-	g_assert_cmpint (data->red, ==, 64879);
-	g_assert_cmpint (data->green, ==, 64879);
-	g_assert_cmpint (data->blue, ==, 64879);
-
-	g_ptr_array_unref (array);
-
-	/* set some initial properties */
-	g_object_set (clut,
-		      "contrast", 100.0f,
-		      "brightness", 1.0f,
-		      NULL);
-
-	array = gcm_clut_get_array (clut);
-	g_assert_cmpint (array->len, ==, 3);
-
-	data = g_ptr_array_index (array, 0);
-	g_assert_cmpint (data->red, ==, 655);
-	g_assert_cmpint (data->green, ==, 655);
-	g_assert_cmpint (data->blue, ==, 655);
-	data = g_ptr_array_index (array, 1);
-	g_assert_cmpint (data->red, ==, 33094);
-	g_assert_cmpint (data->green, ==, 33094);
-	g_assert_cmpint (data->blue, ==, 33094);
-	data = g_ptr_array_index (array, 2);
-	g_assert_cmpint (data->red, ==, 65535);
-	g_assert_cmpint (data->green, ==, 65535);
-	g_assert_cmpint (data->blue, ==, 65535);
-
-	g_ptr_array_unref (array);
-
-	g_object_unref (clut);
-}
-
 static guint _changes = 0;
 
 static void
@@ -695,70 +606,6 @@ gcm_test_print_func (void)
 }
 
 static void
-gcm_test_profile_func (void)
-{
-	GcmProfile *profile;
-	GFile *file;
-	GcmClut *clut;
-	gboolean ret;
-	GError *error = NULL;
-	GcmXyz *xyz;
-
-	/* bluish test */
-	profile = gcm_profile_new ();
-	file = g_file_new_for_path (TESTDATADIR "/bluish.icc");
-	ret = gcm_profile_parse (profile, file, &error);
-	g_assert_no_error (error);
-	g_assert (ret);
-	g_object_unref (file);
-
-	/* get CLUT */
-	clut = gcm_profile_generate_vcgt (profile, 256);
-	g_assert (clut != NULL);
-	g_assert_cmpint (gcm_clut_get_size (clut), ==, 256);
-
-	g_assert_cmpstr (gcm_profile_get_copyright (profile), ==, "Copyright (c) 1998 Hewlett-Packard Company");
-	g_assert_cmpstr (gcm_profile_get_manufacturer (profile), ==, "IEC http://www.iec.ch";);
-	g_assert_cmpstr (gcm_profile_get_model (profile), ==, "IEC 61966-2.1 Default RGB colour space - sRGB");
-	g_assert_cmpstr (gcm_profile_get_datetime (profile), ==, "February  9 1998, 06:49:00 AM");
-	g_assert_cmpstr (gcm_profile_get_description (profile), ==, "Blueish Test");
-	g_assert_cmpstr (gcm_profile_get_checksum (profile), ==, "8e2aed5dac6f8b5d8da75610a65b7f27");
-	g_assert_cmpint (gcm_profile_get_kind (profile), ==, GCM_PROFILE_KIND_DISPLAY_DEVICE);
-	g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, GCM_COLORSPACE_RGB);
-	g_assert (gcm_profile_get_has_vcgt (profile));
-
-	/* get extra data */
-	g_object_get (profile,
-		      "red", &xyz,
-		      NULL);
-	g_assert_cmpfloat (fabs (gcm_xyz_get_x (xyz) - 0.648454), <, 0.01);
-
-	g_object_unref (xyz);
-	g_object_unref (clut);
-	g_object_unref (profile);
-
-	/* Adobe test */
-	profile = gcm_profile_new ();
-	file = g_file_new_for_path (TESTDATADIR "/AdobeGammaTest.icm");
-	ret = gcm_profile_parse (profile, file, &error);
-	g_assert_no_error (error);
-	g_assert (ret);
-	g_object_unref (file);
-
-	g_assert_cmpstr (gcm_profile_get_copyright (profile), ==, "Copyright (c) 1998 Hewlett-Packard Company Modified using Adobe Gamma");
-	g_assert_cmpstr (gcm_profile_get_manufacturer (profile), ==, "IEC http://www.iec.ch";);
-	g_assert_cmpstr (gcm_profile_get_model (profile), ==, "IEC 61966-2.1 Default RGB colour space - sRGB");
-	g_assert_cmpstr (gcm_profile_get_datetime (profile), ==, "August 16 2005, 09:49:54 PM");
-	g_assert_cmpstr (gcm_profile_get_description (profile), ==, "ADOBEGAMMA-Test");
-	g_assert_cmpstr (gcm_profile_get_checksum (profile), ==, "bd847723f676e2b846daaf6759330624");
-	g_assert_cmpint (gcm_profile_get_kind (profile), ==, GCM_PROFILE_KIND_DISPLAY_DEVICE);
-	g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, GCM_COLORSPACE_RGB);
-	g_assert (gcm_profile_get_has_vcgt (profile));
-
-	g_object_unref (profile);
-}
-
-static void
 gcm_test_profile_store_func (void)
 {
 	GcmProfileStore *store;
@@ -887,11 +734,6 @@ gcm_test_utils_func (void)
 	g_assert_cmpstr (filename, ==, "Hel lo__Wo-(r)ld_");
 	g_free (filename);
 
-	text = g_strdup ("1\r34 67_90");
-	gcm_utils_ensure_printable (text);
-	g_assert_cmpstr (text, ==, "134 67 90");
-	g_free (text);
-
 	/* get default config location (when in make check) */
 	g_setenv ("GCM_TEST", "1", TRUE);
 	filename = gcm_utils_get_default_config_location ();
@@ -903,38 +745,6 @@ gcm_test_utils_func (void)
 }
 
 static void
-gcm_test_xyz_func (void)
-{
-	GcmXyz *xyz;
-	gdouble value;
-
-	xyz = gcm_xyz_new ();
-	g_assert (xyz != NULL);
-
-	/* nothing set */
-	value = gcm_xyz_get_x (xyz);
-	g_assert_cmpfloat (fabs (value - 0.0f), <, 0.001f);
-
-	/* set dummy values */
-	g_object_set (xyz,
-		      "cie-x", 0.125,
-		      "cie-y", 0.25,
-		      "cie-z", 0.5,
-		      NULL);
-
-	value = gcm_xyz_get_x (xyz);
-	g_assert_cmpfloat (fabs (value - 0.142857143f), <, 0.001f);
-
-	value = gcm_xyz_get_y (xyz);
-	g_assert_cmpfloat (fabs (value - 0.285714286f), <, 0.001f);
-
-	value = gcm_xyz_get_z (xyz);
-	g_assert_cmpfloat (fabs (value - 0.571428571f), <, 0.001f);
-
-	g_object_unref (xyz);
-}
-
-static void
 gcm_test_client_func (void)
 {
 	GcmClient *client;
@@ -1049,10 +859,7 @@ main (int argc, char **argv)
 	g_test_add_func ("/color/exif", gcm_test_exif_func);
 	g_test_add_func ("/color/utils", gcm_test_utils_func);
 	g_test_add_func ("/color/device", gcm_test_device_func);
-	g_test_add_func ("/color/profile", gcm_test_profile_func);
 	g_test_add_func ("/color/profile_store", gcm_test_profile_store_func);
-	g_test_add_func ("/color/clut", gcm_test_clut_func);
-	g_test_add_func ("/color/xyz", gcm_test_xyz_func);
 	g_test_add_func ("/color/calibrate_dialog", gcm_test_calibrate_dialog_func);
 	if (g_test_thorough ()) {
 		g_test_add_func ("/color/brightness", gcm_test_brightness_func);
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 2189e50..a2e0468 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -296,29 +296,6 @@ gcm_utils_output_is_lcd (const gchar *output_name)
 }
 
 /**
- * gcm_utils_ensure_printable:
- **/
-void
-gcm_utils_ensure_printable (gchar *text)
-{
-	guint i;
-	guint idx = 0;
-
-	g_return_if_fail (text != NULL);
-
-	for (i=0; text[i] != '\0'; i++) {
-		if (g_ascii_isalnum (text[i]) ||
-		    g_ascii_ispunct (text[i]) ||
-		    text[i] == ' ')
-			text[idx++] = text[i];
-	}
-	text[idx] = '\0';
-
-	/* broken profiles have _ instead of spaces */
-	g_strdelimit (text, "_", ' ');
-}
-
-/**
  * gcm_utils_mkdir_with_parents:
  **/
 gboolean
@@ -582,20 +559,6 @@ gcm_utils_device_kind_to_profile_kind (GcmDeviceKind kind)
 }
 
 /**
- * gcm_utils_format_date_time:
- **/
-gchar *
-gcm_utils_format_date_time (const struct tm *created)
-{
-	gchar buffer[256];
-
-	/* TRANSLATORS: this is the profile creation date strftime format */
-	strftime (buffer, sizeof(buffer), _("%B %e %Y, %I:%M:%S %p"), created);
-
-	return g_strdup (g_strchug (buffer));
-}
-
-/**
  * gcm_intent_to_localized_text:
  **/
 const gchar *
@@ -645,3 +608,20 @@ gcm_intent_to_localized_description (GcmIntent intent)
 	return "unknown";
 }
 
+/**
+ * gcm_colorspace_to_localised_string:
+ **/
+const gchar *
+gcm_colorspace_to_localised_string (GcmColorspace colorspace)
+{
+	if (colorspace == GCM_COLORSPACE_RGB) {
+		/* TRANSLATORS: this is the colorspace, e.g. red, green, blue */
+		return _("RGB");
+	}
+	if (colorspace == GCM_COLORSPACE_CMYK) {
+		/* TRANSLATORS: this is the colorspace, e.g. cyan, magenta, yellow, black */
+		return _("CMYK");
+	}
+	return NULL;
+}
+
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index bda16f7..d4a9268 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -97,15 +97,14 @@ void		 gcm_utils_alphanum_lcase		(gchar			*string);
 void		 gcm_utils_ensure_sensible_filename	(gchar			*string);
 gchar		*gcm_utils_get_default_config_location	(void);
 GcmProfileKind	 gcm_utils_device_kind_to_profile_kind	(GcmDeviceKind		 kind);
-gchar		*gcm_utils_format_date_time		(const struct tm	*created);
 gboolean	 gcm_utils_install_package		(const gchar		*package_name,
 							 GtkWindow		*window);
 gboolean	 gcm_utils_is_package_installed		(const gchar		*package_name);
-void		 gcm_utils_ensure_printable		(gchar			*text);
 gboolean	 gcm_utils_is_icc_profile		(GFile			*file);
 gchar		*gcm_utils_linkify			(const gchar		*text);
 const gchar	*gcm_intent_to_localized_text		(GcmIntent	 intent);
 const gchar	*gcm_intent_to_localized_description	(GcmIntent	 intent);
+const gchar	*gcm_colorspace_to_localised_string	(GcmColorspace	 colorspace);
 
 #endif /* __GCM_UTILS_H */
 



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