[gnome-color-manager] trivial: use cd_client_import_profile_sync in gcm-viewer



commit 73afaa91c53672c899111c4c04e0624558f5cf3b
Author: Richard Hughes <richard hughsie com>
Date:   Tue Aug 23 20:35:50 2011 +0100

    trivial: use cd_client_import_profile_sync in gcm-viewer

 src/gcm-calibrate-argyll.c |   31 +++++++++++++++++++++++++++++++
 src/gcm-utils.c            |   31 -------------------------------
 src/gcm-utils.h            |    3 ---
 src/gcm-viewer.c           |   14 +++++++-------
 4 files changed, 38 insertions(+), 41 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index 642dd0a..b6d5116 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -918,6 +918,37 @@ gcm_calibrate_argyll_reference_kind_to_filename (GcmCalibrateReferenceKind kind)
 }
 
 /**
+ * gcm_utils_mkdir_and_copy:
+ **/
+static gboolean
+gcm_utils_mkdir_and_copy (GFile *source, GFile *destination, GError **error)
+{
+	gboolean ret;
+	GFile *parent;
+
+	g_return_val_if_fail (source != NULL, FALSE);
+	g_return_val_if_fail (destination != NULL, FALSE);
+
+	/* get parent */
+	parent = g_file_get_parent (destination);
+
+	/* create directory */
+	if (!g_file_query_exists (parent, NULL)) {
+		ret = g_file_make_directory_with_parents (parent, NULL, error);
+		if (!ret)
+			goto out;
+	}
+
+	/* do the copy */
+	ret = g_file_copy (source, destination, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, error);
+	if (!ret)
+		goto out;
+out:
+	g_object_unref (parent);
+	return ret;
+}
+
+/**
  * gcm_calibrate_argyll_device_copy:
  **/
 static gboolean
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 287b70f..54fb103 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -286,37 +286,6 @@ out:
 }
 
 /**
- * gcm_utils_mkdir_and_copy:
- **/
-gboolean
-gcm_utils_mkdir_and_copy (GFile *source, GFile *destination, GError **error)
-{
-	gboolean ret;
-	GFile *parent;
-
-	g_return_val_if_fail (source != NULL, FALSE);
-	g_return_val_if_fail (destination != NULL, FALSE);
-
-	/* get parent */
-	parent = g_file_get_parent (destination);
-
-	/* create directory */
-	if (!g_file_query_exists (parent, NULL)) {
-		ret = g_file_make_directory_with_parents (parent, NULL, error);
-		if (!ret)
-			goto out;
-	}
-
-	/* do the copy */
-	ret = g_file_copy (source, destination, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, error);
-	if (!ret)
-		goto out;
-out:
-	g_object_unref (parent);
-	return ret;
-}
-
-/**
  * gcm_utils_get_profile_destination:
  **/
 GFile *
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index 9f678e5..e94a3be 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -40,9 +40,6 @@
 
 gboolean	 gcm_utils_mkdir_for_filename		(const gchar		*filename,
 							 GError			**error);
-gboolean	 gcm_utils_mkdir_and_copy		(GFile			*source,
-							 GFile			*destination,
-							 GError			**error);
 GFile		*gcm_utils_get_profile_destination	(GFile			*file);
 gchar		**gcm_utils_ptr_array_to_strv		(GPtrArray		*array);
 gboolean	 gcm_gnome_help				(const gchar		*link_id);
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index d259327..fe010e7 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -398,7 +398,7 @@ gcm_viewer_profile_import_file (GcmViewerPrivate *viewer, GFile *file)
 {
 	gboolean ret;
 	GError *error = NULL;
-	GFile *destination = NULL;
+	CdProfile *profile_tmp = NULL;
 
 	/* check if correct type */
 	ret = gcm_utils_is_icc_profile (file);
@@ -407,18 +407,18 @@ gcm_viewer_profile_import_file (GcmViewerPrivate *viewer, GFile *file)
 		goto out;
 	}
 
-	/* copy icc file to ~/.color/icc */
-	destination = gcm_utils_get_profile_destination (file);
-	ret = gcm_utils_mkdir_and_copy (file, destination, &error);
-	if (!ret) {
+	/* copy icc file to users profile path */
+	profile_tmp = cd_client_import_profile_sync (viewer->client,
+						     file, NULL, &error);
+	if (profile_tmp == NULL) {
 		/* TRANSLATORS: could not read file */
 		gcm_viewer_error_dialog (viewer, _("Failed to copy file"), error->message);
 		g_error_free (error);
 		goto out;
 	}
 out:
-	if (destination != NULL)
-		g_object_unref (destination);
+	if (profile_tmp != NULL)
+		g_object_unref (profile_tmp);
 	return ret;
 }
 



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