summaryrefslogtreecommitdiff
path: root/contrib/session-helper
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-02-26 16:28:02 +0000
committerRichard Hughes <richard@hughsie.com>2013-02-26 16:28:02 +0000
commit945648e125da7fcf060294c67655d5ba67373cfa (patch)
treee227e8246b770e725db2fe800d9d36f8dafc43c5 /contrib/session-helper
parent38be3e026a55c6478554ded92daf31eb51fce452 (diff)
downloadcolord-945648e125da7fcf060294c67655d5ba67373cfa.tar.gz
session-helper: Set the sample color as a sensor option when displaying patches
This allows us to return a valid XYZ value, which allows us to write self tests.
Diffstat (limited to 'contrib/session-helper')
-rw-r--r--contrib/session-helper/cd-main.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/contrib/session-helper/cd-main.c b/contrib/session-helper/cd-main.c
index 6f9d9de..a4ac025 100644
--- a/contrib/session-helper/cd-main.c
+++ b/contrib/session-helper/cd-main.c
@@ -147,9 +147,14 @@ cd_main_calib_idle_delay (guint ms)
/**
* cd_main_emit_update_sample:
**/
-static void
-cd_main_emit_update_sample (CdMainPrivate *priv, CdColorRGB *color)
+static gboolean
+cd_main_emit_update_sample (CdMainPrivate *priv,
+ CdColorRGB *color,
+ GError **error)
{
+ gboolean ret = TRUE;
+ GHashTable *hash = NULL;
+
/* emit signal */
g_debug ("CdMain: Emitting UpdateSample(%f,%f,%f)",
color->R, color->G, color->B);
@@ -163,7 +168,34 @@ cd_main_emit_update_sample (CdMainPrivate *priv, CdColorRGB *color)
color->G,
color->B),
NULL);
+
+ /* if this is the dummy sensor then set the sample RGB value */
+ if (cd_sensor_get_kind (priv->sensor) == CD_SENSOR_KIND_DUMMY) {
+ hash = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) g_variant_unref);
+ g_hash_table_insert (hash,
+ g_strdup ("sample[red]"),
+ g_variant_new_double (color->R));
+ g_hash_table_insert (hash,
+ g_strdup ("sample[green]"),
+ g_variant_new_double (color->G));
+ g_hash_table_insert (hash,
+ g_strdup ("sample[blue]"),
+ g_variant_new_double (color->B));
+ ret = cd_sensor_set_options_sync (priv->sensor,
+ hash,
+ priv->cancellable,
+ error);
+ if (!ret)
+ goto out;
+ }
cd_main_calib_idle_delay (200);
+out:
+ if (hash != NULL)
+ g_hash_table_unref (hash);
+ return ret;
}
/**
@@ -357,7 +389,9 @@ cd_main_calib_get_native_whitepoint (CdMainPrivate *priv,
rgb.R = 1.0;
rgb.G = 1.0;
rgb.B = 1.0;
- cd_main_emit_update_sample (priv, &rgb);
+ ret = cd_main_emit_update_sample (priv, &rgb, error);
+ if (!ret)
+ goto out;
ret = cd_main_calib_get_sample (priv, &xyz, error);
if (!ret)
@@ -746,7 +780,9 @@ cd_main_calib_process (CdMainPrivate *priv,
rgb.R = 1.0 / (gdouble) (priv->array->len - 1) * (gdouble) i;
rgb.G = 1.0 / (gdouble) (priv->array->len - 1) * (gdouble) i;
rgb.B = 1.0 / (gdouble) (priv->array->len - 1) * (gdouble) i;
- cd_main_emit_update_sample (priv, &rgb);
+ ret = cd_main_emit_update_sample (priv, &rgb, error);
+ if (!ret)
+ goto out;
/* process this section */
item = g_ptr_array_index (priv->array, i);
@@ -1202,7 +1238,9 @@ cd_main_display_get_samples (CdMainPrivate *priv,
i,
&rgb,
NULL);
- cd_main_emit_update_sample (priv, &rgb);
+ ret = cd_main_emit_update_sample (priv, &rgb, error);
+ if (!ret)
+ goto out;
ret = cd_main_calib_get_sample (priv, &xyz, error);
if (!ret)
goto out;