[gtk+] gtk: Add _gtk_animation_description_to_string()



commit dc43239a6132f478b585d26b3ed6e5dc73211a7c
Author: Benjamin Otte <otte redhat com>
Date:   Wed Apr 6 21:42:21 2011 +0200

    gtk: Add _gtk_animation_description_to_string()
    
    Reverses _gtk_animation_description_from_string()

 gtk/gtkanimationdescription.c |   43 +++++++++++++++++++++++++++++++++++++++++
 gtk/gtkanimationdescription.h |    1 +
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkanimationdescription.c b/gtk/gtkanimationdescription.c
index f46ab4b..497c550 100644
--- a/gtk/gtkanimationdescription.c
+++ b/gtk/gtkanimationdescription.c
@@ -123,6 +123,49 @@ _gtk_animation_description_from_string (const gchar *str)
   return _gtk_animation_description_new ((gdouble) duration, progress_type, loop);
 }
 
+char *
+_gtk_animation_description_to_string (GtkAnimationDescription *desc)
+{
+  GString *str;
+  int duration;
+
+  g_return_val_if_fail (desc != NULL, NULL);
+
+  str = g_string_new ("");
+
+  duration = desc->duration;
+  if (duration % 1000 == 0)
+    g_string_append_printf (str, "%ds", (int) desc->duration / 1000);
+  else
+    g_string_append_printf (str, "%dms", (int) desc->duration);
+
+  switch (desc->progress_type)
+    {
+    case GTK_TIMELINE_PROGRESS_LINEAR:
+      g_string_append (str, " linear");
+      break;
+    case GTK_TIMELINE_PROGRESS_EASE:
+      g_string_append (str, " ease");
+      break;
+    case GTK_TIMELINE_PROGRESS_EASE_IN:
+      g_string_append (str, " ease-in");
+      break;
+    case GTK_TIMELINE_PROGRESS_EASE_OUT:
+      g_string_append (str, " ease-out");
+      break;
+    case GTK_TIMELINE_PROGRESS_EASE_IN_OUT:
+      g_string_append (str, " ease-in-out");
+      break;
+    default:
+      g_assert_not_reached ();
+    }
+
+  if (desc->loop)
+    g_string_append (str, " loop");
+
+  return g_string_free (str, FALSE);
+}
+
 GType
 _gtk_animation_description_get_type (void)
 {
diff --git a/gtk/gtkanimationdescription.h b/gtk/gtkanimationdescription.h
index 7bff674..5423cd4 100644
--- a/gtk/gtkanimationdescription.h
+++ b/gtk/gtkanimationdescription.h
@@ -43,6 +43,7 @@ GtkAnimationDescription * _gtk_animation_description_ref               (GtkAnima
 void                      _gtk_animation_description_unref             (GtkAnimationDescription *desc);
 
 GtkAnimationDescription * _gtk_animation_description_from_string       (const gchar *str);
+char *                    _gtk_animation_description_to_string         (GtkAnimationDescription *desc);
 
 G_END_DECLS
 



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