[gnome-color-manager] Don't assume dispcal is /usr/bin/dispcal



commit cc8b0f4df60c05208ab6778c2a01a8aec6335b41
Author: Alexandre Rostovtsev <tetromino gentoo org>
Date:   Wed Mar 14 08:49:45 2012 +0000

    Don't assume dispcal is /usr/bin/dispcal
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gcm-calibrate-argyll.c |   99 ++++++++++++++++++++++++-------------------
 1 files changed, 55 insertions(+), 44 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index b3c7fce..d54b176 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -111,22 +111,73 @@ gcm_calibrate_argyll_get_quality_arg (GcmCalibrateArgyll *calibrate_argyll)
 }
 
 /**
+ * gcm_calibrate_argyll_get_tool_filename:
+ **/
+static gchar *
+gcm_calibrate_argyll_get_tool_filename (const gchar *command,
+					GError **error)
+{
+	gboolean ret;
+	gchar *filename;
+
+	/* try the original argyllcms filename installed in /usr/local/bin */
+	filename = g_strdup_printf ("/usr/local/bin/%s", command);
+	ret = g_file_test (filename, G_FILE_TEST_EXISTS);
+	if (ret)
+		goto out;
+
+	/* try the debian filename installed in /usr/bin */
+	g_free (filename);
+	filename = g_strdup_printf ("/usr/bin/argyll-%s", command);
+	ret = g_file_test (filename, G_FILE_TEST_EXISTS);
+	if (ret)
+		goto out;
+
+	/* try the original argyllcms filename installed in /usr/bin */
+	g_free (filename);
+	filename = g_strdup_printf ("/usr/bin/%s", command);
+	ret = g_file_test (filename, G_FILE_TEST_EXISTS);
+	if (ret)
+		goto out;
+
+	/* eek */
+	g_free (filename);
+	filename = NULL;
+	g_set_error (error,
+		     GCM_CALIBRATE_ERROR,
+		     GCM_CALIBRATE_ERROR_INTERNAL,
+		     "failed to get filename for %s", command);
+out:
+	return filename;
+}
+
+/**
  * gcm_calibrate_argyll_get_display:
  **/
 static guint
 gcm_calibrate_argyll_get_display (const gchar *output_name,
 				  GError **error)
 {
-	gboolean ret;
+	gboolean ret = FALSE;
+	gchar *command = NULL;
 	gchar *data = NULL;
+	gchar *name;
 	gchar **split = NULL;
 	gint exit_status;
 	guint display = G_MAXUINT;
 	guint i;
-	gchar *name;
+
+	/* get correct name of the command */
+	command = gcm_calibrate_argyll_get_tool_filename ("dispcal", error);
+	if (command == NULL)
+		goto out;
 
 	/* execute it and capture stderr */
-	ret = g_spawn_command_line_sync ("dispcal", NULL, &data, &exit_status, error);
+	ret = g_spawn_command_line_sync (command,
+					 NULL,
+					 &data,
+					 &exit_status,
+					 error);
 	if (!ret)
 		goto out;
 
@@ -158,6 +209,7 @@ gcm_calibrate_argyll_get_display (const gchar *output_name,
 		goto out;
 	}
 out:
+	g_free (command);
 	g_free (data);
 	g_strfreev (split);
 	return display;
@@ -197,47 +249,6 @@ gcm_calibrate_argyll_debug_argv (const gchar *program, gchar **argv)
 }
 
 /**
- * gcm_calibrate_argyll_get_tool_filename:
- **/
-static gchar *
-gcm_calibrate_argyll_get_tool_filename (const gchar *command,
-					GError **error)
-{
-	gboolean ret;
-	gchar *filename;
-
-	/* try the original argyllcms filename installed in /usr/local/bin */
-	filename = g_strdup_printf ("/usr/local/bin/%s", command);
-	ret = g_file_test (filename, G_FILE_TEST_EXISTS);
-	if (ret)
-		goto out;
-
-	/* try the debian filename installed in /usr/bin */
-	g_free (filename);
-	filename = g_strdup_printf ("/usr/bin/argyll-%s", command);
-	ret = g_file_test (filename, G_FILE_TEST_EXISTS);
-	if (ret)
-		goto out;
-
-	/* try the original argyllcms filename installed in /usr/bin */
-	g_free (filename);
-	filename = g_strdup_printf ("/usr/bin/%s", command);
-	ret = g_file_test (filename, G_FILE_TEST_EXISTS);
-	if (ret)
-		goto out;
-
-	/* eek */
-	g_free (filename);
-	filename = NULL;
-	g_set_error (error,
-		     GCM_CALIBRATE_ERROR,
-		     GCM_CALIBRATE_ERROR_INTERNAL,
-		     "failed to get filename for %s", command);
-out:
-	return filename;
-}
-
-/**
  * gcm_calibrate_argyll_fork_command:
  **/
 static gboolean



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