]> Pileus Git - ~andy/gtk/commitdiff
gtk: Add _gtk_animation_description_to_string()
authorBenjamin Otte <otte@redhat.com>
Wed, 6 Apr 2011 19:42:21 +0000 (21:42 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 18 May 2011 19:58:43 +0000 (21:58 +0200)
Reverses _gtk_animation_description_from_string()

gtk/gtkanimationdescription.c
gtk/gtkanimationdescription.h

index f46ab4bef3b195ff08833e353e6299b1bb418209..497c550712ffa09e95eed6a3c71220fd94792cab 100644 (file)
@@ -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)
 {
index 7bff674cc1f87df27aea1a4595fae9700d1b7afc..5423cd43343aa18a20aa4a2a714a1500876a70dd 100644 (file)
@@ -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