[cheese/videobalance] Set default values for "unset" gconf keys
- From: Filippo Argiolas <fargiolas src gnome org>
- To: svn-commits-list gnome org
- Subject: [cheese/videobalance] Set default values for "unset" gconf keys
- Date: Thu, 23 Apr 2009 12:31:46 -0400 (EDT)
commit 0e5c6762f84ed41908a4952691a9ebe97ba94570
Author: Filippo Argiolas <filippo argiolas gmail com>
Date: Thu Apr 23 18:17:25 2009 +0200
Set default values for "unset" gconf keys
If a gconf key doesn't exist, doesn't have a schema or is just unset set
the value to the paramspec default. This fixes the picture being black if
no schema installed (brightness and contrast set to 0).
The best thing would be to ask gstreamer for the default as we do in the
preferences dialog but at the moment CheeseGconf is still unaware of
CheeseWebcam.
The method used (check gconf_client_get to be non NULL) is a bit tricky
but that's the only way to get information about unset keys.
Yes, gconf sucks.
---
src/cheese-gconf.c | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/cheese-gconf.c b/src/cheese-gconf.c
index 2ed05aa..0f3aed6 100644
--- a/src/cheese-gconf.c
+++ b/src/cheese-gconf.c
@@ -114,19 +114,34 @@ cheese_gconf_get_property (GObject *object, guint prop_id, GValue *value,
NULL));
break;
case GCONF_PROP_BRIGHTNESS:
- g_value_set_double (value, gconf_client_get_float (priv->client,
- CHEESE_GCONF_PREFIX "/brightness",
- NULL));
+ if (!gconf_client_get (priv->client,
+ CHEESE_GCONF_PREFIX "/brightness",
+ NULL))
+ g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value);
+ else
+ g_value_set_double (value, gconf_client_get_float (priv->client,
+ CHEESE_GCONF_PREFIX "/brightness",
+ NULL));
break;
case GCONF_PROP_CONTRAST:
- g_value_set_double (value, gconf_client_get_float (priv->client,
- CHEESE_GCONF_PREFIX "/contrast",
- NULL));
+ if (!gconf_client_get (priv->client,
+ CHEESE_GCONF_PREFIX "/contrast",
+ NULL))
+ g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value);
+ else
+ g_value_set_double (value, gconf_client_get_float (priv->client,
+ CHEESE_GCONF_PREFIX "/contrast",
+ NULL));
break;
case GCONF_PROP_SATURATION:
- g_value_set_double (value, gconf_client_get_float (priv->client,
- CHEESE_GCONF_PREFIX "/saturation",
- NULL));
+ if (!gconf_client_get (priv->client,
+ CHEESE_GCONF_PREFIX "/saturation",
+ NULL))
+ g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value);
+ else
+ g_value_set_double (value, gconf_client_get_float (priv->client,
+ CHEESE_GCONF_PREFIX "/saturation",
+ NULL));
break;
case GCONF_PROP_VIDEO_PATH:
g_value_set_string (value, gconf_client_get_string (priv->client,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]