mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
state: Return a boolean when getting the key value
Since the copy might fail, we should return a boolean value and not just warn on the console - similarly to what ClutterAnimator does.
This commit is contained in:
parent
786285a245
commit
1ca0c2a6d1
@ -1403,20 +1403,26 @@ clutter_state_key_get_mode (const ClutterStateKey *state_key)
|
||||
* @state_key: a #ClutterStateKey
|
||||
* @value: a #GValue initialized with the correct type for the @state_key
|
||||
*
|
||||
* Copies of the value for a #ClutterStateKey into @value
|
||||
* Retrieves a copy of the value for a #ClutterStateKey.
|
||||
*
|
||||
* The #GValue needs to be already initialized for the value type
|
||||
* of the property or to a transformable type
|
||||
* of the property or to a type that allow transformation from the value
|
||||
* type of the key.
|
||||
*
|
||||
* Use g_value_unset() when done.
|
||||
*
|
||||
* Return value: %TRUE if the value was successfully retrieved,
|
||||
* and %FALSE otherwise
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
void
|
||||
gboolean
|
||||
clutter_state_key_get_value (const ClutterStateKey *state_key,
|
||||
GValue *value)
|
||||
{
|
||||
g_return_if_fail (state_key != NULL);
|
||||
g_return_if_fail (value != NULL);
|
||||
g_return_if_fail (G_VALUE_TYPE (value) != G_TYPE_INVALID);
|
||||
g_return_val_if_fail (state_key != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
g_return_val_if_fail (G_VALUE_TYPE (value) != G_TYPE_INVALID, FALSE);
|
||||
|
||||
if (!g_type_is_a (G_VALUE_TYPE (&state_key->value), G_VALUE_TYPE (value)))
|
||||
{
|
||||
@ -1424,14 +1430,14 @@ clutter_state_key_get_value (const ClutterStateKey *state_key,
|
||||
G_VALUE_TYPE (value)))
|
||||
{
|
||||
g_value_copy (&state_key->value, value);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_value_type_transformable (G_VALUE_TYPE (&state_key->value),
|
||||
G_VALUE_TYPE (value)))
|
||||
{
|
||||
if (g_value_transform (&state_key->value, value))
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_warning ("%s: Unable to convert from %s to %s for the "
|
||||
@ -1441,9 +1447,13 @@ clutter_state_key_get_value (const ClutterStateKey *state_key,
|
||||
g_type_name (G_VALUE_TYPE (value)),
|
||||
state_key->property_name,
|
||||
G_OBJECT_TYPE_NAME (state_key->object));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
g_value_copy (&state_key->value, value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +147,7 @@ GType clutter_state_key_get_type (void) G_GNUC_CONS
|
||||
gdouble clutter_state_key_get_pre_delay (const ClutterStateKey *state_key);
|
||||
gdouble clutter_state_key_get_post_delay (const ClutterStateKey *state_key);
|
||||
gulong clutter_state_key_get_mode (const ClutterStateKey *state_key);
|
||||
void clutter_state_key_get_value (const ClutterStateKey *state_key,
|
||||
gboolean clutter_state_key_get_value (const ClutterStateKey *state_key,
|
||||
GValue *value);
|
||||
GType clutter_state_key_get_property_type (const ClutterStateKey *key);
|
||||
GObject * clutter_state_key_get_object (const ClutterStateKey *state_key);
|
||||
|
Loading…
Reference in New Issue
Block a user