[glide] Animations are again saved



commit aa379069d0631ec419de0175f0609f6445edaee7
Author: Robert Carr <racarr Valentine localdomain>
Date:   Tue Apr 27 02:24:25 2010 -0400

    Animations are again saved

 src/glide-json-util.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 src/glide-json-util.h |    8 ++++++++
 src/glide-slide.c     |   14 +++++++-------
 3 files changed, 60 insertions(+), 8 deletions(-)
---
diff --git a/src/glide-json-util.c b/src/glide-json-util.c
index d2a37d2..2cbe397 100644
--- a/src/glide-json-util.c
+++ b/src/glide-json-util.c
@@ -18,6 +18,7 @@
 
 
 #include "glide-json-util.h"
+
 #include <math.h>
 #include <stdlib.h>
 
@@ -42,6 +43,49 @@ glide_json_object_get_string (JsonObject *obj, const gchar *prop)
 }
 
 void
+glide_json_object_get_animation (JsonObject *obj,
+				const gchar *prop,
+				GlideAnimationInfo *info)
+{
+  JsonNode *n = json_object_get_member (obj, prop);
+  JsonObject *anim_obj = json_node_get_object (n);
+  const gchar *name;
+  guint duration;
+  const GlideAnimation *animation;
+  
+  name = glide_json_object_get_string (anim_obj, "name");
+  duration = glide_json_object_get_double (anim_obj, "duration");
+  
+  animation = glide_animation_manager_get_animation (name);
+  info->animation = animation;
+  info->duration = duration;
+}
+
+void
+glide_json_object_set_animation (JsonObject *obj,
+				 const gchar *prop,
+				 const GlideAnimationInfo *info)
+{
+  JsonNode *n = json_node_new (JSON_NODE_OBJECT);
+  JsonObject *animation_obj = json_object_new ();
+  
+  json_node_set_object (n, animation_obj);
+  
+  if (info && info->animation)
+    {
+      glide_json_object_set_string (animation_obj, "name", info->animation->name);
+      glide_json_object_set_double (animation_obj, "duration", info->duration);
+    }
+  else
+    {
+      glide_json_object_set_string (animation_obj, "name", "None");
+      glide_json_object_set_double (animation_obj, "duration", 0);
+    }
+  
+  json_object_set_member (obj, "animation", n);
+}
+
+void
 glide_json_object_set_double (JsonObject *obj, const gchar *prop, gdouble value)
 {
   gchar *s;
@@ -57,7 +101,7 @@ glide_json_object_set_double (JsonObject *obj, const gchar *prop, gdouble value)
 }
 
 gdouble
-glide_json_object_get_double (JsonObject *obj, const char *prop)
+glide_json_object_get_double (JsonObject *obj, const gchar *prop)
 {
   JsonNode *n = json_object_get_member (obj, prop);
   const gchar *ds;
diff --git a/src/glide-json-util.h b/src/glide-json-util.h
index eed6464..b3ed93d 100644
--- a/src/glide-json-util.h
+++ b/src/glide-json-util.h
@@ -21,13 +21,21 @@
 #define __GLIDE_JSON_UTIL_H__
 
 #include "glide-actor.h"
+#include "glide-animation-manager.h"
 
 void glide_json_object_set_string (JsonObject *obj, const gchar *prop, const gchar *value);
 const gchar *glide_json_object_get_string (JsonObject *obj, const gchar *prop);
 
 void glide_json_object_set_double (JsonObject *obj, const gchar *prop, gdouble value);
+gdouble glide_json_object_get_double (JsonObject *obj, const gchar *prop);
 
 void glide_json_object_add_actor_geometry (JsonObject *obj, ClutterActor *actor);
 void glide_json_object_restore_actor_geometry (JsonObject *obj, ClutterActor *actor);
+void glide_json_object_set_animation (JsonObject *obj,
+				      const gchar *prop,
+				      const GlideAnimationInfo *info);
+void glide_json_object_get_animation (JsonObject *obj,
+				      const gchar *prop,
+				      GlideAnimationInfo *info);
 
 #endif
diff --git a/src/glide-slide.c b/src/glide-slide.c
index f8c1543..79c6928 100644
--- a/src/glide-slide.c
+++ b/src/glide-slide.c
@@ -480,9 +480,9 @@ glide_slide_serialize (GlideActor *self)
   
   if (slide->priv->background)
     glide_json_object_set_string (obj, "background", slide->priv->background); 
-  /*  if (slide->priv->animation)
-    glide_json_object_set_string (obj, "animation", slide->priv->animation); 
-    else*/
+  if (slide->priv->animation)
+    glide_json_object_set_animation (obj, "animation", slide->priv->animation); 
+  else
     glide_json_object_set_string (obj, "animation", "None"); 
   
   return node;
@@ -640,7 +640,8 @@ glide_slide_construct_from_json (GlideSlide *slide, JsonObject *slide_obj, Glide
   JsonNode *actors_n;
   JsonArray *actors;
   GList *actors_l, *a;
-  const gchar *background, *animation;
+  const gchar *background;
+  GlideAnimationInfo info;
   
   actors_n = json_object_get_member (slide_obj, "actors");
   actors = json_node_get_array (actors_n);
@@ -649,9 +650,8 @@ glide_slide_construct_from_json (GlideSlide *slide, JsonObject *slide_obj, Glide
   if (background)
     glide_slide_set_background (slide, background);
 
-  animation = glide_json_object_get_string (slide_obj, "animation");
-  //  if (animation)
-  //    glide_slide_set_animation (slide, animation);
+  glide_json_object_get_animation (slide_obj, "animation", &info);
+  glide_slide_set_animation (slide, &info);
   
   actors_l = json_array_get_elements (actors);
   for (a = actors_l; a; a = a->next)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]