[glide] Add a duration thingy



commit c9d4881071acb778db5534dc2b2b3574ae57542a
Author: Robert Carr <racarr Valentine localdomain>
Date:   Sat May 1 21:37:13 2010 -0400

    Add a duration thingy

 src/glide-inspector-animation-priv.h |    2 +
 src/glide-inspector-animation.c      |   55 ++++++++++++++++++++++++++++++++--
 2 files changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/src/glide-inspector-animation-priv.h b/src/glide-inspector-animation-priv.h
index 83d4ec4..60108a6 100644
--- a/src/glide-inspector-animation-priv.h
+++ b/src/glide-inspector-animation-priv.h
@@ -31,6 +31,8 @@ struct _GlideInspectorAnimationPrivate
   GtkWidget *main_vbox;
   GtkWidget *effect_box;
   GtkWidget *direction_box;
+  
+  GtkWidget *duration_spin;
 };
 
 G_END_DECLS
diff --git a/src/glide-inspector-animation.c b/src/glide-inspector-animation.c
index 7e09e42..deca489 100644
--- a/src/glide-inspector-animation.c
+++ b/src/glide-inspector-animation.c
@@ -35,6 +35,15 @@ enum {
 };
 
 static void
+glide_inspector_animation_update_duration (GlideInspectorAnimation *ins)
+{
+  GlideAnimationInfo *info = (GlideAnimationInfo *)glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
+  
+  if (info)
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (ins->priv->duration_spin), info->duration/1000);
+}
+
+static void
 glide_inspector_animation_set_animation_direction (GlideInspectorAnimation *ins)
 {
   const GlideAnimationInfo *info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
@@ -104,6 +113,17 @@ glide_inspector_animation_update_direction_box (GlideInspectorAnimation *insp,
 }
 
 static void
+glide_inspector_animation_duration_spin_changed (GtkWidget *spin,
+						 gpointer user_data)
+{
+  GlideInspectorAnimation *ins = (GlideInspectorAnimation *)user_data;
+  GlideAnimationInfo *info;
+  
+  info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
+  info->duration = 1000 * gtk_spin_button_get_value (GTK_SPIN_BUTTON (ins->priv->duration_spin));
+}
+
+static void
 glide_inspector_animation_direction_box_changed (GtkWidget *cbox,
 						 gpointer user_data)
 {
@@ -149,11 +169,14 @@ glide_inspector_animation_effect_box_changed (GtkWidget *cbox,
   old_info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
   ga = glide_animation_manager_get_animation (animation);
 
-  info.duration = 1000;
+  info.duration = 1000*gtk_spin_button_get_value (GTK_SPIN_BUTTON (ins->priv->duration_spin));
   info.animation = ga;
   if (old_info && old_info->animation && 
       !strcmp (old_info->animation->name, animation))
-    info.option = g_strdup (old_info->option);
+    {
+      info.option = g_strdup (old_info->option);
+      info.duration = old_info->duration;
+    }
   else
     info.option = NULL;
   
@@ -272,11 +295,33 @@ glide_inspector_animation_set_property (GObject *object,
     }
 }
 
+static GtkWidget *
+glide_inspector_animation_make_duration (GlideInspectorAnimation *ins)
+{
+  GtkWidget *ret = gtk_hbox_new (FALSE, 10);
+  GtkWidget *duration_label = gtk_label_new (NULL);
+  ins->priv->duration_spin = gtk_spin_button_new_with_range (0, 10, 0.1);
+  
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (ins->priv->duration_spin), 1.0);
+  
+  gtk_label_set_markup (GTK_LABEL (duration_label), "<b>Duration:</b>");
+  
+  gtk_box_pack_start (GTK_BOX (ret), duration_label, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (ret), ins->priv->duration_spin, FALSE, FALSE, 0);
+  
+  g_signal_connect (ins->priv->duration_spin, "value-changed",
+		    G_CALLBACK (glide_inspector_animation_duration_spin_changed), 
+		    ins);
+  
+  return ret;
+}
+
 static void
 glide_inspector_animation_setup_ui (GlideInspectorAnimation *ins)
 {
   GtkWidget *effect_label, *direction_label;
   GtkWidget *box = gtk_vbox_new (FALSE, 2);
+  GtkWidget *duration_box;
  
   ins->priv->main_vbox = box;
   ins->priv->effect_box = gtk_combo_box_new ();
@@ -289,12 +334,15 @@ glide_inspector_animation_setup_ui (GlideInspectorAnimation *ins)
   gtk_misc_set_alignment (GTK_MISC (effect_label), 0, 0);
   gtk_label_set_markup (GTK_LABEL (direction_label), "<b>Direction:</b>");
   gtk_misc_set_alignment (GTK_MISC (direction_label), 0, 0);
+  
+  duration_box = glide_inspector_animation_make_duration (ins);
 
   gtk_box_pack_start (GTK_BOX (box), effect_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (box), ins->priv->effect_box, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (box), direction_label, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (box), ins->priv->direction_box, FALSE, FALSE, 0);
-  
+  gtk_box_pack_start (GTK_BOX (box), duration_box, FALSE, FALSE, 0);
+
   gtk_container_add (GTK_CONTAINER (ins), box);
   
   glide_inspector_animation_setup_comboboxes (ins);
@@ -357,6 +405,7 @@ glide_inspector_animation_set_actor (GlideInspectorAnimation *inspector,
   else
     {
       gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
+      glide_inspector_animation_update_duration (inspector);
       glide_inspector_effect_box_set_animation (inspector);
     }
   



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