[gnome-color-manager] trivial: Do not show a modal failed dialog for when the user aborts a dialog



commit b56dea13188c76efe551e03d6403cb728304758f
Author: Richard Hughes <richard hughsie com>
Date:   Mon Feb 22 08:58:47 2010 +0000

    trivial: Do not show a modal failed dialog for when the user aborts a dialog

 src/gcm-calibrate-argyll.c |   85 +++++++++++++++++++++++++++++++++++---------
 src/gcm-calibrate-manual.c |    4 ++-
 src/gcm-calibrate.c        |   55 +++++++++++++++++++++++------
 src/gcm-calibrate.h        |   11 ++++++
 src/gcm-prefs.c            |    8 +++-
 5 files changed, 132 insertions(+), 31 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index 22383d9..6cf2a0d 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -212,7 +212,10 @@ gcm_calibrate_argyll_get_display (const gchar *output_name, GError **error)
 	split = g_strsplit (data, "\n", -1);
 	for (i=0; split[i] != NULL; i++) {
 		if (g_strstr_len (split[i], -1, "XRandR 1.2 is faulty") != NULL) {
-			g_set_error_literal (error, 1, 0, "failed to match display as RandR is faulty");
+			g_set_error_literal (error,
+					     GCM_CALIBRATE_ERROR,
+					     GCM_CALIBRATE_ERROR_INTERNAL,
+					     "failed to match display as RandR is faulty");
 			goto out;
 		}
 		name = g_strdup (split[i]);
@@ -226,7 +229,10 @@ gcm_calibrate_argyll_get_display (const gchar *output_name, GError **error)
 
 	/* nothing found */
 	if (display == G_MAXUINT) {
-		g_set_error_literal (error, 1, 0, "failed to match display");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "failed to match display");
 		goto out;
 	}
 out:
@@ -300,7 +306,10 @@ gcm_calibrate_argyll_get_tool_filename (const gchar *command, GError **error)
 	/* eek */
 	g_free (filename);
 	filename = NULL;
-	g_set_error (error, 1, 0, "failed to get filename for %s", command);
+	g_set_error (error,
+		     GCM_CALIBRATE_ERROR,
+		     GCM_CALIBRATE_ERROR_INTERNAL,
+		     "failed to get filename for %s", command);
 out:
 	return filename;
 }
@@ -388,14 +397,20 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		g_set_error_literal (error, 1, 0, "calibration was cancelled");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
 		gchar *vte_text;
 		vte_text = vte_terminal_get_text (VTE_TERMINAL(priv->terminal), NULL, NULL, NULL);
-		g_set_error (error, 1, 0, "command failed to run successfully: %s", vte_text);
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_INTERNAL,
+			     "command failed to run successfully: %s", vte_text);
 		g_free (vte_text);
 		ret = FALSE;
 		goto out;
@@ -468,14 +483,20 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		g_set_error_literal (error, 1, 0, "calibration was cancelled");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
 		gchar *vte_text;
 		vte_text = vte_terminal_get_text (VTE_TERMINAL(priv->terminal), NULL, NULL, NULL);
-		g_set_error (error, 1, 0, "command failed to run successfully: %s", vte_text);
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_INTERNAL,
+			     "command failed to run successfully: %s", vte_text);
 		g_free (vte_text);
 		ret = FALSE;
 		goto out;
@@ -553,14 +574,20 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		g_set_error_literal (error, 1, 0, "calibration was cancelled");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
 		gchar *vte_text;
 		vte_text = vte_terminal_get_text (VTE_TERMINAL(priv->terminal), NULL, NULL, NULL);
-		g_set_error (error, 1, 0, "command failed to run successfully: %s", vte_text);
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_INTERNAL,
+			     "command failed to run successfully: %s", vte_text);
 		g_free (vte_text);
 		ret = FALSE;
 		goto out;
@@ -659,14 +686,20 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		g_set_error_literal (error, 1, 0, "calibration was cancelled");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
 		gchar *vte_text;
 		vte_text = vte_terminal_get_text (VTE_TERMINAL(priv->terminal), NULL, NULL, NULL);
-		g_set_error (error, 1, 0, "command failed to run successfully: %s", vte_text);
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_INTERNAL,
+			     "command failed to run successfully: %s", vte_text);
 		g_free (vte_text);
 		ret = FALSE;
 		goto out;
@@ -869,14 +902,20 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		g_set_error_literal (error, 1, 0, "calibration was cancelled");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
 		gchar *vte_text;
 		vte_text = vte_terminal_get_text (VTE_TERMINAL(priv->terminal), NULL, NULL, NULL);
-		g_set_error (error, 1, 0, "command failed to run successfully: %s", vte_text);
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_INTERNAL,
+			     "command failed to run successfully: %s", vte_text);
 		g_free (vte_text);
 		ret = FALSE;
 		goto out;
@@ -983,14 +1022,20 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		g_set_error_literal (error, 1, 0, "calibration was cancelled");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
 		gchar *vte_text;
 		vte_text = vte_terminal_get_text (VTE_TERMINAL(priv->terminal), NULL, NULL, NULL);
-		g_set_error (error, 1, 0, "command failed to run successfully: %s", vte_text);
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_INTERNAL,
+			     "command failed to run successfully: %s", vte_text);
 		g_free (vte_text);
 		ret = FALSE;
 		goto out;
@@ -1055,7 +1100,10 @@ gcm_calibrate_argyll_finish (GcmCalibrateArgyll *calibrate_argyll, GError **erro
 	/* we can't have finished with success */
 	if (basename == NULL) {
 		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "profile was not generated");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "profile was not generated");
 		goto out;
 	}
 
@@ -1065,7 +1113,10 @@ gcm_calibrate_argyll_finish (GcmCalibrateArgyll *calibrate_argyll, GError **erro
 	/* we never finished all the steps */
 	if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
 		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "could not find completed profile");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "could not find completed profile");
 		goto out;
 	}
 
diff --git a/src/gcm-calibrate-manual.c b/src/gcm-calibrate-manual.c
index baa2edc..de45e6b 100644
--- a/src/gcm-calibrate-manual.c
+++ b/src/gcm-calibrate-manual.c
@@ -96,7 +96,9 @@ gcm_calibrate_manual_close_cb (GtkWidget *widget, GcmCalibrateManual *calibrate)
 	/* we closed */
 	priv->ret = FALSE;
 	if (priv->error != NULL)
-		*(priv->error) = g_error_new (1, 0, "user closed window");
+		*(priv->error) = g_error_new (GCM_CALIBRATE_ERROR,
+					      GCM_CALIBRATE_ERROR_USER_ABORT,
+					      "user closed window");
 
 	/* we're done */
 	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_calibrate"));
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index bf64691..4a3bb3a 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -237,7 +237,10 @@ gcm_calibrate_set_from_device (GcmCalibrate *calibrate, GcmDevice *device, GErro
 	/* display specific properties */
 	if (type == GCM_DEVICE_TYPE_ENUM_DISPLAY) {
 		if (native_device == NULL) {
-			g_set_error (error, 1, 0, "failed to get output");
+			g_set_error (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "failed to get output");
 			ret = FALSE;
 			goto out;
 		}
@@ -276,7 +279,10 @@ gcm_calibrate_set_from_exif (GcmCalibrate *calibrate, const gchar *filename, GEr
 
 	/* we failed to get data */
 	if (manufacturer == NULL || model == NULL) {
-		g_set_error (error, 1, 0, "failed to get EXIF data from TIFF");
+		g_set_error (error,
+			     GCM_CALIBRATE_ERROR,
+			     GCM_CALIBRATE_ERROR_NO_DATA,
+			     "failed to get EXIF data from TIFF");
 		ret = FALSE;
 		goto out;
 	}
@@ -326,7 +332,10 @@ gcm_calibrate_get_display_type (GcmCalibrate *calibrate, GtkWindow *window, GErr
 	response = gcm_calibrate_dialog_run (priv->calibrate_dialog);
 	if (response != GTK_RESPONSE_OK) {
 		gcm_calibrate_dialog_hide (priv->calibrate_dialog);
-		g_set_error_literal (error, 1, 0, "user did not choose crt or lcd");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "user did not choose crt or lcd");
 		ret = FALSE;
 		goto out;
 	}
@@ -350,7 +359,10 @@ gcm_calibrate_get_display_type (GcmCalibrate *calibrate, GtkWindow *window, GErr
 		response = gcm_calibrate_dialog_run (priv->calibrate_dialog);
 		if (response != GTK_RESPONSE_OK) {
 			gcm_calibrate_dialog_hide (priv->calibrate_dialog);
-			g_set_error_literal (error, 1, 0, "hardware not capable of profiling a projector");
+			g_set_error_literal (error,
+					     GCM_CALIBRATE_ERROR,
+					     GCM_CALIBRATE_ERROR_NO_SUPPORT,
+					     "hardware not capable of profiling a projector");
 			ret = FALSE;
 			goto out;
 		}
@@ -379,14 +391,20 @@ gcm_calibrate_display (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
 	/* coldplug source */
 	if (priv->output_name == NULL) {
 		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "no output name set");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "no output name set");
 		goto out;
 	}
 
 	/* coldplug source */
 	if (klass->calibrate_display == NULL) {
 		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "no support");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "no klass support");
 		goto out;
 	}
 
@@ -448,7 +466,10 @@ gcm_calibrate_display (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
 		response = gcm_calibrate_dialog_run (priv->calibrate_dialog);
 		if (response != GTK_RESPONSE_OK) {
 			gcm_calibrate_dialog_hide (priv->calibrate_dialog);
-			g_set_error_literal (error, 1, 0, "user did not follow calibration steps");
+			g_set_error_literal (error,
+					     GCM_CALIBRATE_ERROR,
+					     GCM_CALIBRATE_ERROR_USER_ABORT,
+					     "user did not follow calibration steps");
 			ret = FALSE;
 			goto out;
 		}
@@ -722,7 +743,10 @@ gcm_calibrate_device (GcmCalibrate *calibrate, GtkWindow *window, GError **error
 	response = gcm_calibrate_dialog_run (priv->calibrate_dialog);
 	if (response != GTK_RESPONSE_OK) {
 		gcm_calibrate_dialog_hide (priv->calibrate_dialog);
-		g_set_error_literal (error, 1, 0, "user did not choose chart type");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "user did not choose chart type");
 		ret = FALSE;
 		goto out;
 	}
@@ -735,7 +759,10 @@ gcm_calibrate_device (GcmCalibrate *calibrate, GtkWindow *window, GError **error
 	window = gcm_calibrate_dialog_get_window (priv->calibrate_dialog);
 	reference_image = gcm_calibrate_device_get_reference_image (directory, window);
 	if (reference_image == NULL) {
-		g_set_error_literal (error, 1, 0, "could not get reference image");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "could not get reference image");
 		ret = FALSE;
 		goto out;
 	}
@@ -749,7 +776,10 @@ gcm_calibrate_device (GcmCalibrate *calibrate, GtkWindow *window, GError **error
 	directory = has_shared_targets ? "/usr/share/color/targets" : "/media";
 	reference_data = gcm_calibrate_device_get_reference_data (directory, window);
 	if (reference_data == NULL) {
-		g_set_error_literal (error, 1, 0, "could not get reference target");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_USER_ABORT,
+				     "could not get reference target");
 		ret = FALSE;
 		goto out;
 	}
@@ -768,7 +798,10 @@ gcm_calibrate_device (GcmCalibrate *calibrate, GtkWindow *window, GError **error
 
 	/* coldplug source */
 	if (klass->calibrate_device == NULL) {
-		g_set_error_literal (error, 1, 0, "no support");
+		g_set_error_literal (error,
+				     GCM_CALIBRATE_ERROR,
+				     GCM_CALIBRATE_ERROR_INTERNAL,
+				     "no klass support");
 		goto out;
 	}
 
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index 8e22ee2..e8d0af0 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -63,6 +63,17 @@ struct _GcmCalibrateClass
 	void (*_gcm_reserved5) (void);
 };
 
+typedef enum
+{
+	GCM_CALIBRATE_ERROR_USER_ABORT,
+	GCM_CALIBRATE_ERROR_NO_SUPPORT,
+	GCM_CALIBRATE_ERROR_NO_DATA,
+	GCM_CALIBRATE_ERROR_INTERNAL
+} GcmCalibrateError;
+
+/* dummy */
+#define GCM_CALIBRATE_ERROR	1
+
 typedef enum {
 	GCM_CALIBRATE_REFERENCE_KIND_CMP_DIGITAL_TARGET_3,
 	GCM_CALIBRATE_REFERENCE_KIND_CMP_DT_003,
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 0f153af..e3b045d 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -311,8 +311,12 @@ gcm_prefs_calibrate_device (GcmCalibrate *calibrate)
 	window = GTK_WINDOW(gtk_builder_get_object (builder, "dialog_prefs"));
 	ret = gcm_calibrate_device (calibrate, window, &error);
 	if (!ret) {
-		/* TRANSLATORS: could not calibrate */
-		gcm_prefs_error_dialog (_("Failed to calibrate"), error->message);
+		if (error->code != GCM_CALIBRATE_ERROR_USER_ABORT) {
+			/* TRANSLATORS: could not calibrate */
+			gcm_prefs_error_dialog (_("Failed to calibrate"), error->message);
+		} else {
+			egg_warning ("failed to calibrate: %s", error->message);
+		}
 		g_error_free (error);
 		goto out;
 	}



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