[gnome-color-manager] trivial: make the GcmCalibrateDialog more HIG compliant, and catch one extra argyllcms error



commit a1750b79e05e0c967f9d8190c9abd3b4779a8525
Author: Richard Hughes <richard hughsie com>
Date:   Tue Feb 23 20:47:45 2010 +0000

    trivial: make the GcmCalibrateDialog more HIG compliant, and catch one extra argyllcms error

 src/gcm-calibrate-argyll.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 src/gcm-calibrate-dialog.c |   15 +++++++++++++++
 src/gcm-calibrate-dialog.h |    2 ++
 3 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index cec5e23..7271b77 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -1737,6 +1737,9 @@ gcm_calibrate_argyll_interaction_attach (GcmCalibrateArgyll *calibrate_argyll)
 	gcm_calibrate_dialog_set_image_filename (priv->calibrate_dialog, filename);
 	gcm_calibrate_dialog_set_show_expander (priv->calibrate_dialog, FALSE);
 
+	/* TRANSLATORS: button text */
+	gcm_calibrate_dialog_set_button_ok_id (priv->calibrate_dialog, _("Continue"));
+
 	/* set state */
 	priv->state = GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN,
 
@@ -1787,6 +1790,9 @@ gcm_calibrate_argyll_interaction_calibrate (GcmCalibrateArgyll *calibrate_argyll
 	gcm_calibrate_dialog_set_image_filename (priv->calibrate_dialog, filename);
 	gcm_calibrate_dialog_set_show_expander (priv->calibrate_dialog, TRUE);
 
+	/* TRANSLATORS: button text */
+	gcm_calibrate_dialog_set_button_ok_id (priv->calibrate_dialog, _("Continue"));
+
 	/* play sound from the naming spec */
 	ca_context_play (ca_gtk_context_get (), 0,
 			 CA_PROP_EVENT_ID, "dialog-information",
@@ -1835,6 +1841,9 @@ gcm_calibrate_argyll_interaction_surface (GcmCalibrateArgyll *calibrate_argyll)
 	gcm_calibrate_dialog_set_image_filename (priv->calibrate_dialog, filename);
 	gcm_calibrate_dialog_set_show_expander (priv->calibrate_dialog, TRUE);
 
+	/* TRANSLATORS: button text */
+	gcm_calibrate_dialog_set_button_ok_id (priv->calibrate_dialog, _("Continue"));
+
 	/* play sound from the naming spec */
 	ca_context_play (ca_gtk_context_get (), 0,
 			 CA_PROP_EVENT_ID, "dialog-information",
@@ -1881,6 +1890,34 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 		goto out;
 	}
 
+	/* something went wrong with a measurement */
+	if (g_strstr_len (line, -1, "Measurement misread") != NULL) {
+		/* TRANSLATORS: title, the calibration failed */
+		title = _("Calibration error");
+
+		/* TRANSLATORS: message, the sample was not read correctly */
+		message = _("The sample could not be read at this time.");
+
+		/* push new messages into the UI */
+		gcm_calibrate_dialog_show (priv->calibrate_dialog, GCM_CALIBRATE_DIALOG_TAB_GENERIC, title, message);
+		gcm_calibrate_dialog_set_show_button_ok (priv->calibrate_dialog, TRUE);
+		gcm_calibrate_dialog_set_show_expander (priv->calibrate_dialog, TRUE);
+
+		/* TRANSLATORS: button text */
+		gcm_calibrate_dialog_set_button_ok_id (priv->calibrate_dialog, _("Try again"));
+
+		/* set state */
+		priv->state = GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN;
+
+		/* play sound from the naming spec */
+		ca_context_play (ca_gtk_context_get (), 0,
+				 CA_PROP_EVENT_ID, "dialog-warning",
+				 /* TRANSLATORS: this is the application name for libcanberra */
+				 CA_PROP_APPLICATION_NAME, _("GNOME Color Manager"),
+				 CA_PROP_EVENT_DESCRIPTION, message, NULL);
+		goto out;
+	}
+
 	/* lines we're ignoring */
 	if (g_strcmp0 (line, "Q") == 0 ||
 	    g_strcmp0 (line, "Sample read stopped at user request!") == 0 ||
@@ -1911,7 +1948,8 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 		} else if (g_strstr_len (line, -1, "Pattern match wasn't good enough") != NULL) {
 			/* TRANSLATORS: message, the image wasn't good enough */
 			message = _("The pattern match wasn't good enough. Ensure you have the correct type of target selected.");
-		} else if (g_strstr_len (line, -1, "Aprox. fwd matrix unexpectedly singular") != NULL) {
+		} else if (g_strstr_len (line, -1, "Aprox. fwd matrix unexpectedly singular") != NULL ||
+			   g_strstr_len (line, -1, "Inverting aprox. fwd matrix failed") != NULL) {
 			/* TRANSLATORS: message, the sensor got no readings */
 			message = _("The colorimeter got no valid readings. Please ensure the aperture is fully open.");
 		} else if (g_strstr_len (line, -1, "Device or resource busy") != NULL) {
@@ -1923,8 +1961,9 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 
 		/* push new messages into the UI */
 		gcm_calibrate_dialog_show (priv->calibrate_dialog, GCM_CALIBRATE_DIALOG_TAB_GENERIC, title, message);
-		gcm_calibrate_dialog_set_show_button_ok (priv->calibrate_dialog, TRUE);
+		gcm_calibrate_dialog_set_show_button_ok (priv->calibrate_dialog, FALSE);
 		gcm_calibrate_dialog_set_show_expander (priv->calibrate_dialog, TRUE);
+
 		egg_debug ("VTE: error: %s", found+8);
 
 		/* set state */
diff --git a/src/gcm-calibrate-dialog.c b/src/gcm-calibrate-dialog.c
index 3f2264e..9401e9e 100644
--- a/src/gcm-calibrate-dialog.c
+++ b/src/gcm-calibrate-dialog.c
@@ -278,6 +278,20 @@ gcm_calibrate_dialog_run (GcmCalibrateDialog *calibrate_dialog)
 }
 
 /**
+ * gcm_calibrate_set_button_ok_id:
+ **/
+void
+gcm_calibrate_dialog_set_button_ok_id (GcmCalibrateDialog *calibrate_dialog, const gchar *button_id)
+{
+	GtkWidget *widget;
+	GcmCalibrateDialogPrivate *priv = calibrate_dialog->priv;
+
+	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_ok"));
+	gtk_button_set_label (GTK_BUTTON (widget), button_id);
+	gtk_button_set_use_stock (GTK_BUTTON (widget), g_str_has_prefix (button_id, "gtk-"));
+}
+
+/**
  * gcm_calibrate_dialog_show:
  **/
 void
@@ -314,6 +328,7 @@ gcm_calibrate_dialog_show (GcmCalibrateDialog		*calibrate_dialog,
 	gcm_calibrate_dialog_set_show_expander (calibrate_dialog, FALSE);
 	gcm_calibrate_dialog_set_show_button_ok (calibrate_dialog, FALSE);
 	gcm_calibrate_dialog_set_image_filename_private (calibrate_dialog, NULL);
+	gcm_calibrate_dialog_set_button_ok_id (calibrate_dialog, GTK_STOCK_OK);
 
 	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_title"));
 	gtk_label_set_label (GTK_LABEL (widget), title);
diff --git a/src/gcm-calibrate-dialog.h b/src/gcm-calibrate-dialog.h
index c4892f4..8787548 100644
--- a/src/gcm-calibrate-dialog.h
+++ b/src/gcm-calibrate-dialog.h
@@ -77,6 +77,8 @@ void			 gcm_calibrate_dialog_set_show_expander	(GcmCalibrateDialog	*calibrate_di
 								 gboolean		 visible);
 void			 gcm_calibrate_dialog_set_show_button_ok (GcmCalibrateDialog	*calibrate_dialog,
 								 gboolean		 visible);
+void			 gcm_calibrate_dialog_set_button_ok_id	(GcmCalibrateDialog	*calibrate_dialog,
+								 const gchar		*button_id);
 void			 gcm_calibrate_dialog_set_image_filename (GcmCalibrateDialog	*calibrate_dialog,
 								 const gchar		*image_filename);
 void			 gcm_calibrate_dialog_pop		(GcmCalibrateDialog	*calibrate_dialog);



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