[Swfdec] Branch 'vivi' - 3 commits - player/Makefile.am player/swfdec_debug_movies.c player/swfdec_debug_movies.h vivified/core vivified/ui

Benjamin Otte company at kemper.freedesktop.org
Fri Aug 17 14:38:00 PDT 2007


 player/Makefile.am               |   27 ++-----
 player/swfdec_debug_movies.h     |   67 ------------------
 vivified/core/vivi_initialize.as |    3 
 vivified/ui/Makefile.am          |    2 
 vivified/ui/vivi_movie_list.c    |  140 +++++++++++++++++++--------------------
 vivified/ui/vivi_movie_list.h    |   66 ++++++++++++++++++
 6 files changed, 148 insertions(+), 157 deletions(-)

New commits:
diff-tree 2f123ef946932f1b5e684b90fd27a056c0ea98f6 (from 3cd1dcc154eab81a8ff46e0ae56a24b1487fe802)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 22:57:40 2007 +0200

    disable build of swfdebug

diff --git a/player/Makefile.am b/player/Makefile.am
index ce3d1fe..53e52c1 100644
--- a/player/Makefile.am
+++ b/player/Makefile.am
@@ -1,31 +1,20 @@
-noinst_PROGRAMS = swfplay swfdebug
+noinst_PROGRAMS = swfplay 
 
 swfplay_SOURCES = \
 	swfdec_slow_loader.c \
 	swfplay.c 
 
-swfdebug_SOURCES = \
-	swfdebug.c \
-	swfdec_debug_movies.c \
-	swfdec_debug_script.c \
-	swfdec_debug_scripts.c \
-	swfdec_debug_stack.c \
-	swfdec_player_manager.c \
-	swfdec_debug_widget.c
+#swfdebug_SOURCES = \
+#	swfdebug.c \
+#	swfdec_debug_script.c \
+#	swfdec_debug_scripts.c \
+#	swfdec_debug_stack.c \
+#	swfdec_player_manager.c \
+#	swfdec_debug_widget.c
 
 noinst_HEADERS = \
-	swfdec_debug_movies.h \
-	swfdec_debug_script.h \
-	swfdec_debug_scripts.h \
-	swfdec_debug_stack.h \
-	swfdec_debug_widget.h \
-	swfdec_player_manager.h \
 	swfdec_slow_loader.h
 
 swfplay_CFLAGS = $(GLOBAL_CFLAGS) $(GTK_CFLAGS) $(SWFDEC_GTK_CFLAGS)
 swfplay_LDFLAGS = $(SWFDEC_GTK_LIBS) $(GTK_LIBS)
 
-swfdebug_CFLAGS = $(GLOBAL_CFLAGS) $(GTK_CFLAGS) $(SWFDEC_GTK_CFLAGS)
-swfdebug_LDFLAGS = $(SWFDEC_GTK_LIBS) $(GTK_LIBS)
-
-
diff-tree 3cd1dcc154eab81a8ff46e0ae56a24b1487fe802 (from 7c412eac2ef2b94b8419b0002ec5f253f47ba038)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 22:56:17 2007 +0200

    port SwfdecDebugMovies to vivified (doesn't work yet)

diff --git a/player/swfdec_debug_movies.c b/player/swfdec_debug_movies.c
deleted file mode 100644
index 331b4c9..0000000
--- a/player/swfdec_debug_movies.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, to_string to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gtk/gtk.h>
-#include <libswfdec/swfdec_debugger.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include "swfdec_debug_movies.h"
-
-/*** GTK_TREE_MODEL ***/
-
-#if 0
-#  define REPORT g_print ("%s\n", G_STRFUNC)
-#else
-#  define REPORT 
-#endif
-static GtkTreeModelFlags 
-swfdec_debug_movies_get_flags (GtkTreeModel *tree_model)
-{
-  REPORT;
-  return 0;
-}
-
-static gint
-swfdec_debug_movies_get_n_columns (GtkTreeModel *tree_model)
-{
-  REPORT;
-  return SWFDEC_DEBUG_MOVIES_N_COLUMNS;
-}
-
-static GType
-swfdec_debug_movies_get_column_type (GtkTreeModel *tree_model, gint index_)
-{
-  REPORT;
-  switch (index_) {
-    case SWFDEC_DEBUG_MOVIES_COLUMN_MOVIE:
-      return G_TYPE_POINTER;
-    case SWFDEC_DEBUG_MOVIES_COLUMN_NAME:
-      return G_TYPE_STRING;
-    case SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH:
-      return G_TYPE_INT;
-    case SWFDEC_DEBUG_MOVIES_COLUMN_TYPE:
-      return G_TYPE_STRING;
-    default:
-      break;
-  }
-  g_assert_not_reached ();
-  return G_TYPE_NONE;
-}
-
-static gboolean
-swfdec_debug_movies_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
-{
-  SwfdecDebugMovies *movies = SWFDEC_DEBUG_MOVIES (tree_model);
-  GNode *node;
-  guint i, depth;
-  int *indices;
-
-  REPORT;
-  depth = gtk_tree_path_get_depth (path);
-  indices = gtk_tree_path_get_indices (path);
-  if (indices == NULL)
-    return FALSE;
-  node = movies->root;
-  for (i = 0; i < depth; i++) {
-    node = g_node_nth_child (node, indices[i]);
-    if (node == NULL)
-      return FALSE;
-  }
-  iter->user_data = node;
-  iter->stamp = movies->stamp;
-  return TRUE;
-}
-
-static GtkTreePath *
-swfdec_debug_movies_node_to_path (GNode *node)
-{
-  GtkTreePath *path;
-
-  path = gtk_tree_path_new ();
-  while (node->parent != NULL) {
-    gtk_tree_path_prepend_index (path, g_node_child_position (node->parent, node));
-    node = node->parent;
-  }
-  return path;
-}
-
-static GtkTreePath *
-swfdec_debug_movies_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
-{
-  REPORT;
-  return swfdec_debug_movies_node_to_path (iter->user_data);
-}
-
-static void 
-swfdec_debug_movies_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter,
-    gint column, GValue *value)
-{
-  SwfdecMovie *movie = ((GNode *) iter->user_data)->data;
-
-  REPORT;
-  switch (column) {
-    case SWFDEC_DEBUG_MOVIES_COLUMN_MOVIE:
-      g_value_init (value, G_TYPE_POINTER);
-      g_value_set_pointer (value, movie);
-      return;
-    case SWFDEC_DEBUG_MOVIES_COLUMN_NAME:
-      g_value_init (value, G_TYPE_STRING);
-      if (movie->name[0])
-	g_value_set_string (value, movie->name);
-      else
-	g_value_set_string (value, movie->original_name);
-      return;
-    case SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH:
-      g_value_init (value, G_TYPE_INT);
-      g_value_set_int (value, movie->depth);
-      return;
-    case SWFDEC_DEBUG_MOVIES_COLUMN_TYPE:
-      g_value_init (value, G_TYPE_STRING);
-      /* big hack: we skip the "Swfdec" here */
-      g_value_set_string (value, G_OBJECT_TYPE_NAME (movie) + 6);
-      return;
-    default:
-      break;
-  }
-  g_assert_not_reached ();
-}
-
-static gboolean
-swfdec_debug_movies_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
-{
-  GNode *node;
-
-  REPORT;
-  node = iter->user_data;
-  node = node->next;
-  if (node == NULL)
-    return FALSE;
-  iter->user_data = node;
-  return TRUE;
-}
-
-static gboolean
-swfdec_debug_movies_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
-{
-  GNode *node;
-
-  REPORT;
-  if (parent) {
-    node = parent->user_data;
-  } else {
-    node = SWFDEC_DEBUG_MOVIES (tree_model)->root;
-  }
-  if (node->children == NULL)
-    return FALSE;
-  iter->user_data = node->children;
-  return TRUE;
-}
-
-static gboolean
-swfdec_debug_movies_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
-{
-  GtkTreeIter unused;
-
-  REPORT;
-  return swfdec_debug_movies_iter_children (tree_model, &unused, iter);
-}
-
-static gint
-swfdec_debug_movies_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
-{
-  GNode *node;
-
-  REPORT;
-  if (iter) {
-    node = iter->user_data;
-  } else {
-    node = SWFDEC_DEBUG_MOVIES (tree_model)->root;
-  }
-  return g_node_n_children (node);
-}
-
-static gboolean
-swfdec_debug_movies_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter,
-    GtkTreeIter *parent, gint n)
-{
-  GNode *node;
-
-  REPORT;
-  if (parent) {
-    node = parent->user_data;
-  } else {
-    node = SWFDEC_DEBUG_MOVIES (tree_model)->root;
-  }
-  node = g_node_nth_child (node, n);
-  if (node == NULL)
-    return FALSE;
-  iter->user_data = node;
-  return TRUE;
-}
-
-static gboolean
-swfdec_debug_movies_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
-{
-  GNode *node;
-
-  REPORT;
-  node = child->user_data;
-  node = node->parent;
-  if (node->parent == NULL)
-    return FALSE;
-  iter->user_data = node;
-  return TRUE;
-}
-
-static void
-swfdec_debug_movies_tree_model_init (GtkTreeModelIface *iface)
-{
-  iface->get_flags = swfdec_debug_movies_get_flags;
-  iface->get_n_columns = swfdec_debug_movies_get_n_columns;
-  iface->get_column_type = swfdec_debug_movies_get_column_type;
-  iface->get_iter = swfdec_debug_movies_get_iter;
-  iface->get_path = swfdec_debug_movies_get_path;
-  iface->get_value = swfdec_debug_movies_get_value;
-  iface->iter_next = swfdec_debug_movies_iter_next;
-  iface->iter_children = swfdec_debug_movies_iter_children;
-  iface->iter_has_child = swfdec_debug_movies_iter_has_child;
-  iface->iter_n_children = swfdec_debug_movies_iter_n_children;
-  iface->iter_nth_child = swfdec_debug_movies_iter_nth_child;
-  iface->iter_parent = swfdec_debug_movies_iter_parent;
-}
-
-/*** SWFDEC_DEBUG_MOVIES ***/
-
-G_DEFINE_TYPE_WITH_CODE (SwfdecDebugMovies, swfdec_debug_movies, G_TYPE_OBJECT,
-    G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, swfdec_debug_movies_tree_model_init))
-
-static int
-swfdec_debug_movies_get_index (GNode *parent, GNode *new)
-{
-  GNode *walk;
-  int i = 0;
-
-  for (walk = parent->children; walk; walk = walk->next) {
-    if (walk == new)
-      continue;
-    if (swfdec_movie_compare_depths (walk->data, new->data) < 0) {
-      i++;
-      continue;
-    }
-    break;
-  }
-  return i;
-}
-
-static void
-swfdec_debug_movies_added (SwfdecPlayer *player, SwfdecMovie *movie, SwfdecDebugMovies *movies)
-{
-  GtkTreePath *path;
-  GtkTreeIter iter;
-  GNode *node, *new;
-  int pos;
-
-  if (movie->parent) {
-    node = g_hash_table_lookup (movies->nodes, movie->parent);
-    g_assert (node);
-  } else {
-    node = movies->root;
-  }
-  new = g_node_new (movie);
-  g_hash_table_insert (movies->nodes, movie, new);
-  pos = swfdec_debug_movies_get_index (node, new);
-  g_node_insert (node, pos, new);
-  movies->stamp++;
-  iter.stamp = movies->stamp;
-  iter.user_data = new;
-  path = swfdec_debug_movies_node_to_path (new);
-  gtk_tree_model_row_inserted (GTK_TREE_MODEL (movies), path, &iter);
-  gtk_tree_path_free (path);
-}
-
-static void
-swfdec_debug_movies_movie_notify (SwfdecMovie *movie, GParamSpec *pspec, SwfdecDebugMovies *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 = swfdec_debug_movies_node_to_path (node);
-  gtk_tree_model_row_changed (GTK_TREE_MODEL (movies), path, &iter);
-  gtk_tree_path_free (path);
-}
-
-static void
-swfdec_debug_movies_removed (SwfdecPlayer *player, SwfdecMovie *movie, SwfdecDebugMovies *movies)
-{
-  GNode *node;
-  GtkTreePath *path;
-
-  node = g_hash_table_lookup (movies->nodes, movie);
-  g_hash_table_remove (movies->nodes, movie);
-  g_signal_handlers_disconnect_by_func (movie, swfdec_debug_movies_movie_notify, movies);
-  path = swfdec_debug_movies_node_to_path (node);
-  g_assert (g_node_n_children (node) == 0);
-  g_node_destroy (node);
-  gtk_tree_model_row_deleted (GTK_TREE_MODEL (movies), path);
-  gtk_tree_path_free (path);
-}
-
-static void
-swfdec_debug_movies_dispose (GObject *object)
-{
-  SwfdecDebugMovies *movies = SWFDEC_DEBUG_MOVIES (object);
-
-  g_signal_handlers_disconnect_by_func (movies->player, swfdec_debug_movies_removed, movies);
-  g_signal_handlers_disconnect_by_func (movies->player, swfdec_debug_movies_added, movies);
-  g_object_unref (movies->player);
-  g_assert (g_node_n_children (movies->root) == 0);
-  g_node_destroy (movies->root);
-  g_hash_table_destroy (movies->nodes);
-
-  G_OBJECT_CLASS (swfdec_debug_movies_parent_class)->dispose (object);
-}
-
-static void
-swfdec_debug_movies_class_init (SwfdecDebugMoviesClass *class)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-  object_class->dispose = swfdec_debug_movies_dispose;
-}
-
-static void
-swfdec_debug_movies_init (SwfdecDebugMovies *movies)
-{
-  movies->root = g_node_new (NULL);
-  movies->nodes = g_hash_table_new (g_direct_hash, g_direct_equal);
-}
-
-SwfdecDebugMovies *
-swfdec_debug_movies_new (SwfdecPlayer *player)
-{
-  SwfdecDebugMovies *movies;
-
-  movies = g_object_new (SWFDEC_TYPE_DEBUG_MOVIES, NULL);
-  movies->player = player;
-  g_object_ref (player);
-  if (SWFDEC_IS_DEBUGGER (player)) {
-    g_signal_connect (player, "movie-added", G_CALLBACK (swfdec_debug_movies_added), movies);
-    g_signal_connect (player, "movie-removed", G_CALLBACK (swfdec_debug_movies_removed), movies);
-  }
-  return movies;
-}
-
diff --git a/player/swfdec_debug_movies.h b/player/swfdec_debug_movies.h
deleted file mode 100644
index 35e92da..0000000
--- a/player/swfdec_debug_movies.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-#ifndef _SWFDEC_DEBUG_MOVIES_H_
-#define _SWFDEC_DEBUG_MOVIES_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-enum {
-  SWFDEC_DEBUG_MOVIES_COLUMN_MOVIE,
-  SWFDEC_DEBUG_MOVIES_COLUMN_NAME,
-  SWFDEC_DEBUG_MOVIES_COLUMN_DEPTH,
-  SWFDEC_DEBUG_MOVIES_COLUMN_TYPE,
-  /* add more */
-  SWFDEC_DEBUG_MOVIES_N_COLUMNS
-};
-
-typedef struct _SwfdecDebugMovies SwfdecDebugMovies;
-typedef struct _SwfdecDebugMoviesClass SwfdecDebugMoviesClass;
-
-#define SWFDEC_TYPE_DEBUG_MOVIES                    (swfdec_debug_movies_get_type())
-#define SWFDEC_IS_DEBUG_MOVIES(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DEBUG_MOVIES))
-#define SWFDEC_IS_DEBUG_MOVIES_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DEBUG_MOVIES))
-#define SWFDEC_DEBUG_MOVIES(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DEBUG_MOVIES, SwfdecDebugMovies))
-#define SWFDEC_DEBUG_MOVIES_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DEBUG_MOVIES, SwfdecDebugMoviesClass))
-
-struct _SwfdecDebugMovies
-{
-  GObject		object;
-
-  SwfdecPlayer *	player;		/* the video we play */
-  GNode *		root;		/* the root node containing all the movies */
-  int			stamp;		/* to validate tree iters */
-  GHashTable *		nodes;		/* movies => node fast lookup table */
-};
-
-struct _SwfdecDebugMoviesClass
-{
-  GObjectClass		object_class;
-};
-
-GType		swfdec_debug_movies_get_type		(void);
-
-SwfdecDebugMovies *
-		swfdec_debug_movies_new			(SwfdecPlayer *		player);
-
-
-G_END_DECLS
-#endif
diff --git a/vivified/ui/Makefile.am b/vivified/ui/Makefile.am
index 2a8ed4a..3413b4c 100644
--- a/vivified/ui/Makefile.am
+++ b/vivified/ui/Makefile.am
@@ -8,10 +8,12 @@ vivified_LDADD = \
 
 vivified_SOURCES = \
 	vivi_commandline.c \
+	vivi_movie_list.c \
 	vivi_player.c \
 	main.c
 
 noinst_HEADERS = \
 	vivi_commandline.h \
+	vivi_movie_list.h \
 	vivi_player.h
 
diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
new file mode 100644
index 0000000..7178a32
--- /dev/null
+++ b/vivified/ui/vivi_movie_list.c
@@ -0,0 +1,379 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, to_string to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_player_internal.h>
+#include "vivi_movie_list.h"
+
+/*** GTK_TREE_MODEL ***/
+
+#if 0
+#  define REPORT g_print ("%s\n", G_STRFUNC)
+#else
+#  define REPORT 
+#endif
+static GtkTreeModelFlags 
+vivi_movie_list_get_flags (GtkTreeModel *tree_model)
+{
+  REPORT;
+  return 0;
+}
+
+static gint
+vivi_movie_list_get_n_columns (GtkTreeModel *tree_model)
+{
+  REPORT;
+  return VIVI_MOVIE_LIST_N_COLUMNS;
+}
+
+static GType
+vivi_movie_list_get_column_type (GtkTreeModel *tree_model, gint index_)
+{
+  REPORT;
+  switch (index_) {
+    case VIVI_MOVIE_LIST_COLUMN_MOVIE:
+      return G_TYPE_POINTER;
+    case VIVI_MOVIE_LIST_COLUMN_NAME:
+      return G_TYPE_STRING;
+    case VIVI_MOVIE_LIST_COLUMN_DEPTH:
+      return G_TYPE_INT;
+    case VIVI_MOVIE_LIST_COLUMN_TYPE:
+      return G_TYPE_STRING;
+    default:
+      break;
+  }
+  g_assert_not_reached ();
+  return G_TYPE_NONE;
+}
+
+static gboolean
+vivi_movie_list_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
+{
+  ViviMovieList *movies = VIVI_MOVIE_LIST (tree_model);
+  GNode *node;
+  guint i, depth;
+  int *indices;
+
+  REPORT;
+  depth = gtk_tree_path_get_depth (path);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices == NULL)
+    return FALSE;
+  node = movies->root;
+  for (i = 0; i < depth; i++) {
+    node = g_node_nth_child (node, indices[i]);
+    if (node == NULL)
+      return FALSE;
+  }
+  iter->user_data = node;
+  iter->stamp = movies->stamp;
+  return TRUE;
+}
+
+static GtkTreePath *
+vivi_movie_list_node_to_path (GNode *node)
+{
+  GtkTreePath *path;
+
+  path = gtk_tree_path_new ();
+  while (node->parent != NULL) {
+    gtk_tree_path_prepend_index (path, g_node_child_position (node->parent, node));
+    node = node->parent;
+  }
+  return path;
+}
+
+static GtkTreePath *
+vivi_movie_list_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+  REPORT;
+  return vivi_movie_list_node_to_path (iter->user_data);
+}
+
+static void 
+vivi_movie_list_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter,
+    gint column, GValue *value)
+{
+  SwfdecMovie *movie = ((GNode *) iter->user_data)->data;
+
+  REPORT;
+  switch (column) {
+    case VIVI_MOVIE_LIST_COLUMN_MOVIE:
+      g_value_init (value, G_TYPE_POINTER);
+      g_value_set_pointer (value, movie);
+      return;
+    case VIVI_MOVIE_LIST_COLUMN_NAME:
+      g_value_init (value, G_TYPE_STRING);
+      if (movie->name[0])
+	g_value_set_string (value, movie->name);
+      else
+	g_value_set_string (value, movie->original_name);
+      return;
+    case VIVI_MOVIE_LIST_COLUMN_DEPTH:
+      g_value_init (value, G_TYPE_INT);
+      g_value_set_int (value, movie->depth);
+      return;
+    case VIVI_MOVIE_LIST_COLUMN_TYPE:
+      g_value_init (value, G_TYPE_STRING);
+      /* big hack: we skip the "Swfdec" here */
+      g_value_set_string (value, G_OBJECT_TYPE_NAME (movie) + 6);
+      return;
+    default:
+      break;
+  }
+  g_assert_not_reached ();
+}
+
+static gboolean
+vivi_movie_list_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+  GNode *node;
+
+  REPORT;
+  node = iter->user_data;
+  node = node->next;
+  if (node == NULL)
+    return FALSE;
+  iter->user_data = node;
+  return TRUE;
+}
+
+static gboolean
+vivi_movie_list_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
+{
+  GNode *node;
+
+  REPORT;
+  if (parent) {
+    node = parent->user_data;
+  } else {
+    node = VIVI_MOVIE_LIST (tree_model)->root;
+  }
+  if (node->children == NULL)
+    return FALSE;
+  iter->user_data = node->children;
+  return TRUE;
+}
+
+static gboolean
+vivi_movie_list_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+  GtkTreeIter unused;
+
+  REPORT;
+  return vivi_movie_list_iter_children (tree_model, &unused, iter);
+}
+
+static gint
+vivi_movie_list_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
+{
+  GNode *node;
+
+  REPORT;
+  if (iter) {
+    node = iter->user_data;
+  } else {
+    node = VIVI_MOVIE_LIST (tree_model)->root;
+  }
+  return g_node_n_children (node);
+}
+
+static gboolean
+vivi_movie_list_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter,
+    GtkTreeIter *parent, gint n)
+{
+  GNode *node;
+
+  REPORT;
+  if (parent) {
+    node = parent->user_data;
+  } else {
+    node = VIVI_MOVIE_LIST (tree_model)->root;
+  }
+  node = g_node_nth_child (node, n);
+  if (node == NULL)
+    return FALSE;
+  iter->user_data = node;
+  return TRUE;
+}
+
+static gboolean
+vivi_movie_list_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
+{
+  GNode *node;
+
+  REPORT;
+  node = child->user_data;
+  node = node->parent;
+  if (node->parent == NULL)
+    return FALSE;
+  iter->user_data = node;
+  return TRUE;
+}
+
+static void
+vivi_movie_list_tree_model_init (GtkTreeModelIface *iface)
+{
+  iface->get_flags = vivi_movie_list_get_flags;
+  iface->get_n_columns = vivi_movie_list_get_n_columns;
+  iface->get_column_type = vivi_movie_list_get_column_type;
+  iface->get_iter = vivi_movie_list_get_iter;
+  iface->get_path = vivi_movie_list_get_path;
+  iface->get_value = vivi_movie_list_get_value;
+  iface->iter_next = vivi_movie_list_iter_next;
+  iface->iter_children = vivi_movie_list_iter_children;
+  iface->iter_has_child = vivi_movie_list_iter_has_child;
+  iface->iter_n_children = vivi_movie_list_iter_n_children;
+  iface->iter_nth_child = vivi_movie_list_iter_nth_child;
+  iface->iter_parent = vivi_movie_list_iter_parent;
+}
+
+/*** VIVI_MOVIE_LIST ***/
+
+G_DEFINE_TYPE_WITH_CODE (ViviMovieList, vivi_movie_list, G_TYPE_OBJECT,
+    G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, vivi_movie_list_tree_model_init))
+
+static int
+vivi_movie_list_get_index (GNode *parent, GNode *new)
+{
+  GNode *walk;
+  int i = 0;
+
+  for (walk = parent->children; walk; walk = walk->next) {
+    if (walk == new)
+      continue;
+    if (swfdec_movie_compare_depths (walk->data, new->data) < 0) {
+      i++;
+      continue;
+    }
+    break;
+  }
+  return i;
+}
+
+static void
+vivi_movie_list_added (SwfdecPlayer *player, SwfdecMovie *movie, ViviMovieList *movies)
+{
+  GtkTreePath *path;
+  GtkTreeIter iter;
+  GNode *node, *new;
+  int pos;
+
+  if (movie->parent) {
+    node = g_hash_table_lookup (movies->nodes, movie->parent);
+    g_assert (node);
+  } else {
+    node = movies->root;
+  }
+  new = g_node_new (movie);
+  g_hash_table_insert (movies->nodes, movie, new);
+  pos = vivi_movie_list_get_index (node, new);
+  g_node_insert (node, pos, new);
+  movies->stamp++;
+  iter.stamp = movies->stamp;
+  iter.user_data = new;
+  path = vivi_movie_list_node_to_path (new);
+  gtk_tree_model_row_inserted (GTK_TREE_MODEL (movies), path, &iter);
+  gtk_tree_path_free (path);
+}
+
+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_removed (SwfdecPlayer *player, SwfdecMovie *movie, ViviMovieList *movies)
+{
+  GNode *node;
+  GtkTreePath *path;
+
+  node = g_hash_table_lookup (movies->nodes, movie);
+  g_hash_table_remove (movies->nodes, movie);
+  g_signal_handlers_disconnect_by_func (movie, vivi_movie_list_movie_notify, movies);
+  path = vivi_movie_list_node_to_path (node);
+  g_assert (g_node_n_children (node) == 0);
+  g_node_destroy (node);
+  gtk_tree_model_row_deleted (GTK_TREE_MODEL (movies), path);
+  gtk_tree_path_free (path);
+}
+
+static void
+vivi_movie_list_dispose (GObject *object)
+{
+  ViviMovieList *movies = VIVI_MOVIE_LIST (object);
+
+  g_signal_handlers_disconnect_by_func (movies->player, vivi_movie_list_removed, movies);
+  g_signal_handlers_disconnect_by_func (movies->player, vivi_movie_list_added, movies);
+  g_object_unref (movies->player);
+  g_assert (g_node_n_children (movies->root) == 0);
+  g_node_destroy (movies->root);
+  g_hash_table_destroy (movies->nodes);
+
+  G_OBJECT_CLASS (vivi_movie_list_parent_class)->dispose (object);
+}
+
+static void
+vivi_movie_list_class_init (ViviMovieListClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->dispose = vivi_movie_list_dispose;
+}
+
+static void
+vivi_movie_list_init (ViviMovieList *movies)
+{
+  movies->root = g_node_new (NULL);
+  movies->nodes = g_hash_table_new (g_direct_hash, g_direct_equal);
+}
+
+ViviMovieList *
+vivi_movie_list_new (SwfdecPlayer *player)
+{
+  ViviMovieList *movies;
+
+  movies = g_object_new (VIVI_TYPE_MOVIE_LIST, NULL);
+  movies->player = player;
+  g_object_ref (player);
+  g_signal_connect (player, "movie-added", G_CALLBACK (vivi_movie_list_added), movies);
+  g_signal_connect (player, "movie-removed", G_CALLBACK (vivi_movie_list_removed), movies);
+  return movies;
+}
+
diff --git a/vivified/ui/vivi_movie_list.h b/vivified/ui/vivi_movie_list.h
new file mode 100644
index 0000000..eaa7eb6
--- /dev/null
+++ b/vivified/ui/vivi_movie_list.h
@@ -0,0 +1,66 @@
+/* Vivi
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#include <libswfdec/swfdec.h>
+
+#ifndef _VIVI_MOVIE_LIST_H_
+#define _VIVI_MOVIE_LIST_H_
+
+G_BEGIN_DECLS
+
+enum {
+  VIVI_MOVIE_LIST_COLUMN_MOVIE,
+  VIVI_MOVIE_LIST_COLUMN_NAME,
+  VIVI_MOVIE_LIST_COLUMN_DEPTH,
+  VIVI_MOVIE_LIST_COLUMN_TYPE,
+  /* add more */
+  VIVI_MOVIE_LIST_N_COLUMNS
+};
+
+typedef struct _ViviMovieList ViviMovieList;
+typedef struct _ViviMovieListClass ViviMovieListClass;
+
+#define VIVI_TYPE_MOVIE_LIST                    (vivi_movie_list_get_type())
+#define VIVI_IS_MOVIE_LIST(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIVI_TYPE_MOVIE_LIST))
+#define VIVI_IS_MOVIE_LIST_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), VIVI_TYPE_MOVIE_LIST))
+#define VIVI_MOVIE_LIST(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIVI_TYPE_MOVIE_LIST, ViviMovieList))
+#define VIVI_MOVIE_LIST_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), VIVI_TYPE_MOVIE_LIST, ViviMovieListClass))
+
+struct _ViviMovieList
+{
+  GObject		object;
+
+  SwfdecPlayer *	player;		/* the video we play */
+  GNode *		root;		/* the root node containing all the movies */
+  int			stamp;		/* to validate tree iters */
+  GHashTable *		nodes;		/* movies => node fast lookup table */
+};
+
+struct _ViviMovieListClass
+{
+  GObjectClass		object_class;
+};
+
+GType		vivi_movie_list_get_type		(void);
+
+ViviMovieList *	vivi_movie_list_new			(SwfdecPlayer *		player);
+
+
+G_END_DECLS
+#endif
diff-tree 7c412eac2ef2b94b8419b0002ec5f253f47ba038 (from 85702bb6de0af42a70cd4dccda70c5f4d6cd33fc)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Aug 17 21:24:45 2007 +0200

    add toString () for breakpoints

diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index 93c1ecf..964f5b3 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -37,6 +37,9 @@ Breakpoint = function () extends Native.
 };
 Breakpoint.list = new Array ();
 Breakpoint.prototype.addProperty ("active", Native.breakpoint_active_get, Native.breakpoint_active_set);
+Breakpoint.prototype.toString = function () {
+  return "user-defined breakpoint";
+};
 
 /*** information about the player ***/
 


More information about the Swfdec mailing list