[gnome-color-manager] Use a state machine when we are dealing with argyll as we may have more than one different type of r
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Use a state machine when we are dealing with argyll as we may have more than one different type of r
- Date: Wed, 27 Jan 2010 16:46:18 +0000 (UTC)
commit fb676f7b905075e4cc557d53038b330e382778fb
Author: Richard Hughes <richard hughsie com>
Date: Wed Jan 27 16:45:46 2010 +0000
Use a state machine when we are dealing with argyll as we may have more than one different type of request
src/gcm-calibrate-argyll.c | 256 ++++++++++++++++++++++++++++----------------
1 files changed, 163 insertions(+), 93 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index bc0b45e..9435348 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 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2009-2010 Richard Hughes <richard hughsie com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -55,6 +55,14 @@ typedef enum {
GCM_CALIBRATE_ARGYLL_PRECISION_LAST
} GcmCalibrateArgyllPrecision;
+typedef enum {
+ GCM_CALIBRATE_ARGYLL_STATE_IDLE,
+ GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN,
+ GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_LOOP,
+ GCM_CALIBRATE_ARGYLL_STATE_RUNNING,
+ GCM_CALIBRATE_ARGYLL_STATE_LAST
+} GcmCalibrateArgyllState;
+
/**
* GcmCalibrateArgyllPrivate:
*
@@ -66,7 +74,6 @@ struct _GcmCalibrateArgyllPrivate
GConfClient *gconf_client;
GcmCalibrateArgyllPrecision precision;
GMainLoop *loop;
- GMainLoop *loop_ui;
GtkWidget *terminal;
GtkBuilder *builder;
pid_t child_pid;
@@ -74,9 +81,10 @@ struct _GcmCalibrateArgyllPrivate
GcmScreen *screen;
glong vte_previous_row;
glong vte_previous_col;
- gchar *cached_title;
- gchar *cached_message;
+ GPtrArray *cached_titles;
+ GPtrArray *cached_messages;
gboolean already_on_window;
+ GcmCalibrateArgyllState state;
};
enum {
@@ -205,49 +213,65 @@ gcm_calibrate_argyll_get_display_type (GcmCalibrateArgyll *calibrate_argyll)
}
/**
- * gcm_calibrate_argyll_set_title:
+ * gcm_calibrate_argyll_set_dialog:
**/
static void
-gcm_calibrate_argyll_set_title (GcmCalibrateArgyll *calibrate_argyll, const gchar *title)
+gcm_calibrate_argyll_set_dialog (GcmCalibrateArgyll *calibrate_argyll, const gchar *title, const gchar *message)
{
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
GtkWidget *widget;
gchar *text;
/* save in case we need to reuse */
- if (title != priv->cached_title) {
- g_free (priv->cached_title);
- priv->cached_title = g_strdup (title);
- }
+ g_ptr_array_add (priv->cached_titles, g_strdup (title));
+ g_ptr_array_add (priv->cached_messages, g_strdup (message));
/* set the text */
text = g_strdup_printf ("<big><b>%s</b></big>", title);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_title"));
gtk_label_set_markup (GTK_LABEL(widget), text);
g_free (text);
+
+ /* set the text */
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_message"));
+ gtk_label_set_markup (GTK_LABEL(widget), message);
}
/**
- * gcm_calibrate_argyll_set_message:
+ * gcm_calibrate_argyll_pop_dialog:
**/
static void
-gcm_calibrate_argyll_set_message (GcmCalibrateArgyll *calibrate_argyll, const gchar *title)
+gcm_calibrate_argyll_pop_dialog (GcmCalibrateArgyll *calibrate_argyll)
{
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
GtkWidget *widget;
gchar *text;
+ const gchar *title;
+ const gchar *message;
+ guint len;
/* save in case we need to reuse */
- if (title != priv->cached_message) {
- g_free (priv->cached_message);
- priv->cached_message = g_strdup (title);
+ len = priv->cached_titles->len;
+ if (len < 2) {
+ egg_warning ("cannot pop dialog as nothing to recover");
+ return;
}
+ title = g_ptr_array_index (priv->cached_titles, len-2);
+ message = g_ptr_array_index (priv->cached_messages, len-2);
/* set the text */
- text = g_strdup_printf ("%s", title);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_message"));
+ text = g_strdup_printf ("<big><b>%s</b></big>", title);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_title"));
gtk_label_set_markup (GTK_LABEL(widget), text);
g_free (text);
+
+ /* set the text */
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_message"));
+ gtk_label_set_markup (GTK_LABEL(widget), message);
+
+ /* remove from the stack */
+ g_ptr_array_remove_index (priv->cached_titles, len-1);
+ g_ptr_array_remove_index (priv->cached_messages, len-1);
}
/**
@@ -316,6 +340,8 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
gint x, y;
gchar *basename = NULL;
gchar *output_name = NULL;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -354,9 +380,13 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
gtk_window_move (GTK_WINDOW(widget), 10, y);
/* TRANSLATORS: title, default paramters needed to calibrate_argyll */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Getting default parameters"));
+ title = _("Getting default parameters");
+
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("This pre-calibrates the screen by sending colored and gray patches to your screen and measuring them with the hardware device."));
+ message = _("This pre-calibrates the screen by sending colored and gray patches to your screen and measuring them with the hardware device.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* argument array */
array = g_ptr_array_new_with_free_func (g_free);
@@ -373,6 +403,7 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
gcm_calibrate_argyll_debug_argv (command, argv);
/* start up the command */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
vte_terminal_reset (VTE_TERMINAL(priv->terminal), TRUE, FALSE);
priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL(priv->terminal), command, argv, NULL, GCM_CALIBRATE_ARGYLL_TEMP_DIR, FALSE, FALSE, FALSE);
@@ -412,6 +443,8 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
gchar **argv = NULL;
GPtrArray *array = NULL;
gchar *basename = NULL;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -426,9 +459,12 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
}
/* TRANSLATORS: title, patches are specific colours used in calibration */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Generating the patches"));
+ title = _("Generating the patches");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Generating the patches that will be measured with the hardware device."));
+ message = _("Generating the patches that will be measured with the hardware device.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* argument array */
array = g_ptr_array_new_with_free_func (g_free);
@@ -442,6 +478,7 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
gcm_calibrate_argyll_debug_argv (command, argv);
/* start up the command */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
vte_terminal_reset (VTE_TERMINAL(priv->terminal), TRUE, FALSE);
priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL(priv->terminal), command, argv, NULL, GCM_CALIBRATE_ARGYLL_TEMP_DIR, FALSE, FALSE, FALSE);
@@ -481,6 +518,8 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
gchar **argv = NULL;
GPtrArray *array = NULL;
gchar *basename = NULL;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -498,9 +537,12 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
type = gcm_calibrate_argyll_get_display_type (calibrate_argyll);
/* TRANSLATORS: title, drawing means painting to the screen */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Drawing the patches"));
+ title = _("Drawing the patches");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Drawing the generated patches to the screen, which will then be measured by the hardware device."));
+ message = _("Drawing the generated patches to the screen, which will then be measured by the hardware device.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* argument array */
array = g_ptr_array_new_with_free_func (g_free);
@@ -516,6 +558,7 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
gcm_calibrate_argyll_debug_argv (command, argv);
/* start up the command */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
vte_terminal_reset (VTE_TERMINAL(priv->terminal), TRUE, FALSE);
priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL(priv->terminal), command, argv, NULL, GCM_CALIBRATE_ARGYLL_TEMP_DIR, FALSE, FALSE, FALSE);
@@ -562,6 +605,8 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
gchar *model = NULL;
GPtrArray *array = NULL;
GtkWidget *widget;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -594,9 +639,12 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
gtk_widget_hide (widget);
/* TRANSLATORS: title, a profile is a ICC file */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Generating the profile"));
+ title = _("Generating the profile");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Generating the ICC color profile that can be used with this screen."));
+ message = _("Generating the ICC color profile that can be used with this screen.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* argument array */
array = g_ptr_array_new_with_free_func (g_free);
@@ -614,6 +662,7 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
gcm_calibrate_argyll_debug_argv (command, argv);
/* start up the command */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
vte_terminal_reset (VTE_TERMINAL(priv->terminal), TRUE, FALSE);
priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL(priv->terminal), command, argv, NULL, GCM_CALIBRATE_ARGYLL_TEMP_DIR, FALSE, FALSE, FALSE);
@@ -657,11 +706,12 @@ gcm_calibrate_argyll_device_setup (GcmCalibrateArgyll *calibrate_argyll, GError
gboolean ret = TRUE;
GString *string = NULL;
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
+ const gchar *title;
string = g_string_new ("");
/* TRANSLATORS: title, we're setting up the device ready for calibration */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Setting up device"));
+ title = _("Setting up device");
/* TRANSLATORS: dialog message, preface */
g_string_append_printf (string, "%s\n", _("Before calibrating the device, you have to manually acquire a reference image and save it as a TIFF image file."));
@@ -679,10 +729,15 @@ gcm_calibrate_argyll_device_setup (GcmCalibrateArgyll *calibrate_argyll, GError
g_string_append_printf (string, "\n%s", _("Do you have a scanned TIFF file of a IT8.7/2 reference image?"));
/* set the message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, string->str);
- /* wait until user selects okay or closes window */
- g_main_loop_run (priv->loop_ui);
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, string->str);
+
+ /* set state */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_LOOP;
+
+ /* wait until finished */
+ g_main_loop_run (priv->loop);
/* get result */
if (priv->response != GTK_RESPONSE_OK) {
@@ -710,6 +765,8 @@ gcm_calibrate_argyll_device_copy (GcmCalibrateArgyll *calibrate_argyll, GError *
gchar *basename = NULL;
gchar *filename_source = NULL;
gchar *filename_reference = NULL;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -719,9 +776,12 @@ gcm_calibrate_argyll_device_copy (GcmCalibrateArgyll *calibrate_argyll, GError *
NULL);
/* TRANSLATORS: title, a profile is a ICC file */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Copying files"));
+ title = _("Copying files");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Copying source image, chart data and CIE reference values."));
+ message = _("Copying source image, chart data and CIE reference values.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* build filenames */
filename = g_strdup_printf ("%s.tif", basename);
@@ -763,6 +823,8 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
gchar *filename = NULL;
gchar *command = NULL;
gchar *basename = NULL;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -770,9 +832,12 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
NULL);
/* TRANSLATORS: title, drawing means painting to the screen */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Measuring the patches"));
+ title = _("Measuring the patches");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Detecting the reference patches and measuring them."));
+ message = _("Detecting the reference patches and measuring them.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* get correct name of the command */
command = gcm_calibrate_argyll_get_tool_filename ("scanin", error);
@@ -794,6 +859,7 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
gcm_calibrate_argyll_debug_argv (command, argv);
/* start up the command */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
vte_terminal_reset (VTE_TERMINAL(priv->terminal), TRUE, FALSE);
priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL(priv->terminal), command, argv, NULL, GCM_CALIBRATE_ARGYLL_TEMP_DIR, FALSE, FALSE, FALSE);
@@ -840,6 +906,8 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
gchar *manufacturer = NULL;
gchar *model = NULL;
gchar *device = NULL;
+ const gchar *title;
+ const gchar *message;
/* get shared data */
g_object_get (calibrate_argyll,
@@ -868,9 +936,12 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
copyright = g_strdup_printf ("%s %04i %s", _("Copyright (c)"), date->year, g_get_real_name ());
/* TRANSLATORS: title, a profile is a ICC file */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Generating the profile"));
+ title = _("Generating the profile");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Generating the ICC color profile that can be used with this device."));
+ message = _("Generating the ICC color profile that can be used with this device.");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* argument array */
array = g_ptr_array_new_with_free_func (g_free);
@@ -888,6 +959,7 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
gcm_calibrate_argyll_debug_argv (command, argv);
/* start up the command */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_RUNNING;
vte_terminal_reset (VTE_TERMINAL(priv->terminal), TRUE, FALSE);
priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL(priv->terminal), command, argv, NULL, GCM_CALIBRATE_ARGYLL_TEMP_DIR, FALSE, FALSE, FALSE);
@@ -1003,6 +1075,8 @@ gcm_calibrate_argyll_display (GcmCalibrate *calibrate, GtkWindow *window, GError
GcmCalibrateArgyll *calibrate_argyll = GCM_CALIBRATE_ARGYLL(calibrate);
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
gboolean ret;
+ const gchar *title;
+ const gchar *message;
/* show main UI */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_calibrate"));
@@ -1011,10 +1085,13 @@ gcm_calibrate_argyll_display (GcmCalibrate *calibrate, GtkWindow *window, GError
gdk_window_set_transient_for (gtk_widget_get_window (widget), gtk_widget_get_window (GTK_WIDGET(window)));
/* TRANSLATORS: title, hardware refers to a calibration device */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Set up display"));
+ title = _("Set up display");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Setting up display device for use..."));
+ message = _("Setting up display device for use...");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* step 1 */
ret = gcm_calibrate_argyll_display_neutralise (calibrate_argyll, error);
@@ -1054,6 +1131,8 @@ gcm_calibrate_argyll_device (GcmCalibrate *calibrate, GtkWindow *window, GError
GcmCalibrateArgyll *calibrate_argyll = GCM_CALIBRATE_ARGYLL(calibrate);
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
gboolean ret;
+ const gchar *title;
+ const gchar *message;
/* show main UI */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_calibrate"));
@@ -1062,10 +1141,13 @@ gcm_calibrate_argyll_device (GcmCalibrate *calibrate, GtkWindow *window, GError
gdk_window_set_transient_for (gtk_widget_get_window (widget), gtk_widget_get_window (GTK_WIDGET(window)));
/* TRANSLATORS: title, hardware refers to a calibration device */
- gcm_calibrate_argyll_set_title (calibrate_argyll, _("Set up device"));
+ title = _("Set up device");
/* TRANSLATORS: dialog message */
- gcm_calibrate_argyll_set_message (calibrate_argyll, _("Setting up device for use..."));
+ message = _("Setting up device for use...");
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
/* step 0 */
ret = gcm_calibrate_argyll_device_setup (calibrate_argyll, error);
@@ -1113,48 +1195,10 @@ gcm_calibrate_argyll_exit_cb (VteTerminal *terminal, GcmCalibrateArgyll *calibra
priv->response = GTK_RESPONSE_REJECT;
priv->child_pid = -1;
- if (g_main_loop_is_running (priv->loop))
+ if (g_main_loop_is_running (priv->loop)) {
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_IDLE;
g_main_loop_quit (priv->loop);
-}
-
-/**
- * gcm_calibrate_argyll_interaction_required:
- **/
-static void
-gcm_calibrate_argyll_interaction_required (GcmCalibrateArgyll *calibrate_argyll, const gchar *title, const gchar *message)
-{
- gchar *saved_title = NULL;
- gchar *saved_message = NULL;
- GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
-
- /* save for later */
- saved_title = g_strdup (priv->cached_title);
- saved_message = g_strdup (priv->cached_message);
-
- /* set this to our new text */
- gcm_calibrate_argyll_set_title (calibrate_argyll, title);
- gcm_calibrate_argyll_set_message (calibrate_argyll, message);
-
- /* wait until user selects okay or closes window */
- g_main_loop_run (priv->loop_ui);
-
- /* get result */
- if (priv->response == GTK_RESPONSE_CANCEL) {
- egg_debug ("sending quit");
- vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), "Q", 1);
- goto out;
}
-
- /* send the terminal an okay */
- egg_debug ("sending okay");
- vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), " ", 1);
-
- /* restore to what we were trying to do in the first place */
- gcm_calibrate_argyll_set_title (calibrate_argyll, saved_title);
- gcm_calibrate_argyll_set_message (calibrate_argyll, saved_message);
-out:
- g_free (saved_title);
- g_free (saved_message);
}
/**
@@ -1195,7 +1239,13 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
message = _("Please attach the hardware device to the center of the screen on the gray square.");
/* block for a response */
- gcm_calibrate_argyll_interaction_required (calibrate_argyll, title, message);
+ egg_debug ("blocking waiting for user input: %s", title);
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
+
+ /* set state */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN,
/* save as we know the device is on the screen now */
priv->already_on_window = TRUE;
@@ -1213,7 +1263,13 @@ gcm_calibrate_argyll_process_output_cmd (GcmCalibrateArgyll *calibrate_argyll, c
message = _("Please set the device to calibration mode.");
/* block for a response */
- gcm_calibrate_argyll_interaction_required (calibrate_argyll, title, message);
+ egg_debug ("blocking waiting for user input: %s", title);
+
+ /* push new messages into the UI */
+ gcm_calibrate_argyll_set_dialog (calibrate_argyll, title, message);
+
+ /* set state */
+ priv->state = GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN;
goto out;
}
@@ -1267,7 +1323,6 @@ gcm_calibrate_argyll_cursor_moved_cb (VteTerminal *terminal, GcmCalibrateArgyll
gcm_calibrate_argyll_selection_func_cb,
calibrate_argyll,
NULL);
- egg_debug ("raw output: '%s'", output);
split = g_strsplit (output, "\n", -1);
for (i=0; split[i] != NULL; i++) {
g_strchomp (split[i]);
@@ -1306,11 +1361,18 @@ gcm_calibrate_argyll_cancel_cb (GtkWidget *widget, GcmCalibrateArgyll *calibrate
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
priv->response = GTK_RESPONSE_CANCEL;
- vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), "Q", 1);
+
+ /* send input if waiting */
+ if (priv->state == GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN)
+ vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), "Q", 1);
+
+ /* clear loop if waiting */
+ if (priv->state == GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_LOOP)
+ g_main_loop_quit (priv->loop);
+
+ /* stop loop */
if (g_main_loop_is_running (priv->loop))
g_main_loop_quit (priv->loop);
- if (g_main_loop_is_running (priv->loop_ui))
- g_main_loop_quit (priv->loop_ui);
}
/**
@@ -1320,9 +1382,18 @@ static void
gcm_calibrate_argyll_ok_cb (GtkWidget *widget, GcmCalibrateArgyll *calibrate_argyll)
{
GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
+
+ /* send input if waiting */
+ if (priv->state == GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_STDIN) {
+ vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), " ", 1);
+ gcm_calibrate_argyll_pop_dialog (calibrate_argyll);
+ }
+
+ /* clear loop if waiting */
+ if (priv->state == GCM_CALIBRATE_ARGYLL_STATE_WAITING_FOR_LOOP)
+ g_main_loop_quit (priv->loop);
+
priv->response = GTK_RESPONSE_OK;
- if (g_main_loop_is_running (priv->loop_ui))
- g_main_loop_quit (priv->loop_ui);
gtk_widget_hide (widget);
}
@@ -1383,12 +1454,12 @@ gcm_calibrate_argyll_init (GcmCalibrateArgyll *calibrate_argyll)
calibrate_argyll->priv = GCM_CALIBRATE_ARGYLL_GET_PRIVATE (calibrate_argyll);
calibrate_argyll->priv->child_pid = -1;
calibrate_argyll->priv->loop = g_main_loop_new (NULL, FALSE);
- calibrate_argyll->priv->loop_ui = g_main_loop_new (NULL, FALSE);
calibrate_argyll->priv->vte_previous_row = 0;
calibrate_argyll->priv->vte_previous_col = 0;
- calibrate_argyll->priv->cached_title = NULL;
- calibrate_argyll->priv->cached_message = NULL;
+ calibrate_argyll->priv->cached_titles = g_ptr_array_new_with_free_func (g_free);
+ calibrate_argyll->priv->cached_messages = g_ptr_array_new_with_free_func (g_free);
calibrate_argyll->priv->already_on_window = FALSE;
+ calibrate_argyll->priv->state = GCM_CALIBRATE_ARGYLL_STATE_IDLE;
/* get UI */
calibrate_argyll->priv->builder = gtk_builder_new ();
@@ -1459,12 +1530,11 @@ gcm_calibrate_argyll_finalize (GObject *object)
gtk_widget_hide (widget);
g_main_loop_unref (priv->loop);
- g_main_loop_unref (priv->loop_ui);
g_object_unref (priv->builder);
g_object_unref (priv->screen);
g_object_unref (priv->gconf_client);
- g_free (priv->cached_title);
- g_free (priv->cached_message);
+ g_ptr_array_unref (priv->cached_titles);
+ g_ptr_array_unref (priv->cached_messages);
G_OBJECT_CLASS (gcm_calibrate_argyll_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]