diff options
author | Richard Hughes <richard@hughsie.com> | 2013-02-27 13:10:22 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2013-02-27 13:12:03 +0000 |
commit | a579108442984831b08c0057573cb5a69c6c2836 (patch) | |
tree | 64a0ded673c8bed417d3de9a262fcf09ff5d221f /contrib/session-helper | |
parent | f4ad100048eb971114883b3500c9e0af169c7fd6 (diff) | |
download | colord-a579108442984831b08c0057573cb5a69c6c2836.tar.gz |
Set the target gamma when using the session-helper
This doesn't do much yet, but will be hooked up soon.
Diffstat (limited to 'contrib/session-helper')
-rw-r--r-- | contrib/session-helper/cd-example.c | 8 | ||||
-rw-r--r-- | contrib/session-helper/cd-main.c | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/contrib/session-helper/cd-example.c b/contrib/session-helper/cd-example.c index 0fc489b..5ad22cc 100644 --- a/contrib/session-helper/cd-example.c +++ b/contrib/session-helper/cd-example.c @@ -474,6 +474,7 @@ main (int argc, char **argv) gchar *sensor_id = NULL; gchar *title = NULL; GDBusConnection *connection = NULL; + gdouble gamma = 2.2f; GError *error = NULL; gint retval = EXIT_FAILURE; GOptionContext *context; @@ -502,6 +503,9 @@ main (int argc, char **argv) { "whitepoint", '\0', 0, G_OPTION_ARG_INT, &whitepoint, /* TRANSLATORS: command line option */ "Target this specific whitepoint, or 0 for native", NULL }, + { "gamma", '\0', 0, G_OPTION_ARG_DOUBLE, &gamma, + /* TRANSLATORS: command line option */ + "Target this gamma (default 2.2)", NULL }, { NULL} }; @@ -635,6 +639,10 @@ main (int argc, char **argv) "{sv}", "DeviceKind", g_variant_new_uint32 (CD_SENSOR_CAP_LCD)); + g_variant_builder_add (&builder, + "{sv}", + "Gamma", + g_variant_new_double (gamma)); retvax = g_dbus_proxy_call_sync (priv->proxy, "Start", g_variant_new ("(ssa{sv})", diff --git a/contrib/session-helper/cd-main.c b/contrib/session-helper/cd-main.c index 2880f97..b07e366 100644 --- a/contrib/session-helper/cd-main.c +++ b/contrib/session-helper/cd-main.c @@ -54,6 +54,7 @@ typedef struct { GPtrArray *array; cmsCIEXYZ whitepoint; gdouble native_whitepoint; + gdouble target_gamma; guint target_whitepoint; guint screen_brightness; CdIt8 *it8_cal; @@ -1778,6 +1779,7 @@ cd_main_daemon_method_call (GDBusConnection *connection, /* set the default parameters */ priv->quality = CD_PROFILE_QUALITY_MEDIUM; priv->device_kind = CD_SENSOR_CAP_LCD; + priv->target_gamma = 2.2; while (g_variant_iter_next (iter, "{&sv}", &prop_key, &prop_value)) { if (g_strcmp0 (prop_key, "Quality") == 0) { @@ -1798,6 +1800,9 @@ cd_main_daemon_method_call (GDBusConnection *connection, } else if (g_strcmp0 (prop_key, "Brightness") == 0) { priv->screen_brightness = g_variant_get_uint32 (prop_value); g_debug ("Device brightness: %i", priv->screen_brightness); + } else if (g_strcmp0 (prop_key, "Gamma") == 0) { + priv->target_gamma = g_variant_get_double (prop_value); + g_debug ("Gamma: %.2f", priv->target_gamma); } else { /* not a fatal warning */ g_warning ("option %s unsupported", prop_key); @@ -1827,6 +1832,17 @@ cd_main_daemon_method_call (GDBusConnection *connection, goto out; } + /* check the gamma */ + if (priv->target_gamma < 1.0 || priv->target_gamma > 4.0) { + g_dbus_method_invocation_return_error (invocation, + CD_SESSION_ERROR, + CD_SESSION_ERROR_INVALID_VALUE, + "invalid target gamma value %f", + priv->target_gamma); + goto out; + } + + /* check the whitepoint */ if (priv->target_whitepoint != 0 && (priv->target_whitepoint < 1000 || priv->target_whitepoint > 100000)) { |