[gnome-color-manager] Use CdIcc to load and save ICC profiles



commit f852c24bbdf5482591f2357d3ae2aee853ff93ae
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 26 16:42:55 2013 +0000

    Use CdIcc to load and save ICC profiles

 configure.ac                  |    2 +-
 po/POTFILES.in                |    1 -
 src/Makefile.am               |    6 -
 src/gcm-cell-renderer-color.c |   16 +-
 src/gcm-cell-renderer-color.h |    2 +-
 src/gcm-cie-widget.c          |    2 +-
 src/gcm-cie-widget.h          |    4 +-
 src/gcm-hull-widget.c         |    5 +-
 src/gcm-hull-widget.h         |    5 +-
 src/gcm-image.c               |   34 +-
 src/gcm-image.h               |    9 +-
 src/gcm-import.c              |   23 +-
 src/gcm-inspect.c             |   18 +-
 src/gcm-named-color.c         |  248 ----
 src/gcm-named-color.h         |   62 -
 src/gcm-picker.c              |    2 +-
 src/gcm-profile.c             | 2479 -----------------------------------------
 src/gcm-profile.h             |  150 ---
 src/gcm-self-test.c           |  178 +---
 src/gcm-trc-widget.c          |    1 -
 src/gcm-utils.c               |  595 ++++++++++-
 src/gcm-utils.h               |   38 +-
 src/gcm-viewer.c              |  112 +--
 23 files changed, 730 insertions(+), 3262 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b041613..d9fdf1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,7 +84,7 @@ PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 2.91.0)
 PKG_CHECK_MODULES(LCMS, lcms2 >= 2.2)
 PKG_CHECK_MODULES(X11, x11)
 PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-3.0)
-PKG_CHECK_MODULES(COLORD, colord >= 0.1.28 colord-gtk >= 0.1.20)
+PKG_CHECK_MODULES(COLORD, colord >= 0.1.32 colord-gtk >= 0.1.20)
 
 dnl **** Check for clutter ****
 AC_ARG_ENABLE(clutter, AS_HELP_STRING([--enable-clutter],[Enable clutter for 3D support]), 
enable_clutter=$enableval, enable_clutter=yes)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 371250f..3c617c0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,6 +12,5 @@ src/gcm-debug.c
 src/gcm-import.c
 src/gcm-inspect.c
 src/gcm-picker.c
-src/gcm-profile.c
 src/gcm-utils.c
 src/gcm-viewer.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 48909ac..a960060 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,10 +40,6 @@ libgcmshared_a_SOURCES =                             \
        gcm-image.h                                     \
        gcm-print.c                                     \
        gcm-print.h                                     \
-       gcm-profile.c                                   \
-       gcm-profile.h                                   \
-       gcm-named-color.c                               \
-       gcm-named-color.h                               \
        gcm-trc-widget.c                                \
        gcm-trc-widget.h                                \
        gcm-utils.c                                     \
@@ -197,8 +193,6 @@ gcm_self_test_SOURCES =                                     \
        gcm-calibrate.h                                 \
        gcm-gamma-widget.c                              \
        gcm-gamma-widget.h                              \
-       gcm-named-color.c                               \
-       gcm-named-color.h                               \
        gcm-self-test.c
 
 gcm_self_test_LDADD =                                  \
diff --git a/src/gcm-cell-renderer-color.c b/src/gcm-cell-renderer-color.c
index b6629eb..8839002 100644
--- a/src/gcm-cell-renderer-color.c
+++ b/src/gcm-cell-renderer-color.c
@@ -70,7 +70,7 @@ gcm_cell_renderer_set_color (GcmCellRendererColor *renderer)
        guchar *pixels;
        guint pos;
        cmsHPROFILE profile_srgb = NULL;
-       cmsHPROFILE profile_xyz = NULL;
+       cmsHPROFILE profile_lab = NULL;
        cmsHTRANSFORM xform = NULL;
 
        /* nothing set yet */
@@ -78,9 +78,9 @@ gcm_cell_renderer_set_color (GcmCellRendererColor *renderer)
                goto out;
 
        /* convert the color to sRGB */
-       profile_xyz = cmsCreateXYZProfile ();
+       profile_lab = cmsCreateLab2Profile (NULL);
        profile_srgb = cmsCreate_sRGBProfile ();
-       xform = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL,
+       xform = cmsCreateTransform (profile_lab, TYPE_Lab_DBL,
                                    profile_srgb, TYPE_RGB_8,
                                    INTENT_ABSOLUTE_COLORIMETRIC, 0);
        cmsDoTransform (xform, renderer->color, &rgb, 1);
@@ -102,8 +102,8 @@ out:
        g_object_set (renderer, "pixbuf", pixbuf, NULL);
        if (profile_srgb != NULL)
                cmsCloseProfile (profile_srgb);
-       if (profile_xyz != NULL)
-               cmsCloseProfile (profile_xyz);
+       if (profile_lab != NULL)
+               cmsCloseProfile (profile_lab);
        if (xform != NULL)
                cmsDeleteTransform (xform);
        if (pixbuf != NULL)
@@ -118,7 +118,7 @@ gcm_cell_renderer_color_set_property (GObject *object, guint param_id,
 
        switch (param_id) {
        case PROP_COLOR:
-               cd_color_xyz_copy (g_value_get_boxed (value), renderer->color);
+               cd_color_lab_copy (g_value_get_boxed (value), renderer->color);
                gcm_cell_renderer_set_color (renderer);
                break;
        case PROP_PROFILE:
@@ -143,7 +143,7 @@ gcm_cell_renderer_finalize (GObject *object)
        GcmCellRendererColor *renderer;
        renderer = GCM_CELL_RENDERER_COLOR (object);
        g_free (renderer->icon_name);
-       cd_color_xyz_free (renderer->color);
+       cd_color_lab_free (renderer->color);
        if (renderer->profile != NULL)
                g_object_unref (renderer->profile);
        G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -179,7 +179,7 @@ gcm_cell_renderer_color_class_init (GcmCellRendererColorClass *class)
 static void
 gcm_cell_renderer_color_init (GcmCellRendererColor *renderer)
 {
-       renderer->color = cd_color_xyz_new ();
+       renderer->color = cd_color_lab_new ();
 }
 
 /**
diff --git a/src/gcm-cell-renderer-color.h b/src/gcm-cell-renderer-color.h
index a6585cd..ce02dc8 100644
--- a/src/gcm-cell-renderer-color.h
+++ b/src/gcm-cell-renderer-color.h
@@ -41,7 +41,7 @@ typedef struct _GcmCellRendererColorClass     GcmCellRendererColorClass;
 struct _GcmCellRendererColor
 {
        GtkCellRendererPixbuf    parent;
-       CdColorXYZ              *color;
+       CdColorLab              *color;
        CdProfile               *profile;
        gchar                   *icon_name;
 };
diff --git a/src/gcm-cie-widget.c b/src/gcm-cie-widget.c
index 4b4a709..42fbf72 100644
--- a/src/gcm-cie-widget.c
+++ b/src/gcm-cie-widget.c
@@ -513,7 +513,7 @@ gcm_cie_widget_class_init (GcmCieWidgetClass *class)
  * gcm_cie_widget_set_from_profile:
  **/
 void
-gcm_cie_widget_set_from_profile (GtkWidget *widget, GcmProfile *profile)
+gcm_cie_widget_set_from_profile (GtkWidget *widget, CdIcc *profile)
 {
        GcmCieWidget *cie = GCM_CIE_WIDGET (widget);
        CdColorXYZ *white;
diff --git a/src/gcm-cie-widget.h b/src/gcm-cie-widget.h
index e931b44..054872d 100644
--- a/src/gcm-cie-widget.h
+++ b/src/gcm-cie-widget.h
@@ -23,7 +23,7 @@
 #define __GCM_CIE_WIDGET_H__
 
 #include <gtk/gtk.h>
-#include <gcm-profile.h>
+#include <colord.h>
 
 G_BEGIN_DECLS
 
@@ -52,7 +52,7 @@ struct GcmCieWidgetClass
 GType           gcm_cie_widget_get_type                (void);
 GtkWidget      *gcm_cie_widget_new                     (void);
 void            gcm_cie_widget_set_from_profile        (GtkWidget      *widget,
-                                                        GcmProfile     *profile);
+                                                        CdIcc          *profile);
 
 G_END_DECLS
 
diff --git a/src/gcm-hull-widget.c b/src/gcm-hull-widget.c
index 47b966d..a5f6b50 100644
--- a/src/gcm-hull-widget.c
+++ b/src/gcm-hull-widget.c
@@ -28,6 +28,7 @@
 
 #include "gcm-hull.h"
 #include "gcm-hull-widget.h"
+#include "gcm-utils.h"
 
 G_DEFINE_TYPE (GcmHullWidget, gcm_hull_widget, GTK_CLUTTER_TYPE_EMBED);
 #define GCM_HULL_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_HULL_WIDGET, 
GcmHullWidgetPrivate))
@@ -89,7 +90,7 @@ gcm_hull_widget_set_actor_position (GcmHullWidget *hull_widget,
  **/
 gboolean
 gcm_hull_widget_add (GcmHullWidget *hull_widget,
-                    GcmProfile *profile)
+                    CdIcc *profile)
 {
        ClutterActor *model = NULL;
        gboolean ret = FALSE;
@@ -98,7 +99,7 @@ gcm_hull_widget_add (GcmHullWidget *hull_widget,
        GError *error = NULL;
 
        /* generate hull */
-       hull = gcm_profile_generate_gamut_hull (profile, 12);
+       hull = cd_icc_generate_gamut_hull (profile, 12);
        if (hull == NULL)
                goto out;
 
diff --git a/src/gcm-hull-widget.h b/src/gcm-hull-widget.h
index d169547..94d3455 100644
--- a/src/gcm-hull-widget.h
+++ b/src/gcm-hull-widget.h
@@ -24,8 +24,7 @@
 
 #include <gtk/gtk.h>
 #include <clutter-gtk/clutter-gtk.h>
-
-#include "gcm-profile.h"
+#include <colord.h>
 
 G_BEGIN_DECLS
 
@@ -55,7 +54,7 @@ GType          gcm_hull_widget_get_type       (void);
 GtkWidget      *gcm_hull_widget_new            (void);
 void            gcm_hull_widget_clear          (GcmHullWidget  *hull_widget);
 gboolean        gcm_hull_widget_add            (GcmHullWidget  *hull_widget,
-                                                GcmProfile     *profile);
+                                                CdIcc  *profile);
 
 G_END_DECLS
 
diff --git a/src/gcm-image.c b/src/gcm-image.c
index 904369b..7479a76 100644
--- a/src/gcm-image.c
+++ b/src/gcm-image.c
@@ -39,9 +39,9 @@ struct _GcmImagePrivate
 {
        gboolean                         has_embedded_profile;
        gboolean                         use_embedded_profile;
-       GcmProfile                      *output_profile;
-       GcmProfile                      *input_profile;
-       GcmProfile                      *abstract_profile;
+       CdIcc                           *output_profile;
+       CdIcc                           *input_profile;
+       CdIcc                           *abstract_profile;
        GdkPixbuf                       *original_pixbuf;
 };
 
@@ -163,14 +163,14 @@ gcm_image_cms_convert_pixbuf (GcmImage *image)
        } else if (priv->input_profile != NULL) {
 
                /* not RGB */
-               if (gcm_profile_get_colorspace (priv->input_profile) != CD_COLORSPACE_RGB) {
+               if (cd_icc_get_colorspace (priv->input_profile) != CD_COLORSPACE_RGB) {
                        g_warning ("input colorspace has to be RGB!");
                        goto out;
                }
 
                /* use built-in */
-               g_debug ("using input profile of %s", gcm_profile_get_filename (priv->input_profile));
-               profile_in = gcm_profile_get_handle (priv->input_profile);
+               g_debug ("using input profile of %s", cd_icc_get_filename (priv->input_profile));
+               profile_in = cd_icc_get_handle (priv->input_profile);
                profile_close_input = FALSE;
        } else {
                g_debug ("no input profile, assume sRGB");
@@ -182,14 +182,14 @@ gcm_image_cms_convert_pixbuf (GcmImage *image)
        if (priv->output_profile != NULL) {
 
                /* not RGB */
-               if (gcm_profile_get_colorspace (priv->output_profile) != CD_COLORSPACE_RGB) {
+               if (cd_icc_get_colorspace (priv->output_profile) != CD_COLORSPACE_RGB) {
                        g_warning ("output colorspace has to be RGB!");
                        goto out;
                }
 
                /* use built-in */
-               g_debug ("using output profile of %s", gcm_profile_get_filename (priv->output_profile));
-               profile_out = gcm_profile_get_handle (priv->output_profile);
+               g_debug ("using output profile of %s", cd_icc_get_filename (priv->output_profile));
+               profile_out = cd_icc_get_handle (priv->output_profile);
                profile_close_output = FALSE;
        } else {
                g_debug ("no output profile, assume sRGB");
@@ -202,14 +202,14 @@ gcm_image_cms_convert_pixbuf (GcmImage *image)
                cmsHPROFILE profiles[3];
 
                /* not LAB */
-               if (gcm_profile_get_colorspace (priv->abstract_profile) != CD_COLORSPACE_LAB) {
+               if (cd_icc_get_colorspace (priv->abstract_profile) != CD_COLORSPACE_LAB) {
                        g_warning ("abstract profile has to be LAB!");
                        goto out;
                }
 
                /* generate a devicelink */
                profiles[0] = profile_in;
-               profiles[1] = gcm_profile_get_handle (priv->abstract_profile);
+               profiles[1] = cd_icc_get_handle (priv->abstract_profile);
                profiles[2] = profile_out;
                transform = cmsCreateMultiprofileTransform (profiles, 3, format, format, INTENT_PERCEPTUAL, 
0);
 
@@ -295,7 +295,7 @@ out:
  * gcm_image_set_input_profile:
  **/
 void
-gcm_image_set_input_profile (GcmImage *image, GcmProfile *profile)
+gcm_image_set_input_profile (GcmImage *image, CdIcc *profile)
 {
        GcmImagePrivate *priv = image->priv;
        if (priv->input_profile != NULL) {
@@ -313,7 +313,7 @@ gcm_image_set_input_profile (GcmImage *image, GcmProfile *profile)
  * gcm_image_set_output_profile:
  **/
 void
-gcm_image_set_output_profile (GcmImage *image, GcmProfile *profile)
+gcm_image_set_output_profile (GcmImage *image, CdIcc *profile)
 {
        GcmImagePrivate *priv = image->priv;
        if (priv->output_profile != NULL) {
@@ -329,7 +329,7 @@ gcm_image_set_output_profile (GcmImage *image, GcmProfile *profile)
  * gcm_image_set_abstract_profile:
  **/
 void
-gcm_image_set_abstract_profile (GcmImage *image, GcmProfile *profile)
+gcm_image_set_abstract_profile (GcmImage *image, CdIcc *profile)
 {
        GcmImagePrivate *priv = image->priv;
        if (priv->abstract_profile != NULL) {
@@ -450,7 +450,7 @@ gcm_image_class_init (GcmImageClass *klass)
         * GcmImage:output-profile:
         */
        pspec = g_param_spec_object ("output-profile", NULL, NULL,
-                                    GCM_TYPE_PROFILE,
+                                    CD_TYPE_ICC,
                                     G_PARAM_READWRITE);
        g_object_class_install_property (object_class, PROP_OUTPUT_PROFILE, pspec);
 
@@ -458,7 +458,7 @@ gcm_image_class_init (GcmImageClass *klass)
         * GcmImage:input-profile:
         */
        pspec = g_param_spec_object ("input-profile", NULL, NULL,
-                                    GCM_TYPE_PROFILE,
+                                    CD_TYPE_ICC,
                                     G_PARAM_READWRITE);
        g_object_class_install_property (object_class, PROP_INPUT_PROFILE, pspec);
 
@@ -466,7 +466,7 @@ gcm_image_class_init (GcmImageClass *klass)
         * GcmImage:abstract-profile:
         */
        pspec = g_param_spec_object ("abstract-profile", NULL, NULL,
-                                    GCM_TYPE_PROFILE,
+                                    CD_TYPE_ICC,
                                     G_PARAM_READWRITE);
        g_object_class_install_property (object_class, PROP_ABSTRACT_PROFILE, pspec);
 
diff --git a/src/gcm-image.h b/src/gcm-image.h
index 5c6a216..a768114 100644
--- a/src/gcm-image.h
+++ b/src/gcm-image.h
@@ -24,8 +24,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-
-#include "gcm-profile.h"
+#include <colord.h>
 
 G_BEGIN_DECLS
 
@@ -61,11 +60,11 @@ GType                gcm_image_get_type             (void);
 GcmImage       *gcm_image_new                  (void);
 
 void            gcm_image_set_input_profile    (GcmImage       *image,
-                                                GcmProfile     *profile);
+                                                CdIcc          *profile);
 void            gcm_image_set_output_profile   (GcmImage       *image,
-                                                GcmProfile     *profile);
+                                                CdIcc          *profile);
 void            gcm_image_set_abstract_profile (GcmImage       *image,
-                                                GcmProfile     *profile);
+                                                CdIcc          *profile);
 gboolean        gcm_image_has_embedded_profile (GcmImage       *image);
 void            gcm_image_use_embedded_profile (GcmImage       *image,
                                                 gboolean        use_embedded_profile);
diff --git a/src/gcm-import.c b/src/gcm-import.c
index c9bf56e..6ccc5e4 100644
--- a/src/gcm-import.c
+++ b/src/gcm-import.c
@@ -28,7 +28,6 @@
 #include <locale.h>
 #include <colord.h>
 
-#include "gcm-profile.h"
 #include "gcm-utils.h"
 #include "gcm-debug.h"
 
@@ -82,9 +81,10 @@ main (int argc, char **argv)
        const gchar *copyright;
        const gchar *description;
        const gchar *title;
+       const gchar *lang;
        gboolean ret;
        gchar **files = NULL;
-       GcmProfile *profile = NULL;
+       CdIcc *icc = NULL;
        GError *error = NULL;
        GFile *destination = NULL;
        GFile *file = NULL;
@@ -133,9 +133,11 @@ main (int argc, char **argv)
        }
 
        /* load profile */
-       profile = gcm_profile_new ();
+       icc = cd_icc_new ();
        file = g_file_new_for_path (files[0]);
-       ret = gcm_profile_parse (profile, file, &error);
+       ret = cd_icc_load_file (icc, file,
+                               CD_ICC_LOAD_FLAGS_FALLBACK_MD5,
+                               NULL, &error);
        if (!ret) {
                /* TRANSLATORS: could not read file */
                dialog = gtk_message_dialog_new (NULL,
@@ -156,8 +158,9 @@ main (int argc, char **argv)
        }
 
        /* get data */
-       description = gcm_profile_get_description (profile);
-       copyright = gcm_profile_get_copyright (profile);
+       lang = g_getenv ("LANG");
+       description = cd_icc_get_description (icc, lang, NULL);
+       copyright = cd_icc_get_copyright (icc, lang, NULL);
 
        /* use the same icon as the color control panel */
        image = gtk_image_new_from_icon_name ("preferences-color",
@@ -195,7 +198,7 @@ main (int argc, char **argv)
 
        profile_tmp = cd_client_find_profile_by_property_sync (client,
                                                              CD_PROFILE_METADATA_FILE_CHECKSUM,
-                                                             gcm_profile_get_checksum (profile),
+                                                             cd_icc_get_checksum (icc),
                                                              NULL,
                                                              NULL);
        if (profile_tmp != NULL) {
@@ -231,7 +234,7 @@ main (int argc, char **argv)
        }
 
        /* get correct title */
-       switch (gcm_profile_get_kind (profile)) {
+       switch (cd_icc_get_kind (icc)) {
        case CD_PROFILE_KIND_DISPLAY_DEVICE:
                /* TRANSLATORS: the profile type */
                title = _("Import display color profile?");
@@ -299,8 +302,8 @@ out:
                g_object_unref (file);
        if (string != NULL)
                g_string_free (string, TRUE);
-       if (profile != NULL)
-               g_object_unref (profile);
+       if (icc != NULL)
+               g_object_unref (icc);
        if (client != NULL)
                g_object_unref (client);
        if (profile_tmp != NULL)
diff --git a/src/gcm-inspect.c b/src/gcm-inspect.c
index b7975f8..e8d7768 100644
--- a/src/gcm-inspect.c
+++ b/src/gcm-inspect.c
@@ -24,9 +24,9 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <locale.h>
+#include <colord.h>
 
 #include "gcm-utils.h"
-#include "gcm-profile.h"
 #include "gcm-debug.h"
 
 /**
@@ -35,13 +35,15 @@
 static gboolean
 gcm_inspect_print_data_info (const gchar *title, const guint8 *data, gsize length)
 {
-       GcmProfile *profile = NULL;
+       CdIcc *icc = NULL;
        GError *error = NULL;
        gboolean ret;
 
        /* parse the data */
-       profile = gcm_profile_new ();
-       ret = gcm_profile_parse_data (profile, data, length, &error);
+       icc = cd_icc_new ();
+       ret = cd_icc_load_data (icc, data, length,
+                               CD_ICC_LOAD_FLAGS_NONE,
+                               &error);
        if (!ret) {
                g_warning ("failed to parse data: %s", error->message);
                g_error_free (error);
@@ -52,13 +54,13 @@ gcm_inspect_print_data_info (const gchar *title, const guint8 *data, gsize lengt
        g_print ("%s\n", title);
 
        /* TRANSLATORS: this is the ICC profile description stored in an atom in the XServer */
-       g_print (" - %s %s\n", _("Description:"), gcm_profile_get_description (profile));
+       g_print (" - %s %s\n", _("Description:"), cd_icc_get_description (icc, NULL, NULL));
 
        /* TRANSLATORS: this is the ICC profile copyright */
-       g_print (" - %s %s\n", _("Copyright:"), gcm_profile_get_copyright (profile));
+       g_print (" - %s %s\n", _("Copyright:"), cd_icc_get_copyright (icc, NULL, NULL));
 out:
-       if (profile != NULL)
-               g_object_unref (profile);
+       if (icc != NULL)
+               g_object_unref (icc);
        return ret;
 }
 
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index 29bf3bd..8e102c1 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -588,7 +588,7 @@ gcm_prefs_setup_space_combobox (GtkWidget *widget)
 
                /* only for correct kind */
                has_vcgt = cd_profile_get_has_vcgt (profile);
-               has_colorspace_description = gcm_profile_has_colorspace_description (profile);
+               has_colorspace_description = cd_icc_has_colorspace_description (profile);
                colorspace = cd_profile_get_colorspace (profile);
                if (!has_vcgt && has_colorspace_description &&
                    colorspace == CD_COLORSPACE_RGB) {
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 397bed2..10474be 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -35,9 +35,7 @@
 #include "gcm-gamma-widget.h"
 #include "gcm-hull.h"
 #include "gcm-image.h"
-#include "gcm-named-color.h"
 #include "gcm-print.h"
-#include "gcm-profile.h"
 #include "gcm-trc-widget.h"
 #include "gcm-utils.h"
 
@@ -103,130 +101,37 @@ gcm_test_hull_func (void)
 static void
 gcm_test_profile_func (void)
 {
-       GcmProfile *profile;
+       CdIcc *profile;
        GFile *file;
        GcmClut *clut;
        gboolean ret;
        GError *error = NULL;
-       CdColorXYZ *xyz;
-       CdColorYxy yxy;
-       CdColorYxy red;
-       CdColorYxy green;
-       CdColorYxy blue;
-       CdColorYxy white;
        GcmHull *hull;
        gchar *data;
 
        /* bluish test */
-       profile = gcm_profile_new ();
+       profile = cd_icc_new ();
        file = g_file_new_for_path (TESTDATADIR "/bluish.icc");
-       ret = gcm_profile_parse (profile, file, &error);
+       ret = cd_icc_load_file (profile, file, CD_ICC_LOAD_FLAGS_NONE, NULL, &error);
        g_assert_no_error (error);
        g_assert (ret);
        g_object_unref (file);
 
        /* get CLUT */
-       clut = gcm_profile_generate_vcgt (profile, 256);
+       clut = cd_icc_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), ==, CD_PROFILE_KIND_DISPLAY_DEVICE);
-       g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, CD_COLORSPACE_RGB);
-       g_assert_cmpint (gcm_profile_get_temperature (profile), ==, 6500);
-
-       /* get extra data */
-       g_object_get (profile,
-                     "red", &xyz,
-                     NULL);
-       g_assert (xyz != NULL);
-       cd_color_xyz_to_yxy (xyz, &yxy);
-       g_assert_cmpfloat (fabs (yxy.x - 0.648454), <, 0.01);
-
-       cd_color_xyz_free (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), ==, CD_PROFILE_KIND_DISPLAY_DEVICE);
-       g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, CD_COLORSPACE_RGB);
-       g_assert_cmpint (gcm_profile_get_temperature (profile), ==, 6500);
-
-       g_object_unref (profile);
-
-       /* create test */
-       profile = gcm_profile_new ();
-
-       /* from my T61 */
-       cd_color_yxy_set (&red, 1.0f, 0.569336f, 0.332031f);
-       cd_color_yxy_set (&green, 1.0f, 0.311523f, 0.543945f);
-       cd_color_yxy_set (&blue, 1.0f, 0.149414f, 0.131836f);
-       cd_color_yxy_set (&white, 1.0f, 0.313477f, 0.329102f);
-
-       /* create from chroma */
-       ret = gcm_profile_create_from_chroma (profile, 2.2f, &red, &green, &blue, &white, &error);
-       g_assert_no_error (error);
-       g_assert (ret);
-
-       /* add vcgt */
-       ret = gcm_profile_guess_and_add_vcgt (profile, &error);
-       g_assert_no_error (error);
-       g_assert (ret);
-
-       /* save */
-       gcm_profile_save (profile, "dave.icc", &error);
-       g_assert_no_error (error);
-       g_assert (ret);
-       g_object_unref (profile);
-
-       /* verify values */
-       profile = gcm_profile_new ();
-       file = g_file_new_for_path ("dave.icc");
-       ret = gcm_profile_parse (profile, file, &error);
-       g_assert_no_error (error);
-       g_assert (ret);
-
-       g_assert_cmpstr (gcm_profile_get_copyright (profile), ==, "No copyright, use freely");
-       g_assert_cmpstr (gcm_profile_get_manufacturer (profile), ==, NULL);
-       g_assert_cmpstr (gcm_profile_get_model (profile), ==, NULL);
-       g_assert_cmpstr (gcm_profile_get_description (profile), ==, "RGB built-in");
-       g_assert_cmpint (gcm_profile_get_kind (profile), ==, CD_PROFILE_KIND_DISPLAY_DEVICE);
-       g_assert_cmpint (gcm_profile_get_colorspace (profile), ==, CD_COLORSPACE_RGB);
-       g_assert_cmpint (gcm_profile_get_temperature (profile), ==, 6400);
-
-       /* delete temp file */
-       ret = g_file_delete (file, NULL, &error);
-       g_assert_no_error (error);
-       g_assert (ret);
-
-       g_object_unref (file);
-       g_object_unref (profile);
-
        /* get gamut hull */
-       profile = gcm_profile_new ();
+       profile = cd_icc_new ();
        file = g_file_new_for_path (TESTDATADIR "/ibm-t61.icc");
-       ret = gcm_profile_parse (profile, file, &error);
+       ret = cd_icc_load_file (profile, file, CD_ICC_LOAD_FLAGS_NONE, NULL, &error);
        g_assert_no_error (error);
        g_assert (ret);
-       hull = gcm_profile_generate_gamut_hull (profile, 12);
+       hull = cd_icc_generate_gamut_hull (profile, 12);
        g_assert (hull != NULL);
 
        /* save as PLY file */
@@ -320,7 +225,7 @@ gcm_test_image_func (void)
        GtkWidget *vbox;
        gint response;
        gboolean ret;
-       GcmProfile *profile;
+       CdIcc *profile;
        GFile *file;
 
        image = gcm_image_new ();
@@ -361,9 +266,9 @@ gcm_test_image_func (void)
                      NULL);
 
        /* get test file */
-       profile = gcm_profile_new ();
+       profile = cd_icc_new ();
        file = g_file_new_for_path (TESTDATADIR "/ibm-t61.icc");
-       ret = gcm_profile_parse (profile, file, NULL);
+       ret = cd_icc_load_file (profile, file, CD_ICC_LOAD_FLAGS_NONE, NULL, NULL);
        g_object_unref (file);
        g_assert (ret);
        gcm_image_set_output_profile (image, profile);
@@ -411,7 +316,7 @@ gcm_test_cie_widget_func (void)
        GtkWidget *image;
        GtkWidget *dialog;
        GtkWidget *vbox;
-       GcmProfile *profile;
+       CdIcc *profile;
        CdColorXYZ *white;
        CdColorXYZ *red;
        CdColorXYZ *green;
@@ -426,9 +331,9 @@ gcm_test_cie_widget_func (void)
        widget = gcm_cie_widget_new ();
        g_assert (widget != NULL);
 
-       profile = gcm_profile_new ();
+       profile = cd_icc_new ();
        file = g_file_new_for_path (TESTDATADIR "/bluish.icc");
-       gcm_profile_parse (profile, file, NULL);
+       cd_icc_load_file (profile, file, CD_ICC_LOAD_FLAGS_NONE, NULL, NULL);
        g_object_get (profile,
                      "white", &white,
                      "red", &red,
@@ -599,17 +504,17 @@ gcm_test_trc_widget_func (void)
        GtkWidget *dialog;
        GtkWidget *vbox;
        GcmClut *clut;
-       GcmProfile *profile;
+       CdIcc *profile;
        gint response;
        GFile *file;
 
        widget = gcm_trc_widget_new ();
        g_assert (widget != NULL);
 
-       profile = gcm_profile_new ();
+       profile = cd_icc_new ();
        file = g_file_new_for_path (TESTDATADIR "/AdobeGammaTest.icm");
-       gcm_profile_parse (profile, file, NULL);
-       clut = gcm_profile_generate_vcgt (profile, 256);
+       cd_icc_load_file (profile, file, CD_ICC_LOAD_FLAGS_NONE, NULL, NULL);
+       clut = cd_icc_generate_vcgt (profile, 256);
        g_object_set (widget,
                      "clut", clut,
                      NULL);
@@ -682,54 +587,6 @@ gcm_test_utils_func (void)
        g_free (filename);
 }
 
-static void
-gcm_test_named_color_func (void)
-{
-       GcmNamedColor *nc;
-       CdColorXYZ *xyz;
-       CdColorXYZ *xyz2;
-       const CdColorXYZ *xyz_new;
-       gchar *tmp = NULL;
-
-       nc = gcm_named_color_new ();
-
-       gcm_named_color_set_title (nc, "Hello world");
-
-       xyz = cd_color_xyz_new ();
-
-       /* use setters */
-       cd_color_xyz_set (xyz, 0.1, 0.2, 0.3);
-       gcm_named_color_set_value (nc, xyz);
-
-       /* test getters */
-       g_assert_cmpstr (gcm_named_color_get_title (nc), ==, "Hello world");
-       xyz_new = gcm_named_color_get_value (nc);
-       g_assert_cmpfloat (abs (xyz_new->X - 0.1), <, 0.01);
-       g_assert_cmpfloat (abs (xyz_new->Y - 0.2), <, 0.01);
-       g_assert_cmpfloat (abs (xyz_new->Z - 0.3), <, 0.01);
-
-       /* overwrite using properties */
-       cd_color_xyz_set (xyz, 0.4, 0.5, 0.6);
-       g_object_set (nc,
-                     "title", "dave",
-                     "value", xyz,
-                     NULL);
-
-       /* test property getters */
-       g_object_get (nc,
-                     "title", &tmp,
-                     "value", &xyz2,
-                     NULL);
-       g_assert_cmpstr (gcm_named_color_get_title (nc), ==, "dave");
-       g_assert_cmpfloat (abs (xyz2->X - 0.4), <, 0.01);
-       g_assert_cmpfloat (abs (xyz2->Y - 0.5), <, 0.01);
-       g_assert_cmpfloat (abs (xyz2->Z - 0.6), <, 0.01);
-
-       g_free (tmp);
-       cd_color_xyz_free (xyz);
-       cd_color_xyz_free (xyz2);
-}
-
 int
 main (int argc, char **argv)
 {
@@ -739,7 +596,6 @@ main (int argc, char **argv)
        /* setup manually as we have no GMainContext */
        gcm_debug_setup (g_getenv ("VERBOSE") != NULL);
 
-       g_test_add_func ("/color/named-color", gcm_test_named_color_func);
        g_test_add_func ("/color/calibrate", gcm_test_calibrate_func);
        g_test_add_func ("/color/exif", gcm_test_exif_func);
        g_test_add_func ("/color/utils", gcm_test_utils_func);
diff --git a/src/gcm-trc-widget.c b/src/gcm-trc-widget.c
index ac7800e..df74e14 100644
--- a/src/gcm-trc-widget.c
+++ b/src/gcm-trc-widget.c
@@ -26,7 +26,6 @@
 #include <math.h>
 
 #include "gcm-clut.h"
-#include "gcm-profile.h"
 #include "gcm-trc-widget.h"
 
 G_DEFINE_TYPE (GcmTrcWidget, gcm_trc_widget, GTK_TYPE_DRAWING_AREA);
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 2a0987c..f8790d8 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -25,6 +25,8 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #include <colord.h>
+#include <lcms2.h>
+#include <math.h>
 
 #include "gcm-utils.h"
 
@@ -339,7 +341,7 @@ cd_colorspace_to_localised_string (CdColorspace colorspace)
 }
 
 /**
- * gcm_profile_has_colorspace_description:
+ * cd_icc_has_colorspace_description:
  * @profile: A valid #CdProfile
  *
  * Finds out if the profile contains a colorspace description.
@@ -348,7 +350,7 @@ cd_colorspace_to_localised_string (CdColorspace colorspace)
  * e.g. "Adobe RGB" for %CD_COLORSPACE_RGB.
  **/
 gboolean
-gcm_profile_has_colorspace_description (CdProfile *profile)
+cd_icc_has_colorspace_description (CdProfile *profile)
 {
        CdColorspace colorspace;
        const gchar *description;
@@ -366,3 +368,592 @@ gcm_profile_has_colorspace_description (CdProfile *profile)
        /* nothing */
        return FALSE;
 }
+
+/**
+ * cd_icc_generate_vcgt:
+ * @icc: A valid #CdIcc
+ * @size: the size of the table to generate
+ *
+ * Generates a VCGT table of a specified size.
+ *
+ * Return value: A #GcmClut object, or %NULL. Free with g_object_unref()
+ **/
+GcmClut *
+cd_icc_generate_vcgt (CdIcc *icc, guint size)
+{
+       cmsFloat32Number in;
+       cmsHPROFILE lcms_profile;
+       const cmsToneCurve **vcgt;
+       GcmClut *clut = NULL;
+       GcmClutData *tmp;
+       GPtrArray *array = NULL;
+       guint i;
+
+       /* get tone curves from icc */
+       lcms_profile = cd_icc_get_handle (icc);
+       vcgt = cmsReadTag (lcms_profile, cmsSigVcgtType);
+       if (vcgt == NULL || vcgt[0] == NULL) {
+               g_debug ("icc does not have any VCGT data");
+               goto out;
+       }
+
+       /* create array */
+       array = g_ptr_array_new_with_free_func (g_free);
+       for (i = 0; i < size; i++) {
+               in = (gdouble) i / (gdouble) (size - 1);
+               tmp = g_new0 (GcmClutData, 1);
+               tmp->red = cmsEvalToneCurveFloat(vcgt[0], in) * (gdouble) 0xffff;
+               tmp->green = cmsEvalToneCurveFloat(vcgt[1], in) * (gdouble) 0xffff;
+               tmp->blue = cmsEvalToneCurveFloat(vcgt[2], in) * (gdouble) 0xffff;
+               g_ptr_array_add (array, tmp);
+       }
+
+       /* create new scaled CLUT */
+       clut = gcm_clut_new ();
+       gcm_clut_set_source_array (clut, array);
+out:
+       if (array != NULL)
+               g_ptr_array_unref (array);
+       return clut;
+}
+
+/**
+ * cd_icc_generate_curve:
+ * @icc: A valid #CdIcc
+ * @size: the size of the curve to generate
+ *
+ * Generates a curve of a specified size.
+ *
+ * Return value: A #GcmClut object, or %NULL. Free with g_object_unref()
+ **/
+GcmClut *
+cd_icc_generate_curve (CdIcc *icc, guint size)
+{
+       GcmClut *clut = NULL;
+       gdouble *values_in = NULL;
+       gdouble *values_out = NULL;
+       guint i;
+       GcmClutData *data;
+       GPtrArray *array = NULL;
+       gfloat divamount;
+       gfloat divadd;
+       guint component_width;
+       cmsHPROFILE srgb_profile = NULL;
+       cmsHTRANSFORM transform = NULL;
+       guint type;
+       CdColorspace colorspace;
+       gdouble tmp;
+       cmsHPROFILE lcms_profile;
+
+       /* run through the icc */
+       colorspace = cd_icc_get_colorspace (icc);
+       if (colorspace == CD_COLORSPACE_RGB) {
+
+               /* RGB */
+               component_width = 3;
+               type = TYPE_RGB_DBL;
+
+               /* create input array */
+               values_in = g_new0 (gdouble, size * 3 * component_width);
+               divamount = 1.0f / (gfloat) (size - 1);
+               for (i = 0; i < size; i++) {
+                       divadd = divamount * (gfloat) i;
+
+                       /* red component */
+                       values_in[(i * 3 * component_width)+0] = divadd;
+                       values_in[(i * 3 * component_width)+1] = 0.0f;
+                       values_in[(i * 3 * component_width)+2] = 0.0f;
+
+                       /* green component */
+                       values_in[(i * 3 * component_width)+3] = 0.0f;
+                       values_in[(i * 3 * component_width)+4] = divadd;
+                       values_in[(i * 3 * component_width)+5] = 0.0f;
+
+                       /* blue component */
+                       values_in[(i * 3 * component_width)+6] = 0.0f;
+                       values_in[(i * 3 * component_width)+7] = 0.0f;
+                       values_in[(i * 3 * component_width)+8] = divadd;
+               }
+       }
+
+       /* do each transform */
+       if (values_in != NULL) {
+               /* create output array */
+               values_out = g_new0 (gdouble, size * 3 * component_width);
+
+               /* create a transform from icc to sRGB */
+               srgb_profile = cmsCreate_sRGBProfile ();
+               lcms_profile = cd_icc_get_handle (icc);
+               transform = cmsCreateTransform (lcms_profile, type, srgb_profile, TYPE_RGB_DBL, 
INTENT_PERCEPTUAL, 0);
+               if (transform == NULL)
+                       goto out;
+
+               /* do transform */
+               cmsDoTransform (transform, values_in, values_out, size * 3);
+
+               /* create output array */
+               array = g_ptr_array_new_with_free_func (g_free);
+
+               for (i = 0; i < size; i++) {
+                       data = g_new0 (GcmClutData, 1);
+
+                       /* default values */
+                       data->red = 0;
+                       data->green = 0;
+                       data->blue = 0;
+
+                       /* only save curve data if it is positive */
+                       tmp = values_out[(i * 3 * component_width)+0] * (gfloat) 0xffff;
+                       if (tmp > 0.0f)
+                               data->red = tmp;
+                       tmp = values_out[(i * 3 * component_width)+4] * (gfloat) 0xffff;
+                       if (tmp > 0.0f)
+                               data->green = tmp;
+                       tmp = values_out[(i * 3 * component_width)+8] * (gfloat) 0xffff;
+                       if (tmp > 0.0f)
+                               data->blue = tmp;
+                       g_ptr_array_add (array, data);
+               }
+               clut = gcm_clut_new ();
+               gcm_clut_set_source_array (clut, array);
+       }
+
+out:
+       g_free (values_in);
+       g_free (values_out);
+       if (array != NULL)
+               g_ptr_array_unref (array);
+       if (transform != NULL)
+               cmsDeleteTransform (transform);
+       if (srgb_profile != NULL)
+               cmsCloseProfile (srgb_profile);
+       return clut;
+}
+
+#define HYP(a,b)               (sqrt((a)*(a) + (b)*(b)))
+
+/**
+ * cd_icc_create_lab_cube:
+ *
+ * The original code was taken from icc_examin,
+ *  Copyright 2004-2009 Kai-Uwe Behrmann <ku b gmx de>
+ **/
+static gdouble *
+cd_icc_create_lab_cube (guint res)
+{
+       gdouble *lab = NULL;
+       gdouble max = 0.99;
+       gdouble min = 0.01;
+       gint area;
+       gint channels_n = 3;
+       gint pos;
+       gsize size;
+       guint x, y;
+
+       size = 4 * res * (res+1) + 2 * (res-1) * (res-1);
+       lab = g_new0 (gdouble, size * channels_n);
+       if (lab == NULL)
+               goto out;
+
+       g_debug ("created 2*%ix%i array", (guint)size, (guint)channels_n);
+
+       /* side squares */
+       for (y = 0; y <= res; ++y) {
+               for (x = 0; x < 4 * res; ++x) {
+                       area = 0;
+                       pos = (y * 4 * res + x) * channels_n;
+
+                       lab[pos + 0] = pow(0.9999 - (gdouble)y / (gdouble)res, 2.0) + 0.0001;
+                       if (area * res <= x && x < ++area * res) {
+                               lab[pos + 1] = min + (x - (area - 1) * res) / (gdouble)res * (max-min);
+                               lab[pos + 2] = min;
+                       } else if (area * res <= x && x < ++area * res) {
+                               lab[pos + 1] = max;
+                               lab[pos + 2] = min + (x - (area - 1) * res) / (gdouble)res * (max-min);
+                       } else if (area * res <= x && x < ++area * res) {
+                               lab[pos + 1] = max - (x - (area - 1) * res) / (gdouble)res * (max-min);
+                               lab[pos + 2] = max;
+                       } else if (area * res <= x && x < ++area * res) {
+                               lab[pos + 1] = min;
+                               lab[pos + 2] = max - (x - (area - 1) * res) / (double)res * (max-min);
+                       }
+               }
+       }
+
+       /* bottom and top square */
+       for (y = 0; y < (res - 1); ++y) {
+               for (x = 0; x < 2 * (res - 1); ++x) {
+                       gint x_pos;
+                       gint y_pos;
+                       gdouble val;
+
+                       pos = (4 * res * (res + 1) + y * 2 * (res - 1) + x) * channels_n;
+                       area = 1;
+                       x_pos = x + 1;
+                       y_pos = y + 1;
+                       val = (gdouble)y_pos/(gdouble)res * (max-min);
+
+                       if (/*0 <= x &&*/ x < res - 1) {
+                               lab[pos + 0] = 1.0;
+                               lab[pos + 1] = min + (x_pos - (area - 1) * (res - 1)) / (gdouble)res * 
(max-min);
+                               lab[pos + 2] = min + val;
+                       } else if (res - 1 <= x && x < 2 * res - 2) {
+                               ++area;
+                               lab[pos + 1] = min + (x_pos - (area - 1) * (res - 1)) / (gdouble)res * 
(max-min);
+                               lab[pos + 2] = min + val;
+                               lab[pos + 0] = HYP (lab[pos + 1] - 0.5, lab[pos + 2] - 0.5)/100.; /* 0.0 */
+                       }
+               }
+       }
+out:
+       return lab;
+}
+
+/**
+ * cd_icc_create_hull_for_data:
+ *
+ * The original code was taken from icc_examin,
+ *  Copyright 2004-2009 Kai-Uwe Behrmann <ku b gmx de>
+ **/
+static GcmHull *
+cd_icc_create_hull_for_data (guint res, gdouble *lab, gdouble *rgb)
+{
+       CdColorRGB color;
+       CdColorXYZ xyz;
+       GcmHull *hull = NULL;
+       gint channels_n = 3;
+       gint off;
+       gsize i;
+       gsize size;
+       guint face[3];
+       guint x, y;
+
+       size = 4 * res * (res+1) + 2 * (res-1) * (res-1);
+
+       hull = gcm_hull_new ();
+
+       /* collect colour points */
+       for (i = 0; i < size; ++i) {
+               xyz.X = lab[i*channels_n+0];
+               xyz.Y = lab[i*channels_n+1];
+               xyz.Z = lab[i*channels_n+2];
+               color.R = rgb[i*channels_n+0];
+               color.G = rgb[i*channels_n+1];
+               color.B = rgb[i*channels_n+2];
+               gcm_hull_add_vertex (hull, &xyz, &color);
+       }
+
+       for (y = 0; y < res; ++y) {
+               for (x = 0; x < 4 * res; ++x) {
+                       gint x_ = x;
+                       if (x == 4 * res - 1)
+                               x_ = -1;
+                       face[0] = y * 4*res+x;
+                       face[1] = y * 4*res+x_+1;
+                       face[2] = (y+1)*4*res+x;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       face[0] = y * 4*res+x_+1;
+                       face[1] = (y+1)*4*res+x_+1;
+                       face[2] = (y+1)*4*res+x;
+                       gcm_hull_add_face (hull, face, 3);
+               }
+       }
+
+       off = 4 * res * (res + 1);
+
+       /* 1 0 0 (L res b) */
+       face[0] = 4*res-1;
+       face[1] = off;
+       face[2] = 0;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[0] = off;
+       face[2] = 0;
+       face[1] = 1;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 0 0 0 */
+       face[1] = off-1;
+       face[0] = off+res-1;
+       face[2] = off-4*res;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[1] = off+res-1;
+       face[2] = off-4*res;
+       face[0] = off - 4*res+1;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 0 0 1 */
+       face[2] = off-res;
+       face[1] = off-res-1;
+       face[0] = off+2*(res-1)*(res-1)-res+1;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[0] = off-res;
+       face[1] = off-res+1;
+       face[2] = off+2*(res-1)*(res-1)-res+1;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 0 1 1 */
+       face[0] = off-2*res+1;
+       face[2] = off-2*res;
+       face[1] = off+2*(res-1)*(res-1)-1;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[1] = off-2*res;
+       face[2] = off+2*(res-1)*(res-1)-1;
+       face[0] = off-2*res-1;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 1 1 1 */
+       face[0] = 2*res-1;
+       face[2] = 2*res;
+       face[1] = off+2*(res-1)*(res-1)-res;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[1] = 2*res;
+       face[2] = off+2*(res-1)*(res-1)-res;
+       face[0] = 2*res+1;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 1 0 1 */
+       face[2] = 3*res;
+       face[0] = 3*res-1;
+       face[1] = off+2*(res-1)*(res-1)-2*res+2;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[2] = 3*res;
+       face[1] = 3*res+1;
+       face[0] = off+2*(res-1)*(res-1)-2*res+2;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 1 1 0 */
+       face[0] = off+res-2;
+       face[1] = res + 1;
+       face[2] = res - 1;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[0] = res + 1;
+       face[2] = res - 1;
+       face[1] = res;
+       gcm_hull_add_face (hull, face, 3);
+
+       /* 0 1 0 */
+       face[0] = off+2*(res-1)-1;
+       face[1] = off-3*res-1;
+       face[2] = off-3*res;
+       gcm_hull_add_face (hull, face, 3);
+
+       face[1] = off+2*(res-1)-1;
+       face[0] = off-3*res+1;
+       face[2] = off-3*res+0;
+       gcm_hull_add_face (hull, face, 3);
+
+       for (y = 0; y < res; ++y) {
+               if (0 < y && y < res - 1) {
+                       /* 0 0 . */
+                       face[2] = off-y;
+                       face[0] = off+(y+1)*2*(res-1)-res+1;
+                       face[1] = off-y-1;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       face[0] = off+(y+0)*2*(res-1)-res+1;
+                       face[2] = off-y;
+                       face[1] = off+(y+1)*2*(res-1)-res+1;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       /* 0 1 . */
+                       face[1] = off+(y+1)*2*(res-1)-1;
+                       face[0] = off-3*res+y+1;
+                       face[2] = off+(y)*2*(res-1)-1;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       face[1] = off-3*res+y+1;
+                       face[2] = off+(y)*2*(res-1)-1;
+                       face[0] = off-3*res+y;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       /* 1 0 . */
+                       face[0] = off+2*(res-1)*(res-1)-(y+1)*2*(res-1);
+                       face[1] = 3*res+y+1;
+                       face[2] = off+2*(res-1)*(res-1)-y*2*(res-1);
+                       gcm_hull_add_face (hull, face, 3);
+
+                       face[0] = 3*res+y+1;
+                       face[2] = off+2*(res-1)*(res-1)-y*2*(res-1);
+                       face[1] = 3*res+y;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       /* 1 1 . */
+                       face[0] = off+2*(res-1)*(res-1)-(y+1)*2*(res-1)+res-2;
+                       face[1] = off+2*(res-1)*(res-1)-(y+0)*2*(res-1)+res-2;
+                       face[2] = 2*res-y;
+                       gcm_hull_add_face (hull, face, 3);
+
+                       face[0] = 2*res-y-1;
+                       face[1] = off+2*(res-1)*(res-1)-(y+1)*2*(res-1)+res-2;
+                       face[2] = 2*res-y;
+                       gcm_hull_add_face (hull, face, 3);
+               }
+
+               for (x = 0; x < 2 * res; ++x) {
+                       gint x_ = x + off;
+
+                       /* lower border */
+                       if ( y == 0 ) {
+                               if (x == 0) {
+                               } else if (x == res - 1) {
+                               } else if (x < res - 1) {
+                                       /* 1 . 0 */
+                                       face[0] = off + x - 1;
+                                       face[1] = off + x;
+                                       face[2] = x;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                                       face[0] = off + x;
+                                       face[2] = x;
+                                       face[1] = x + 1;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                                       /* 0 . 1 */
+                                       face[0] = off-res-x;
+                                       face[2] = off-res-x-1;
+                                       face[1] = off+2*(res-1)*(res-1)-res+x;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                                       face[2] = off-res-x-1;
+                                       face[0] = off+2*(res-1)*(res-1)-res+x;
+                                       face[1] = off+2*(res-1)*(res-1)-res+x+1;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                                       /* 1 . 1 */
+                                       face[0] = 3*res - x;
+                                       face[1] = 3*res - x-1;
+                                       face[2] = off+2*(res-1)*(res-1)-2*(res-1)+x-1;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                                       face[0] = 3*res - x-1;
+                                       face[2] = off+2*(res-1)*(res-1)-2*(res-1)+x-1;
+                                       face[1] = off+2*(res-1)*(res-1)-2*(res-1)+x;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                               } else if (x > res + 1) {
+                                       /* 0 . 0 */
+                                       face[0] = off+x-3;
+                                       face[2] = off+x-3+1;
+                                       face[1] = 4*res*(res+1)-4*res + x-res-1;
+                                       gcm_hull_add_face (hull, face, 3);
+
+                                       face[1] = off+x-3+1;
+                                       face[2] = 4*res*(res+1)-4*res + x-res-1;
+                                       face[0] = 4*res*(res+1)-4*res + x-res;
+                                       gcm_hull_add_face (hull, face, 3);
+                               }
+
+                       /* upper border */
+                       } else if ( y == res - 1 ) {
+                               if (x == 0) {
+                               }
+                       } else if (/*0 <= x &&*/ x < res - 1 - 1) {
+
+                               /* upper middle field (*L=0.0) */
+                               face[0] = (y-1) * 2*(res-1)+x_;
+                               face[2] = (y-1)*2*(res-1)+x_+1;
+                               face[1] = (y+0)*2*(res-1)+x_;
+                               gcm_hull_add_face (hull, face, 3);
+
+                               face[2] = (y-1)*2*(res-1)+x_+1;
+                               face[0] = (y+0)*2*(res-1)+x_;
+                               face[1] = (y+0)*2*(res-1)+x_+1;
+                               gcm_hull_add_face (hull, face, 3);
+
+                       } else if (res - 1 <= x && x < 2 * res - 2 - 1) {
+
+                               /* lower middle field (*L=1.0) */
+                               face[0] = (y-1) * 2*(res-1)+x_;
+                               face[1] = (y-1)*2*(res-1)+x_+1;
+                               face[2] = (y+0)*2*(res-1)+x_;
+                               gcm_hull_add_face (hull, face, 3);
+
+                               face[0] = (y-1)*2*(res-1)+x_+1;
+                               face[2] = (y+0)*2*(res-1)+x_;
+                               face[1] = (y+0)*2*(res-1)+x_+1;
+                               gcm_hull_add_face (hull, face, 3);
+                       }
+               }
+       }
+
+       return hull;
+}
+
+/**
+ * cd_icc_generate_gamut_hull:
+ * @icc: a #CdIcc
+ * @res: The resolution. 10 is quick, 20 is more precise. 12 is a good default.
+ *
+ * A cube from six squares with the range of the Lab cube will be
+ * transformed to a icc colour space and then converted to a
+ * mesh.
+ *
+ * The original code was taken from icc_examin,
+ *  Copyright 2004-2009 Kai-Uwe Behrmann <ku b gmx de>
+ **/
+GcmHull *
+cd_icc_generate_gamut_hull (CdIcc *icc, guint res)
+{
+       cmsHPROFILE lab_profile = NULL;
+       cmsHPROFILE srgb_profile = NULL;
+       cmsHTRANSFORM lab_transform = NULL;
+       cmsHTRANSFORM srgb_transform = NULL;
+       cmsHPROFILE lcms_profile;
+       GcmHull *hull = NULL;
+       gdouble *lab = NULL;
+       gdouble *rgb = NULL;
+       gint channels_n = 3;
+       gsize size = 4 * res * (res+1) + 2 * (res-1) * (res-1);
+
+       /* create data array */
+       lab = cd_icc_create_lab_cube (res);
+       rgb = g_new0 (gdouble, size * channels_n);
+       if (rgb == NULL)
+               goto out;
+
+       /* run the cube through the Lab icc */
+       lab_profile = cmsCreateLab4Profile (cmsD50_xyY ());
+       lcms_profile = cd_icc_get_handle (icc);
+       lab_transform = cmsCreateTransform (lcms_profile, TYPE_RGB_DBL,
+                                           lab_profile, TYPE_Lab_DBL,
+                                           INTENT_ABSOLUTE_COLORIMETRIC, 0);
+       if (lab_transform == NULL) {
+               g_warning ("failed to create Lab transform");
+               goto out;
+       }
+       cmsDoTransform (lab_transform, lab, lab, size);
+
+       /* run the cube through the sRGB icc */
+       srgb_profile = cmsCreate_sRGBProfile ();
+       srgb_transform = cmsCreateTransform (lab_profile, TYPE_Lab_DBL,
+                                            srgb_profile, TYPE_RGB_DBL,
+                                            INTENT_ABSOLUTE_COLORIMETRIC, 0);
+       if (srgb_transform == NULL) {
+               g_warning ("failed to create sRGB transform");
+               goto out;
+       }
+       cmsDoTransform (srgb_transform, lab, rgb, size);
+
+       /* create gamut hull */
+       hull = cd_icc_create_hull_for_data (res, lab, rgb);
+out:
+       g_free (rgb);
+       g_free (lab);
+       if (lab_profile != NULL)
+               cmsCloseProfile (lab_profile);
+       if (srgb_profile != NULL)
+               cmsCloseProfile (srgb_profile);
+       if (lab_transform != NULL)
+               cmsDeleteTransform (lab_transform);
+       if (srgb_transform != NULL)
+               cmsDeleteTransform (srgb_transform);
+       return hull;
+}
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index d017342..12a3ff9 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -25,38 +25,14 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
-#include "gcm-profile.h"
+#include "gcm-clut.h"
+#include "gcm-hull.h"
 
 #define GCM_STOCK_ICON                                 "gnome-color-manager"
 #define GCM_DBUS_SERVICE                               "org.gnome.ColorManager"
 #define GCM_DBUS_INTERFACE                             "org.gnome.ColorManager"
 #define GCM_DBUS_PATH                                  "/org/gnome/ColorManager"
 
-#ifndef CD_PROFILE_METADATA_MEASUREMENT_DEVICE
-#define CD_PROFILE_METADATA_MEASUREMENT_DEVICE         "MEASUREMENT_device"
-#endif
-#ifndef CD_PROFILE_METADATA_SCREEN_SURFACE
-#define CD_PROFILE_METADATA_SCREEN_SURFACE             "SCREEN_surface"
-#endif
-#ifndef CD_PROFILE_METADATA_CONNECTION_TYPE
-#define CD_PROFILE_METADATA_CONNECTION_TYPE            "CONNECTION_type"
-#endif
-#ifndef CD_PROFILE_METADATA_ACCURACY_DE76_AVG
-#define CD_PROFILE_METADATA_ACCURACY_DE76_AVG          "ACCURACY_dE76_avg"
-#endif
-#ifndef CD_PROFILE_METADATA_ACCURACY_DE76_MAX
-#define CD_PROFILE_METADATA_ACCURACY_DE76_MAX          "ACCURACY_dE76_max"
-#endif
-#ifndef CD_PROFILE_METADATA_ACCURACY_DE76_RMS
-#define CD_PROFILE_METADATA_ACCURACY_DE76_RMS          "ACCURACY_dE76_rms"
-#endif
-#ifndef CD_PROFILE_METADATA_MAPPING_DEVICE_ID
-#define CD_PROFILE_METADATA_MAPPING_DEVICE_ID          "MAPPING_device_id"
-#endif
-#ifndef CD_PROFILE_METADATA_SCREEN_BRIGHTNESS
-#define CD_PROFILE_METADATA_SCREEN_BRIGHTNESS          "SCREEN_brightness"
-#endif
-
 /* DISTROS: you will have to patch if you have changed the name of these packages */
 #define GCM_PREFS_PACKAGE_NAME_SHARED_COLOR_TARGETS    "shared-color-targets"
 #define GCM_PREFS_PACKAGE_NAME_ARGYLLCMS               "argyllcms"
@@ -73,8 +49,14 @@ void          gcm_utils_ensure_sensible_filename     (gchar                  *string);
 gboolean        gcm_utils_install_package              (const gchar            *package_name,
                                                         GtkWindow              *window);
 gchar          *gcm_utils_linkify                      (const gchar            *text);
-const gchar    *cd_colorspace_to_localised_string      (CdColorspace    colorspace);
-gboolean        gcm_profile_has_colorspace_description (CdProfile              *profile);
+const gchar    *cd_colorspace_to_localised_string      (CdColorspace            colorspace);
+gboolean        cd_icc_has_colorspace_description      (CdProfile              *profile);
+GcmClut                *cd_icc_generate_vcgt                   (CdIcc                  *profile,
+                                                        guint                   size);
+GcmClut                *cd_icc_generate_curve                  (CdIcc                  *icc,
+                                                        guint                   size);
+GcmHull                *cd_icc_generate_gamut_hull             (CdIcc                  *icc,
+                                                        guint                   res);
 
 #endif /* __GCM_UTILS_H */
 
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index 007a086..617e780 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -38,10 +38,9 @@
 #include "gcm-cell-renderer-color.h"
 #include "gcm-cie-widget.h"
 #include "gcm-image.h"
-#include "gcm-profile.h"
 #include "gcm-trc-widget.h"
-#include "gcm-named-color.h"
 #include "gcm-utils.h"
+#include "gcm-clut.h"
 #include "gcm-debug.h"
 
 #ifdef HAVE_CLUTTER
@@ -63,6 +62,7 @@ typedef struct {
        gchar           *profile_id;
        gchar           *filename;
        guint            xid;
+       const gchar     *lang;
        GtkListStore    *liststore_nc;
        GtkListStore    *liststore_metadata;
 } GcmViewerPrivate;
@@ -740,44 +740,28 @@ gcm_viewer_profile_colorspace_to_string (CdColorspace colorspace)
  * gcm_viewer_add_named_colors:
  **/
 static gboolean
-gcm_viewer_add_named_colors (GcmViewerPrivate *viewer,
-                            GcmProfile *profile)
+gcm_viewer_add_named_colors (GcmViewerPrivate *viewer, CdIcc *icc)
 {
-       gboolean ret = FALSE;
-       GcmNamedColor *nc;
-       GError *error = NULL;
+       CdColorSwatch *nc;
        GPtrArray *ncs = NULL;
        GtkTreeIter iter;
        guint i;
 
        /* get profile named colors */
-       ncs = gcm_profile_get_named_colors (profile, &error);
-       if (ncs == NULL) {
-               g_warning ("failed to get named colors: %s",
-                          error->message);
-               g_error_free (error);
-               goto out;
-       }
-
-       /* add items */
        gtk_list_store_clear (viewer->liststore_nc);
-       for (i=0; i<ncs->len; i++) {
+       ncs = cd_icc_get_named_colors (icc);
+       for (i = 0; i < ncs->len; i++) {
                nc = g_ptr_array_index (ncs, i);
                gtk_list_store_append (viewer->liststore_nc, &iter);
                gtk_list_store_set (viewer->liststore_nc,
                                    &iter,
                                    GCM_NAMED_COLORS_COLUMN_SORT, "1",
-                                   GCM_NAMED_COLORS_COLUMN_TITLE, gcm_named_color_get_title (nc),
-                                   GCM_NAMED_COLORS_COLUMN_COLOR, gcm_named_color_get_value (nc),
+                                   GCM_NAMED_COLORS_COLUMN_TITLE, cd_color_swatch_get_name (nc),
+                                   GCM_NAMED_COLORS_COLUMN_COLOR, cd_color_swatch_get_value (nc),
                                    -1);
        }
-
-       /* success */
-       ret= TRUE;
-out:
-       if (ncs != NULL)
-               g_ptr_array_unref (ncs);
-       return ret;
+       g_ptr_array_unref (ncs);
+       return TRUE;
 }
 
 struct {
@@ -931,10 +915,10 @@ out:
 }
 
 /**
- * gcm_profile_warning_to_string:
+ * cd_icc_warning_to_string:
  **/
 static const gchar *
-gcm_profile_warning_to_string (CdProfileWarning kind_enum)
+cd_icc_warning_to_string (CdProfileWarning kind_enum)
 {
        const gchar *kind = NULL;
        switch (kind_enum) {
@@ -994,14 +978,13 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
 {
        GtkWidget *widget;
        GtkWindow *window;
-       GFile *file;
-       GcmProfile *gcm_profile = NULL;
+       CdIcc *icc = NULL;
        GcmClut *clut_trc = NULL;
        GcmClut *clut_vcgt = NULL;
        const gchar *profile_copyright;
        const gchar *profile_manufacturer;
        const gchar *profile_model ;
-       const gchar *profile_datetime;
+       GDateTime *created;
        const gchar *profile_title;
        gchar *temp;
        const gchar *filename;
@@ -1031,27 +1014,21 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
                goto out;
        }
 
-       gcm_profile = gcm_profile_new ();
-       file = g_file_new_for_path (cd_profile_get_filename (profile));
-       gcm_profile_parse (gcm_profile,
-                          file,
-                          NULL);
-       g_object_unref (file);
-
        /* set the preview widgets */
+       icc = cd_profile_load_icc (profile, CD_ICC_LOAD_FLAGS_ALL, NULL, NULL);
        if (cd_profile_get_colorspace (profile) == CD_COLORSPACE_RGB &&
            cd_profile_get_kind (profile) != CD_PROFILE_KIND_NAMED_COLOR) {
-               gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), gcm_profile);
+               gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), icc);
                gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_input), NULL);
-               gcm_image_set_output_profile (GCM_IMAGE(viewer->preview_widget_output), gcm_profile);
+               gcm_image_set_output_profile (GCM_IMAGE(viewer->preview_widget_output), icc);
                gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), NULL);
                show_section = TRUE;
        } else if (cd_profile_get_colorspace (profile) == CD_COLORSPACE_LAB &&
                   cd_profile_get_kind (profile) != CD_PROFILE_KIND_NAMED_COLOR) {
                gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), NULL);
-               gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_input), gcm_profile);
+               gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_input), icc);
                gcm_image_set_output_profile (GCM_IMAGE(viewer->preview_widget_output), NULL);
-               gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), gcm_profile);
+               gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), icc);
                show_section = TRUE;
        } else {
                gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), NULL);
@@ -1065,14 +1042,14 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        if (cd_profile_get_colorspace (profile) == CD_COLORSPACE_RGB &&
            cd_profile_get_kind (profile) != CD_PROFILE_KIND_NAMED_COLOR) {
                gcm_cie_widget_set_from_profile (viewer->cie_widget,
-                                                gcm_profile);
+                                                icc);
                gtk_widget_show (widget);
        } else {
                gtk_widget_hide (widget);
        }
 
        /* get curve data */
-       clut_trc = gcm_profile_generate_curve (gcm_profile, 256);
+       clut_trc = cd_icc_generate_curve (icc, 256);
 
        /* only show if there is useful information */
        size = 0;
@@ -1092,13 +1069,13 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        /* show 3d gamut hull */
        gtk_widget_show (viewer->hull_widget);
        gcm_hull_widget_clear (GCM_HULL_WIDGET (viewer->hull_widget));
-       ret = gcm_hull_widget_add (GCM_HULL_WIDGET (viewer->hull_widget), gcm_profile);
+       ret = gcm_hull_widget_add (GCM_HULL_WIDGET (viewer->hull_widget), icc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_3d"));
        gtk_widget_set_visible (widget, ret);
 #endif
 
        /* get vcgt data */
-       clut_vcgt = gcm_profile_generate_vcgt (gcm_profile, 256);
+       clut_vcgt = cd_icc_generate_vcgt (icc, 256);
 
        /* only show if there is useful information */
        size = 0;
@@ -1176,7 +1153,7 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
                        g_debug ("warnings[i]=%s", warnings[i]);
                        warning = cd_profile_warning_from_string (warnings[i]);
                        g_string_append_printf (str, "• %s\n",
-                                               gcm_profile_warning_to_string (warning));
+                                               cd_icc_warning_to_string (warning));
                }
                if (str->len > 0)
                        g_string_set_size (str, str->len - 1);
@@ -1185,13 +1162,13 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* set profile version */
-       filename = gcm_profile_get_version (gcm_profile);
-       widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder,
-                            "label_version"));
-       gtk_label_set_label (GTK_LABEL (widget), filename);
+       temp = g_strdup_printf ("%.1f", cd_icc_get_version (icc));
+       widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_version"));
+       gtk_label_set_label (GTK_LABEL (widget), temp);
+       g_free (temp);
 
        /* set whitepoint */
-       temperature = gcm_profile_get_temperature (gcm_profile);
+       temperature = cd_icc_get_temperature (icc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_title_temp"));
        gtk_widget_set_visible (widget, temperature > 0);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_temp"));
@@ -1209,7 +1186,7 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* set size */
-       filesize = gcm_profile_get_size (gcm_profile);
+       filesize = cd_icc_get_size (icc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_title_size"));
        gtk_widget_set_visible (widget, filesize > 0);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_size"));
@@ -1220,7 +1197,7 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* set new copyright */
-       profile_copyright = gcm_profile_get_copyright (gcm_profile);
+       profile_copyright = cd_icc_get_copyright (icc, viewer->lang, NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_title_copyright"));
        gtk_widget_set_visible (widget, profile_copyright != NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_copyright"));
@@ -1232,7 +1209,7 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* set new manufacturer */
-       profile_manufacturer = gcm_profile_get_manufacturer (gcm_profile);
+       profile_manufacturer = cd_icc_get_manufacturer (icc, viewer->lang, NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_title_profile_manufacturer"));
        gtk_widget_set_visible (widget, profile_manufacturer != NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_profile_manufacturer"));
@@ -1244,7 +1221,7 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* set new model */
-       profile_model = gcm_profile_get_model (gcm_profile);
+       profile_model = cd_icc_get_model (icc, viewer->lang, NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_title_profile_model"));
        gtk_widget_set_visible (widget, profile_model != NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_profile_model"));
@@ -1256,18 +1233,22 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        }
 
        /* set new datetime */
-       profile_datetime = gcm_profile_get_datetime (gcm_profile);
+       created = cd_icc_get_created  (icc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_title_datetime"));
-       gtk_widget_set_visible (widget, profile_datetime != NULL);
+       gtk_widget_set_visible (widget, created != NULL);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_datetime"));
-       gtk_widget_set_visible (widget, profile_datetime != NULL);
-       if (profile_datetime != NULL)
-               gtk_label_set_label (GTK_LABEL(widget), profile_datetime);
+       gtk_widget_set_visible (widget, created != NULL);
+       if (created != NULL) {
+               /* TRANSLATORS: this is the icc creation date strftime format */
+               temp = g_date_time_format (created, _("%B %e %Y, %I:%M:%S %p"));
+               gtk_label_set_label (GTK_LABEL(widget), temp);
+               g_free (temp);
+       }
 
        /* setup named color tab */
        ret = FALSE;
        if (profile_kind == CD_PROFILE_KIND_NAMED_COLOR)
-               ret = gcm_viewer_add_named_colors (viewer, gcm_profile);
+               ret = gcm_viewer_add_named_colors (viewer, icc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_named_colors"));
        gtk_widget_set_visible (widget, ret);
 
@@ -1277,7 +1258,7 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        gtk_widget_set_visible (widget, ret);
 
        /* set delete sensitivity */
-       ret = gcm_profile_get_can_delete (gcm_profile);
+       ret = cd_icc_get_can_delete (icc);
        widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "toolbutton_profile_delete"));
        gtk_widget_set_sensitive (widget, ret);
        if (ret) {
@@ -1295,8 +1276,8 @@ gcm_viewer_set_profile (GcmViewerPrivate *viewer, CdProfile *profile)
        gtk_widget_set_visible (widget, show_section);
 
 out:
-       if (gcm_profile != NULL)
-               g_object_unref (gcm_profile);
+       if (icc != NULL)
+               g_object_unref (icc);
        if (clut_trc != NULL)
                g_object_unref (clut_trc);
        if (clut_vcgt != NULL)
@@ -1879,6 +1860,7 @@ main (int argc, char **argv)
        viewer->xid = xid;
        viewer->profile_id = profile_id;
        viewer->filename = filename;
+       viewer->lang = g_getenv ("LANG");
 
        /* ensure single instance */
        viewer->application = gtk_application_new ("org.gnome.ColorManager.Viewer", 0);


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