[gnome-color-manager] Hide the target whitepoint selection screen if the sensor is a colorimeter



commit 5fab2ca0fff7eed094622f78bb690db67cabb8b7
Author: Richard Hughes <richard hughsie com>
Date:   Thu May 10 09:30:27 2012 +0100

    Hide the target whitepoint selection screen if the sensor is a colorimeter
    
    Only expensive photospectometer devices are able to get the accurate readings
    required to do this without getting a color cast.
    
    Too many users are reporting the screen 'goes pink' using colorimeter devices,
    and so force them to have a native whitepoint used during calibration.

 src/gcm-calibrate-main.c |   85 ++++++++++++++++++++++++---------------------
 1 files changed, 45 insertions(+), 40 deletions(-)
---
diff --git a/src/gcm-calibrate-main.c b/src/gcm-calibrate-main.c
index 0bd693c..77298c9 100644
--- a/src/gcm-calibrate-main.c
+++ b/src/gcm-calibrate-main.c
@@ -1889,6 +1889,47 @@ gcm_calib_setup_page_failure (GcmCalibratePriv *calib)
 }
 
 /**
+ * gcm_calib_got_sensor:
+ **/
+static void
+gcm_calib_got_sensor (GcmCalibratePriv *calib, CdSensor *sensor)
+{
+	gboolean is_photospectrometer = FALSE;
+	gboolean ret;
+	GError *error = NULL;
+	GtkWidget *vbox;
+
+	/* connect to sensor */
+	ret = cd_sensor_connect_sync (sensor, NULL, &error);
+	if (!ret) {
+		g_warning ("failed to connect to sensor: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
+	gcm_calibrate_set_sensor (calib->calibrate, sensor);
+
+	/* hide the prompt for the user to insert a sensor */
+	vbox = gcm_calib_get_vbox_for_page (calib,
+					    GCM_CALIBRATE_PAGE_SENSOR);
+	gtk_widget_hide (vbox);
+
+	/* if the device is a simple colorimeter, hide the temperature
+	 * chooser. Only expensive accurate spectrophotometers are
+	 * accurate enough to do a good job without a color cast */
+	if (cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_I1_PRO ||
+	    cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_COLOR_MUNKI ||
+	    cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_I1_DISPLAY3) {
+		is_photospectrometer = TRUE;
+	}
+	vbox = gcm_calib_get_vbox_for_page (calib,
+					    GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE);
+	gtk_widget_set_visible (vbox, is_photospectrometer);
+out:
+	return;
+}
+
+/**
  * gcm_calib_get_sensors_cb:
  **/
 static void
@@ -1901,8 +1942,6 @@ gcm_calib_get_sensors_cb (GObject *object,
 	GcmCalibratePriv *calib = (GcmCalibratePriv *) user_data;
 	GError *error = NULL;
 	GPtrArray *sensors;
-	GtkWidget *vbox;
-	gboolean ret;
 
 	/* get the result */
 	sensors = cd_client_get_sensors_finish (client, res, &error);
@@ -1913,22 +1952,10 @@ gcm_calib_get_sensors_cb (GObject *object,
 		goto out;
 	}
 
-	/* hide the sensors screen */
-	if (sensors->len > 0) {
+	/* we've got a sensor */
+	if (sensors->len != 0) {
 		sensor_tmp = g_ptr_array_index (sensors, 0);
-
-		ret = cd_sensor_connect_sync (sensor_tmp, NULL, &error);
-		if (!ret) {
-			g_warning ("failed to connect to sensor: %s",
-				   error->message);
-			g_error_free (error);
-			goto out;
-		}
-
-		gcm_calibrate_set_sensor (calib->calibrate, sensor_tmp);
-		vbox = gcm_calib_get_vbox_for_page (calib,
-						    GCM_CALIBRATE_PAGE_SENSOR);
-		gtk_widget_hide (vbox);
+		gcm_calib_got_sensor (calib, sensor_tmp);
 	}
 out:
 	if (sensors != NULL)
@@ -2007,31 +2034,9 @@ gcm_calib_add_pages (GcmCalibratePriv *calib)
 static void
 gcm_calib_sensor_added_cb (CdClient *client, CdSensor *sensor, GcmCalibratePriv *calib)
 {
-	gboolean ret;
-	GError *error = NULL;
-	GtkWidget *vbox;
-
 	g_debug ("sensor inserted");
-
-	/* connect */
-	ret = cd_sensor_connect_sync (sensor, NULL, &error);
-	if (!ret) {
-		g_warning ("failed to connect to sensor: %s",
-			   error->message);
-		g_error_free (error);
-		goto out;
-	}
-
-	/* fix up UI */
-	gcm_calibrate_set_sensor (calib->calibrate, sensor);
-	vbox = gcm_calib_get_vbox_for_page (calib,
-					    GCM_CALIBRATE_PAGE_SENSOR);
-	gtk_assistant_set_page_complete (GTK_ASSISTANT (calib->main_window),
-					 vbox, TRUE);
-	gtk_widget_hide (vbox);
+	gcm_calib_got_sensor (calib, sensor);
 	gtk_assistant_next_page (GTK_ASSISTANT (calib->main_window));
-out:
-	return;
 }
 
 /**



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