From: Emmanuele Bassi Date: Fri, 13 Nov 2009 13:21:47 +0000 (+0000) Subject: animation: Override parsing :mode X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9bae5535646b64e7c43f3a628942531d14e5a0f1;p=profile%2Fivi%2Fclutter.git animation: Override parsing :mode Like in ClutterAlpha, ClutterAnimation:mode must be overridden when parsing a Script definition, as we accept both a numeric id and the string id for easing modes. --- diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c index b314456..01ba759 100644 --- a/clutter/clutter-animation.c +++ b/clutter/clutter-animation.c @@ -85,6 +85,8 @@ #include "clutter-enum-types.h" #include "clutter-interval.h" #include "clutter-private.h" +#include "clutter-scriptable.h" +#include "clutter-script-private.h" enum { @@ -125,7 +127,11 @@ static guint animation_signals[LAST_SIGNAL] = { 0, }; static GQuark quark_object_animation = 0; -G_DEFINE_TYPE (ClutterAnimation, clutter_animation, G_TYPE_OBJECT); +static void clutter_scriptable_init (ClutterScriptableIface *iface); + +G_DEFINE_TYPE_WITH_CODE (ClutterAnimation, clutter_animation, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE, + clutter_scriptable_init)); static void clutter_animation_real_completed (ClutterAnimation *self) @@ -303,6 +309,49 @@ clutter_animation_get_property (GObject *gobject, } } +static gboolean +clutter_animation_parse_custom_node (ClutterScriptable *scriptable, + ClutterScript *script, + GValue *value, + const gchar *name, + JsonNode *node) +{ + if (strncmp (name, "mode", 4) == 0) + { + if (json_node_get_node_type (node) != JSON_NODE_VALUE) + return FALSE; + + g_value_init (value, G_TYPE_ULONG); + + if (json_node_get_value_type (node) == G_TYPE_INT64) + { + g_value_set_ulong (value, json_node_get_int (node)); + return TRUE; + } + else if (json_node_get_value_type (node) == G_TYPE_STRING) + { + const gchar *str = json_node_get_string (node); + gulong mode = CLUTTER_LINEAR; + + mode = clutter_script_resolve_animation_mode (str); + g_value_set_ulong (value, mode); + + return TRUE; + } + else + g_warning ("Expected an integer id or a string id for " + "the ClutterAnimation mode property"); + } + + return FALSE; +} + +static void +clutter_scriptable_init (ClutterScriptableIface *iface) +{ + iface->parse_custom_node = clutter_animation_parse_custom_node; +} + static void clutter_animation_class_init (ClutterAnimationClass *klass) {