[Swfdec] Branch 'vivi' - vivified/ui
Benjamin Otte
company at kemper.freedesktop.org
Tue Aug 21 14:51:03 PDT 2007
vivified/ui/vivi_movie_list.c | 76 +++++++++++++++++++++++++++++++-----------
1 file changed, 57 insertions(+), 19 deletions(-)
New commits:
diff-tree cd4771d4b96dc96212d69810b22724d076d3a283 (from 8ff61bf0eec2a7f45c5e4eabd558a8db899b489c)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Aug 21 23:48:43 2007 +0200
implement depth notifications and reordering
diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
index 2ac4104..497ee27 100644
--- a/vivified/ui/vivi_movie_list.c
+++ b/vivified/ui/vivi_movie_list.c
@@ -272,6 +272,62 @@ vivi_movie_list_get_index (GNode *parent
return i;
}
+static void
+vivi_movie_list_movie_notify (SwfdecMovie *movie, GParamSpec *pspec, ViviMovieList *movies)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GNode *node;
+
+ node = g_hash_table_lookup (movies->nodes, movie);
+ if (g_str_equal (pspec->name, "depth")) {
+ guint old, new;
+ GNode *parent;
+
+ parent = node->parent;
+ old = g_node_child_position (parent, node);
+ new = vivi_movie_list_get_index (parent, node);
+ if (old != new) {
+ /* reorder */
+ guint min = MIN (old, new);
+ guint max = MAX (old, new);
+ guint i;
+ guint count = g_node_n_children (parent);
+ int *positions = g_new (int, count);
+ g_print ("reordering %u => %u (%u total)\n", old, new, count);
+ for (i = 0; i < min; i++) {
+ positions[i] = i;
+ }
+ if (old < new) {
+ for (i = min; i < max; i++) {
+ positions[i] = i + 1;
+ }
+ } else {
+ for (i = min + 1; i <= max; i++) {
+ positions[i] = i - 1;
+ }
+ }
+ positions[new] = old;
+ for (i = max + 1; i < count; i++) {
+ positions[i] = i;
+ }
+ g_node_unlink (node);
+ g_node_insert (parent, new, node);
+ iter.stamp = movies->stamp;
+ iter.user_data = parent;
+ path = vivi_movie_list_node_to_path (parent);
+ gtk_tree_model_rows_reordered (GTK_TREE_MODEL (movies), path, &iter, positions);
+ gtk_tree_path_free (path);
+ g_free (positions);
+ }
+ }
+ iter.stamp = movies->stamp;
+ iter.user_data = node;
+ path = vivi_movie_list_node_to_path (node);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (movies), path, &iter);
+ gtk_tree_path_free (path);
+}
+
static gboolean
vivi_movie_list_added (ViviDebugger *debugger, SwfdecAsObject *object, ViviMovieList *movies)
{
@@ -284,6 +340,7 @@ vivi_movie_list_added (ViviDebugger *deb
if (!SWFDEC_IS_MOVIE (object))
return FALSE;
movie = SWFDEC_MOVIE (object);
+ g_signal_connect (movie, "notify", G_CALLBACK (vivi_movie_list_movie_notify), movies);
if (movie->parent) {
node = g_hash_table_lookup (movies->nodes, movie->parent);
g_assert (node);
@@ -304,25 +361,6 @@ vivi_movie_list_added (ViviDebugger *deb
}
static void
-vivi_movie_list_movie_notify (SwfdecMovie *movie, GParamSpec *pspec, ViviMovieList *movies)
-{
- GtkTreeIter iter;
- GtkTreePath *path;
- GNode *node;
-
- node = g_hash_table_lookup (movies->nodes, movie);
- if (g_str_equal (pspec->name, "depth")) {
- /* reorder when depth changes */
- g_printerr ("FIXME: implement depth changes\n");
- }
- iter.stamp = movies->stamp;
- iter.user_data = node;
- path = vivi_movie_list_node_to_path (node);
- gtk_tree_model_row_changed (GTK_TREE_MODEL (movies), path, &iter);
- gtk_tree_path_free (path);
-}
-
-static void
vivi_movie_list_remove_node (ViviMovieList *movies, GNode *node)
{
GNode *walk;
More information about the Swfdec
mailing list