[gnome-color-manager] Add in initial printer calibration support. Needs more work.



commit f393ea7843122cfce9db909c41b2bd17d65ab7fd
Author: Richard Hughes <richard hughsie com>
Date:   Mon Feb 22 17:59:20 2010 +0000

    Add in initial printer calibration support. Needs more work.

 src/gcm-calibrate-argyll.c |   44 +++++++++++++++++++++++++++++++++++++++++++-
 src/gcm-calibrate.c        |   24 ++++++++++++++++++++++++
 src/gcm-calibrate.h        |    6 ++++++
 src/gcm-prefs.c            |   43 +++++++++++++++++++++++++++++++++++++++----
 4 files changed, 112 insertions(+), 5 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index aff40ef..0a29370 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -43,6 +43,7 @@
 #include "gcm-colorimeter.h"
 #include "gcm-utils.h"
 #include "gcm-screen.h"
+#include "gcm-print.h"
 #include "gcm-calibrate-dialog.h"
 
 #include "egg-debug.h"
@@ -454,10 +455,12 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
 	gchar *basename = NULL;
 	const gchar *title;
 	const gchar *message;
+	GcmDeviceTypeEnum device_type;
 
 	/* get shared data */
 	g_object_get (calibrate_argyll,
 		      "basename", &basename,
+		      "device-type", &device_type,
 		      NULL);
 
 	/* get correct name of the command */
@@ -482,7 +485,16 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
 
 	/* setup the command */
 	g_ptr_array_add (array, g_strdup ("-v9"));
-	g_ptr_array_add (array, g_strdup ("-d3"));
+	if (device_type == GCM_DEVICE_TYPE_ENUM_PRINTER) {
+		/* print RGB */
+		g_ptr_array_add (array, g_strdup ("-d2"));
+
+		/* Grey axis RGB steps */
+		g_ptr_array_add (array, g_strdup ("-g20"));
+	} else {
+		/* video RGB */
+		g_ptr_array_add (array, g_strdup ("-d3"));
+	}
 	g_ptr_array_add (array, g_strdup (gcm_calibrate_argyll_precision_to_patches_arg (priv->precision)));
 	g_ptr_array_add (array, g_strdup (basename));
 	argv = gcm_utils_ptr_array_to_strv (array);
@@ -1198,6 +1210,35 @@ out:
 }
 
 /**
+ * gcm_calibrate_argyll_printer:
+ **/
+static gboolean
+gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, GtkWindow *window, GError **error)
+{
+	gboolean ret;
+	GcmCalibrateArgyll *calibrate_argyll = GCM_CALIBRATE_ARGYLL(calibrate);
+//	GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
+
+	/* need to ask if we are printing now, or using old data */
+
+	/* step 1 */
+	ret = gcm_calibrate_argyll_display_generate_patches (calibrate_argyll, error);
+	if (!ret)
+		goto out;
+
+// printtarg -v -i CM -h -t 300 -p A4 test
+// chartread -v test
+// colprof -v -A "bla" -M "bla" -D "bla" -C "bla"  -a l -q m test
+
+	/* step 4 */
+	ret = gcm_calibrate_argyll_device_generate_profile (calibrate_argyll, error);
+	if (!ret)
+		goto out;
+out:
+	return ret;
+}
+
+/**
  * gcm_calibrate_argyll_device:
  **/
 static gboolean
@@ -1624,6 +1665,7 @@ gcm_calibrate_argyll_class_init (GcmCalibrateArgyllClass *klass)
 	/* setup klass links */
 	parent_class->calibrate_display = gcm_calibrate_argyll_display;
 	parent_class->calibrate_device = gcm_calibrate_argyll_device;
+	parent_class->calibrate_printer = gcm_calibrate_argyll_printer;
 
 	g_type_class_add_private (klass, sizeof (GcmCalibrateArgyllPrivate));
 }
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index ae3e992..e2e4a9e 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -662,6 +662,30 @@ out:
 }
 
 /**
+ * gcm_calibrate_printer:
+ **/
+gboolean
+gcm_calibrate_printer (GcmCalibrate *calibrate, GtkWindow *window, GError **error)
+{
+	gboolean ret = FALSE;
+	GcmCalibrateClass *klass = GCM_CALIBRATE_GET_CLASS (calibrate);
+
+	/* coldplug source */
+	if (klass->calibrate_printer == NULL) {
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "no klass support");
+		goto out;
+	}
+
+	/* proxy */
+	ret = klass->calibrate_printer (calibrate, window, error);
+out:
+	return ret;
+}
+
+/**
  * gcm_calibrate_device:
  **/
 gboolean
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index e8d0af0..596232f 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -55,6 +55,9 @@ struct _GcmCalibrateClass
 	gboolean	 (*calibrate_device)		(GcmCalibrate	*calibrate,
 							 GtkWindow	*window,
 							 GError		**error);
+	gboolean	 (*calibrate_printer)		(GcmCalibrate	*calibrate,
+							 GtkWindow	*window,
+							 GError		**error);
 	/* padding for future expansion */
 	void (*_gcm_reserved1) (void);
 	void (*_gcm_reserved2) (void);
@@ -103,6 +106,9 @@ gboolean	 gcm_calibrate_display			(GcmCalibrate	*calibrate,
 gboolean	 gcm_calibrate_device			(GcmCalibrate	*calibrate,
 							 GtkWindow	*window,
 							 GError		**error);
+gboolean	 gcm_calibrate_printer			(GcmCalibrate	*calibrate,
+							 GtkWindow	*window,
+							 GError		**error);
 gboolean	 gcm_calibrate_set_from_device		(GcmCalibrate	*calibrate,
 							 GcmDevice	*device,
 							 GError		**error);
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 2730ed4..9c6e845 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -314,7 +314,42 @@ gcm_prefs_calibrate_device (GcmCalibrate *calibrate)
 	if (!ret) {
 		if (error->code != GCM_CALIBRATE_ERROR_USER_ABORT) {
 			/* TRANSLATORS: could not calibrate */
-			gcm_prefs_error_dialog (_("Failed to calibrate"), error->message);
+			gcm_prefs_error_dialog (_("Failed to calibrate device"), error->message);
+		} else {
+			egg_warning ("failed to calibrate: %s", error->message);
+		}
+		g_error_free (error);
+		goto out;
+	}
+out:
+	return ret;
+}
+
+/**
+ * gcm_prefs_calibrate_printer:
+ **/
+static gboolean
+gcm_prefs_calibrate_printer (GcmCalibrate *calibrate)
+{
+	gboolean ret = FALSE;
+	GError *error = NULL;
+	GtkWindow *window;
+
+	/* set defaults from device */
+	ret = gcm_calibrate_set_from_device (calibrate, current_device, &error);
+	if (!ret) {
+		egg_warning ("failed to calibrate: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* do each step */
+	window = GTK_WINDOW(gtk_builder_get_object (builder, "dialog_prefs"));
+	ret = gcm_calibrate_printer (calibrate, window, &error);
+	if (!ret) {
+		if (error->code != GCM_CALIBRATE_ERROR_USER_ABORT) {
+			/* TRANSLATORS: could not calibrate */
+			gcm_prefs_error_dialog (_("Failed to calibrate printer"), error->message);
 		} else {
 			egg_warning ("failed to calibrate: %s", error->message);
 		}
@@ -728,6 +763,9 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
 	case GCM_DEVICE_TYPE_ENUM_CAMERA:
 		ret = gcm_prefs_calibrate_device (calibrate);
 		break;
+	case GCM_DEVICE_TYPE_ENUM_PRINTER:
+		ret = gcm_prefs_calibrate_printer (calibrate);
+		break;
 	default:
 		egg_warning ("calibration not supported for this device");
 		goto out;
@@ -1018,9 +1056,6 @@ gcm_prefs_set_calibrate_button_sensitivity (void)
 			goto out;
 		}
 
-		/* TRANSLATORS: this is when the button is insensitive */
-		tooltip = _("Cannot calibrate this type of device (although support is planned)");
-
 	} else {
 
 		/* TRANSLATORS: this is when the button is insensitive */



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