[gnome-color-manager/colord: 31/72] Port gcm-viewer to colord



commit ce3ddcb3bd696b624bef6c7073bd88f936cf9931
Author: Richard Hughes <richard hughsie com>
Date:   Sat Jan 29 20:16:02 2011 +0000

    Port gcm-viewer to colord

 src/gcm-cell-renderer-profile-icon.c |    6 +-
 src/gcm-cell-renderer-profile-icon.h |    5 +-
 src/gcm-cell-renderer-profile-text.c |    6 +-
 src/gcm-cell-renderer-profile-text.h |    5 +-
 src/gcm-list-store-profiles.c        |   10 +-
 src/gcm-profile.c                    |   41 ---------
 src/gcm-profile.h                    |    1 -
 src/gcm-self-test.c                  |    3 -
 src/gcm-viewer.c                     |  161 ++++++++++++++++++++-------------
 9 files changed, 112 insertions(+), 126 deletions(-)
---
diff --git a/src/gcm-cell-renderer-profile-icon.c b/src/gcm-cell-renderer-profile-icon.c
index 80e21ea..b7cf048 100644
--- a/src/gcm-cell-renderer-profile-icon.c
+++ b/src/gcm-cell-renderer-profile-icon.c
@@ -58,8 +58,8 @@ gcm_cell_renderer_set_icon_name (GcmCellRendererProfileIcon *renderer)
 {
 	const gchar *icon_name = NULL;
 
-	if (gcm_profile_get_kind (renderer->profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
-	    !gcm_profile_get_has_vcgt (renderer->profile))
+	if (cd_profile_get_kind (renderer->profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
+	    !cd_profile_get_has_vcgt (renderer->profile))
 		icon_name = "dialog-information";
 
 	g_object_set (renderer, "icon-name", icon_name, NULL);
@@ -112,7 +112,7 @@ gcm_cell_renderer_profile_icon_class_init (GcmCellRendererProfileIconClass *clas
 
 	g_object_class_install_property (object_class, PROP_PROFILE,
 					 g_param_spec_object ("profile", NULL,
-					 NULL, GCM_TYPE_PROFILE, G_PARAM_READWRITE));
+					 NULL, CD_TYPE_PROFILE, G_PARAM_READWRITE));
 }
 
 /**
diff --git a/src/gcm-cell-renderer-profile-icon.h b/src/gcm-cell-renderer-profile-icon.h
index 6335041..0d152de 100644
--- a/src/gcm-cell-renderer-profile-icon.h
+++ b/src/gcm-cell-renderer-profile-icon.h
@@ -24,8 +24,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-
-#include "gcm-profile.h"
+#include <colord.h>
 
 #define GCM_TYPE_CELL_RENDERER_PROFILE_ICON		(gcm_cell_renderer_profile_icon_get_type())
 #define GCM_CELL_RENDERER_PROFILE_ICON(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), GCM_TYPE_CELL_RENDERER_PROFILE_ICON, GcmCellRendererProfileIcon))
@@ -42,7 +41,7 @@ typedef struct _GcmCellRendererProfileIconClass		GcmCellRendererProfileIconClass
 struct _GcmCellRendererProfileIcon
 {
 	GtkCellRendererPixbuf	 parent;
-	GcmProfile		*profile;
+	CdProfile		*profile;
 	gchar			*icon_name;
 };
 
diff --git a/src/gcm-cell-renderer-profile-text.c b/src/gcm-cell-renderer-profile-text.c
index a0c4c98..d8dfb1f 100644
--- a/src/gcm-cell-renderer-profile-text.c
+++ b/src/gcm-cell-renderer-profile-text.c
@@ -69,9 +69,9 @@ gcm_cell_renderer_set_markup (GcmCellRendererProfileText *renderer)
 		string = g_string_new (_("No profile"));
 	} else {
 		/* add profile description */
-		description = gcm_profile_get_description (renderer->profile);
+		description = cd_profile_get_title (renderer->profile);
 		if (description == NULL)
-			description = gcm_profile_get_filename (renderer->profile);
+			description = cd_profile_get_filename (renderer->profile);
 		string = g_string_new (description);
 
 		/* TRANSLATORS: this is the default profile */
@@ -136,7 +136,7 @@ gcm_cell_renderer_profile_text_class_init (GcmCellRendererProfileTextClass *clas
 
 	g_object_class_install_property (object_class, PROP_PROFILE,
 					 g_param_spec_object ("profile", "PROFILE",
-					 "PROFILE", GCM_TYPE_PROFILE, G_PARAM_READWRITE));
+					 "PROFILE", CD_TYPE_PROFILE, G_PARAM_READWRITE));
 	g_object_class_install_property (object_class, PROP_IS_DEFAULT,
 					 g_param_spec_boolean ("is-default", "IS_DEFAULT",
 					 "IS_DEFAULT", FALSE, G_PARAM_READWRITE));
diff --git a/src/gcm-cell-renderer-profile-text.h b/src/gcm-cell-renderer-profile-text.h
index 594cbba..2cd228a 100644
--- a/src/gcm-cell-renderer-profile-text.h
+++ b/src/gcm-cell-renderer-profile-text.h
@@ -24,8 +24,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-
-#include "gcm-profile.h"
+#include <colord.h>
 
 #define GCM_TYPE_CELL_RENDERER_PROFILE_TEXT		(gcm_cell_renderer_profile_text_get_type())
 #define GCM_CELL_RENDERER_PROFILE_TEXT(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), GCM_TYPE_CELL_RENDERER_PROFILE_TEXT, GcmCellRendererProfileText))
@@ -42,7 +41,7 @@ typedef struct _GcmCellRendererProfileTextClass		GcmCellRendererProfileTextClass
 struct _GcmCellRendererProfileText
 {
 	GtkCellRendererText	 parent;
-	GcmProfile		*profile;
+	CdProfile		*profile;
 	gboolean		 is_default;
 	gchar			*markup;
 };
diff --git a/src/gcm-list-store-profiles.c b/src/gcm-list-store-profiles.c
index a89cc4b..08f8d84 100644
--- a/src/gcm-list-store-profiles.c
+++ b/src/gcm-list-store-profiles.c
@@ -40,13 +40,13 @@ struct GcmListStoreProfilesPrivate
  * cc_color_panel_profile_get_tooltip:
  **/
 static const gchar *
-cc_color_panel_profile_get_tooltip (GcmProfile *profile)
+cc_color_panel_profile_get_tooltip (CdProfile *profile)
 {
 	const gchar *tooltip = NULL;
 
 	/* VCGT warning */
-	if (gcm_profile_get_kind (profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
-	    !gcm_profile_get_has_vcgt (profile)) {
+	if (cd_profile_get_kind (profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
+	    !cd_profile_get_has_vcgt (profile)) {
 		/* TRANSLATORS: this is displayed when the profile is crap */
 		tooltip = _("This profile does not have the information required for whole-screen color correction.");
 		goto out;
@@ -63,7 +63,7 @@ gcm_list_store_refresh_profiles (GtkListStore *list_store)
 {
 	GPtrArray *profiles;
 	GtkTreeIter iter;
-	GcmProfile *profile;
+	CdProfile *profile;
 	guint i;
 	GcmListStoreProfilesPrivate *priv = GCM_LIST_STORE_PROFILES(list_store)->priv;
 
@@ -125,7 +125,7 @@ gcm_list_store_profiles_set_from_device (GtkListStore *list_store, CdDevice *dev
 static void
 gcm_list_store_profiles_init (GcmListStoreProfiles *list_store)
 {
-	GType types[] = { G_TYPE_STRING, GCM_TYPE_PROFILE, G_TYPE_BOOLEAN, G_TYPE_STRING };
+	GType types[] = { G_TYPE_STRING, CD_TYPE_PROFILE, G_TYPE_BOOLEAN, G_TYPE_STRING };
 	list_store->priv = GCM_LIST_STORE_PROFILES_GET_PRIVATE (list_store);
 	gtk_list_store_set_column_types (GTK_LIST_STORE (list_store), GCM_LIST_STORE_PROFILES_COLUMN_LAST, types);
 }
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index 547941c..530310d 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -53,7 +53,6 @@ struct _GcmProfilePrivate
 	CdProfileKind		 kind;
 	CdColorspace		 colorspace;
 	guint			 size;
-	gboolean		 has_vcgt;
 	gboolean		 can_delete;
 	gchar			*description;
 	gchar			*filename;
@@ -87,7 +86,6 @@ enum {
 	PROP_KIND,
 	PROP_COLORSPACE,
 	PROP_SIZE,
-	PROP_HAS_VCGT,
 	PROP_CAN_DELETE,
 	PROP_WHITE,
 	PROP_BLACK,
@@ -572,27 +570,6 @@ gcm_profile_set_colorspace (GcmProfile *profile, CdColorspace colorspace)
 }
 
 /**
- * gcm_profile_get_has_vcgt:
- **/
-gboolean
-gcm_profile_get_has_vcgt (GcmProfile *profile)
-{
-	g_return_val_if_fail (GCM_IS_PROFILE (profile), FALSE);
-	return profile->priv->has_vcgt;
-}
-
-/**
- * gcm_profile_set_has_vcgt:
- **/
-static void
-gcm_profile_set_has_vcgt (GcmProfile *profile, gboolean has_vcgt)
-{
-	g_return_if_fail (GCM_IS_PROFILE (profile));
-	profile->priv->has_vcgt = has_vcgt;
-	g_object_notify (G_OBJECT (profile), "has_vcgt");
-}
-
-/**
  * gcm_profile_get_handle:
  *
  * Return value: Do not call cmsCloseProfile() on this value!
@@ -860,10 +837,6 @@ gcm_profile_parse_data (GcmProfile *profile, const guint8 *data, gsize length, G
 		g_free (text);
 	}
 
-	/* do we have vcgt */
-	ret = cmsIsTag (priv->lcms_profile, cmsSigVcgtTag);
-	gcm_profile_set_has_vcgt (profile, ret);
-
 	/* allocate temporary buffer */
 	text = g_new0 (gchar, 1024);
 
@@ -1592,9 +1565,6 @@ gcm_profile_get_property (GObject *object, guint prop_id, GValue *value, GParamS
 	case PROP_SIZE:
 		g_value_set_uint (value, priv->size);
 		break;
-	case PROP_HAS_VCGT:
-		g_value_set_boolean (value, priv->has_vcgt);
-		break;
 	case PROP_CAN_DELETE:
 		g_value_set_boolean (value, priv->can_delete);
 		break;
@@ -1659,9 +1629,6 @@ gcm_profile_set_property (GObject *object, guint prop_id, const GValue *value, G
 	case PROP_SIZE:
 		gcm_profile_set_size (profile, g_value_get_uint (value));
 		break;
-	case PROP_HAS_VCGT:
-		gcm_profile_set_has_vcgt (profile, g_value_get_boolean (value));
-		break;
 	case PROP_WHITE:
 		gcm_color_copy_XYZ (g_value_get_boxed (value), priv->white);
 		break;
@@ -1776,14 +1743,6 @@ gcm_profile_class_init (GcmProfileClass *klass)
 	g_object_class_install_property (object_class, PROP_SIZE, pspec);
 
 	/**
-	 * GcmProfile:has-vcgt:
-	 */
-	pspec = g_param_spec_boolean ("has-vcgt", NULL, NULL,
-				      FALSE,
-				      G_PARAM_READWRITE);
-	g_object_class_install_property (object_class, PROP_HAS_VCGT, pspec);
-
-	/**
 	 * GcmProfile:can-delete:
 	 */
 	pspec = g_param_spec_boolean ("can-delete", NULL, NULL,
diff --git a/src/gcm-profile.h b/src/gcm-profile.h
index 1e98191..0dc350a 100644
--- a/src/gcm-profile.h
+++ b/src/gcm-profile.h
@@ -128,7 +128,6 @@ void		 gcm_profile_set_kind			(GcmProfile	*profile,
 CdColorspace	 gcm_profile_get_colorspace		(GcmProfile	*profile);
 void		 gcm_profile_set_colorspace		(GcmProfile	*profile,
 							 CdColorspace	 colorspace);
-gboolean	 gcm_profile_get_has_vcgt		(GcmProfile	*profile);
 gboolean	 gcm_profile_has_colorspace_description	(GcmProfile	*profile);
 guint		 gcm_profile_get_temperature		(GcmProfile	*profile);
 const GcmColorXYZ *gcm_profile_get_red			(GcmProfile	*profile);
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 1c76c55..adb2a14 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -424,7 +424,6 @@ gcm_test_profile_func (void)
 	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_assert (gcm_profile_get_has_vcgt (profile));
 
 	/* get extra data */
 	g_object_get (profile,
@@ -455,7 +454,6 @@ gcm_test_profile_func (void)
 	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_assert (gcm_profile_get_has_vcgt (profile));
 
 	g_object_unref (profile);
 
@@ -498,7 +496,6 @@ gcm_test_profile_func (void)
 	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), ==, 5000);
-	g_assert (gcm_profile_get_has_vcgt (profile));
 
 	/* delete temp file */
 	ret = g_file_delete (file, NULL, &error);
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index ac01068..9c215f6 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -27,13 +27,12 @@
 #include <glib/gstdio.h>
 #include <locale.h>
 #include <canberra-gtk.h>
+#include <colord.h>
 
 #include "gcm-cell-renderer-profile-text.h"
-#include "gcm-calibrate-argyll.h"
 #include "gcm-cie-widget.h"
 #include "gcm-image.h"
 #include "gcm-profile.h"
-#include "gcm-profile-store.h"
 #include "gcm-trc-widget.h"
 #include "gcm-utils.h"
 #include "gcm-color.h"
@@ -45,7 +44,7 @@ typedef struct {
 	GtkBuilder	*builder;
 	GtkApplication	*application;
 	GtkListStore	*list_store_profiles;
-	GcmProfileStore	*profile_store;
+	CdClient	*client;
 	GtkWidget	*cie_widget;
 	GtkWidget	*trc_widget;
 	GtkWidget	*vcgt_widget;
@@ -225,16 +224,25 @@ gcm_viewer_update_profile_list (GcmViewerPrivate *viewer)
 	const gchar *description;
 	const gchar *icon_name;
 	CdProfileKind profile_kind = CD_PROFILE_KIND_UNKNOWN;
-	GcmProfile *profile;
+	CdProfile *profile;
 	guint i;
 	const gchar *filename = NULL;
 	gchar *sort = NULL;
 	GPtrArray *profile_array = NULL;
+	GError *error = NULL;
 
 	g_debug ("updating profile list");
 
 	/* get new list */
-//	profile_array = gcm_profile_store_get_array (viewer->profile_store);
+	profile_array = cd_client_get_profiles_sync (viewer->client,
+						     NULL,
+						     &error);
+	if (profile_array == NULL) {
+		g_warning ("failed to get profiles: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
 
 	/* clear existing list */
 	gtk_list_store_clear (viewer->list_store_profiles);
@@ -243,14 +251,14 @@ gcm_viewer_update_profile_list (GcmViewerPrivate *viewer)
 	for (i=0; i<profile_array->len; i++) {
 		profile = g_ptr_array_index (profile_array, i);
 
-		profile_kind = gcm_profile_get_kind (profile);
+		profile_kind = cd_profile_get_kind (profile);
 		icon_name = gcm_viewer_profile_kind_to_icon_name (profile_kind);
 		gtk_list_store_append (viewer->list_store_profiles, &iter);
-		description = gcm_profile_get_description (profile);
+		description = cd_profile_get_title (profile);
 		sort = g_strdup_printf ("%s%s",
 					gcm_viewer_profile_get_sort_string (profile_kind),
 					description);
-		filename = gcm_profile_get_filename (profile);
+		filename = cd_profile_get_filename (profile);
 		g_debug ("add %s to profiles list", filename);
 		gtk_list_store_set (viewer->list_store_profiles, &iter,
 				    GCM_PROFILES_COLUMN_ID, filename,
@@ -261,6 +269,7 @@ gcm_viewer_update_profile_list (GcmViewerPrivate *viewer)
 
 		g_free (sort);
 	}
+out:
 	if (profile_array != NULL)
 		g_ptr_array_unref (profile_array);
 }
@@ -531,9 +540,12 @@ gcm_viewer_add_profiles_columns (GcmViewerPrivate *viewer, GtkTreeView *treeview
 		      "wrap-width", GCM_VIEWER_TREEVIEW_WIDTH - 62,
 		      NULL);
 	column = gtk_tree_view_column_new_with_attributes ("", renderer,
-							   "profile", GCM_PROFILES_COLUMN_PROFILE, NULL);
+							   "profile", GCM_PROFILES_COLUMN_PROFILE,
+							   NULL);
 	gtk_tree_view_column_set_sort_column_id (column, GCM_PROFILES_COLUMN_SORT);
-	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (viewer->list_store_profiles), GCM_PROFILES_COLUMN_SORT, GTK_SORT_ASCENDING);
+	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (viewer->list_store_profiles),
+					      GCM_PROFILES_COLUMN_SORT,
+					      GTK_SORT_ASCENDING);
 	gtk_tree_view_append_column (treeview, column);
 	gtk_tree_view_column_set_expand (column, TRUE);
 }
@@ -635,7 +647,9 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 	GtkWidget *widget;
-	GcmProfile *profile;
+	GFile *file;
+	CdProfile *profile;
+	GcmProfile *gcm_profile;
 	GcmClut *clut_trc = NULL;
 	GcmClut *clut_vcgt = NULL;
 	const gchar *profile_copyright;
@@ -668,18 +682,25 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 			    GCM_PROFILES_COLUMN_PROFILE, &profile,
 			    -1);
 
+	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 */
-	if (gcm_profile_get_colorspace (profile) == CD_COLORSPACE_RGB) {
-		gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), profile);
+	if (cd_profile_get_colorspace (profile) == CD_COLORSPACE_RGB) {
+		gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), gcm_profile);
 		gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_input), NULL);
-		gcm_image_set_output_profile (GCM_IMAGE(viewer->preview_widget_output), profile);
+		gcm_image_set_output_profile (GCM_IMAGE(viewer->preview_widget_output), gcm_profile);
 		gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), NULL);
 		show_section = TRUE;
-	} else if (gcm_profile_get_colorspace (profile) == CD_COLORSPACE_LAB) {
+	} else if (cd_profile_get_colorspace (profile) == CD_COLORSPACE_LAB) {
 		gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), NULL);
-		gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_input), profile);
+		gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_input), gcm_profile);
 		gcm_image_set_output_profile (GCM_IMAGE(viewer->preview_widget_output), NULL);
-		gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), profile);
+		gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), gcm_profile);
 		show_section = TRUE;
 	} else {
 		gcm_image_set_input_profile (GCM_IMAGE(viewer->preview_widget_input), NULL);
@@ -689,10 +710,10 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	}
 
 	/* setup cie widget */
-	gcm_cie_widget_set_from_profile (viewer->cie_widget, profile);
+	gcm_cie_widget_set_from_profile (viewer->cie_widget, gcm_profile);
 
 	/* get curve data */
-	clut_trc = gcm_profile_generate_curve (profile, 256);
+	clut_trc = gcm_profile_generate_curve (gcm_profile, 256);
 
 	/* only show if there is useful information */
 	if (clut_trc != NULL)
@@ -707,7 +728,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	}
 
 	/* get vcgt data */
-	clut_vcgt = gcm_profile_generate_vcgt (profile, 256);
+	clut_vcgt = gcm_profile_generate_vcgt (gcm_profile, 256);
 
 	/* only show if there is useful information */
 	if (clut_vcgt != NULL)
@@ -723,7 +744,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set kind */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_type"));
-	profile_kind = gcm_profile_get_kind (profile);
+	profile_kind = cd_profile_get_kind (profile);
 	if (profile_kind == CD_PROFILE_KIND_UNKNOWN) {
 		gtk_widget_hide (widget);
 	} else {
@@ -735,7 +756,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set colorspace */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_colorspace"));
-	profile_colorspace = gcm_profile_get_colorspace (profile);
+	profile_colorspace = cd_profile_get_colorspace (profile);
 	if (profile_colorspace == CD_COLORSPACE_UNKNOWN) {
 		gtk_widget_hide (widget);
 	} else {
@@ -749,7 +770,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_vcgt"));
 	gtk_widget_set_visible (widget, (profile_kind == CD_PROFILE_KIND_DISPLAY_DEVICE));
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_vcgt"));
-	has_vcgt = gcm_profile_get_has_vcgt (profile);
+	has_vcgt = cd_profile_get_has_vcgt (profile);
 	if (has_vcgt) {
 		/* TRANSLATORS: if the device has a VCGT profile */
 		gtk_label_set_label (GTK_LABEL (widget), _("Yes"));
@@ -759,7 +780,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	}
 
 	/* set basename */
-	filename = gcm_profile_get_filename (profile);
+	filename = cd_profile_get_filename (profile);
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_filename"));
 	basename = g_path_get_basename (filename);
 	temp = g_markup_escape_text (basename, -1);
@@ -767,7 +788,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	g_free (temp);
 
 	/* set whitepoint */
-	temperature = gcm_profile_get_temperature (profile);
+	temperature = gcm_profile_get_temperature (gcm_profile);
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "label_temp"));
 	temp = g_strdup_printf ("%i°K", temperature);
 	gtk_label_set_label (GTK_LABEL (widget), temp);
@@ -777,7 +798,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set size */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_size"));
-	filesize = gcm_profile_get_size (profile);
+	filesize = gcm_profile_get_size (gcm_profile);
 	if (filesize == 0) {
 		gtk_widget_hide (widget);
 	} else {
@@ -789,7 +810,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set new copyright */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_copyright"));
-	profile_copyright = gcm_profile_get_copyright (profile);
+	profile_copyright = gcm_profile_get_copyright (gcm_profile);
 	if (profile_copyright == NULL) {
 		gtk_widget_hide (widget);
 	} else {
@@ -802,7 +823,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set new manufacturer */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_profile_manufacturer"));
-	profile_manufacturer = gcm_profile_get_manufacturer (profile);
+	profile_manufacturer = gcm_profile_get_manufacturer (gcm_profile);
 	if (profile_manufacturer == NULL) {
 		gtk_widget_hide (widget);
 	} else {
@@ -815,7 +836,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set new model */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_profile_model"));
-	profile_model = gcm_profile_get_model (profile);
+	profile_model = gcm_profile_get_model (gcm_profile);
 	if (profile_model == NULL) {
 		gtk_widget_hide (widget);
 	} else {
@@ -826,7 +847,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 
 	/* set new datetime */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "hbox_datetime"));
-	profile_datetime = gcm_profile_get_datetime (profile);
+	profile_datetime = gcm_profile_get_datetime (gcm_profile);
 	if (profile_datetime == NULL) {
 		gtk_widget_hide (widget);
 	} else {
@@ -836,7 +857,7 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	}
 
 	/* set delete sensitivity */
-	ret = gcm_profile_get_can_delete (profile);
+	ret = gcm_profile_get_can_delete (gcm_profile);
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "button_profile_delete"));
 	gtk_widget_set_sensitive (widget, ret);
 	if (ret) {
@@ -853,6 +874,8 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_profile_info"));
 	gtk_widget_set_visible (widget, TRUE);
 
+	if (gcm_profile != NULL)
+		g_object_unref (gcm_profile);
 	if (clut_trc != NULL)
 		g_object_unref (clut_trc);
 	if (clut_vcgt != NULL)
@@ -862,28 +885,23 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
 }
 
 /**
- * gcm_viewer_profile_store_added_cb:
+ * gcm_viewer_client_profile_added_cb:
  **/
 static void
-gcm_viewer_profile_store_added_cb (GcmProfileStore *profile_store, GcmProfile *profile, GcmViewerPrivate *viewer)
+gcm_viewer_client_profile_added_cb (CdClient *client,
+				    CdProfile *profile,
+				    GcmViewerPrivate *viewer)
 {
 	gcm_viewer_update_profile_list (viewer);
 }
 
 /**
- * gcm_viewer_profile_store_removed_cb:
+ * gcm_viewer_client_profile_removed_cb:
  **/
 static void
-gcm_viewer_profile_store_removed_cb (GcmProfileStore *profile_store, GcmProfile *profile, GcmViewerPrivate *viewer)
-{
-	gcm_viewer_update_profile_list (viewer);
-}
-
-/**
- * gcm_viewer_profile_store_changed_cb:
- **/
-static void
-gcm_viewer_profile_store_changed_cb (GcmProfileStore *profile_store, GcmViewerPrivate *viewer)
+gcm_viewer_client_profile_removed_cb (CdClient *client,
+				      CdProfile *profile,
+				      GcmViewerPrivate *viewer)
 {
 	gcm_viewer_update_profile_list (viewer);
 }
@@ -899,13 +917,12 @@ gcm_viewer_startup_phase1_idle_cb (GcmViewerPrivate *viewer)
 	GtkTreePath *path;
 
 	/* search the disk for profiles */
-	gcm_profile_store_search (viewer->profile_store);
-	g_signal_connect (viewer->profile_store, "changed",
-			  G_CALLBACK(gcm_viewer_profile_store_changed_cb), viewer);
-	g_signal_connect (viewer->profile_store, "added",
-			  G_CALLBACK (gcm_viewer_profile_store_added_cb), viewer);
-	g_signal_connect (viewer->profile_store, "removed",
-			  G_CALLBACK (gcm_viewer_profile_store_removed_cb), viewer);
+	g_signal_connect (viewer->client, "profile-added",
+			  G_CALLBACK (gcm_viewer_client_profile_added_cb),
+			  viewer);
+	g_signal_connect (viewer->client, "profile-removed",
+			  G_CALLBACK (gcm_viewer_client_profile_removed_cb),
+			  viewer);
 
 	/* update list of profiles */
 	gcm_viewer_update_profile_list (viewer);
@@ -1032,21 +1049,25 @@ gcm_viewer_activate_cb (GApplication *application, GcmViewerPrivate *viewer)
 static void
 gcm_viewer_startup_cb (GApplication *application, GcmViewerPrivate *viewer)
 {
-	GtkWidget *main_window;
-	GtkWidget *widget;
-	GError *error = NULL;
-	GtkTreeSelection *selection;
+	gboolean ret;
 	GdkScreen *screen;
+	GError *error = NULL;
 	gint retval;
+	GtkTreeSelection *selection;
+	GtkWidget *main_window;
+	GtkWidget *widget;
 
 	/* setup defaults */
 	viewer->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
 
 	/* get UI */
 	viewer->builder = gtk_builder_new ();
-	retval = gtk_builder_add_from_file (viewer->builder, GCM_DATA "/gcm-viewer.ui", &error);
+	retval = gtk_builder_add_from_file (viewer->builder,
+					    GCM_DATA "/gcm-viewer.ui",
+					    &error);
 	if (retval == 0) {
-		g_warning ("failed to load ui: %s", error->message);
+		g_warning ("failed to load ui: %s",
+			   error->message);
 		g_error_free (error);
 		goto out;
 	}
@@ -1056,11 +1077,23 @@ gcm_viewer_startup_cb (GApplication *application, GcmViewerPrivate *viewer)
 	                                   GCM_DATA G_DIR_SEPARATOR_S "icons");
 
 	/* maintain a list of profiles */
-	viewer->profile_store = gcm_profile_store_new ();
+	viewer->client = cd_client_new ();
+	ret = cd_client_connect_sync (viewer->client,
+				      NULL,
+				      &error);
+	if (!ret) {
+		g_warning ("failed to connect to client: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
 
 	/* create list stores */
-	viewer->list_store_profiles = gtk_list_store_new (GCM_PROFILES_COLUMN_LAST, G_TYPE_STRING,
-						  G_TYPE_STRING, G_TYPE_STRING, GCM_TYPE_PROFILE);
+	viewer->list_store_profiles = gtk_list_store_new (GCM_PROFILES_COLUMN_LAST,
+							  G_TYPE_STRING,
+							  G_TYPE_STRING,
+							  G_TYPE_STRING,
+							  CD_TYPE_PROFILE);
 
 	/* create profile tree view */
 	widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "treeview_profiles"));
@@ -1221,7 +1254,7 @@ main (int argc, char **argv)
 
 	gtk_init (&argc, &argv);
 
-	context = g_option_context_new ("gnome-color-manager prefs program");
+	context = g_option_context_new ("gnome-color-manager profile viewer");
 	g_option_context_add_main_entries (context, options, NULL);
 	g_option_context_add_group (context, gcm_debug_get_option_group ());
 	g_option_context_add_group (context, gtk_get_option_group (TRUE));
@@ -1231,7 +1264,7 @@ main (int argc, char **argv)
 	viewer = g_new0 (GcmViewerPrivate, 1);
 
 	/* ensure single instance */
-	viewer->application = gtk_application_new ("org.gnome.ColorManager.Profile", 0);
+	viewer->application = gtk_application_new ("org.gnome.ColorManager.Viewer", 0);
 	g_signal_connect (viewer->application, "startup",
 			  G_CALLBACK (gcm_viewer_startup_cb), viewer);
 	g_signal_connect (viewer->application, "activate",
@@ -1245,8 +1278,8 @@ main (int argc, char **argv)
 		g_object_unref (viewer->settings);
 	if (viewer->builder != NULL)
 		g_object_unref (viewer->builder);
-	if (viewer->profile_store != NULL)
-		g_object_unref (viewer->profile_store);
+	if (viewer->client != NULL)
+		g_object_unref (viewer->client);
 	g_free (viewer);
 	return status;
 }



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