[gnome-color-manager] Provide a way for a program to find out if calibration is enabled



commit 0286297628da8b1ddd6f957f66646250c40a1862
Author: Richard Hughes <richard hughsie com>
Date:   Wed Mar 14 08:50:49 2012 +0000

    Provide a way for a program to find out if calibration is enabled
    
    Also, do this without exposing internal parts of GcmCalibrateArgyll to the clients.
    
    Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=672028

 src/gcm-calibrate-argyll.c |   24 ++++++++++++++++++++++++
 src/gcm-calibrate-main.c   |    2 +-
 src/gcm-calibrate.c        |   12 ++++++++++++
 src/gcm-calibrate.h        |    2 ++
 4 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index d54b176..23f8314 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -1446,6 +1446,29 @@ out:
 }
 
 /**
+ * gcm_calibrate_argyll_get_enabled:
+ **/
+static gboolean
+gcm_calibrate_argyll_get_enabled (GcmCalibrate *calibrate)
+{
+	gboolean ret = TRUE;
+	gchar *command;
+	GError *error = NULL;
+
+	/* get correct name of the command */
+	command = gcm_calibrate_argyll_get_tool_filename ("dispcal", &error);
+	if (command == NULL) {
+		g_debug ("Failed to find dispcal: %s", error->message);
+		g_error_free (error);
+		ret = FALSE;
+		goto out;
+	}
+out:
+	g_free (command);
+	return ret;
+}
+
+/**
  * gcm_calibrate_argyll_render_cb:
  **/
 static GPtrArray *
@@ -2545,6 +2568,7 @@ gcm_calibrate_argyll_class_init (GcmCalibrateArgyllClass *klass)
 	parent_class->calibrate_display = gcm_calibrate_argyll_display;
 	parent_class->calibrate_device = gcm_calibrate_argyll_device;
 	parent_class->calibrate_printer = gcm_calibrate_argyll_printer;
+	parent_class->get_enabled = gcm_calibrate_argyll_get_enabled;
 	parent_class->interaction = gcm_calibrate_argyll_interaction;
 
 	g_type_class_add_private (klass, sizeof (GcmCalibrateArgyllPrivate));
diff --git a/src/gcm-calibrate-main.c b/src/gcm-calibrate-main.c
index 901a428..ce71392 100644
--- a/src/gcm-calibrate-main.c
+++ b/src/gcm-calibrate-main.c
@@ -1789,7 +1789,7 @@ gcm_calib_add_pages (GcmCalibratePriv *calib)
 		gcm_calib_setup_page_sensor (calib);
 
 	/* find whether argyllcms is installed using a tool which should exist */
-	ret = g_file_test ("/usr/bin/dispcal", G_FILE_TEST_EXISTS);
+	ret = gcm_calibrate_get_enabled (calib->calibrate);
 	if (!ret)
 		gcm_calib_setup_page_install_argyllcms (calib);
 
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index 75f3a14..60c1c9f 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -1934,6 +1934,18 @@ out:
 }
 
 /**
+ * gcm_calibrate_get_enabled:
+ **/
+gboolean
+gcm_calibrate_get_enabled (GcmCalibrate *calibrate)
+{
+	GcmCalibrateClass *klass = GCM_CALIBRATE_GET_CLASS (calibrate);
+	if (klass->get_enabled != NULL)
+		return klass->get_enabled (calibrate);
+	return TRUE;
+}
+
+/**
  * gcm_calibrate_camera:
  **/
 static gboolean
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index ae6842e..98554fc 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -64,6 +64,7 @@ struct _GcmCalibrateClass
 							 CdSensor	*sensor,
 							 GtkWindow	*window,
 							 GError		**error);
+	gboolean	 (*get_enabled)	(GcmCalibrate	*calibrate);
 	void		 (*interaction)			(GcmCalibrate	*calibrate,
 							 GtkResponseType response);
 
@@ -189,6 +190,7 @@ gboolean	 gcm_calibrate_display_calibration	(GcmCalibrate	*calibrate,
 							 CdDevice	*device,
 							 GtkWindow	*window,
 							 GError		**error);
+gboolean	 gcm_calibrate_get_enabled		(GcmCalibrate	*calibrate);
 
 G_END_DECLS
 



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