[Swfdec] Branch 'vivi' - 10 commits - libswfdec/swfdec_button_movie.c libswfdec/swfdec_movie.c libswfdec/swfdec_player.c vivified/core vivified/dock vivified/ui

Benjamin Otte company at kemper.freedesktop.org
Tue Aug 21 14:29:49 PDT 2007


 libswfdec/swfdec_button_movie.c  |    9 +++++++-
 libswfdec/swfdec_movie.c         |    1 
 libswfdec/swfdec_player.c        |    2 -
 vivified/core/vivi_application.c |    4 +++
 vivified/core/vivi_initialize.as |    1 
 vivified/core/vivi_player_as.c   |   25 ++++++++++++++++++++++++
 vivified/dock/vivi_vdock.c       |    2 -
 vivified/ui/Makefile.am          |    1 
 vivified/ui/main.c               |   19 ++++++++++++++----
 vivified/ui/vivi_movie_list.c    |   33 ++++++++++++++++++++++++++------
 vivified/ui/vivi_movie_list.h    |    2 -
 vivified/ui/vivi_movies.c        |   40 +++++++++++++++++++++++++++++++++++++++
 vivified/ui/vivi_movies.xml      |   38 +++++++++++++++++++++++++++++++++++++
 13 files changed, 163 insertions(+), 14 deletions(-)

New commits:
diff-tree 8ff61bf0eec2a7f45c5e4eabd558a8db899b489c (from 4c236240442cdbb060e83af8540ef6e9253a06d3)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:55:00 2007 +0200

    add a movies list on the left

diff --git a/vivified/ui/Makefile.am b/vivified/ui/Makefile.am
index 2d492c7..c88facd 100644
--- a/vivified/ui/Makefile.am
+++ b/vivified/ui/Makefile.am
@@ -9,6 +9,7 @@ vivified_LDADD = \
 vivified_SOURCES = \
 	vivi_command_line.c \
 	vivi_movie_list.c \
+	vivi_movies.c \
 	vivi_player.c \
 	vivi_vivi_docklet.c \
 	main.c
diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 8ca2e4b..f497e32 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -58,7 +58,7 @@ set_title (ViviApplication *app, GParamS
 static void
 setup (const char *filename, const char *variables)
 {
-  GtkWidget *window, *box, *widget;
+  GtkWidget *window, *box, *paned, *widget;
   ViviApplication *app;
   GtkBuilder *builder;
   GError *error = NULL;
@@ -69,17 +69,22 @@ setup (const char *filename, const char 
 
   builder = gtk_builder_new ();
   if (!gtk_builder_add_from_file (builder, "vivi_player.xml", &error) ||
-      !gtk_builder_add_from_file (builder, "vivi_command_line.xml", &error))
+      !gtk_builder_add_from_file (builder, "vivi_command_line.xml", &error) ||
+      !gtk_builder_add_from_file (builder, "vivi_movies.xml", &error))
     g_error ("%s", error->message);
   gtk_builder_connect_signals (builder, app);
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_default_size (GTK_WINDOW (window), 400, 450);
+  gtk_window_set_default_size (GTK_WINDOW (window), 600, 450);
   g_signal_connect_swapped (app, "notify::quit", G_CALLBACK (gtk_widget_destroy), window);
   g_signal_connect (app, "notify::filename", G_CALLBACK (set_title), window);
   set_title (app, NULL, GTK_WINDOW (window));
+  paned = gtk_hpaned_new ();
+  gtk_paned_set_position (GTK_PANED (paned), 200);
+  gtk_container_add (GTK_CONTAINER (window), paned);
+
   box = vivi_vdock_new ();
-  gtk_container_add (GTK_CONTAINER (window), box);
+  gtk_paned_add2 (GTK_PANED (paned), box);
   widget = GTK_WIDGET (gtk_builder_get_object (builder, "player"));
   g_object_set (widget, "application", app, NULL);
   vivi_vdock_add (VIVI_VDOCK (box), widget);
@@ -88,6 +93,12 @@ setup (const char *filename, const char 
   vivi_vdock_add (VIVI_VDOCK (box), widget);
   gtk_container_foreach (GTK_CONTAINER (widget), try_grab_focus, NULL);
 
+  box = vivi_vdock_new ();
+  gtk_paned_add1 (GTK_PANED (paned), box);
+  widget = GTK_WIDGET (gtk_builder_get_object (builder, "movies"));
+  g_object_set (widget, "application", app, NULL);
+  vivi_vdock_add (VIVI_VDOCK (box), widget);
+
   g_signal_connect (window, "delete-event", G_CALLBACK (delete_event), app);
   g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), app);
   gtk_widget_show_all (window);
diff --git a/vivified/ui/vivi_movies.c b/vivified/ui/vivi_movies.c
new file mode 100644
index 0000000..a4c8e37
--- /dev/null
+++ b/vivified/ui/vivi_movies.c
@@ -0,0 +1,40 @@
+/* Vivified
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <libswfdec-gtk/swfdec-gtk.h>
+#include "vivi_vivi_docklet.h"
+#include "vivi_movie_list.h"
+
+void
+vivi_movies_application_set (ViviViviDocklet *docklet, ViviApplication *app);
+void
+vivi_movies_application_set (ViviViviDocklet *docklet, ViviApplication *app)
+{
+  GtkWidget *view = vivi_vivi_docklet_find_widget_by_type (docklet, GTK_TYPE_TREE_VIEW);
+  GtkTreeModel *model;
+
+  model = vivi_movie_list_new (app);
+  gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
+  g_object_unref (model);
+}
+
diff --git a/vivified/ui/vivi_movies.xml b/vivified/ui/vivi_movies.xml
new file mode 100644
index 0000000..47f1bdf
--- /dev/null
+++ b/vivified/ui/vivi_movies.xml
@@ -0,0 +1,38 @@
+<interface>
+  <object class="ViviViviDocklet" id="movies">
+    <property name="title">Movies</property>
+    <signal name="application-set" handler="vivi_movies_application_set" />
+    <child>
+      <object class="GtkScrolledWindow" id="1">
+	<property name="hscrollbar-policy">automatic</property>
+	<property name="vscrollbar-policy">automatic</property>
+	<child>
+	  <object class="GtkTreeView" id="x">
+	    <child>
+	      <object class="GtkTreeViewColumn" id="x">
+		<property name="title">Movie</property>
+		<child>
+		  <object class="GtkCellRendererText" id="x"/>
+		  <attributes>
+		    <attribute name="text">1</attribute>
+		  </attributes>
+		</child>
+	      </object>
+	    </child>
+	    <child>
+	      <object class="GtkTreeViewColumn" id="x">
+		<property name="title">Depth</property>
+		<child>
+		  <object class="GtkCellRendererText" id="x"/>
+		  <attributes>
+		    <attribute name="text">2</attribute>
+		  </attributes>
+		</child>
+	      </object>
+	    </child>
+	  </object>
+	</child>
+      </object>
+    </child>
+  </object>
+</interface>
diff-tree 4c236240442cdbb060e83af8540ef6e9253a06d3 (from cd57b9ab579ac803f64b351459380fb749daaa0f)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:54:41 2007 +0200

    create the path before destroying the node

diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
index 7cca226..2ac4104 100644
--- a/vivified/ui/vivi_movie_list.c
+++ b/vivified/ui/vivi_movie_list.c
@@ -347,8 +347,8 @@ vivi_movie_list_removed (ViviDebugger *d
   if (node == NULL)
     return FALSE;
   vivi_movie_list_remove_node (movies, node);
-  g_node_destroy (node);
   path = vivi_movie_list_node_to_path (node);
+  g_node_destroy (node);
   gtk_tree_model_row_deleted (GTK_TREE_MODEL (movies), path);
   gtk_tree_path_free (path);
   return FALSE;
diff-tree cd57b9ab579ac803f64b351459380fb749daaa0f (from 1c017203cce97b97487e8513c645f9c6fe8b24e4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:53:56 2007 +0200

    add a Player.sound property so disabling sound is possible
    
    It's incredibly useful in valgrind

diff --git a/vivified/core/vivi_initialize.as b/vivified/core/vivi_initialize.as
index 68c4c09..8245fb1 100644
--- a/vivified/core/vivi_initialize.as
+++ b/vivified/core/vivi_initialize.as
@@ -49,6 +49,7 @@ Player = {};
 Player.addProperty ("filename", Native.player_filename_get, Native.player_filename_set);
 Player.addProperty ("frame", Native.player_frame_get, null);
 Player.addProperty ("global", Native.player_global_get, null);
+Player.addProperty ("sound", Native.player_sound_get, Native.player_sound_set);
 Player.addProperty ("variables", Native.player_variables_get, Native.player_variables_set);
 
 /*** commands available for debugging ***/
diff --git a/vivified/core/vivi_player_as.c b/vivified/core/vivi_player_as.c
index c7e36ad..4552cd4 100644
--- a/vivified/core/vivi_player_as.c
+++ b/vivified/core/vivi_player_as.c
@@ -24,6 +24,7 @@
 #include "vivi_wrap.h"
 #include "vivi_application.h"
 #include "vivi_function.h"
+#include <libswfdec-gtk/swfdec-gtk.h>
 
 VIVI_FUNCTION ("player_frame_get", vivi_player_as_frame_get)
 void
@@ -105,3 +106,27 @@ vivi_player_as_global_get (SwfdecAsConte
   }
 }
 
+VIVI_FUNCTION ("player_sound_get", vivi_player_as_sound_get)
+void
+vivi_player_as_sound_get (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  
+  SWFDEC_AS_VALUE_SET_BOOLEAN (retval,
+      swfdec_gtk_player_get_audio_enabled (SWFDEC_GTK_PLAYER (app->player)));
+}
+
+VIVI_FUNCTION ("player_sound_set", vivi_player_as_sound_set)
+void
+vivi_player_as_sound_set (SwfdecAsContext *cx, SwfdecAsObject *this,
+    guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  ViviApplication *app = VIVI_APPLICATION (cx);
+  
+  if (argc == 0)
+    return;
+  swfdec_gtk_player_set_audio_enabled (SWFDEC_GTK_PLAYER (app->player),
+      swfdec_as_value_to_boolean (cx, &argv[0]));
+}
+
diff-tree 1c017203cce97b97487e8513c645f9c6fe8b24e4 (from 913c4a3ab5636a3864733de41909cef0c847a52a)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:53:01 2007 +0200

    save the sound enabled state across resets

diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index b7f3b9f..19be22d 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -179,12 +179,16 @@ vivi_application_init_player (ViviApplic
 void
 vivi_application_reset (ViviApplication *app)
 {
+  gboolean audio;
+
   g_return_if_fail (VIVI_IS_APPLICATION (app));
 
   if (app->loop != NULL)
     g_main_loop_quit (app->loop);
+  audio = swfdec_gtk_player_get_audio_enabled (SWFDEC_GTK_PLAYER (app->player));
   g_object_unref (app->player);
   app->player = swfdec_gtk_player_new (SWFDEC_AS_DEBUGGER (app->debugger));
+  swfdec_gtk_player_set_audio_enabled (SWFDEC_GTK_PLAYER (app->player), audio);
   app->player_inited = FALSE;
   g_object_notify (G_OBJECT (app), "player");
 }
diff-tree 913c4a3ab5636a3864733de41909cef0c847a52a (from e0014e23b2e4e34f777eeeb8bf5001af8cdd3ce5)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:49:48 2007 +0200

    improve the assertion message

diff --git a/libswfdec/swfdec_button_movie.c b/libswfdec/swfdec_button_movie.c
index b48c746..c6d5b3c 100644
--- a/libswfdec/swfdec_button_movie.c
+++ b/libswfdec/swfdec_button_movie.c
@@ -171,7 +171,14 @@ swfdec_button_movie_change_mouse (Swfdec
 		     [(movie->mouse_in ? 2 : 0) + movie->mouse_button]
 		     [(mouse_in ? 2 : 0) + button];
 
-  g_assert (event != (guint) -1);
+#ifndef G_DISABLE_ASSERT
+  if (event == (guint) -1) {
+    g_error ("Unhandled event for %s: %u => %u",
+	movie->button->menubutton ? "menu" : "button",
+	(movie->mouse_in ? 2 : 0) + movie->mouse_button,
+	(mouse_in ? 2 : 0) + button);
+  }
+#endif
   if (event != 0) {
     SWFDEC_LOG ("emitting event for condition %u", event);
     swfdec_button_movie_execute (movie, event);
diff-tree e0014e23b2e4e34f777eeeb8bf5001af8cdd3ce5 (from 268e7076b34235aac77568686c29cc49c127171e)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:49:34 2007 +0200

    mark the original name, too

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 420c508..6a03bd1 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -794,6 +794,7 @@ swfdec_movie_mark (SwfdecAsObject *objec
   SwfdecMovie *movie = SWFDEC_MOVIE (object);
   GList *walk;
 
+  swfdec_as_string_mark (movie->original_name);
   swfdec_as_string_mark (movie->name);
   for (walk = movie->list; walk; walk = walk->next) {
     swfdec_as_object_mark (walk->data);
diff-tree 268e7076b34235aac77568686c29cc49c127171e (from 27da7a35529646e527d6430f7372f2535c66d623)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 22:04:37 2007 +0200

    print log message before executing action
    
    reason: the action can add new actions and this may invalidate the memory used
    by action. So we cannot print a debugging message with that data later

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index fa6eaab..1f9b2a3 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -309,9 +309,9 @@ swfdec_player_do_action (SwfdecPlayer *p
       return FALSE;
   } while (action->object == NULL); /* skip removed actions */
 
-  action->func (action->object, action->data);
   SWFDEC_LOG ("executing action %p %p %p", 
       action->object, action->func, action->data);
+  action->func (action->object, action->data);
 
   return TRUE;
 }
diff-tree 27da7a35529646e527d6430f7372f2535c66d623 (from 9a9bfa3d15f91d15beca8e7e926872029d1bae86)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 19:51:39 2007 +0200

    more fixes for disposing

diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
index 9177121..7cca226 100644
--- a/vivified/ui/vivi_movie_list.c
+++ b/vivified/ui/vivi_movie_list.c
@@ -329,9 +329,9 @@ vivi_movie_list_remove_node (ViviMovieLi
 
   for (walk = node->children; walk; walk = walk->next) {
     vivi_movie_list_remove_node (movies, walk);
-    g_hash_table_remove (movies->nodes, walk->data);
-    g_signal_handlers_disconnect_by_func (walk->data, vivi_movie_list_movie_notify, movies);
   }
+  g_hash_table_remove (movies->nodes, node->data);
+  g_signal_handlers_disconnect_by_func (node->data, vivi_movie_list_movie_notify, movies);
 }
 
 static gboolean
@@ -359,14 +359,21 @@ vivi_movie_list_dispose (GObject *object
 {
   ViviMovieList *movies = VIVI_MOVIE_LIST (object);
   ViviDebugger *debugger;
+  GNode *walk;
 
   debugger = movies->app->debugger;
   g_signal_handlers_disconnect_by_func (debugger, vivi_movie_list_removed, movies);
   g_signal_handlers_disconnect_by_func (debugger, vivi_movie_list_added, movies);
   g_object_unref (movies->app);
-  g_assert (g_node_n_children (movies->root) == 0);
+  for (walk = movies->root->children; walk; walk = walk->next) {
+    vivi_movie_list_remove_node (movies, walk);
+  }
   g_node_destroy (movies->root);
-  g_assert (g_hash_table_size (movies->nodes) == 0);
+#ifndef G_DISABLE_ASSERT
+  if (g_hash_table_size (movies->nodes) != 0) {
+    g_error ("%u items left in hash table", g_hash_table_size (movies->nodes));
+  }
+#endif
   g_hash_table_destroy (movies->nodes);
 
   G_OBJECT_CLASS (vivi_movie_list_parent_class)->dispose (object);
diff-tree 9a9bfa3d15f91d15beca8e7e926872029d1bae86 (from 317e8a19139a3dbf3ee2e291f7b5795bea7c2eb4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 15:14:34 2007 +0200

    various bug fixes
    
    - crashers on removing
    - API: return a tree model from new()

diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
index 7a4ddef..9177121 100644
--- a/vivified/ui/vivi_movie_list.c
+++ b/vivified/ui/vivi_movie_list.c
@@ -322,6 +322,18 @@ vivi_movie_list_movie_notify (SwfdecMovi
   gtk_tree_path_free (path);
 }
 
+static void
+vivi_movie_list_remove_node (ViviMovieList *movies, GNode *node)
+{
+  GNode *walk;
+
+  for (walk = node->children; walk; walk = walk->next) {
+    vivi_movie_list_remove_node (movies, walk);
+    g_hash_table_remove (movies->nodes, walk->data);
+    g_signal_handlers_disconnect_by_func (walk->data, vivi_movie_list_movie_notify, movies);
+  }
+}
+
 static gboolean
 vivi_movie_list_removed (ViviDebugger *debugger, SwfdecAsObject *object, ViviMovieList *movies)
 {
@@ -331,11 +343,12 @@ vivi_movie_list_removed (ViviDebugger *d
   if (!SWFDEC_IS_MOVIE (object))
     return FALSE;
   node = g_hash_table_lookup (movies->nodes, object);
-  g_hash_table_remove (movies->nodes, object);
-  g_signal_handlers_disconnect_by_func (object, vivi_movie_list_movie_notify, movies);
-  path = vivi_movie_list_node_to_path (node);
-  g_assert (g_node_n_children (node) == 0);
+  /* happens when parent was already removed */
+  if (node == NULL)
+    return FALSE;
+  vivi_movie_list_remove_node (movies, node);
   g_node_destroy (node);
+  path = vivi_movie_list_node_to_path (node);
   gtk_tree_model_row_deleted (GTK_TREE_MODEL (movies), path);
   gtk_tree_path_free (path);
   return FALSE;
@@ -353,6 +366,7 @@ vivi_movie_list_dispose (GObject *object
   g_object_unref (movies->app);
   g_assert (g_node_n_children (movies->root) == 0);
   g_node_destroy (movies->root);
+  g_assert (g_hash_table_size (movies->nodes) == 0);
   g_hash_table_destroy (movies->nodes);
 
   G_OBJECT_CLASS (vivi_movie_list_parent_class)->dispose (object);
@@ -373,7 +387,7 @@ vivi_movie_list_init (ViviMovieList *mov
   movies->nodes = g_hash_table_new (g_direct_hash, g_direct_equal);
 }
 
-ViviMovieList *
+GtkTreeModel *
 vivi_movie_list_new (ViviApplication *app)
 {
   ViviMovieList *movies;
@@ -385,6 +399,6 @@ vivi_movie_list_new (ViviApplication *ap
   debugger = app->debugger;
   g_signal_connect (debugger, "add", G_CALLBACK (vivi_movie_list_added), movies);
   g_signal_connect (debugger, "remove", G_CALLBACK (vivi_movie_list_removed), movies);
-  return movies;
+  return GTK_TREE_MODEL (movies);
 }
 
diff --git a/vivified/ui/vivi_movie_list.h b/vivified/ui/vivi_movie_list.h
index ddd4a81..a030549 100644
--- a/vivified/ui/vivi_movie_list.h
+++ b/vivified/ui/vivi_movie_list.h
@@ -59,7 +59,7 @@ struct _ViviMovieListClass
 
 GType		vivi_movie_list_get_type		(void);
 
-ViviMovieList *	vivi_movie_list_new			(ViviApplication *	app);
+GtkTreeModel *	vivi_movie_list_new			(ViviApplication *	app);
 
 
 G_END_DECLS
diff-tree 317e8a19139a3dbf3ee2e291f7b5795bea7c2eb4 (from 3e6829af094100400d58f5540f3c13d7f6d7f63a)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Aug 21 15:13:10 2007 +0200

    make adding a third item work

diff --git a/vivified/dock/vivi_vdock.c b/vivified/dock/vivi_vdock.c
index f79cb2d..a7a4b34 100644
--- a/vivified/dock/vivi_vdock.c
+++ b/vivified/dock/vivi_vdock.c
@@ -92,7 +92,7 @@ vivi_vdock_add (ViviVDock *vdock, GtkWid
     if (parent == (GtkWidget *) vdock) {
       gtk_container_add (GTK_CONTAINER (vdock), paned);
     } else {
-      gtk_paned_pack1 (GTK_PANED (parent), paned, TRUE, FALSE);
+      gtk_paned_pack2 (GTK_PANED (parent), paned, TRUE, FALSE);
     }
   }
   vdock->docklets = g_list_prepend (vdock->docklets, widget);


More information about the Swfdec mailing list