[glide] Start moving some animation stuff into inspector
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Start moving some animation stuff into inspector
- Date: Sun, 2 May 2010 01:48:22 +0000 (UTC)
commit 40a1360728ebaf9644cfa67aa7d50ac26d4de823
Author: Robert Carr <racarr Valentine localdomain>
Date: Sat May 1 20:58:25 2010 -0400
Start moving some animation stuff into inspector
src/glide-inspector-animation-priv.h | 4 +
src/glide-inspector-animation.c | 245 +++++++++++++++++++++++++++++++++-
src/glide-inspector-animation.h | 4 +-
src/glide-inspector-notebook.c | 2 +
src/glide-stage-manager.c | 49 ++++---
src/glide-window.c | 15 +-
6 files changed, 285 insertions(+), 34 deletions(-)
---
diff --git a/src/glide-inspector-animation-priv.h b/src/glide-inspector-animation-priv.h
index 977be0c..83d4ec4 100644
--- a/src/glide-inspector-animation-priv.h
+++ b/src/glide-inspector-animation-priv.h
@@ -27,6 +27,10 @@ G_BEGIN_DECLS
struct _GlideInspectorAnimationPrivate
{
GlideActor *actor;
+
+ GtkWidget *main_vbox;
+ GtkWidget *effect_box;
+ GtkWidget *direction_box;
};
G_END_DECLS
diff --git a/src/glide-inspector-animation.c b/src/glide-inspector-animation.c
index ceb44d6..7e09e42 100644
--- a/src/glide-inspector-animation.c
+++ b/src/glide-inspector-animation.c
@@ -19,9 +19,15 @@
#include "glide-inspector-animation.h"
#include "glide-inspector-animation-priv.h"
+#include "glide-slide.h"
+
+#include <string.h>
+
+#include "glide-animation-manager.h"
+
#define GLIDE_INSPECTOR_ANIMATION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GLIDE_TYPE_INSPECTOR_ANIMATION, GlideInspectorAnimationPrivate))
-G_DEFINE_TYPE(GlideInspectorAnimation, glide_inspector_animation, GTK_TYPE_VBOX);
+G_DEFINE_TYPE(GlideInspectorAnimation, glide_inspector_animation, GTK_TYPE_ALIGNMENT);
enum {
PROP_0,
@@ -29,6 +35,200 @@ enum {
};
static void
+glide_inspector_animation_set_animation_direction (GlideInspectorAnimation *ins)
+{
+ const GlideAnimationInfo *info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
+ GtkTreeModel *m = gtk_combo_box_get_model (GTK_COMBO_BOX (ins->priv->direction_box));
+ GtkTreeIter iter;
+ const gchar *option;
+
+ if (!info)
+ return;
+ else if (!info->option && info->animation->list_options)
+ {
+ gtk_tree_model_get_iter_first (m, &iter);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ins->priv->direction_box), &iter);
+
+ return;
+ }
+ else
+ option = info->option;
+
+ if (!info->animation->list_options)
+ return;
+
+ gtk_tree_model_get_iter_first (m, &iter);
+ do {
+ gchar *e;
+
+ gtk_tree_model_get (m, &iter, 0, &e, -1);
+ if (!strcmp (e, option))
+ {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ins->priv->direction_box), &iter);
+ g_free (e);
+ return;
+ }
+ g_free (e);
+ } while (gtk_tree_model_iter_next (m, &iter));
+
+ gtk_tree_model_get_iter_first (m, &iter);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ins->priv->direction_box), &iter);
+}
+
+static void
+glide_inspector_animation_update_direction_box (GlideInspectorAnimation *insp,
+ const GlideAnimation *anim)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GList *options, *o;
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (insp->priv->direction_box), GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ if (anim && anim->list_options)
+ options = anim->list_options ();
+ else
+ return;
+
+ for (o = options; o; o = o->next)
+ {
+ gchar *option = (gchar *)o->data;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, option,
+ -1);
+ }
+
+ glide_inspector_animation_set_animation_direction (insp);
+}
+
+static void
+glide_inspector_animation_direction_box_changed (GtkWidget *cbox,
+ gpointer user_data)
+{
+ GlideInspectorAnimation *ins = (GlideInspectorAnimation *)user_data;
+ GlideAnimationInfo *info;
+ gchar *option = NULL;
+ GtkTreeIter iter;
+
+
+ info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (cbox), &iter))
+ {
+ GtkTreeModel *model;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (cbox));
+ gtk_tree_model_get(model, &iter, 0, &option, -1);
+ }
+ info->option = option;
+}
+
+static void
+glide_inspector_animation_effect_box_changed (GtkWidget *cbox,
+ gpointer user_data)
+{
+ GlideInspectorAnimation *ins = (GlideInspectorAnimation *)user_data;
+ GtkTreeIter iter;
+ gchar *animation;
+ GlideAnimationInfo info, *old_info;
+ const GlideAnimation *ga;
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (cbox), &iter))
+ {
+ GtkTreeModel *model;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (cbox));
+ gtk_tree_model_get (model, &iter, 0, &animation, -1);
+ }
+ else
+ {
+ return;
+ }
+
+ old_info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
+ ga = glide_animation_manager_get_animation (animation);
+
+ info.duration = 1000;
+ info.animation = ga;
+ if (old_info && old_info->animation &&
+ !strcmp (old_info->animation->name, animation))
+ info.option = g_strdup (old_info->option);
+ else
+ info.option = NULL;
+
+ glide_slide_set_animation (GLIDE_SLIDE (ins->priv->actor), &info);
+ glide_inspector_animation_update_direction_box (ins, ga);
+ g_free (animation);
+}
+
+static void
+glide_inspector_effect_box_set_animation (GlideInspectorAnimation *ins)
+{
+ const GlideAnimationInfo *info = glide_slide_get_animation (GLIDE_SLIDE (ins->priv->actor));
+ GtkTreeModel *m = gtk_combo_box_get_model (GTK_COMBO_BOX (ins->priv->effect_box));
+ GtkTreeIter iter;
+ const gchar *animation;
+
+ if (!info || !info->animation)
+ animation = "None";
+ else
+ animation = info->animation->name;
+
+ gtk_tree_model_get_iter_first (m, &iter);
+ do {
+ gchar *e;
+
+ gtk_tree_model_get (m, &iter, 0, &e, -1);
+ if (!strcmp (e, animation))
+ {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ins->priv->effect_box), &iter);
+
+ g_free (e);
+ return;
+ }
+ g_free (e);
+ } while (gtk_tree_model_iter_next (m, &iter));
+ // TODO: What to do when say loading a file that has an animation our version doesn't have?
+}
+
+
+static void
+glide_inspector_animation_setup_comboboxes (GlideInspectorAnimation *ins)
+{
+ GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
+ GtkCellRenderer *renderer;
+ GtkTreeIter iter;
+ const GList *animations, *a;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "None", -1);
+
+ animations = glide_animation_manager_get_animations ();
+ for (a = animations; a; a = a->next)
+ {
+ GlideAnimation *animation = (GlideAnimation *)a->data;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, animation->name,
+ -1);
+ }
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (ins->priv->effect_box), GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ins->priv->effect_box), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(ins->priv->effect_box), renderer, "text", 0, NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ins->priv->direction_box), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(ins->priv->direction_box), renderer, "text", 0, NULL);
+
+ g_signal_connect (ins->priv->effect_box, "changed", G_CALLBACK (glide_inspector_animation_effect_box_changed), ins);
+ g_signal_connect (ins->priv->direction_box, "changed", G_CALLBACK (glide_inspector_animation_direction_box_changed), ins);
+}
+
+static void
glide_inspector_animation_finalize (GObject *object)
{
@@ -73,11 +273,42 @@ glide_inspector_animation_set_property (GObject *object,
}
static void
+glide_inspector_animation_setup_ui (GlideInspectorAnimation *ins)
+{
+ GtkWidget *effect_label, *direction_label;
+ GtkWidget *box = gtk_vbox_new (FALSE, 2);
+
+ ins->priv->main_vbox = box;
+ ins->priv->effect_box = gtk_combo_box_new ();
+ ins->priv->direction_box = gtk_combo_box_new ();
+
+ effect_label = gtk_label_new (NULL);
+ direction_label = gtk_label_new (NULL);
+
+ gtk_label_set_markup (GTK_LABEL (effect_label), "<b>Effect:</b>");
+ 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);
+
+ 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_container_add (GTK_CONTAINER (ins), box);
+
+ glide_inspector_animation_setup_comboboxes (ins);
+}
+
+static void
glide_inspector_animation_init (GlideInspectorAnimation *inspector)
{
inspector->priv = GLIDE_INSPECTOR_ANIMATION_GET_PRIVATE (inspector);
+
+ glide_inspector_animation_setup_ui (inspector);
+ gtk_widget_set_sensitive (GTK_WIDGET (inspector), FALSE);
- gtk_widget_set_size_request (GTK_WIDGET (inspector), 200, 20);
+ gtk_alignment_set (GTK_ALIGNMENT (inspector), .5, 0, 0.9, 1.0);
}
static void
@@ -119,5 +350,15 @@ glide_inspector_animation_set_actor (GlideInspectorAnimation *inspector,
{
inspector->priv->actor = actor;
+ if (!GLIDE_IS_SLIDE (actor))
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (inspector), FALSE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
+ glide_inspector_effect_box_set_animation (inspector);
+ }
+
g_object_notify (G_OBJECT (inspector), "actor");
}
diff --git a/src/glide-inspector-animation.h b/src/glide-inspector-animation.h
index 8d578cd..5cbd488 100644
--- a/src/glide-inspector-animation.h
+++ b/src/glide-inspector-animation.h
@@ -38,7 +38,7 @@ typedef struct _GlideInspectorAnimation GlideInspectorAnimation;
struct _GlideInspectorAnimation
{
- GtkVBox vbox;
+ GtkAlignment alignment;
GlideInspectorAnimationPrivate *priv;
};
@@ -47,7 +47,7 @@ typedef struct _GlideInspectorAnimationClass GlideInspectorAnimationClass;
struct _GlideInspectorAnimationClass
{
- GtkVBoxClass parent_class;
+ GtkAlignmentClass parent_class;
};
GType glide_inspector_animation_get_type (void) G_GNUC_CONST;
diff --git a/src/glide-inspector-notebook.c b/src/glide-inspector-notebook.c
index 834ebc3..d65677a 100644
--- a/src/glide-inspector-notebook.c
+++ b/src/glide-inspector-notebook.c
@@ -103,6 +103,8 @@ glide_inspector_notebook_init (GlideInspectorNotebook *inspector)
inspector->priv = GLIDE_INSPECTOR_NOTEBOOK_GET_PRIVATE (inspector);
glide_inspector_notebook_add_pages (inspector);
+
+ gtk_widget_set_size_request (GTK_WIDGET (inspector), 200, 20);
}
static void
diff --git a/src/glide-stage-manager.c b/src/glide-stage-manager.c
index 023e606..7ebd860 100644
--- a/src/glide-stage-manager.c
+++ b/src/glide-stage-manager.c
@@ -118,19 +118,24 @@ glide_stage_manager_set_selection_real (GlideStageManager *m,
a ? GLIDE_ACTOR_DISPLAY_NAME (a) : "unknown", a);
if (a)
- {
- GLIDE_NOTE (STAGE_MANAGER, "New selection geometry: (%f, %f), (%f, %f)",
- clutter_actor_get_x (CLUTTER_ACTOR (a)), clutter_actor_get_y (CLUTTER_ACTOR (a)),
- clutter_actor_get_width (CLUTTER_ACTOR (a)), clutter_actor_get_height (CLUTTER_ACTOR (a)));
- }
-
+ GLIDE_NOTE (STAGE_MANAGER, "New selection geometry: (%f, %f), (%f, %f)",
+ clutter_actor_get_x (CLUTTER_ACTOR (a)), clutter_actor_get_y (CLUTTER_ACTOR (a)),
+ clutter_actor_get_width (CLUTTER_ACTOR (a)), clutter_actor_get_height (CLUTTER_ACTOR (a)));
m->priv->selection = a;
- if (a)
- clutter_actor_raise_top (CLUTTER_ACTOR (a));
- glide_manipulator_set_target(m->priv->manip, CLUTTER_ACTOR (a));
- glide_manipulator_set_width_only(m->priv->manip, FALSE);
+ if (a){
+
+ clutter_actor_raise_top (CLUTTER_ACTOR (a));
+
+ if (GLIDE_IS_SLIDE (a))
+ glide_manipulator_set_target (m->priv->manip, NULL);
+ else
+ {
+ glide_manipulator_set_target(m->priv->manip, CLUTTER_ACTOR (a));
+ glide_manipulator_set_width_only(m->priv->manip, FALSE);
+ }
+ }
g_signal_emit (m, stage_manager_signals[SELECTION_CHANGED], 0, old);
}
@@ -207,7 +212,7 @@ glide_stage_manager_document_slide_added_cb (GlideDocument *document,
clutter_actor_set_size (CLUTTER_ACTOR (slide), width, height);
glide_stage_manager_set_slide (manager, manager->priv->current_slide+1);
- glide_stage_manager_set_selection (manager, NULL);
+ glide_stage_manager_set_selection (manager, GLIDE_ACTOR (slide));
}
void
@@ -282,7 +287,7 @@ glide_stage_manager_button_pressed (ClutterActor *actor,
if (manager->priv->presenting)
glide_stage_manager_advance_slide (manager);
else
- glide_stage_manager_set_selection (manager, NULL);
+ glide_stage_manager_set_selection (manager, GLIDE_ACTOR (glide_document_get_nth_slide (manager->priv->document, manager->priv->current_slide)));
return TRUE;
}
@@ -423,10 +428,10 @@ glide_stage_manager_binding_move_up (GlideStageManager *self,
{
ClutterActor *selection = CLUTTER_ACTOR (glide_stage_manager_get_selection (self));
- if (self->priv->presenting)
+ if (self->priv->presenting)
return FALSE;
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -450,7 +455,7 @@ glide_stage_manager_binding_move_down (GlideStageManager *self,
if (self->priv->presenting)
return FALSE;
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -477,7 +482,7 @@ glide_stage_manager_binding_move_left (GlideStageManager *self,
return TRUE;
}
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -504,7 +509,7 @@ glide_stage_manager_binding_move_right (GlideStageManager *self,
return TRUE;
}
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -528,7 +533,7 @@ glide_stage_manager_binding_move_up_snap (GlideStageManager *self,
if (self->priv->presenting)
return FALSE;
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -553,7 +558,7 @@ glide_stage_manager_binding_move_down_snap (GlideStageManager *self,
if (self->priv->presenting)
return FALSE;
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -579,7 +584,7 @@ glide_stage_manager_binding_move_left_snap (GlideStageManager *self,
return FALSE;
}
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -605,7 +610,7 @@ glide_stage_manager_binding_move_right_snap (GlideStageManager *self,
{
return FALSE;
}
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return FALSE;
glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (selection)),
@@ -883,7 +888,7 @@ glide_stage_manager_delete_selection (GlideStageManager *manager)
{
GlideActor *selection = glide_stage_manager_get_selection (manager);
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE(selection))
return;
glide_undo_manager_append_delete (manager->priv->undo_manager, selection);
diff --git a/src/glide-window.c b/src/glide-window.c
index 83b684c..a7b5abc 100644
--- a/src/glide-window.c
+++ b/src/glide-window.c
@@ -285,10 +285,9 @@ glide_window_color_set_cb (GtkWidget *b,
gtk_color_button_get_color (GTK_COLOR_BUTTON (b), &c);
glide_clutter_color_from_gdk_color (&c, &cc);
- if (!selection)
+ if (GLIDE_IS_SLIDE (selection))
{
- GlideSlide *s = glide_document_get_nth_slide (w->priv->document,
- glide_stage_manager_get_current_slide (w->priv->manager));
+ GlideSlide *s = GLIDE_SLIDE (selection);
glide_undo_manager_start_slide_action (w->priv->undo_manager, s, "Set slide color.");
glide_slide_set_color (s, &cc);
@@ -330,7 +329,7 @@ glide_window_stage_selection_changed_cb (GlideStageManager *manager,
GlideActor *selection =
glide_stage_manager_get_selection (w->priv->manager);
- if (!selection || GLIDE_IS_TEXT (selection))
+ if (GLIDE_IS_SLIDE (selection) || GLIDE_IS_TEXT (selection))
{
gtk_widget_set_sensitive (GTK_WIDGET (GLIDE_WINDOW_UI_OBJECT (w, "text-color-button")), TRUE);
}
@@ -339,7 +338,7 @@ glide_window_stage_selection_changed_cb (GlideStageManager *manager,
gtk_widget_set_sensitive (GTK_WIDGET (GLIDE_WINDOW_UI_OBJECT (w, "text-color-button")), FALSE);
}
- if (selection && GLIDE_IS_TEXT (selection))
+ if (selection && (GLIDE_IS_TEXT (selection)))
{
GdkColor c;
ClutterColor cc;
@@ -863,7 +862,7 @@ glide_window_paste_contents_text_received (GtkClipboard *clipboard,
selection = glide_stage_manager_get_selection (w->priv->manager);
- if (!selection)
+ if (GLIDE_IS_SLIDE (selection) || !selection)
{
ClutterActor *ntext = glide_text_new ();
ClutterColor cc;
@@ -1056,7 +1055,7 @@ glide_window_copy_action_activate (GtkAction *a,
GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
GlideActor *selection = glide_stage_manager_get_selection (w->priv->manager);
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE (selection))
{
return;
}
@@ -1108,7 +1107,7 @@ glide_window_cut_action_activate (GtkAction *a,
GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
GlideActor *selection = glide_stage_manager_get_selection (w->priv->manager);
- if (!selection)
+ if (!selection || GLIDE_IS_SLIDE (selection))
{
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]