[gnome-color-manager] Correctly restore the calibration status panel after asking the user a question



commit 469d2f58ba048327ea7d1791ead7b48b627f0934
Author: Richard Hughes <richard hughsie com>
Date:   Fri Feb 24 15:37:09 2012 +0000

    Correctly restore the calibration status panel after asking the user a question

 src/gcm-calibrate-argyll.c |  137 +++++++++++++++++++++++++++++---------------
 src/gcm-calibrate-main.c   |    8 ++-
 src/gcm-calibrate.c        |   86 ++++++++++++++++++----------
 src/gcm-calibrate.h        |   17 ++++-
 4 files changed, 165 insertions(+), 83 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index c38aebf..2639e93 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2009-2012 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -323,11 +323,13 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
 
 	/* TRANSLATORS: title, default paramters needed to calibrate_argyll */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Getting default parameters"));
+				 _("Getting default parameters"),
+				 GCM_CALIBRATE_UI_STATUS);
 
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("This pre-calibrates the screen by sending colored and gray patches to your screen and measuring them with the hardware device."));
+				   _("This pre-calibrates the screen by sending colored and gray patches to your screen and measuring them with the hardware device."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* argument array */
 	array = g_ptr_array_new_with_free_func (g_free);
@@ -414,10 +416,13 @@ gcm_calibrate_argyll_display_read_chart (GcmCalibrateArgyll *calibrate_argyll, G
 
 	/* TRANSLATORS: title, patches are specific colours used in calibration */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Reading the patches"));
+				 _("Reading the patches"),
+				 GCM_CALIBRATE_UI_STATUS);
+
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Reading the patches using the color measuring instrument."));
+				   _("Reading the patches using the color measuring instrument."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* argument array */
 	array = g_ptr_array_new_with_free_func (g_free);
@@ -514,10 +519,13 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
 
 	/* TRANSLATORS: title, drawing means painting to the screen */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Drawing the patches"));
+				 _("Drawing the patches"),
+				 GCM_CALIBRATE_UI_STATUS);
+
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Drawing the generated patches to the screen, which will then be measured by the hardware device."));
+				   _("Drawing the generated patches to the screen, which will then be measured by the hardware device."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* argument array */
 	array = g_ptr_array_new_with_free_func (g_free);
@@ -610,10 +618,13 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 
 	/* TRANSLATORS: title, a profile is a ICC file */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Generating the profile"));
+				 _("Generating the profile"),
+				 GCM_CALIBRATE_UI_STATUS);
+
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Generating the ICC color profile that can be used with this screen."));
+				   _("Generating the ICC color profile that can be used with this screen."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* argument array */
 	array = g_ptr_array_new_with_free_func (g_free);
@@ -773,10 +784,13 @@ gcm_calibrate_argyll_device_copy (GcmCalibrateArgyll *calibrate_argyll, GError *
 
 	/* TRANSLATORS: title, a profile is a ICC file */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Copying files"));
+				 _("Copying files"),
+				 GCM_CALIBRATE_UI_STATUS);
+
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Copying source image, chart data and CIE reference values."));
+				   _("Copying source image, chart data and CIE reference values."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* build filenames */
 	filename = g_strdup_printf ("%s.tif", basename);
@@ -845,10 +859,13 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
 
 	/* TRANSLATORS: title, drawing means painting to the screen */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Measuring the patches"));
+				 _("Measuring the patches"),
+				 GCM_CALIBRATE_UI_STATUS);
+
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Detecting the reference patches and measuring them."));
+				   _("Detecting the reference patches and measuring them."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* get correct name of the command */
 	command = gcm_calibrate_argyll_get_tool_filename ("scanin", error);
@@ -951,10 +968,13 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 
 	/* TRANSLATORS: title, a profile is a ICC file */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Generating the profile"));
+				 _("Generating the profile"),
+				 GCM_CALIBRATE_UI_STATUS);
+
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Generating the ICC color profile that can be used with this device."));
+				   _("Generating the ICC color profile that can be used with this device."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* argument array */
 	array = g_ptr_array_new_with_free_func (g_free);
@@ -1213,7 +1233,6 @@ gcm_calibrate_argyll_interaction (GcmCalibrate *calibrate, GtkResponseType respo
 #ifdef HAVE_VTE
 			vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), priv->argyllcms_ok, 1);
 #endif
-			gcm_calibrate_pop (calibrate);
 			priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
 		}
 
@@ -1222,7 +1241,6 @@ gcm_calibrate_argyll_interaction (GcmCalibrate *calibrate, GtkResponseType respo
 			g_main_loop_quit (priv->loop);
 			priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
 		}
-
 		goto out;
 	}
 
@@ -1311,11 +1329,13 @@ gcm_calibrate_argyll_display_generate_targets (GcmCalibrateArgyll *calibrate_arg
 
 	/* TRANSLATORS: title, patches are specific colors used in calibration */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Printing patches"));
+				 _("Printing patches"),
+				 GCM_CALIBRATE_UI_STATUS);
 
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Rendering the patches for the selected paper and ink."));
+				   _("Rendering the patches for the selected paper and ink."),
+				   GCM_CALIBRATE_UI_STATUS);
 
 	/* argument array */
 	array = g_ptr_array_new_with_free_func (g_free);
@@ -1637,11 +1657,13 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, CdDevice *device, CdSenso
 	if (print_kind == GCM_CALIBRATE_PRINT_KIND_LOCAL) {
 		/* TRANSLATORS: title, patches are specific colours used in calibration */
 		gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-					 _("Wait for the ink to dry"));
+					 _("Wait for the ink to dry"),
+					 GCM_CALIBRATE_UI_STATUS);
 
 		/* TRANSLATORS: dialog message */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("Please wait a few minutes for the ink to dry. Profiling damp ink will produce a poor profile and may damage your color measuring instrument."));
+					   _("Please wait a few minutes for the ink to dry. Profiling damp ink will produce a poor profile and may damage your color measuring instrument."),
+					   GCM_CALIBRATE_UI_STATUS);
 
 	}
 
@@ -1809,11 +1831,13 @@ gcm_calibrate_argyll_device (GcmCalibrate *calibrate, CdDevice *device, CdSensor
 
 	/* TRANSLATORS: title, instrument refers to a calibration device */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Set up instrument"));
+				 _("Set up instrument"),
+				 GCM_CALIBRATE_UI_STATUS);
 
 	/* TRANSLATORS: dialog message */
 	gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("Setting up the instrument for useâ"));
+				   _("Setting up the instrument for useâ"),
+				   GCM_CALIBRATE_UI_STATUS);
 
 
 	/* step 1 */
@@ -2016,11 +2040,13 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 	if (g_strstr_len (line, -1, "Measurement misread") != NULL) {
 		/* TRANSLATORS: title, the calibration failed */
 		gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-					 _("Calibration error"));
+					 _("Calibration error"),
+					 GCM_CALIBRATE_UI_ERROR);
 
 		/* TRANSLATORS: message, the sample was not read correctly */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("The sample could not be read at this time."));
+					   _("The sample could not be read at this time."),
+					   GCM_CALIBRATE_UI_ERROR);
 
 
 		/* set state */
@@ -2080,28 +2106,34 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 
 		/* TRANSLATORS: title, the calibration failed */
 		gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-					 _("Calibration error"));
+					 _("Calibration error"),
+					 GCM_CALIBRATE_UI_ERROR);
 
 		if (g_strstr_len (line, -1, "No PLD firmware pattern is available") != NULL) {
 			/* TRANSLATORS: message, no firmware is available */
 			gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("No firmware is installed for this instrument."));
+						   _("No firmware is installed for this instrument."),
+						   GCM_CALIBRATE_UI_ERROR);
 		} else if (g_strstr_len (line, -1, "Pattern match wasn't good enough") != NULL) {
 			/* TRANSLATORS: message, the image wasn't good enough */
 			gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("The pattern match wasn't good enough. Ensure you have the correct type of target selected."));
+						   _("The pattern match wasn't good enough. Ensure you have the correct type of target selected."),
+						   GCM_CALIBRATE_UI_ERROR);
 		} 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 */
 			gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("The measuring instrument got no valid readings. Please ensure the aperture is fully open."));
+						   _("The measuring instrument got no valid readings. Please ensure the aperture is fully open."),
+						   GCM_CALIBRATE_UI_ERROR);
 		} else if (g_strstr_len (line, -1, "Device or resource busy") != NULL) {
 			/* TRANSLATORS: message, the colorimeter has got confused */
 			gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   _("The measuring instrument is busy and is not starting up. Please remove the USB plug and re-insert before trying to use this device."));
+						   _("The measuring instrument is busy and is not starting up. Please remove the USB plug and re-insert before trying to use this device."),
+						   GCM_CALIBRATE_UI_ERROR);
 		} else {
 			gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-				   found + 8);
+						   found + 8,
+						   GCM_CALIBRATE_UI_ERROR);
 		}
 
 
@@ -2134,11 +2166,13 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 	if (g_str_has_prefix (line, "Strip read failed due to misread")) {
 		/* TRANSLATORS: dialog title */
 		gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-					 _("Reading target"));
+					 _("Reading target"),
+					 GCM_CALIBRATE_UI_ERROR);
 
 		/* TRANSLATORS: message, no firmware is available */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("Failed to read the strip correctly."));
+					   _("Failed to read the strip correctly."),
+					   GCM_CALIBRATE_UI_ERROR);
 
 		/* set state */
 		priv->argyllcms_ok = "\n";
@@ -2158,11 +2192,13 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 	if (g_str_has_prefix (line, "Sample read failed due to misread")) {
 		/* TRANSLATORS: dialog title */
 		gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-					 _("Reading sample"));
+					 _("Reading sample"),
+					 GCM_CALIBRATE_UI_ERROR);
 
 		/* TRANSLATORS: message, no firmware is available */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("Failed to read the color sample correctly."));
+					   _("Failed to read the color sample correctly."),
+					   GCM_CALIBRATE_UI_ERROR);
 
 		/* set state */
 		priv->argyllcms_ok = "\n";
@@ -2198,8 +2234,6 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
 		g_string_append (string, _("If you've really measured the right one, it's okay, it could just be unusual paper."));
 		g_string_append (string, "\n\n");
 
-g_debug ("title=%s, message=%s", title_str, string->str);
-
 		/* push new messages into the UI */
 		gcm_calibrate_set_image (GCM_CALIBRATE (calibrate_argyll), "scan-target-bad.svg");
 
@@ -2222,11 +2256,13 @@ g_debug ("title=%s, message=%s", title_str, string->str);
 
 		/* TRANSLATORS: title, the calibration failed */
 		gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-					 _("Device Error"));
+					 _("Device Error"),
+					 GCM_CALIBRATE_UI_ERROR);
 
 		/* TRANSLATORS: message, the sample was not read correctly */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("The device could not measure the color spot correctly."));
+					   _("The device could not measure the color spot correctly."),
+					   GCM_CALIBRATE_UI_ERROR);
 
 		/* set state */
 		priv->argyllcms_ok = " ";
@@ -2276,12 +2312,13 @@ g_debug ("title=%s, message=%s", title_str, string->str);
 		total = atoi (split[3]);
 		if (total > 0) {
 			gcm_calibrate_set_progress (GCM_CALIBRATE (calibrate_argyll),
-						    total * current / 100);
+						    current * 100 / total);
 		}
+		goto out;
 	}
 
 	/* report a warning so friendly people report bugs */
-	g_warning ("VTE: could not screenscrape: %s", line);
+	g_warning ("VTE: could not screenscrape: '%s'", line);
 out:
 	g_free (title_str);
 	g_strfreev (split);
@@ -2352,7 +2389,8 @@ gcm_calibrate_argyll_status_changed_cb (GcmPrint *print, GtkPrintStatus status,
 {
 	/* TRANSLATORS: title, printing reference files to media */
 	gcm_calibrate_set_title (GCM_CALIBRATE (calibrate_argyll),
-				 _("Printing"));
+				 _("Printing"),
+				 GCM_CALIBRATE_UI_STATUS);
 
 	switch (status) {
 	case GTK_PRINT_STATUS_INITIAL:
@@ -2360,29 +2398,34 @@ gcm_calibrate_argyll_status_changed_cb (GcmPrint *print, GtkPrintStatus status,
 	case GTK_PRINT_STATUS_GENERATING_DATA:
 		/* TRANSLATORS: dialog message */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("Preparing the data for the printer."));
+					   _("Preparing the data for the printer."),
+					   GCM_CALIBRATE_UI_STATUS);
 		break;
 	case GTK_PRINT_STATUS_SENDING_DATA:
 	case GTK_PRINT_STATUS_PENDING:
 	case GTK_PRINT_STATUS_PENDING_ISSUE:
 		/* TRANSLATORS: dialog message */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("Sending the targets to the printer."));
+					   _("Sending the targets to the printer."),
+					   GCM_CALIBRATE_UI_STATUS);
 		break;
 	case GTK_PRINT_STATUS_PRINTING:
 		/* TRANSLATORS: dialog message */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("Printing the targets..."));
+					   _("Printing the targets..."),
+					   GCM_CALIBRATE_UI_STATUS);
 		break;
 	case GTK_PRINT_STATUS_FINISHED:
 		/* TRANSLATORS: dialog message */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("The printing has finished."));
+					   _("The printing has finished."),
+					   GCM_CALIBRATE_UI_STATUS);
 		break;
 	case GTK_PRINT_STATUS_FINISHED_ABORTED:
 		/* TRANSLATORS: dialog message */
 		gcm_calibrate_set_message (GCM_CALIBRATE (calibrate_argyll),
-					   _("The print was aborted."));
+					   _("The print was aborted."),
+					   GCM_CALIBRATE_UI_STATUS);
 		break;
 	default:
 		break;
diff --git a/src/gcm-calibrate-main.c b/src/gcm-calibrate-main.c
index 5ab7e17..9540fbe 100644
--- a/src/gcm-calibrate-main.c
+++ b/src/gcm-calibrate-main.c
@@ -372,8 +372,12 @@ gcm_calib_start_idle_cb (gpointer user_data)
 				    calib->main_window,
 				    &error);
 	if (!ret) {
-		gcm_calibrate_set_title (calib->calibrate, _("Failed to calibrate"));
-		gcm_calibrate_set_message (calib->calibrate, error->message);
+		gcm_calibrate_set_title (calib->calibrate,
+					 _("Failed to calibrate"),
+					 GCM_CALIBRATE_UI_ERROR);
+		gcm_calibrate_set_message (calib->calibrate,
+					   error->message,
+					   GCM_CALIBRATE_UI_ERROR);
 		gcm_calibrate_set_image (calib->calibrate, NULL);
 
 		g_warning ("failed to calibrate: %s",
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index b15730c..704b158 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2009-2011 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2009-2012 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -72,8 +72,8 @@ struct _GcmCalibratePrivate
 	guint				 target_whitepoint;
 	GtkWidget			*content_widget;
 	GtkWindow			*sample_window;
-	GPtrArray			*old_message;
-	GPtrArray			*old_title;
+	gchar				*old_message;
+	gchar				*old_title;
 	gboolean			 sensor_on_screen;
 };
 
@@ -349,6 +349,23 @@ gcm_calibrate_interaction (GcmCalibrate *calibrate, GtkResponseType response)
 {
 	GcmCalibrateClass *klass = GCM_CALIBRATE_GET_CLASS (calibrate);
 
+	/* restore old status */
+	if (response == GTK_RESPONSE_OK) {
+		if (calibrate->priv->old_title != NULL) {
+			gcm_calibrate_set_title (calibrate,
+						 calibrate->priv->old_title,
+						 GCM_CALIBRATE_UI_POST_INTERACTION);
+		}
+		if (calibrate->priv->old_message != NULL) {
+			gcm_calibrate_set_message (calibrate,
+						   calibrate->priv->old_message,
+						   GCM_CALIBRATE_UI_POST_INTERACTION);
+		}
+
+		/* ensure the picture is cleared */
+		gcm_calibrate_set_image (calibrate, NULL);
+	}
+
 	/* coldplug source */
 	if (klass->interaction == NULL)
 		return;
@@ -496,7 +513,9 @@ gcm_calibrate_interaction_attach (GcmCalibrate *calibrate)
 	GString *message;
 
 	/* TRANSLATORS: title, instrument is a hardware color calibration sensor */
-	gcm_calibrate_set_title (calibrate, _("Please attach instrument"));
+	gcm_calibrate_set_title (calibrate,
+				 _("Please attach instrument"),
+				 GCM_CALIBRATE_UI_INTERACTION);
 
 	/* different messages with or without image */
 	message = g_string_new ("");
@@ -516,7 +535,9 @@ gcm_calibrate_interaction_attach (GcmCalibrate *calibrate)
 		g_string_append (message, _("You will need to hold the device on the screen for the duration of the calibration."));
 	}
 
-	gcm_calibrate_set_message (calibrate, message->str);
+	gcm_calibrate_set_message (calibrate,
+				   message->str,
+				   GCM_CALIBRATE_UI_INTERACTION);
 	gcm_calibrate_set_image (calibrate, filename);
 	gcm_calibrate_interaction_required (calibrate, _("Continue"));
 
@@ -540,7 +561,8 @@ gcm_calibrate_interaction_screen (GcmCalibrate *calibrate)
 
 	/* TRANSLATORS: title, instrument is a hardware color calibration sensor */
 	gcm_calibrate_set_title (calibrate,
-				 _("Please configure instrument"));
+				 _("Please configure instrument"),
+				 GCM_CALIBRATE_UI_INTERACTION);
 
 	/* get the image, if we have one */
 	filename = gcm_calibrate_get_sensor_image_screen (calibrate);
@@ -549,11 +571,13 @@ gcm_calibrate_interaction_screen (GcmCalibrate *calibrate)
 	if (filename != NULL) {
 		/* TRANSLATORS: this is when the user has to change a setting on the sensor, and we're showing a picture */
 		gcm_calibrate_set_message (calibrate,
-				   _("Please set the measuring instrument to screen mode like the image below."));
+					   _("Please set the measuring instrument to screen mode like the image below."),
+					   GCM_CALIBRATE_UI_INTERACTION);
 	} else {
 		/* TRANSLATORS: this is when the user has to change a setting on the sensor */
 		gcm_calibrate_set_message (calibrate,
-				   _("Please set the measuring instrument to screen mode."));
+					   _("Please set the measuring instrument to screen mode."),
+					   GCM_CALIBRATE_UI_INTERACTION);
 	}
 
 	/* play sound from the naming spec */
@@ -574,7 +598,8 @@ gcm_calibrate_interaction_calibrate (GcmCalibrate *calibrate)
 
 	/* TRANSLATORS: title, instrument is a hardware color calibration sensor */
 	gcm_calibrate_set_title (calibrate,
-				 _("Please configure instrument"));
+				 _("Please configure instrument"),
+				 GCM_CALIBRATE_UI_INTERACTION);
 
 	/* block for a response */
 	g_debug ("blocking waiting for user input");
@@ -586,11 +611,13 @@ gcm_calibrate_interaction_calibrate (GcmCalibrate *calibrate)
 	if (filename != NULL) {
 		/* TRANSLATORS: this is when the user has to change a setting on the sensor, and we're showing a picture */
 		gcm_calibrate_set_message (calibrate,
-				   _("Please set the measuring instrument to calibration mode like the image below."));
+					   _("Please set the measuring instrument to calibration mode like the image below."),
+					   GCM_CALIBRATE_UI_INTERACTION);
 	} else {
 		/* TRANSLATORS: this is when the user has to change a setting on the sensor */
 		gcm_calibrate_set_message (calibrate,
-				   _("Please set the measuring instrument to calibration mode."));
+					   _("Please set the measuring instrument to calibration mode."),
+					   GCM_CALIBRATE_UI_INTERACTION);
 	}
 
 	/* play sound from the naming spec */
@@ -2050,21 +2077,32 @@ out:
 }
 
 void
-gcm_calibrate_set_title (GcmCalibrate *calibrate, const gchar *title)
+gcm_calibrate_set_title (GcmCalibrate *calibrate,
+			 const gchar *title,
+			 GcmCalibrateUiType ui_type)
 {
 	g_signal_emit (calibrate, signals[SIGNAL_TITLE_CHANGED], 0, title);
-	g_ptr_array_add (calibrate->priv->old_title, g_strdup (title));
+	if (ui_type == GCM_CALIBRATE_UI_STATUS && title != NULL) {
+		g_free (calibrate->priv->old_title);
+		calibrate->priv->old_title = g_strdup (title);
+	}
 }
 
 void
-gcm_calibrate_set_message (GcmCalibrate *calibrate, const gchar *message)
+gcm_calibrate_set_message (GcmCalibrate *calibrate,
+			   const gchar *message,
+			   GcmCalibrateUiType ui_type)
 {
 	g_signal_emit (calibrate, signals[SIGNAL_MESSAGE_CHANGED], 0, message);
-	g_ptr_array_add (calibrate->priv->old_message, g_strdup (message));
+	if (ui_type == GCM_CALIBRATE_UI_STATUS && message != NULL) {
+		g_free (calibrate->priv->old_message);
+		calibrate->priv->old_message = g_strdup (message);
+	}
 }
 
 void
-gcm_calibrate_set_image (GcmCalibrate *calibrate, const gchar *filename)
+gcm_calibrate_set_image (GcmCalibrate *calibrate,
+			 const gchar *filename)
 {
 	g_signal_emit (calibrate, signals[SIGNAL_IMAGE_CHANGED], 0, filename);
 }
@@ -2081,16 +2119,6 @@ gcm_calibrate_interaction_required (GcmCalibrate *calibrate, const gchar *button
 	g_signal_emit (calibrate, signals[SIGNAL_INTERACTION_REQUIRED], 0, button_text);
 }
 
-void
-gcm_calibrate_pop (GcmCalibrate *calibrate)
-{
-	const gchar *tmp;
-	tmp = g_ptr_array_index (calibrate->priv->old_title, calibrate->priv->old_title->len - 2);
-	g_signal_emit (calibrate, signals[SIGNAL_TITLE_CHANGED], 0, tmp);
-	tmp = g_ptr_array_index (calibrate->priv->old_message, calibrate->priv->old_message->len - 2);
-	g_signal_emit (calibrate, signals[SIGNAL_MESSAGE_CHANGED], 0, tmp);
-}
-
 /**
  * gcm_calibrate_get_property:
  **/
@@ -2403,8 +2431,6 @@ gcm_calibrate_init (GcmCalibrate *calibrate)
 
 	// FIXME: this has to be per-run specific
 	calibrate->priv->working_path = g_strdup ("/tmp");
-	calibrate->priv->old_title = g_ptr_array_new_with_free_func (g_free);
-	calibrate->priv->old_message = g_ptr_array_new_with_free_func (g_free);
 }
 
 /**
@@ -2427,8 +2453,8 @@ gcm_calibrate_finalize (GObject *object)
 	g_free (priv->device);
 	g_free (priv->serial);
 	g_free (priv->working_path);
-	g_ptr_array_unref (calibrate->priv->old_title);
-	g_ptr_array_unref (calibrate->priv->old_message);
+	g_free (calibrate->priv->old_title);
+	g_free (calibrate->priv->old_message);
 	gtk_widget_destroy (GTK_WIDGET (calibrate->priv->sample_window));
 	g_object_unref (priv->brightness);
 
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index 699a51b..afb1fa8 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2009-2012 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -125,6 +125,14 @@ typedef enum {
 	GCM_CALIBRATE_PRECISION_UNKNOWN
 } GcmCalibratePrecision;
 
+typedef enum {
+	GCM_CALIBRATE_UI_INTERACTION,
+	GCM_CALIBRATE_UI_STATUS,
+	GCM_CALIBRATE_UI_ERROR,
+	GCM_CALIBRATE_UI_POST_INTERACTION,
+	GCM_CALIBRATE_UI_UNKNOWN
+} GcmCalibrateUiType;
+
 GType		 gcm_calibrate_get_type			(void);
 GcmCalibrate	*gcm_calibrate_new			(void);
 
@@ -142,14 +150,15 @@ void		 gcm_calibrate_interaction		(GcmCalibrate	*calibrate,
 void		 gcm_calibrate_set_sensor		(GcmCalibrate	*calibrate,
 							 CdSensor	*sensor);
 void		 gcm_calibrate_set_title		(GcmCalibrate	*calibrate,
-							 const gchar	*title);
+							 const gchar	*title,
+							 GcmCalibrateUiType ui_type);
 void		 gcm_calibrate_set_message		(GcmCalibrate	*calibrate,
-							 const gchar	*message);
+							 const gchar	*message,
+							 GcmCalibrateUiType ui_type);
 void		 gcm_calibrate_set_image		(GcmCalibrate	*calibrate,
 							 const gchar	*filename);
 void		 gcm_calibrate_set_progress		(GcmCalibrate	*calibrate,
 							 guint		 percentage);
-void		 gcm_calibrate_pop			(GcmCalibrate	*calibrate);
 void		 gcm_calibrate_interaction_required	(GcmCalibrate	*calibrate,
 							 const gchar	*button_text);
 GtkWidget	*gcm_calibrate_get_content_widget	(GcmCalibrate	*calibrate);



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