gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10569: Wide-ranging but generally m


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10569: Wide-ranging but generally minor changes to align interfaces and documentation,
Date: Wed, 11 Feb 2009 16:28:11 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10569
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-02-11 16:28:11 +0100
message:
  Wide-ranging but generally minor changes to align interfaces and 
documentation,
  move local functions out of class definitions, clean up GTK code and make
  variable names shorter to reduce the number of very long lines, and
  make access route to VM simpler.
modified:
  gui/Player.cpp
  gui/Player.h
  gui/fltk.cpp
  gui/fltksup.h
  gui/gtk.cpp
  gui/gtksup.h
  gui/gui.cpp
  gui/gui.h
  libbase/IOChannel.cpp
  libbase/IOChannel.h
  libbase/curl_adapter.cpp
  libbase/noseek_fd_adapter.cpp
  libbase/tu_file.cpp
  libbase/tu_file.h
  libbase/zlib_adapter.cpp
  libcore/CharacterProxy.h
  libcore/DisplayList.cpp
  libcore/LoadVariablesThread.cpp
  libcore/MovieClip.cpp
  libcore/Property.cpp
  libcore/PropertyList.cpp
  libcore/PropertyList.h
  libcore/SWFStream.cpp
  libcore/TextField.cpp
  libcore/as_function.cpp
  libcore/as_object.cpp
  libcore/as_object.h
  libcore/as_value.h
  libcore/asobj/ClassHierarchy.cpp
  libcore/asobj/Global.cpp
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/LoadableObject.cpp
  libcore/asobj/Math_as.cpp
  libcore/asobj/NetConnection_as.cpp
  libcore/asobj/Object.cpp
  libcore/asobj/SharedObject_as.cpp
  libcore/asobj/XMLSocket_as.cpp
  libcore/impl.cpp
  libcore/movie_root.h
  libcore/parser/SWFMovieDefinition.cpp
  libcore/parser/SWFMovieDefinition.h
  libcore/swf/tag_loaders.cpp
  libcore/swf_function.cpp
  libcore/vm/ASHandlers.cpp
  libcore/vm/ExecutableCode.h
  libcore/vm/Machine.cpp
  libcore/vm/action.cpp
  libcore/vm/fn_call.h
  libmedia/FLVParser.cpp
  plugin/plugin.cpp
  testsuite/libbase/CurlStreamTest.cpp
  testsuite/libcore.all/PropertyListTest.cpp
  testsuite/libcore.all/StreamTest.cpp
    ------------------------------------------------------------
    revno: 10567.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 08:43:48 +0100
    message:
      Indentation.
    modified:
      libcore/SWFStream.cpp
      libcore/parser/SWFMovieDefinition.cpp
      plugin/plugin.cpp
    ------------------------------------------------------------
    revno: 10567.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 12:33:38 +0100
    message:
      Make IOChannel implementations reflect the documentation more. Drop
      error codes for a boolean bad(). Use streamsize for bytes written to / 
read
      from streams, streampos for positions, and size_t for stream size, which
      is logically correct, consistent, and reduces unnecessary casting.
      
      Silence plugin debugging again.
      
      consumeInput() should also apparently update bytesTotal.
    modified:
      libbase/IOChannel.cpp
      libbase/IOChannel.h
      libbase/curl_adapter.cpp
      libbase/noseek_fd_adapter.cpp
      libbase/tu_file.cpp
      libbase/tu_file.h
      libbase/zlib_adapter.cpp
      libcore/LoadVariablesThread.cpp
      libcore/SWFStream.cpp
      libcore/asobj/NetConnection_as.cpp
      libcore/impl.cpp
      libcore/parser/SWFMovieDefinition.cpp
      libcore/parser/SWFMovieDefinition.h
      libcore/swf/tag_loaders.cpp
      libmedia/FLVParser.cpp
      plugin/plugin.cpp
      testsuite/libbase/CurlStreamTest.cpp
      testsuite/libcore.all/StreamTest.cpp
    ------------------------------------------------------------
    revno: 10567.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 13:23:27 +0100
    message:
      Minor refactoring and formatting.
    modified:
      libcore/parser/SWFMovieDefinition.cpp
      libcore/parser/SWFMovieDefinition.h
    ------------------------------------------------------------
    revno: 10567.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 13:26:18 +0100
    message:
      Add TODO.
    modified:
      libcore/parser/SWFMovieDefinition.cpp
    ------------------------------------------------------------
    revno: 10567.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 15:04:14 +0100
    message:
      Reduce VM singleton use, drop unused step/jump menu methods because they
      use VM::get() and are all disabled.
    modified:
      gui/Player.cpp
      gui/Player.h
      gui/fltk.cpp
      gui/fltksup.h
      gui/gtk.cpp
      gui/gtksup.h
      gui/gui.cpp
      gui/gui.h
      libcore/movie_root.h
    ------------------------------------------------------------
    revno: 10567.1.6
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 16:38:43 +0100
    message:
      Make getting VM from fn_call easier. Hold environment by reference.
      
      Reduce calls to VM::get() by getting it from other places.
      
      Give PropertyList a _vm member.
    modified:
      gui/gui.cpp
      libcore/CharacterProxy.h
      libcore/MovieClip.cpp
      libcore/Property.cpp
      libcore/PropertyList.cpp
      libcore/PropertyList.h
      libcore/TextField.cpp
      libcore/as_function.cpp
      libcore/as_object.cpp
      libcore/as_object.h
      libcore/as_value.h
      libcore/asobj/ClassHierarchy.cpp
      libcore/asobj/Global.cpp
      libcore/asobj/LoadVars_as.cpp
      libcore/asobj/LoadableObject.cpp
      libcore/asobj/Math_as.cpp
      libcore/asobj/Object.cpp
      libcore/asobj/SharedObject_as.cpp
      libcore/asobj/XMLSocket_as.cpp
      libcore/swf_function.cpp
      libcore/vm/ASHandlers.cpp
      libcore/vm/ExecutableCode.h
      libcore/vm/Machine.cpp
      libcore/vm/VM.cpp
      libcore/vm/VM.h
      libcore/vm/action.cpp
      libcore/vm/fn_call.h
      testsuite/libcore.all/PropertyListTest.cpp
    ------------------------------------------------------------
    revno: 10567.1.7
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Tue 2009-02-10 17:01:43 +0100
    message:
      Make getting VM from fn_call easier. Hold environment by reference.
            
      Reduce calls to VM::get() by getting it from other places.
            
      Give PropertyList a _vm member.
    modified:
      libcore/as_function.cpp
      libcore/asobj/Global.cpp
      libcore/vm/VM.cpp
      libcore/vm/VM.h
    ------------------------------------------------------------
    revno: 10567.1.8
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2009-02-11 08:17:56 +0100
    message:
      Formatting.
    modified:
      libcore/DisplayList.cpp
    ------------------------------------------------------------
    revno: 10567.1.9
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2009-02-11 08:48:07 +0100
    message:
      Corrections to curl_adapter types.
    modified:
      libbase/curl_adapter.cpp
    ------------------------------------------------------------
    revno: 10567.1.10
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2009-02-11 10:25:41 +0100
    message:
      Clean up GTK code (less casting, drop commented-out code), add some (not
      yet working) disabled code for quality settings. Don't log on resize_view
      any more, as there doesn't seem to be a bug here.
    modified:
      gui/gtk.cpp
      gui/gui.cpp
    ------------------------------------------------------------
    revno: 10567.1.11
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2009-02-11 12:49:44 +0100
    message:
      Move local callback functions out of the class definition.
    modified:
      gui/gtk.cpp
      gui/gtksup.h
      gui/gui.h
    ------------------------------------------------------------
    revno: 10567.1.12
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2009-02-11 15:10:33 +0100
    message:
      Further clean up.
    modified:
      gui/gtk.cpp
      gui/gtksup.h
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp    2009-02-09 12:30:31 +0000
+++ b/gui/Player.cpp    2009-02-10 14:04:14 +0000
@@ -300,7 +300,8 @@
 
 /* \brief Run, used to open a new flash file. Using previous initialization */
 int
-Player::run(int argc, char* argv[], const std::string& infile, const 
std::string& url)
+Player::run(int argc, char* argv[], const std::string& infile,
+        const std::string& url)
 {
     
     // Call this at run() time, so the caller has
@@ -418,7 +419,7 @@
     SystemClock clock; // use system clock here...
     movie_root root(*_movieDef, clock, *_runInfo);
 
-    _callbacksHandler.reset(new CallbacksHandler(_gui.get())); 
+    _callbacksHandler.reset(new CallbacksHandler(*_gui, *this)); 
     
     // Register Player to receive events from the core (Mouse, Stage,
     // System etc)
@@ -487,52 +488,51 @@
 void
 Player::CallbacksHandler::error(const std::string& msg)
 {
-    _gui->error(msg);
+    _gui.error(msg);
 }
 
 bool
 Player::CallbacksHandler::yesNo(const std::string& query)
 {
-return _gui->yesno(query);
+    return _gui.yesno(query);
 }
 
 std::string
 Player::CallbacksHandler::call(const std::string& event, const std::string& 
arg)
 {
-    if (event == "Mouse.hide")
-    {
-        return _gui->showMouse(false) ? "true" : "false";
+    if (event == "Mouse.hide") {
+        return _gui.showMouse(false) ? "true" : "false";
     }
 
     if (event == "Mouse.show")
     {
-        return _gui->showMouse(true) ? "true" : "false";
+        return _gui.showMouse(true) ? "true" : "false";
     }
     
     if (event == "Stage.displayState")
     {
-        if (arg == "fullScreen") _gui->setFullscreen();
-        else if (arg == "normal") _gui->unsetFullscreen();
+        if (arg == "fullScreen") _gui.setFullscreen();
+        else if (arg == "normal") _gui.unsetFullscreen();
         return "";
     }
 
     if (event == "Stage.scaleMode" || event == "Stage.align" )
     {
-        _gui->updateStageMatrix();
+        _gui.updateStageMatrix();
         return "";
     }
     
     if (event == "System.capabilities.screenResolutionX")
     {
         std::ostringstream ss;
-        ss << _gui->getScreenResX();
+        ss << _gui.getScreenResX();
         return ss.str();
     }
 
     if (event == "System.capabilities.screenResolutionY")
     {
         std::ostringstream ss;
-        ss << _gui->getScreenResY();
+        ss << _gui.getScreenResY();
         return ss.str();
     }
 
@@ -541,25 +541,25 @@
         std::ostringstream ss;
         // Whether the pp actively limits the precision or simply
         // gets a slightly different result isn't clear.
-        ss << std::setprecision(7) << _gui->getPixelAspectRatio();
+        ss << std::setprecision(7) << _gui.getPixelAspectRatio();
         return ss.str();
     }
 
     if (event == "System.capabilities.screenDPI")
     {
         std::ostringstream ss;
-        ss << _gui->getScreenDPI();
+        ss << _gui.getScreenDPI();
         return ss.str();
     }
 
     if (event == "System.capabilities.screenColor")
     {
-        return _gui->getScreenColor();
+        return _gui.getScreenColor();
     }
 
     if (event == "System.capabilities.playerType")
     {
-        return _gui->isPlugin() ? "PlugIn" : "StandAlone";
+        return _gui.isPlugin() ? "PlugIn" : "StandAlone";
     }
 
     log_error(_("Unhandled callback %s with arguments %s"), event, arg);
@@ -567,15 +567,16 @@
 }
 
 void
-Player::CallbacksHandler::notify(const std::string& command, const 
std::string& args)
+Player::CallbacksHandler::notify(const std::string& command,
+        const std::string& args)
 {
     //log_debug(_("fs_callback(%p): %s %s"), (void*)movie, command, args);
 
     gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
 
     // it's _hostfd, but we're a static method...
-    int hostfd = VM::get().getRoot().getHostFD();
-    if ( hostfd != -1 )
+    const int hostfd = _player.getHostFD();
+    if (hostfd != -1)
     {
         //log_debug("user-provided host requests fd is %d", hostfd);
         std::stringstream request;
@@ -608,7 +609,7 @@
 
     /// Fscommands can be ignored using an rcfile setting. As a 
     /// plugin they are always ignored.
-    if (_gui->isPlugin())
+    if (_gui.isPlugin())
     {
         // We log the request to the fd above
         log_debug(_("Running as plugin: skipping internal "
@@ -630,23 +631,23 @@
     // FSCommand quit
     if (noCaseCompare(command, "quit"))
     {
-        _gui->quit();
+        _gui.quit();
         return;
     }
 
     // FSCommand fullscreen
     if (noCaseCompare(command, "fullscreen"))
     {
-        if (noCaseCompare(args, "true")) _gui->setFullscreen();
-        else if (noCaseCompare(args, "false")) _gui->unsetFullscreen();
+        if (noCaseCompare(args, "true")) _gui.setFullscreen();
+        else if (noCaseCompare(args, "false")) _gui.unsetFullscreen();
         return;
     }
        
     // FSCommand showmenu
     if (noCaseCompare(command, "showmenu"))
     {
-        if (noCaseCompare(args, "true")) _gui->showMenu(true);
-        else if (noCaseCompare(args, "false")) _gui->showMenu(false);
+        if (noCaseCompare(args, "true")) _gui.showMenu(true);
+        else if (noCaseCompare(args, "false")) _gui.showMenu(false);
         return;
     }
 
@@ -664,11 +665,11 @@
     if (noCaseCompare(command, "allowscale"))
     {
         //log_debug("allowscale: %s", args);
-        if (noCaseCompare(args, "true")) _gui->allowScale(true);
+        if (noCaseCompare(args, "true")) _gui.allowScale(true);
         else
         {
-                if (strtol(args.c_str(), NULL, 0)) _gui->allowScale(true);
-                else _gui->allowScale(false);
+                if (strtol(args.c_str(), NULL, 0)) _gui.allowScale(true);
+                else _gui.allowScale(false);
         }
         return;
     }

=== modified file 'gui/Player.h'
--- a/gui/Player.h      2009-02-09 12:30:31 +0000
+++ b/gui/Player.h      2009-02-10 14:04:14 +0000
@@ -135,6 +135,10 @@
                _hostfd = fd;
        }
        
+    int getHostFD() const {
+        return _hostfd;
+    }
+
        void setStartFullscreen(bool x) {
            _startFullscreen = x;
        }
@@ -153,9 +157,10 @@
                                     public movie_root::AbstractFsCallback
        {
        public:
-               CallbacksHandler(Gui* gui)
+               CallbacksHandler(Gui& gui, const Player& player)
                        :
-                       _gui(gui)
+                       _gui(gui),
+            _player(player)
                {}
 
                std::string call(const std::string& event,
@@ -173,7 +178,9 @@
 
        private:
 
-               Gui* _gui;
+               Gui& _gui;
+
+        const Player& _player;
        };
 
        std::auto_ptr<CallbacksHandler> _callbacksHandler;

=== modified file 'gui/fltk.cpp'
--- a/gui/fltk.cpp      2008-09-24 07:44:50 +0000
+++ b/gui/fltk.cpp      2009-02-10 14:04:14 +0000
@@ -344,35 +344,6 @@
 }
 
 static void
-fltk_menu_step_forward(Widget*, void* ptr)
-{
-    FltkGui* gui = static_cast<FltkGui*>(ptr);
-    gui->menu_step_forward();
-}
-
-
-static void
-fltk_menu_step_backward(Widget*, void* ptr)
-{
-    FltkGui* gui = static_cast<FltkGui*>(ptr);
-    gui->menu_step_backward();
-}
-
-static void
-fltk_menu_jump_forward(Widget*, void* ptr)
-{
-    FltkGui* gui = static_cast<FltkGui*>(ptr);
-    gui->menu_jump_forward();
-}
-
-static void
-fltk_menu_jump_backward(Widget*, void* ptr)
-{
-    FltkGui* gui = static_cast<FltkGui*>(ptr);
-    gui->menu_jump_backward();
-}
-
-static void
 fltk_menu_toggle_sound(Widget*, void* ptr)
 {
     FltkGui* gui = static_cast<FltkGui*>(ptr);
@@ -408,10 +379,6 @@
     new Item("Pause Movie",             0, fltk_menu_pause, this);
     new Item("Stop Movie",              0, fltk_menu_stop, this);
     new Item("Restart Movie",           0, fltk_menu_restart, this);
-    new Item("Step Forward Frame",      0, fltk_menu_step_forward, this);
-    new Item("Step Backward Frame",     0, fltk_menu_step_backward, this);
-    new Item("Jump Forward 10 Frames",  0, fltk_menu_jump_forward, this);
-    new Item("Jump Backward 10 Frames", 0, fltk_menu_jump_backward, this);
     new Item("Toggle Sound",            0, fltk_menu_toggle_sound, this);
     movie_ctrl->end();
 

=== modified file 'gui/fltksup.h'
--- a/gui/fltksup.h     2008-01-21 20:55:39 +0000
+++ b/gui/fltksup.h     2009-02-10 14:04:14 +0000
@@ -15,8 +15,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#ifndef __FLTKSUP_H__
-#define __FLTKSUP_H__
+#ifndef GNASH_FLTKSUP_H
+#define GNASH_FLTKSUP_H
 
 #ifdef HAVE_CONFIG_H
 #include "gnashconfig.h"

=== modified file 'gui/gtk.cpp'
--- a/gui/gtk.cpp       2009-02-09 12:30:31 +0000
+++ b/gui/gtk.cpp       2009-02-11 14:10:33 +0000
@@ -74,13 +74,62 @@
 # include <hildon/hildon.h>
 #endif
 
+
 namespace gnash 
 {
 
-bool createFileMenu(GtkWidget *obj);
-bool createEditMenu(GtkWidget *obj);
-bool createHelpMenu(GtkWidget *obj);
-bool createControlMenu(GtkWidget *obj);
+// Forward declarations
+namespace {
+
+    // Menu Item callbacks
+    void menuSound(GtkMenuItem *menuitem, gpointer instance);
+    void menuFullscreen(GtkMenuItem *menuitem, gpointer instance);
+    void menuRestart(GtkMenuItem *menuitem, gpointer instance);
+    void menuQuit(GtkMenuItem *menuitem, gpointer instance);
+    void menuPlay(GtkMenuItem *menuitem, gpointer instance);
+    void menuPause(GtkMenuItem *menuitem, gpointer instance);
+    void menuStop(GtkMenuItem *menuitem, gpointer instance);
+    void menuAbout(GtkMenuItem *menuitem, gpointer instance);
+    void menuOpenFile(GtkMenuItem *menuitem, gpointer instance);
+    void menuPreferences(GtkMenuItem *menuitem, gpointer instance);
+    void menuMovieInfo(GtkMenuItem *menuitem, gpointer instance);
+    void menuRefreshView(GtkMenuItem *menuitem, gpointer instance);
+    void menuShowUpdatedRegions(GtkMenuItem *menuitem, gpointer instance); 
+
+    // Event handlers
+    gboolean realizeEvent(GtkWidget *widget, GdkEvent *event, gpointer data);
+    gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, gpointer data);
+    gboolean exposeEvent(GtkWidget *widget, GdkEventExpose *event,
+                                 gpointer data);
+    gboolean configureEvent(GtkWidget *widget, GdkEventConfigure *event,
+                                    gpointer data);
+    gboolean keyPressEvent(GtkWidget *widget, GdkEventKey *event,
+                                    gpointer data);
+    gboolean keyReleaseEvent(GtkWidget *widget, GdkEventKey *event,
+                                    gpointer data);
+    gboolean buttonPressEvent(GtkWidget *widget, GdkEventButton *event,
+                                       gpointer data);
+    gboolean buttonReleaseEvent(GtkWidget *widget, GdkEventButton *event,
+                                         gpointer data);
+    gboolean motionNotifyEvent(GtkWidget *widget, GdkEventMotion *event,
+                                        gpointer data);
+    gint popupHandler(GtkWidget *widget, GdkEvent *event);    
+
+    void openFile(GtkWidget *widget, gpointer data);
+
+    void addPixmapDirectory(const gchar *directory);
+    
+    void addGnashIcon(GtkWindow* window);
+
+    gchar* findPixmapFile(const gchar *filename);
+    
+    GdkPixbuf* createPixbuf(const gchar *filename);
+
+    key::code gdk_to_gnash_key(guint key);
+
+    int gdk_to_gnash_modifier(int key);
+
+}
 
 // This is global so it can be accessed by the evnt handler, which
 // isn't part of this class. 
@@ -129,7 +178,7 @@
 #endif
     _glue->init (argc, argv);
 
-    add_pixmap_directory (PKGDATADIR);
+    addPixmapDirectory (PKGDATADIR);
 
     if (_xid) {
         _window = gtk_plug_new(_xid);
@@ -161,8 +210,7 @@
     g_object_ref(G_OBJECT(_resumeButton));
 
     // This callback indirectly results in playHook() being called.
-    g_signal_connect(G_OBJECT(_resumeButton), "clicked",
-            G_CALLBACK(menuitem_play_callback), this);
+    g_signal_connect(_resumeButton, "clicked", G_CALLBACK(menuPlay), this);
 
     // If we don't set this flag we won't be able to grab focus
     // ( grabFocus() would be a no-op )
@@ -277,9 +325,8 @@
             static_cast<GtkDialogFlags>(GTK_DIALOG_DESTROY_WITH_PARENT),
             GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
 
-
-    g_signal_connect_swapped(G_OBJECT(popup), "response",
-            G_CALLBACK(gtk_widget_destroy), popup);
+    g_signal_connect_swapped(popup, "response", G_CALLBACK(gtk_widget_destroy),
+            popup);
 
     GtkWidget* content = gtk_dialog_get_content_area(GTK_DIALOG(popup));
     GtkWidget* label = gtk_label_new(msg.c_str());
@@ -302,7 +349,6 @@
         _overlay = gtk_window_new (GTK_WINDOW_TOPLEVEL);
         addGnashIcon(GTK_WINDOW(_overlay));
         gtk_window_fullscreen(GTK_WINDOW(_overlay));
-        //log_debug (_("Created fullscreen window"));
         
         // Reparent drawing area from GtkPlug to fullscreen window
         gtk_widget_realize(_overlay);      
@@ -319,11 +365,11 @@
     
         // This is a hack to fix another hack (see createWindow). If the 
minimum
         // size (size request) is larger than the screen, fullscreen messes up.
-        // This way allows the drawing area to be shrunk, which is what we 
really want,
-        // but not only after we've gone fullscreen.
+        // This way allows the drawing area to be shrunk, which is what we
+        // really want, but not only after we've gone fullscreen.
         // It could be a good hack if it were done earlier.
-        // There really doesn't seem to be a proper way of setting the 
starting size
-        // of a widget but allowing it to be shrunk.
+        // There really doesn't seem to be a proper way of setting the
+        // starting size of a widget but allowing it to be shrunk.
         gtk_widget_set_size_request(_drawingArea, -1, -1);
        gtk_window_fullscreen(GTK_WINDOW(_window));
 
@@ -346,12 +392,10 @@
         setupWindowEvents();
         if (_overlay) {
             gtk_widget_destroy(_overlay);
-            //log_debug (_("Destroyed fullscreen window"));
         }        
     }
-    
-    // Stand-alone
     else {
+        // Stand-alone
            gtk_window_unfullscreen(GTK_WINDOW(_window));
            showMenu(true);
     }
@@ -362,30 +406,24 @@
 void
 GtkGui::hideMenu()
 {
-    if (_fullscreen) return;
+    // Not showing menu anyway if it's a plugin
+    if (_fullscreen || _xid) return;
 
-    // Plugin
-    if (_xid) {
-        return; // Not showing menu if it's a plugin anyway
-    }
-    
     // Stand-alone
-    else {
-        showMenu(false);
-    }
+    showMenu(false);
 }
 
 
 void 
 GtkGui::setCursor(gnash_cursor_type newcursor)
 {
-  //GNASH_REPORT_FUNCTION;
 
-       if (! _mouseShown) return;
+       if (!_mouseShown) return;
 
     GdkCursorType cursortype;
 
-    switch(newcursor) {
+    switch (newcursor)
+    {
         case CURSOR_HAND:
             cursortype = GDK_HAND2;
             break;
@@ -403,7 +441,7 @@
     }
 
     // The parent of _drawingArea is different for the plugin in fullscreen
-    gdk_window_set_cursor (_drawingArea->window, gdkcursor);
+    gdk_window_set_cursor(_drawingArea->window, gdkcursor);
   
     if (gdkcursor) {
         gdk_cursor_unref(gdkcursor);
@@ -438,10 +476,7 @@
         _mouseShown = false;
 
     }
-       else if (show)
-    {
-        _mouseShown = true;    
-    }
+       else if (show) _mouseShown = true;
     
     return state;
 }
@@ -450,14 +485,8 @@
 GtkGui::showMenu(bool show)
 {
 #ifdef USE_MENUS
-if (_menubar)
-{
-    if (show) {
-        gtk_widget_show(_menubar);
-           return;
-       }
-    gtk_widget_hide(_menubar);
-}
+    if (!_menubar) return;
+    if (show) gtk_widget_show(_menubar);
 #endif
 }
 
@@ -470,8 +499,8 @@
     // The physical size of the screen may be reported wrongly by gdk (from X),
     // but it's the best we have. This method agrees with the pp in my case.
     double pixelAspectRatio =
-            (gdk_screen_get_height_mm(screen) / 
static_cast<double>(getScreenResY())) / 
-            (gdk_screen_get_width_mm(screen) / 
static_cast<double>(getScreenResX()));
+        (gdk_screen_get_height_mm(screen) / 
static_cast<double>(getScreenResY())) / 
+        (gdk_screen_get_width_mm(screen) / 
static_cast<double>(getScreenResX()));
     return pixelAspectRatio;
 }
 
@@ -502,19 +531,18 @@
 void
 GtkGui::setupWindowEvents()
 {
-    g_signal_connect(G_OBJECT(gtk_widget_get_toplevel(_drawingArea)),
-            "delete_event", G_CALLBACK(delete_event), this);
-    g_signal_connect(G_OBJECT(gtk_widget_get_toplevel(_drawingArea)),
-            "key_press_event", G_CALLBACK(key_press_event), this);
-    g_signal_connect(G_OBJECT(gtk_widget_get_toplevel(_drawingArea)),
-            "key_release_event", G_CALLBACK(key_release_event), this);
+    g_signal_connect(gtk_widget_get_toplevel(_drawingArea),
+            "delete_event", G_CALLBACK(deleteEvent), this);
+    g_signal_connect(gtk_widget_get_toplevel(_drawingArea),
+            "key_press_event", G_CALLBACK(keyPressEvent), this);
+    g_signal_connect(gtk_widget_get_toplevel(_drawingArea),
+            "key_release_event", G_CALLBACK(keyReleaseEvent), this);
 }
 
 // public virtual
 bool
 GtkGui::setupEvents()
 {
-  //GNASH_REPORT_FUNCTION;
 
     setupWindowEvents();
 
@@ -525,24 +553,22 @@
                         | GDK_KEY_PRESS_MASK        
                         | GDK_POINTER_MOTION_MASK);
   
-    g_signal_connect_swapped(G_OBJECT(_drawingArea),
-                            "button_press_event",
-                            G_CALLBACK(popup_handler),
-                            GTK_OBJECT(_popup_menu));
-  
-    g_signal_connect(G_OBJECT(_drawingArea), "button_press_event",
-                   G_CALLBACK(button_press_event), this);
-    g_signal_connect(G_OBJECT(_drawingArea), "button_release_event",
-                   G_CALLBACK(button_release_event), this);
-    g_signal_connect(G_OBJECT(_drawingArea), "motion_notify_event",
-                   G_CALLBACK(motion_notify_event), this);
-  
-    g_signal_connect_after(G_OBJECT (_drawingArea), "realize",
-                         G_CALLBACK (realize_event), NULL);
-    g_signal_connect(G_OBJECT (_drawingArea), "configure_event",
-                   G_CALLBACK (configure_event), this);
-    g_signal_connect(G_OBJECT (_drawingArea), "expose_event",
-                    G_CALLBACK (expose_event), this);
+    g_signal_connect_swapped(_drawingArea, "button_press_event",
+                            G_CALLBACK(popupHandler), _popup_menu);
+  
+    g_signal_connect(_drawingArea, "button_press_event",
+                   G_CALLBACK(buttonPressEvent), this);
+    g_signal_connect(_drawingArea, "button_release_event",
+                   G_CALLBACK(buttonReleaseEvent), this);
+    g_signal_connect(_drawingArea, "motion_notify_event",
+                   G_CALLBACK(motionNotifyEvent), this);
+  
+    g_signal_connect_after(_drawingArea, "realize",
+                         G_CALLBACK (realizeEvent), NULL);
+    g_signal_connect(_drawingArea, "configure_event",
+                   G_CALLBACK (configureEvent), this);
+    g_signal_connect(_drawingArea, "expose_event",
+                    G_CALLBACK (exposeEvent), this);
 
     return true;
 }
@@ -629,20 +655,20 @@
 
     /// The sound handler is initialized after the Gui is created, and
     /// may be disabled or enabled dynamically.
-    GtkCheckMenuItem *menuitem_sound =
+    GtkCheckMenuItem *menusound =
         GTK_CHECK_MENU_ITEM(gtk_check_menu_item_new_with_label(_("Sound")));
-    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuitem_sound), TRUE);
-    gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_sound));
-    gtk_widget_show(GTK_WIDGET(menuitem_sound));
-    g_signal_connect(GTK_OBJECT(menuitem_sound), "activate",
-                     G_CALLBACK(&menuitem_sound_callback), this);
+    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menusound), TRUE);
+    gtk_menu_append(_popup_menu, GTK_WIDGET(menusound));
+    gtk_widget_show(GTK_WIDGET(menusound));
+    g_signal_connect(menusound, "activate",
+                     G_CALLBACK(menusound), this);
 
-    GtkMenuItem *menuitem_quit =
+    GtkMenuItem *menuquit =
        GTK_MENU_ITEM(gtk_menu_item_new_with_label(_("Quit Gnash")));
-    gtk_menu_append(_popup_menu, GTK_WIDGET(menuitem_quit));
-    gtk_widget_show(GTK_WIDGET(menuitem_quit));
-    g_signal_connect(GTK_OBJECT(menuitem_quit), "activate",
-                     G_CALLBACK(&menuitem_quit_callback), this);
+    gtk_menu_append(_popup_menu, GTK_WIDGET(menuquit));
+    gtk_widget_show(GTK_WIDGET(menuquit));
+    g_signal_connect(menuquit, "activate",
+                     G_CALLBACK(menuquit), this);
 
 #ifdef GUI_HILDON
      hildon_window_set_menu(HILDON_WINDOW(_window),
@@ -674,64 +700,6 @@
     return ret;
 }
 
-static GList *pixmaps_directories = NULL;
-
-/* Use this function to set the directory containing installed pixmaps. */
-void
-GtkGui::add_pixmap_directory                   (const gchar     *directory)
-{
-    pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup 
(directory));
-}
-
-
-/* This is an internally used function to find pixmap files. */
-gchar*
-GtkGui::find_pixmap_file                       (const gchar     *filename)
-{
-    GList *elem;
-
-    /* We step through each of the pixmaps directory to find it. */
-    elem = pixmaps_directories;
-    while (elem) {
-        gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
-                G_DIR_SEPARATOR_S, filename);
-        if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-            return pathname;
-        g_free (pathname);
-        elem = elem->next;
-    }
-    return NULL;
-}
-
-
-/* This is an internally used function to create pixmaps. */
-GdkPixbuf*
-GtkGui::createPixbuf (const gchar *filename)
-{
-    gchar *pathname = NULL;
-    GdkPixbuf *pixbuf;
-    GError *error = NULL;
-
-    if (!filename || !filename[0])
-       return NULL;
-
-    pathname = find_pixmap_file (filename);
-
-    if (!pathname) {
-        log_error (_("Couldn't find pixmap file: %s"), filename);
-        g_warning (_("Couldn't find pixmap file: %s"), filename);
-        return NULL;
-    }
-
-    pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
-    if (!pixbuf) {
-        log_error (_("Failed to load pixbuf file: %s: %s"), pathname, 
error->message);
-        g_error_free (error);
-    }
-    g_free (pathname);
-    return pixbuf;
-}
-
 #ifdef USE_SWFTREE
 
 // This creates a GtkTree model for displaying movie info.
@@ -802,16 +770,6 @@
 
 #endif
 
-// Adds the Gnash icon to a window.
-void
-GtkGui::addGnashIcon(GtkWindow* window)
-{
-    GdkPixbuf *window_icon_pixbuf = createPixbuf ("GnashG.png");
-    if (window_icon_pixbuf) {
-        gtk_window_set_icon (GTK_WINDOW (window), window_icon_pixbuf);
-               gdk_pixbuf_unref (window_icon_pixbuf);
-    }
-}
 
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
@@ -916,38 +874,6 @@
 
 }
 
-/// This method is called when the "OK" button is clicked in the open file
-/// dialog. For GTK <= 2.4.0, this is a callback called by GTK itself.
-void GtkGui::openFile (GtkWidget *widget, gpointer /* user_data */)
-{
-#if 0
-    // We'll need this when implementing file opening.
-    GtkGui* gui = static_cast<GtkGui*>(user_data);
-#endif
-   
-#if GTK_CHECK_VERSION(2,4,0)
-    char* filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
-#else   
-    GtkWidget* file_selector = gtk_widget_get_ancestor(widget,
-                                 g_type_from_name("GtkFileSelection"));
-
-    GtkFileSelection* filesel = GTK_FILE_SELECTION (file_selector);
-    const char* filename = gtk_file_selection_get_filename (filesel);
-#endif
-
-    // FIXME: we want to do something like calling gtk_main_quit here, so
-    // run() will return. If run() is then changed to return a pointer to the
-    // next file to be played, then the Player class can play the next file,
-    // unless run() returns NULL.
-    log_error (_("Attempting to open file %s.\n"
-               "NOTE: the file open functionality is not yet implemented!"),
-              filename);
-
-#if GTK_CHECK_VERSION(2,4,0)
-    g_free(filename);
-#endif
-}
-
 
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
@@ -957,9 +883,10 @@
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
-namespace { // anonymous
+namespace { 
 
-class PreferencesDialog {
+class PreferencesDialog
+{
 
 public:
 
@@ -1002,7 +929,7 @@
 #endif
 
        PrefWidgets()
-               :
+                   :
                soundToggle(0),
                actionDumpToggle(0),
                parserDumpToggle(0),
@@ -1032,8 +959,8 @@
                ,DebuggerToggle(0)
 #endif
        {}
+
     };
-    
 
     static void handlePrefs(GtkWidget* widget, gint response, gpointer data);
 
@@ -1059,13 +986,13 @@
 
     GtkWidget* _notebook;
 
-
 };
 
+
 // Callback to read values from the preferences dialogue and set rcfile
 // values accordingly.
 void
-PreferencesDialog::handlePrefs (GtkWidget* dialog, gint response, gpointer 
data)
+PreferencesDialog::handlePrefs(GtkWidget* dialog, gint response, gpointer data)
 {
 
     PrefWidgets *prefs = static_cast<PrefWidgets*>(data);
@@ -1213,11 +1140,11 @@
             _rcfile.setURLOpenerFormat(tmp);
         }
        
-       // Let _rcfile decide which file to update: generally the file being 
used if
-       // specified in GNASHRC environment variable, or in the user's home 
directory
-       // if that can be found.
-       // TODO: We can also specify here which file should be written by 
passing
-       // that instead. How might that best be done?
+       // Let _rcfile decide which file to update: generally the file
+        // being used if specified in GNASHRC environment variable, or in
+        // the user's home directory if that can be found.
+       // TODO: We can also specify here which file should be written
+        // by passing that instead. How might that best be done?
        _rcfile.updateFile();
 
         // Close the window when 'ok' is clicked
@@ -1228,17 +1155,14 @@
         // Close the window when 'cancel' is clicked
         gtk_widget_destroy(dialog);
     }
-    
-    // response == GTK_RESPONSE_DELETE_EVENT
 
     if (prefs) delete prefs;
 }
 
-
 void
 PreferencesDialog::show()
 {
-    gtk_widget_show_all (_prefsDialog);    
+    gtk_widget_show_all(_prefsDialog);
 }
 
 PreferencesDialog::PreferencesDialog(GtkWidget* window)
@@ -1260,7 +1184,7 @@
                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                NULL);
     // Add Gnash icon
-    GtkGui::addGnashIcon(GTK_WINDOW(_prefsDialog));
+    addGnashIcon(GTK_WINDOW(_prefsDialog));
 
     // Add notebook (tabs) to dialogue's vbox
     _notebook = gtk_notebook_new ();
@@ -1301,9 +1225,11 @@
     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
     _prefs->streamsTimeoutScale = gtk_spin_button_new_with_range(0, 300, 1);
-    gtk_box_pack_start(GTK_BOX(timeoutbox), _prefs->streamsTimeoutScale, 
FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(timeoutbox), _prefs->streamsTimeoutScale, FALSE,
+            FALSE, 0);
     // Align to _rcfile value:
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(_prefs->streamsTimeoutScale), 
_rcfile.getStreamsTimeout());
+    gtk_spin_button_set_value(GTK_SPIN_BUTTON(_prefs->streamsTimeoutScale),
+            _rcfile.getStreamsTimeout());
 
 }
 
@@ -1314,7 +1240,8 @@
    
     // Tab label
     GtkWidget *loggingtablabel = gtk_label_new_with_mnemonic (_("_Logging"));
-    gtk_notebook_append_page(GTK_NOTEBOOK(_notebook), GTK_WIDGET(loggingvbox), 
loggingtablabel); 
+    gtk_notebook_append_page(GTK_NOTEBOOK(_notebook), GTK_WIDGET(loggingvbox),
+            loggingtablabel); 
 
     // Logging options
     GtkWidget *logginglabel = gtk_label_new (_("<b>Logging options</b>"));
@@ -1325,64 +1252,81 @@
     gtk_box_pack_start(GTK_BOX(loggingvbox), verbositylabel, FALSE, FALSE, 0);
     gtk_misc_set_alignment (GTK_MISC (verbositylabel), 0, 0.5);
 
-    _prefs->verbosityScale = gtk_hscale_new (GTK_ADJUSTMENT 
(gtk_adjustment_new (_rcfile.verbosityLevel(), 0, 10, 1, 0, 0)));
-    gtk_scale_set_digits (GTK_SCALE (_prefs->verbosityScale), 0);
-    gtk_range_set_update_policy (GTK_RANGE (_prefs->verbosityScale), 
GTK_UPDATE_DISCONTINUOUS);
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->verbosityScale, FALSE, 
FALSE, 0);
-    
-    _prefs->writeLogToggle = gtk_check_button_new_with_mnemonic (_("Log to 
_file"));
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->writeLogToggle, FALSE, 
FALSE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_prefs->writeLogToggle), 
_rcfile.useWriteLog());
-    
-    GtkWidget *logfilelabel = gtk_label_new (_("Logfile name:"));
+    _prefs->verbosityScale = gtk_hscale_new(GTK_ADJUSTMENT(
+                gtk_adjustment_new(_rcfile.verbosityLevel(), 0, 10, 1, 0, 0)));
+    gtk_scale_set_digits(GTK_SCALE(_prefs->verbosityScale), 0);
+    gtk_range_set_update_policy(GTK_RANGE(
+                _prefs->verbosityScale), GTK_UPDATE_DISCONTINUOUS);
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->verbosityScale, FALSE,
+            FALSE, 0);
+    
+    _prefs->writeLogToggle = 
+        gtk_check_button_new_with_mnemonic(_("Log to _file"));
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->writeLogToggle, FALSE,
+            FALSE, 0);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->writeLogToggle),
+            _rcfile.useWriteLog());
+    
+    GtkWidget *logfilelabel = gtk_label_new(_("Logfile name:"));
     gtk_box_pack_start(GTK_BOX(loggingvbox), logfilelabel, FALSE, FALSE, 0);
-    gtk_misc_set_alignment (GTK_MISC (logfilelabel), 0, 0.5);
+    gtk_misc_set_alignment(GTK_MISC(logfilelabel), 0, 0.5);
     
-    _prefs->logfileName = gtk_entry_new ();
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->logfileName, FALSE, 
FALSE, 0);
+    _prefs->logfileName = gtk_entry_new();
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->logfileName, FALSE,
+            FALSE, 0);
+
     // Put debug filename in the entry box      
-    gtk_entry_set_text(GTK_ENTRY(_prefs->logfileName), 
_rcfile.getDebugLog().c_str());
+    gtk_entry_set_text(GTK_ENTRY(_prefs->logfileName),
+            _rcfile.getDebugLog().c_str());
     
-    _prefs->parserDumpToggle = gtk_check_button_new_with_mnemonic (_("Log 
_parser output"));
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->parserDumpToggle, FALSE, 
FALSE, 0);
+    _prefs->parserDumpToggle = 
+        gtk_check_button_new_with_mnemonic(_("Log _parser output"));
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->parserDumpToggle, FALSE,
+            FALSE, 0);
     // Align button state with _rcfile
-    gtk_toggle_button_set_active (
-               GTK_TOGGLE_BUTTON (_prefs->parserDumpToggle),
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(_prefs->parserDumpToggle),
                _rcfile.useParserDump());
 
-    _prefs->actionDumpToggle = gtk_check_button_new_with_mnemonic (_("Log SWF 
_actions"));
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->actionDumpToggle, FALSE, 
FALSE, 0);
+    _prefs->actionDumpToggle =
+        gtk_check_button_new_with_mnemonic(_("Log SWF _actions"));
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->actionDumpToggle, FALSE,
+            FALSE, 0);
     // Align button state with _rcfile
-    gtk_toggle_button_set_active (
-               GTK_TOGGLE_BUTTON (_prefs->actionDumpToggle),
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->actionDumpToggle),
                _rcfile.useActionDump());
 
-    _prefs->malformedSWFToggle = gtk_check_button_new_with_mnemonic (_("Log 
malformed SWF _errors"));
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->malformedSWFToggle, 
FALSE, FALSE, 0);
+    _prefs->malformedSWFToggle = 
+        gtk_check_button_new_with_mnemonic(_("Log malformed SWF _errors"));
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->malformedSWFToggle,
+            FALSE, FALSE, 0);
     // Align button state with _rcfile
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON 
(_prefs->malformedSWFToggle),
-                       _rcfile.showMalformedSWFErrors());
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->malformedSWFToggle),
+            _rcfile.showMalformedSWFErrors());
 
-    _prefs->ASCodingErrorToggle = gtk_check_button_new_with_mnemonic (_("Log 
ActionScript _coding errors"));
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->ASCodingErrorToggle, 
FALSE, FALSE, 0);
+    _prefs->ASCodingErrorToggle = gtk_check_button_new_with_mnemonic(
+            _("Log ActionScript _coding errors"));
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->ASCodingErrorToggle,
+            FALSE, FALSE, 0);
     // Align button state with _rcfile
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON 
(_prefs->ASCodingErrorToggle),
+    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->ASCodingErrorToggle),
                        _rcfile.showASCodingErrors());
 
-    _prefs->lcTraceToggle = gtk_check_button_new_with_mnemonic (
+    _prefs->lcTraceToggle = gtk_check_button_new_with_mnemonic(
                                _("Log _Local Connection activity"));
-    gtk_box_pack_start (GTK_BOX(loggingvbox), _prefs->lcTraceToggle, FALSE, 
FALSE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_prefs->lcTraceToggle),
+    gtk_box_pack_start (GTK_BOX(loggingvbox), _prefs->lcTraceToggle, FALSE,
+            FALSE, 0);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->lcTraceToggle),
                        _rcfile.getLCTrace()); 
 
 #ifdef USE_DEBUGGER
 
-    _prefs->DebuggerToggle = gtk_check_button_new_with_mnemonic (_("Enable 
_debugger"));
-    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->DebuggerToggle, FALSE, 
FALSE, 0);
+    _prefs->DebuggerToggle = 
+        gtk_check_button_new_with_mnemonic(_("Enable _debugger"));
+    gtk_box_pack_start(GTK_BOX(loggingvbox), _prefs->DebuggerToggle, FALSE,
+            FALSE, 0);
     // Align button state with _rcfile
-    gtk_toggle_button_set_active (
-                       GTK_TOGGLE_BUTTON (_prefs->DebuggerToggle),
-                       _rcfile.useDebugger());
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->DebuggerToggle),
+            _rcfile.useDebugger());
 
 #endif
 
@@ -1397,56 +1341,74 @@
     // Security tab title
     GtkWidget *securitytablabel = gtk_label_new_with_mnemonic (_("_Security"));
     
-    gtk_notebook_append_page(GTK_NOTEBOOK(_notebook), 
GTK_WIDGET(securityvbox), securitytablabel); 
+    gtk_notebook_append_page(GTK_NOTEBOOK(_notebook),
+            GTK_WIDGET(securityvbox), securitytablabel); 
     
     // Network connection
-    GtkWidget *netconnectionslabel = gtk_label_new (_("<b>Network 
connections</b>"));
-    gtk_label_set_use_markup (GTK_LABEL (netconnectionslabel), TRUE);
-    gtk_box_pack_start(GTK_BOX(securityvbox), netconnectionslabel, FALSE, 
FALSE, 0);
+    GtkWidget *netconnectionslabel = gtk_label_new(
+            _("<b>Network connections</b>"));
+    gtk_label_set_use_markup(GTK_LABEL(netconnectionslabel), TRUE);
+    gtk_box_pack_start(GTK_BOX(securityvbox), netconnectionslabel, FALSE,
+            FALSE, 0);
  
-    _prefs->localHostToggle = gtk_check_button_new_with_mnemonic (_("Connect 
only to local _host"));
-    gtk_box_pack_start (GTK_BOX(securityvbox), _prefs->localHostToggle, FALSE, 
FALSE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_prefs->localHostToggle), 
_rcfile.useLocalHost());
-    
-    _prefs->localDomainToggle = gtk_check_button_new_with_mnemonic (_("Connect 
only to local _domain"));
-    gtk_box_pack_start (GTK_BOX(securityvbox), _prefs->localDomainToggle, 
FALSE, FALSE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON 
(_prefs->localDomainToggle), _rcfile.useLocalDomain());
-
-    _prefs->insecureSSLToggle = gtk_check_button_new_with_mnemonic (_("Disable 
SSL _verification"));
-    gtk_box_pack_start (GTK_BOX(securityvbox), _prefs->insecureSSLToggle, 
FALSE, FALSE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON 
(_prefs->insecureSSLToggle), _rcfile.insecureSSL());
-    
-    GtkWidget *whitelistexpander = gtk_expander_new_with_mnemonic 
(_("_Whitelist"));
-    gtk_box_pack_start (GTK_BOX (securityvbox), whitelistexpander, FALSE, 
FALSE, 0);
-    
-    GtkWidget *whitelistcomboboxentry1 = gtk_combo_box_entry_new_text ();
-    gtk_container_add (GTK_CONTAINER(whitelistexpander), 
whitelistcomboboxentry1);
-
-    GtkWidget *blacklistexpander = gtk_expander_new_with_mnemonic 
(_("_Blacklist"));
-    gtk_box_pack_start (GTK_BOX (securityvbox), blacklistexpander, FALSE, 
FALSE, 0);
-    
-    GtkWidget *blacklistcomboboxentry2 = gtk_combo_box_entry_new_text ();
-    gtk_container_add (GTK_CONTAINER(blacklistexpander), 
blacklistcomboboxentry2);
+    _prefs->localHostToggle = gtk_check_button_new_with_mnemonic(
+            _("Connect only to local _host"));
+    gtk_box_pack_start(GTK_BOX(securityvbox), _prefs->localHostToggle, FALSE,
+            FALSE, 0);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->localHostToggle),
+            _rcfile.useLocalHost());
+    
+    _prefs->localDomainToggle = gtk_check_button_new_with_mnemonic(
+            _("Connect only to local _domain"));
+    gtk_box_pack_start(GTK_BOX(securityvbox), _prefs->localDomainToggle,
+            FALSE, FALSE, 0);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->localDomainToggle),
+            _rcfile.useLocalDomain());
+
+    _prefs->insecureSSLToggle = gtk_check_button_new_with_mnemonic(
+            _("Disable SSL _verification"));
+    gtk_box_pack_start(GTK_BOX(securityvbox), _prefs->insecureSSLToggle,
+            FALSE, FALSE, 0);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->insecureSSLToggle),
+            _rcfile.insecureSSL());
+    
+    GtkWidget *whitelistexpander =
+        gtk_expander_new_with_mnemonic(_("_Whitelist"));
+    gtk_box_pack_start(GTK_BOX(securityvbox), whitelistexpander, FALSE,
+            FALSE, 0);
+    
+    GtkWidget *whitelistcomboboxentry1 = gtk_combo_box_entry_new_text();
+    gtk_container_add(GTK_CONTAINER(whitelistexpander),
+            whitelistcomboboxentry1);
+
+    GtkWidget *blacklistexpander = 
+        gtk_expander_new_with_mnemonic(_("_Blacklist"));
+    gtk_box_pack_start(GTK_BOX (securityvbox), blacklistexpander, FALSE,
+            FALSE, 0);
+    
+    GtkWidget *blacklistcomboboxentry2 = gtk_combo_box_entry_new_text();
+    gtk_container_add (GTK_CONTAINER(blacklistexpander),
+            blacklistcomboboxentry2);
 
     // Privacy
-    GtkWidget *privacylabel = gtk_label_new (_("<b>Privacy</b>"));
-    gtk_label_set_use_markup (GTK_LABEL (privacylabel), TRUE);
-    gtk_box_pack_start (GTK_BOX(securityvbox), privacylabel, FALSE, FALSE, 0);
+    GtkWidget *privacylabel = gtk_label_new(_("<b>Privacy</b>"));
+    gtk_label_set_use_markup(GTK_LABEL(privacylabel), TRUE);
+    gtk_box_pack_start(GTK_BOX(securityvbox), privacylabel, FALSE, FALSE, 0);
 
-    GtkWidget *solsandboxlabel = gtk_label_new (_("Shared objects 
directory:"));
-    gtk_box_pack_start (GTK_BOX(securityvbox), solsandboxlabel, FALSE,
+    GtkWidget *solsandboxlabel = gtk_label_new(_("Shared objects directory:"));
+    gtk_box_pack_start(GTK_BOX(securityvbox), solsandboxlabel, FALSE,
             FALSE, 0);
-    gtk_misc_set_alignment (GTK_MISC (solsandboxlabel), 0, 0.5);
+    gtk_misc_set_alignment(GTK_MISC (solsandboxlabel), 0, 0.5);
 
     _prefs->solSandbox = gtk_entry_new();
     gtk_entry_set_text(GTK_ENTRY(_prefs->solSandbox), 
             _rcfile.getSOLSafeDir().c_str());
-    gtk_box_pack_start (GTK_BOX(securityvbox), _prefs->solSandbox, FALSE,
+    gtk_box_pack_start(GTK_BOX(securityvbox), _prefs->solSandbox, FALSE,
             FALSE, 0);
 
     _prefs->solReadOnlyToggle = gtk_check_button_new_with_mnemonic( 
                                _("Do _not write Shared Object files"));
-    gtk_box_pack_start (GTK_BOX(securityvbox), _prefs->solReadOnlyToggle,
+    gtk_box_pack_start(GTK_BOX(securityvbox), _prefs->solReadOnlyToggle,
             FALSE, FALSE, 0);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->solReadOnlyToggle),
                        _rcfile.getSOLReadOnly());
@@ -1458,9 +1420,9 @@
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
                 _prefs->solLocalDomainToggle), _rcfile.getSOLLocalDomain());
 
-    _prefs->localConnectionToggle = gtk_check_button_new_with_mnemonic (
+    _prefs->localConnectionToggle = gtk_check_button_new_with_mnemonic(
                                _("Disable Local _Connection object"));
-    gtk_box_pack_start (GTK_BOX(securityvbox), _prefs->localConnectionToggle,
+    gtk_box_pack_start(GTK_BOX(securityvbox), _prefs->localConnectionToggle,
             FALSE, FALSE, 0);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
                 _prefs->localConnectionToggle), _rcfile.getLocalConnection()); 
@@ -1479,13 +1441,13 @@
             GTK_WIDGET(mediavbox), mediatablabel); 
     
     // Sound
-    GtkWidget *soundlabel = gtk_label_new (_("<b>Sound</b>"));
-    gtk_label_set_use_markup (GTK_LABEL (soundlabel), TRUE);
+    GtkWidget *soundlabel = gtk_label_new(_("<b>Sound</b>"));
+    gtk_label_set_use_markup(GTK_LABEL(soundlabel), TRUE);
     gtk_box_pack_start(GTK_BOX(mediavbox), soundlabel, FALSE, FALSE, 0);
    
     _prefs->soundToggle = gtk_check_button_new_with_mnemonic(
             _("Use sound _handler"));
-    gtk_box_pack_start (GTK_BOX(mediavbox), _prefs->soundToggle, FALSE,
+    gtk_box_pack_start(GTK_BOX(mediavbox), _prefs->soundToggle, FALSE,
             FALSE, 0);
     // Align button state with rcfile
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_prefs->soundToggle),
@@ -1537,7 +1499,8 @@
     // Player tab title
     GtkWidget *playertablabel = gtk_label_new_with_mnemonic (_("_Player"));
     
-    gtk_notebook_append_page(GTK_NOTEBOOK(_notebook), GTK_WIDGET(playervbox), 
playertablabel); 
+    gtk_notebook_append_page(GTK_NOTEBOOK(_notebook),
+            GTK_WIDGET(playervbox), playertablabel); 
 
     // Player description
     GtkWidget *descriptionlabel = gtk_label_new (_("<b>Player 
description</b>"));
@@ -1553,9 +1516,12 @@
     gtk_box_pack_start(GTK_BOX(versionhbox), versionlabel, FALSE, FALSE, 0);
 
     _prefs->versionText = gtk_entry_new ();
-    gtk_box_pack_start(GTK_BOX(versionhbox), _prefs->versionText, FALSE, 
FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(versionhbox), _prefs->versionText,
+            FALSE, FALSE, 0);
+
     // Put text in the entry box      
-    gtk_entry_set_text(GTK_ENTRY(_prefs->versionText), 
_rcfile.getFlashVersionString().c_str());
+    gtk_entry_set_text(GTK_ENTRY(_prefs->versionText),
+            _rcfile.getFlashVersionString().c_str());
 
     // OS label
     GtkWidget *oshbox = gtk_hbox_new (FALSE, 2);
@@ -1568,7 +1534,8 @@
     _prefs->osText = gtk_entry_new ();
     gtk_box_pack_start(GTK_BOX(oshbox), _prefs->osText, FALSE, FALSE, 0);
     // Put text in the entry box      
-    gtk_entry_set_text(GTK_ENTRY(_prefs->osText), 
_rcfile.getFlashSystemOS().c_str());
+    gtk_entry_set_text(GTK_ENTRY(_prefs->osText),
+            _rcfile.getFlashSystemOS().c_str());
     
     GtkWidget *OSadvicelabel = gtk_label_new (_("<i>If blank, Gnash will "
                                           "detect your OS</i>"));
@@ -1577,7 +1544,7 @@
     gtk_box_pack_start(GTK_BOX(playervbox), OSadvicelabel, FALSE, FALSE, 0);
 
     // URL opener
-    GtkWidget *urlopenerbox = gtk_hbox_new (FALSE, 2);
+    GtkWidget *urlopenerbox = gtk_hbox_new(FALSE, 2);
     gtk_box_pack_start(GTK_BOX(playervbox), urlopenerbox, FALSE, FALSE, 0);
     
     GtkWidget *urlopenerlabel = gtk_label_new (_("URL opener:"));
@@ -1592,10 +1559,16 @@
             _rcfile.getURLOpenerFormat().c_str());
 
     // Performance
-    GtkWidget *performancelabel = gtk_label_new (_("<b>Performance</b>"));
+    GtkWidget *performancelabel = gtk_label_new(_("<b>Performance</b>"));
     gtk_label_set_use_markup (GTK_LABEL (performancelabel), TRUE);
     gtk_box_pack_start(GTK_BOX(playervbox), performancelabel, FALSE, FALSE, 0);
 
+    GtkWidget* qualitybox = gtk_hbox_new(FALSE, 2);
+    gtk_box_pack_start(GTK_BOX(playervbox), qualitybox, FALSE, FALSE, 0);
+
+    GtkWidget* qualityoptions = gtk_vbox_new(FALSE, 5);
+    gtk_box_pack_start(GTK_BOX(qualitybox), qualityoptions, FALSE, FALSE, 0);
+
     // Library size
     GtkWidget *libraryhbox = gtk_hbox_new (FALSE, 2);
     gtk_box_pack_start(GTK_BOX(playervbox), libraryhbox, FALSE, FALSE, 0);
@@ -1620,8 +1593,7 @@
 } 
 
 
-
-} // end of anonimous namespace
+} // anonymous namespace
 
 
 void
@@ -1639,8 +1611,8 @@
     GtkWidget *propsDialog = gtk_dialog_new_with_buttons(
                                        _("Movie properties"),
                                        GTK_WINDOW(_window),
-                                       // The cast is necessary if there is 
more
-                                       // than one option.
+                        // The cast is necessary if there is more
+                        // than one option.
                                        GtkDialogFlags(
                                        GTK_DIALOG_DESTROY_WITH_PARENT),
                                        // Just a 'close' button
@@ -1649,8 +1621,7 @@
 
     // Not too small... But I'd rather not have to specify
     // a size in pixels.
-    gtk_window_set_default_size (GTK_WINDOW(propsDialog),
-                                 500, 300);
+    gtk_window_set_default_size(GTK_WINDOW(propsDialog), 500, 300);
     
     // Suggest to the window manager to allow "maximize"
     // As there can be (will be) a lot of data.
@@ -1664,20 +1635,19 @@
                G_CALLBACK(gtk_widget_destroy), NULL);
 
     GtkWidget *propsvbox = gtk_vbox_new (FALSE, 1);
-    gtk_container_add (GTK_CONTAINER (
+    gtk_container_add(GTK_CONTAINER(
                         GTK_DIALOG(propsDialog)->vbox), propsvbox);
 
 #ifdef USE_SWFTREE
 
     std::auto_ptr<InfoTree> infoptr = getMovieInfo();
 
-    GtkWidget *scrollwindow1 = gtk_scrolled_window_new (NULL, NULL);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwindow1),
+    GtkWidget *scrollwindow1 = gtk_scrolled_window_new(0, 0);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow1),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_AUTOMATIC);
 
-    gtk_box_pack_start (
-            GTK_BOX (propsvbox), scrollwindow1, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX (propsvbox), scrollwindow1, TRUE, TRUE, 0);
 
     enum
     {
@@ -1710,12 +1680,13 @@
     // Add columns:
     
     // 'Variable' column:
-    renderer = gtk_cell_renderer_text_new ();
-    coloffset = gtk_tree_view_insert_column_with_attributes 
(GTK_TREE_VIEW(treeview),
-                                              -1, _("Variable"),
-                                              renderer, "text",
-                                              STRING1_COLUMN,
-                                              NULL);
+    renderer = gtk_cell_renderer_text_new();
+    coloffset = gtk_tree_view_insert_column_with_attributes(
+            GTK_TREE_VIEW(treeview),
+            -1, _("Variable"),
+            renderer, "text",
+            STRING1_COLUMN,
+            NULL);
     column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), coloffset - 
1);
 
     // 'Value' column:
@@ -1723,19 +1694,20 @@
     // copied; it can't actually be edited, though.
     renderer = gtk_cell_renderer_text_new ();
     g_object_set (renderer, "xalign", 0.0, "editable", TRUE, NULL);
-    coloffset = gtk_tree_view_insert_column_with_attributes 
(GTK_TREE_VIEW(treeview),
-                                              -1, _("Value"),
-                                              renderer, "text",
-                                              STRING2_COLUMN,
-                                              NULL);
-    column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), coloffset - 
1);
+    coloffset = gtk_tree_view_insert_column_with_attributes(
+            GTK_TREE_VIEW(treeview),
+            -1, _("Value"),
+            renderer, "text",
+            STRING2_COLUMN,
+            NULL);
+    column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), coloffset - 1);
 
     //Add tree to scrollwindow.
-    gtk_container_add (GTK_CONTAINER (scrollwindow1), treeview);
+    gtk_container_add(GTK_CONTAINER(scrollwindow1), treeview);
 
 #endif
 
-    gtk_widget_show_all (propsDialog);
+    gtk_widget_show_all(propsDialog);
 
 }
 
@@ -1783,7 +1755,8 @@
 #ifdef HAVE_GST_GST_H
     comments.append(_("\nBuilt against gstreamer version: "));
     std::ostringstream ss;
-    ss << GST_VERSION_MAJOR << "." << GST_VERSION_MINOR << "." << 
GST_VERSION_MICRO;
+    ss << GST_VERSION_MAJOR << "." << GST_VERSION_MINOR << "." <<
+        GST_VERSION_MICRO;
     comments.append(ss.str());
 #endif
 #ifdef HAVE_FFMPEG_AVCODEC_H
@@ -1829,8 +1802,8 @@
     gtk_about_dialog_set_website(about, "http://www.gnu.org/software/gnash/";);
 
     // Destroy the dialogue box when 'close' is clicked.
-    g_signal_connect(G_OBJECT(aboutWidget),
-            "response",  G_CALLBACK(gtk_widget_destroy), aboutWidget);
+    g_signal_connect(aboutWidget, "response", 
+            G_CALLBACK(gtk_widget_destroy), aboutWidget);
 
     gtk_widget_show (aboutWidget);
 
@@ -1860,7 +1833,8 @@
         "GNU General Public License for more details.\n"
         "You should have received a copy of the GNU General Public License\n"
         "along with this program; if not, write to the Free Software\n"
-        "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA",
+        "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301"
+        "  USA",
         "website", "http://www.gnu.org/software/gnash/";,
         NULL);
 #endif
@@ -1868,8 +1842,591 @@
                gdk_pixbuf_unref(logo_pixbuf);
 }
 
-void
-GtkGui::menuitem_openfile_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///                                                                         ///
+///                                Menus                                    ///
+///                                                                         ///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+
+// Create a File menu that can be used from the menu bar or the popup.
+void
+GtkGui::createFileMenu(GtkWidget *obj)
+{
+    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic(_("_File"));
+    gtk_widget_show(menuitem);
+    gtk_container_add(GTK_CONTAINER(obj), menuitem);
+    
+    GtkWidget *menu = gtk_menu_new();
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
+
+    // Open    
+    GtkWidget *open = gtk_image_menu_item_new_from_stock("gtk-open", 0);
+    gtk_widget_show(open);
+    gtk_container_add(GTK_CONTAINER(menu), open);
+    g_signal_connect(open, "activate", G_CALLBACK(menuOpenFile), this);
+
+    // Save    
+    GtkWidget *save = gtk_image_menu_item_new_from_stock("gtk-save", 0);
+    gtk_widget_show(save);
+    gtk_container_add(GTK_CONTAINER(menu), save);
+    // Disabled until save functionality is implemented:
+    gtk_widget_set_sensitive(save, FALSE); 
+
+    // Save as
+    GtkWidget *saveAs = gtk_image_menu_item_new_from_stock("gtk-save-as", 0);
+    gtk_widget_show(saveAs);
+    gtk_container_add(GTK_CONTAINER(menu), saveAs);
+    // Disabled until save-as functionality is implemented:
+    gtk_widget_set_sensitive(saveAs, FALSE);
+    
+    GtkWidget *separatormenuitem1 = gtk_separator_menu_item_new();
+    gtk_widget_show(separatormenuitem1);
+    gtk_container_add(GTK_CONTAINER(menu), separatormenuitem1);
+
+    // Properties
+    GtkWidget *properties =
+        gtk_image_menu_item_new_from_stock("gtk-properties", 0);
+    gtk_widget_show(properties);
+    gtk_container_add(GTK_CONTAINER(menu), properties);
+    g_signal_connect(properties, "activate", G_CALLBACK(menuMovieInfo), this);
+
+    GtkWidget *separator2 = gtk_separator_menu_item_new();
+    gtk_widget_show(separator2);
+    gtk_container_add(GTK_CONTAINER(menu), separator2);
+
+    GtkWidget *quit = gtk_image_menu_item_new_from_stock("gtk-quit", 0);
+    gtk_widget_show(quit);
+    gtk_container_add(GTK_CONTAINER(menu), quit);
+
+    g_signal_connect(quit, "activate", G_CALLBACK(menuQuit), this);
+}
+
+// Create an Edit menu that can be used from the menu bar or the popup.
+void
+GtkGui::createEditMenu(GtkWidget *obj)
+{
+    
+    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic(_("_Edit"));
+    gtk_widget_show(menuitem);
+    gtk_container_add(GTK_CONTAINER(obj), menuitem);
+    
+    GtkWidget *menu = gtk_menu_new();
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
+
+    GtkWidget *preferences =
+        gtk_image_menu_item_new_from_stock("gtk-preferences", 0);
+    gtk_widget_show(preferences);
+    gtk_container_add(GTK_CONTAINER(menu), preferences);
+
+    g_signal_connect(preferences, "activate", G_CALLBACK(menuPreferences),
+                      this);
+}
+
+// Create a Help menu that can be used from the menu bar or the popup.
+void
+GtkGui::createHelpMenu(GtkWidget *obj)
+{
+    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic(_("_Help"));
+    gtk_widget_show(menuitem);
+    gtk_container_add(GTK_CONTAINER (obj), menuitem);
+    
+    GtkWidget *menu = gtk_menu_new();
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
+
+    GtkWidget *about = gtk_image_menu_item_new_from_stock("gtk-about", 0);
+    gtk_widget_show(about);
+    gtk_container_add(GTK_CONTAINER(menu), about);
+    
+    g_signal_connect(about, "activate", G_CALLBACK(menuAbout), this);
+}
+
+
+// Create a View menu that can be used from the menu bar or the popup.
+void
+GtkGui::createViewMenu(GtkWidget *obj)
+{
+
+    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_View"));
+    gtk_widget_show (menuitem);
+    gtk_container_add (GTK_CONTAINER (obj), menuitem);
+    
+    GtkWidget *menu = gtk_menu_new ();
+    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+
+    // Refresh
+    GtkWidget *refresh = gtk_image_menu_item_new_with_label(_("Redraw"));
+    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(refresh),
+        gtk_image_new_from_stock("gtk-refresh", GTK_ICON_SIZE_MENU));
+    gtk_menu_append(menu, refresh);
+    gtk_widget_show(refresh);
+    g_signal_connect(refresh, "activate", G_CALLBACK(menuRefreshView), this);
+
+    // Fullscreen
+#if GTK_CHECK_VERSION(2,8,0)
+    GtkWidget *fullscreen = 
+           gtk_image_menu_item_new_with_label(_("Toggle fullscreen"));
+    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(fullscreen),
+               gtk_image_new_from_stock("gtk-fullscreen", GTK_ICON_SIZE_MENU));
+#else
+    GtkWidget *fullscreen = 
+        gtk_menu_item_new_with_label(_("Toggle fullscreen"));
+#endif
+    gtk_menu_append(menu, fullscreen);
+    gtk_widget_show(GTK_WIDGET(fullscreen));
+    g_signal_connect(fullscreen, "activate", G_CALLBACK(menuFullscreen), this);
+
+// Can be disabled at compile time.
+#ifndef DISABLE_REGION_UPDATES_DEBUGGING
+    GtkWidget *updated_regions =
+        gtk_check_menu_item_new_with_label(_("Show updated ranges"));
+   
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(updated_regions),
+            showUpdatedRegions());
+
+    gtk_menu_append(menu, updated_regions);
+    gtk_widget_show(updated_regions);
+    g_signal_connect(updated_regions, "activate",
+                     G_CALLBACK(menuShowUpdatedRegions), this);
+#endif
+
+}
+
+// Create a Control menu that can be used from the menu bar or the popup.
+void
+GtkGui::createControlMenu(GtkWidget *obj)
+{
+
+    // Movie Control Menu
+    GtkWidget *control = gtk_menu_item_new_with_mnemonic(_("Movie _Control"));
+    gtk_widget_show(control);
+    gtk_container_add(GTK_CONTAINER(obj), control);
+    
+    GtkWidget *menu = gtk_menu_new();
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(control), menu);
+
+    // Play
+#if GTK_CHECK_VERSION(2,6,0)
+    GtkWidget *play = gtk_image_menu_item_new_from_stock("gtk-media-play", 0);
+#else
+    GtkWidget *play = gtk_menu_item_new_with_label(_("Play"));
+#endif
+    gtk_menu_append(menu, play);
+    gtk_widget_show(play);    
+    g_signal_connect (play, "activate", G_CALLBACK(menuPlay), this);
+
+    // Pause
+#if GTK_CHECK_VERSION(2,6,0)
+    GtkWidget *pause = 
+        gtk_image_menu_item_new_from_stock ("gtk-media-pause", 0);
+#else
+    GtkWidget *pause = gtk_menu_item_new_with_label(_("Pause"));
+#endif
+    gtk_menu_append(menu, pause);
+    gtk_widget_show(pause);
+    g_signal_connect(pause, "activate", G_CALLBACK(menuPause), this);
+
+    // Stop
+#if GTK_CHECK_VERSION(2,6,0)
+    GtkWidget *stop = gtk_image_menu_item_new_from_stock("gtk-media-stop", 0);
+#else
+    GtkWidget *stop = gtk_menu_item_new_with_label(_("Stop"));
+#endif
+    gtk_menu_append(menu, stop);
+    gtk_widget_show(stop);
+    g_signal_connect(stop, "activate", G_CALLBACK(menuStop), this);
+
+    GtkWidget *separator1 = gtk_separator_menu_item_new();
+    gtk_widget_show(separator1);
+    gtk_container_add(GTK_CONTAINER(menu), separator1);
+
+    // Restart
+    // 
+    GtkWidget *restart = gtk_image_menu_item_new_with_label(_("Restart 
Movie"));
+
+    // Suitable image?
+    gtk_menu_append(menu, restart);
+    gtk_widget_show(restart);
+    g_signal_connect(restart, "activate", G_CALLBACK(menuRestart), this);
+
+}
+
+bool
+lirc_handler(void*, int, void* /*data*/)
+{ 
+    
+    // want to remove this handler. You may want to close fd.
+    log_debug("%s\n", lirc->getButton());
+  
+    // Want to keep this handler
+    return true;
+}
+
+// This assumes that the parent of _drawingArea is _window, which
+// isn't the case in the plugin fullscreen (it's _overlay). Currently
+// we return from fullscreen when Gui::stop() is called, which
+// seems like a good idea, and also avoids this problem.
+void
+GtkGui::stopHook()
+{
+
+    // Assert they're either both initialised or both uninitialised
+    assert ((_resumeButton && _vbox) || !(_resumeButton || _vbox));
+    if (_resumeButton) {
+        gtk_box_pack_start(GTK_BOX(_vbox), _resumeButton, FALSE, FALSE, 0);
+    }
+}
+
+void
+GtkGui::playHook()
+{
+    assert ((_resumeButton && _vbox) || !(_resumeButton || _vbox));
+    if (_resumeButton) {
+        gtk_container_remove(GTK_CONTAINER(_vbox), _resumeButton);
+    }
+}
+
+
+
+/// Anonymous namespace for callbacks, local functions, event handlers etc.
+namespace {
+
+static GList *pixmaps_directories = NULL;
+
+// Adds the Gnash icon to a window.
+void
+addGnashIcon(GtkWindow* window)
+{
+    GdkPixbuf *window_icon_pixbuf = createPixbuf ("GnashG.png");
+    if (window_icon_pixbuf) {
+        gtk_window_set_icon (GTK_WINDOW (window), window_icon_pixbuf);
+               gdk_pixbuf_unref (window_icon_pixbuf);
+    }
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+createPixbuf (const gchar *filename)
+{
+    gchar *pathname = NULL;
+    GdkPixbuf *pixbuf;
+    GError *error = NULL;
+
+    if (!filename || !filename[0])
+       return NULL;
+
+    pathname = findPixmapFile (filename);
+
+    if (!pathname) {
+        log_error (_("Couldn't find pixmap file: %s"), filename);
+        g_warning (_("Couldn't find pixmap file: %s"), filename);
+        return NULL;
+    }
+
+    pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+    if (!pixbuf) {
+        log_error (_("Failed to load pixbuf file: %s: %s"), pathname, 
error->message);
+        g_error_free (error);
+    }
+    g_free (pathname);
+    return pixbuf;
+}
+
+key::code
+gdk_to_gnash_key(guint key)
+{
+    key::code c(key::INVALID);
+
+    // ascii 32-126 in one range:    
+    if (key >= GDK_space && key <= GDK_asciitilde) {
+        c = (key::code) ((key - GDK_space) + key::SPACE);
+    }
+
+    // Function keys:
+    else if (key >= GDK_F1 && key <= GDK_F15)  {
+        c = (key::code) ((key - GDK_F1) + key::F1);
+    }
+
+    // Keypad:
+    else if (key >= GDK_KP_0 && key <= GDK_KP_9) {
+        c = (key::code) ((key - GDK_KP_0) + key::KP_0);
+    }
+
+    // Extended ascii:
+    else if (key >= GDK_nobreakspace && key <= GDK_ydiaeresis) {
+        c = (key::code) ((key - GDK_nobreakspace) + 
+                key::NOBREAKSPACE);
+    }
+
+    // non-character keys don't correlate, so use a look-up table.
+    else {
+        struct {
+            guint             gdk;
+            key::code  gs;
+        } table[] = {
+            { GDK_BackSpace, key::BACKSPACE },
+            { GDK_Tab, key::TAB },
+            { GDK_Clear, key::CLEAR },
+            { GDK_Return, key::ENTER },
+            
+            { GDK_Shift_L, key::SHIFT },
+            { GDK_Shift_R, key::SHIFT },
+            { GDK_Control_L, key::CONTROL },
+            { GDK_Control_R, key::CONTROL },
+            { GDK_Alt_L, key::ALT },
+            { GDK_Alt_R, key::ALT },
+            { GDK_Caps_Lock, key::CAPSLOCK },
+            
+            { GDK_Escape, key::ESCAPE },
+            
+            { GDK_Page_Down, key::PGDN },
+            { GDK_Page_Up, key::PGUP },
+            { GDK_Home, key::HOME },
+            { GDK_End, key::END },
+            { GDK_Left, key::LEFT },
+            { GDK_Up, key::UP },
+            { GDK_Right, key::RIGHT },
+            { GDK_Down, key::DOWN },
+            { GDK_Insert, key::INSERT },
+            { GDK_Delete, key::DELETEKEY },
+            
+            { GDK_Help, key::HELP },
+            { GDK_Num_Lock, key::NUM_LOCK },
+
+            { GDK_VoidSymbol, key::INVALID }
+        };
+        
+        for (int i = 0; table[i].gdk != GDK_VoidSymbol; i++) {
+            if (key == table[i].gdk) {
+                c = table[i].gs;
+                break;
+            }
+        }
+    }
+    
+    return c;
+}
+
+int
+gdk_to_gnash_modifier(int state)
+{
+    int modifier = key::GNASH_MOD_NONE;
+
+    if (state & GDK_SHIFT_MASK) {
+      modifier = modifier | key::GNASH_MOD_SHIFT;
+    }
+    if (state & GDK_CONTROL_MASK) {
+      modifier = modifier | key::GNASH_MOD_CONTROL;
+    }
+    if (state & GDK_MOD1_MASK) {
+      modifier = modifier | key::GNASH_MOD_ALT;
+    }
+
+    return modifier;
+}
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+addPixmapDirectory(const gchar* directory)
+{
+    pixmaps_directories = 
+        g_list_prepend(pixmaps_directories, g_strdup (directory));
+}
+
+
+/* This is an internally used function to find pixmap files. */
+gchar*
+findPixmapFile(const gchar* filename)
+{
+    GList *elem;
+
+    /* We step through each of the pixmaps directory to find it. */
+    elem = pixmaps_directories;
+    while (elem) {
+        gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+                G_DIR_SEPARATOR_S, filename);
+        if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+            return pathname;
+        g_free (pathname);
+        elem = elem->next;
+    }
+    return NULL;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///                                                                         ///
+///                             Event Handlers                              ///
+///                                                                         ///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+
+gboolean
+exposeEvent(GtkWidget *const /*widget*/, GdkEventExpose *const event,
+        const gpointer data)
+{
+
+    GtkGui* gui = static_cast<GtkGui*>(data);
+
+    gui->expose(event->region);
+
+    return TRUE;
+}
+
+gboolean
+configureEvent(GtkWidget *const widget, GdkEventConfigure *const event,
+        const gpointer data)
+{
+    GtkGui* obj = static_cast<GtkGui*>(data);
+
+    GtkGlue& glue = obj->rendererGlue();
+
+    glue.configure(widget, event);
+    obj->resize_view(event->width, event->height);
+
+    return TRUE;
+}
+
+gboolean
+realizeEvent(GtkWidget* /*widget*/, GdkEvent* /*event*/, gpointer /*data*/)
+{
+    return TRUE;
+}
+
+// Shut everything down and exit when we're destroyed as a window
+gboolean
+deleteEvent(GtkWidget* /*widget*/, GdkEvent* /*event*/, gpointer /*data*/)
+{
+    GNASH_REPORT_FUNCTION;
+
+    gtk_main_quit();
+    return TRUE;
+}
+
+
+gboolean
+keyPressEvent(GtkWidget *const /*widget*/, GdkEventKey *const event,
+        const gpointer data)
+{
+
+    Gui* gui = static_cast<Gui*>(data);
+
+    /* Forward key event to gnash */
+    key::code c = gdk_to_gnash_key(event->keyval);
+    int mod = gdk_to_gnash_modifier(event->state);
+    
+    if (c != key::INVALID) {
+        gui->notify_key_event(c, mod, true);
+    }
+        
+    return true;
+}
+
+gboolean
+keyReleaseEvent(GtkWidget *const /*widget*/, GdkEventKey *const event,
+        const gpointer data)
+{
+
+    Gui* gui = static_cast<Gui*>(data);
+
+    /* Forward key event to gnash */
+    key::code  c = gdk_to_gnash_key(event->keyval);
+    int mod = gdk_to_gnash_modifier(event->state);
+    
+    if (c != key::INVALID) {
+        gui->notify_key_event(c, mod, false);
+    }
+    
+    return true;
+}
+
+gboolean
+buttonPressEvent(GtkWidget *const /*widget*/, GdkEventButton *const event,
+        const gpointer data)
+{
+
+    /// Double- and triple-clicks should not send an extra event!
+    /// Flash has no built-in double click.
+    if (event->type != GDK_BUTTON_PRESS) return false;
+
+    GtkGui *obj = static_cast<GtkGui*>(data);
+
+    obj->grabFocus();
+
+    int        mask = 1 << (event->button - 1);
+    obj->notify_mouse_clicked(true, mask);
+    return true;
+}
+
+gboolean
+buttonReleaseEvent(GtkWidget * const /*widget*/,
+     GdkEventButton * const event, const gpointer data)
+{
+    Gui *obj = static_cast<Gui*>(data);
+
+    int        mask = 1 << (event->button - 1);
+    obj->notify_mouse_clicked(false, mask);
+    return true;
+}
+
+gboolean
+motionNotifyEvent(GtkWidget *const /*widget*/, GdkEventMotion *const event,
+        const gpointer data)
+{
+    Gui *obj = static_cast<Gui *>(data);
+
+    obj->notify_mouse_moved(event->x, event->y);
+    return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///                                                                         ///
+///                             Callbacks                                   ///
+///                                                                         ///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+/// This method is called when the "OK" button is clicked in the open file
+/// dialog. For GTK <= 2.4.0, this is a callback called by GTK itself.
+void
+openFile(GtkWidget *widget, gpointer /* user_data */)
+{
+#if 0
+    // We'll need this when implementing file opening.
+    GtkGui* gui = static_cast<GtkGui*>(user_data);
+#endif
+   
+#if GTK_CHECK_VERSION(2,4,0)
+    char* filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+#else   
+    GtkWidget* file_selector = gtk_widget_get_ancestor(widget,
+                                 g_type_from_name("GtkFileSelection"));
+
+    GtkFileSelection* filesel = GTK_FILE_SELECTION (file_selector);
+    const char* filename = gtk_file_selection_get_filename (filesel);
+#endif
+
+    // FIXME: we want to do something like calling gtk_main_quit here, so
+    // run() will return. If run() is then changed to return a pointer to the
+    // next file to be played, then the Player class can play the next file,
+    // unless run() returns NULL.
+    log_error (_("Attempting to open file %s.\n"
+               "NOTE: the file open functionality is not yet implemented!"),
+              filename);
+
+#if GTK_CHECK_VERSION(2,4,0)
+    g_free(filename);
+#endif
+}
+
+
+void
+menuOpenFile(GtkMenuItem* /*menuitem*/, gpointer data)
 {
     GtkWidget* dialog;
     GtkGui* gui = static_cast<GtkGui*>(data);
@@ -1895,27 +2452,20 @@
     g_signal_connect (selector->ok_button, "clicked", G_CALLBACK (openFile),
                       gui);
 
-    g_signal_connect_swapped (selector->ok_button, "clicked", 
-                              G_CALLBACK (gtk_widget_destroy), dialog);
+    g_signal_connect_swapped(selector->ok_button, "clicked", 
+                              G_CALLBACK(gtk_widget_destroy), dialog);
 
-    g_signal_connect_swapped (selector->cancel_button, "clicked",
-                              G_CALLBACK (gtk_widget_destroy), dialog); 
+    g_signal_connect_swapped(selector->cancel_button, "clicked",
+                              G_CALLBACK(gtk_widget_destroy), dialog); 
    
     gtk_widget_show (dialog);
 #endif // GTK_CHECK_VERSION(2,4,0)
 }
 
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-///                                                                         ///
-///                             Callbacks                                   ///
-///                                                                         ///
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
 
 /// 'About' callback
 void
-GtkGui::menuitem_about_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuAbout(GtkMenuItem* /*menuitem*/, gpointer data)
 {
     GtkGui* gui = static_cast<GtkGui*>(data);
     gui->showAboutDialog();
@@ -1923,16 +2473,15 @@
 
 /// Preferences callback
 void
-GtkGui::menuitem_preferences_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuPreferences(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-    
     GtkGui* gui = static_cast<GtkGui*>(data);
     gui->showPreferencesDialog();
 }
 
 // Properties Callback
 void
-GtkGui::menuitem_movieinfo_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuMovieInfo(GtkMenuItem* /*menuitem*/, gpointer data)
 {
     GtkGui* gui = static_cast<GtkGui*>(data);
     gui->showPropertiesDialog();
@@ -1940,14 +2489,12 @@
 
 // This pops up the menu when the right mouse button is clicked
 gint
-GtkGui::popup_handler(GtkWidget *widget, GdkEvent *event)
+popupHandler(GtkWidget *widget, GdkEvent *event)
 {
-//    GNASH_REPORT_FUNCTION;
-
     GtkMenu *menu = GTK_MENU(widget);
-//    printf("event type # %i\n", event->type);
+    
     if (event->type == GDK_BUTTON_PRESS) {
-        GdkEventButton *event_button = (GdkEventButton *) event;
+        GdkEventButton* event_button = 
reinterpret_cast<GdkEventButton*>(event);
         if (event_button->button == 3) {
             gtk_menu_popup(menu, NULL, NULL, NULL, NULL,
                            event_button->button, event_button->time);
@@ -1959,17 +2506,15 @@
 
 /// \brief Toggle the sound on or off
 void
-GtkGui::menuitem_sound_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuSound(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-//    GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->toggleSound();
 }
 
 void
-GtkGui::menuitem_fullscreen_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuFullscreen(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-//    GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->toggleFullscreen();
 }
@@ -1977,689 +2522,64 @@
 
 /// \brief restart the movie from the beginning
 void
-GtkGui::menuitem_restart_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuRestart(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-    //GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->restart();
 }
 
 /// \brief quit complete, and close the application
 void
-GtkGui::menuitem_quit_callback(GtkMenuItem* /*menuitem*/, gpointer /*data*/)
+menuQuit(GtkMenuItem* /*menuitem*/, gpointer /*data*/)
 {
-//    GNASH_REPORT_FUNCTION;
-
     gtk_main_quit();
 }
 
 /// \brief Start the movie playing from the current frame.
 void
-GtkGui::menuitem_play_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuPlay(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-//    GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->play();
 }
 
 /// \brief toggle between playing or paused.
 void
-GtkGui::menuitem_pause_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuPause(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-//    GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->pause();
 }
 
 /// \brief stop the movie that's playing.
 void
-GtkGui::menuitem_stop_callback(GtkMenuItem* /*menuitem*/, gpointer data)
+menuStop(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-    GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->stop();
 }
 
-/// \brief step forward 1 frame
-void
-GtkGui::menuitem_step_forward_callback(GtkMenuItem* /*menuitem*/,
-               gpointer data)
-{
-//    GNASH_REPORT_FUNCTION;
-    Gui* gui = static_cast<Gui*>(data);
-    gui->menu_step_forward();
-}
-
-/// \brief step backward 1 frame
-void
-GtkGui::menuitem_step_backward_callback(GtkMenuItem* /*menuitem*/,
-               gpointer data)
-{
-//    GNASH_REPORT_FUNCTION;
-    Gui* gui = static_cast<Gui*>(data);
-    gui->menu_step_backward();
-}
-
-/// \brief jump forward 10 frames
-void
-GtkGui::menuitem_jump_forward_callback(GtkMenuItem* /*menuitem*/,
-                               gpointer data)
-{
-//    GNASH_REPORT_FUNCTION;
-    Gui* gui = static_cast<Gui*>(data);
-    gui->menu_jump_forward();
-}
-
-/// \brief jump backward 10 frames
-void
-GtkGui::menuitem_jump_backward_callback(GtkMenuItem* /*menuitem*/,
-                                gpointer data)
-{
-//    GNASH_REPORT_FUNCTION;
-    Gui* gui = static_cast<Gui*>(data);
-    gui->menu_jump_backward();
-}
 
 /// \brief Force redraw
 void
-GtkGui::menuitem_refresh_view_callback(GtkMenuItem* /*menuitem*/,
-                                gpointer data)
+menuRefreshView(GtkMenuItem* /*menuitem*/, gpointer data)
 {
-//    GNASH_REPORT_FUNCTION;
     Gui* gui = static_cast<Gui*>(data);
     gui->refreshView();
 }
 
 /// \brief Force redraw
 void
-GtkGui::menuitem_show_updated_regions_callback(GtkMenuItem* /*menuitem*/,
-                                gpointer data)
+menuShowUpdatedRegions(GtkMenuItem* /*menuitem*/, gpointer data)
 {
     Gui* gui = static_cast<Gui*>(data);
-    gui->showUpdatedRegions(! (gui->showUpdatedRegions()) );
+    gui->showUpdatedRegions(!gui->showUpdatedRegions());
     
     // refresh to clear the remaining red lines...
-    if ( ! (gui->showUpdatedRegions()))
-      gui->refreshView();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-///                                                                         ///
-///                             Event Handlers                              ///
-///                                                                         ///
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-gboolean
-GtkGui::expose_event(GtkWidget *const /*widget*/,
-             GdkEventExpose *const event,
-             const gpointer data)
-{
-//     GNASH_REPORT_FUNCTION;
-
-    GtkGui* gui = static_cast<GtkGui*>(data);
-
-    gui->expose(event->region);
-
-    return TRUE;
-}
-
-gboolean
-GtkGui::configure_event(GtkWidget *const widget,
-                GdkEventConfigure *const event,
-                const gpointer data)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    GtkGui* obj = static_cast<GtkGui*>(data);
-
-    GtkGlue& glue = *(obj->_glue);
-
-    glue.configure(widget, event);
-    obj->resize_view(event->width, event->height);
-
-    return TRUE;
-}
-
-gboolean
-GtkGui::realize_event(GtkWidget* /*widget*/, GdkEvent* /*event*/,
-               gpointer /*data*/)
-{
-    //GNASH_REPORT_FUNCTION;
-
-    return TRUE;
-}
-
-// Shut everything down and exit when we're destroyed as a window
-gboolean
-GtkGui::delete_event(GtkWidget* /*widget*/, GdkEvent* /*event*/,
-                       gpointer /*data*/)
-{
-    GNASH_REPORT_FUNCTION;
-
-    gtk_main_quit();
-    return TRUE;
-}
-
-
-gboolean
-GtkGui::key_press_event(GtkWidget *const /*widget*/,
-                GdkEventKey *const event,
-                const gpointer data)
-{
-    //GNASH_REPORT_FUNCTION;
-
-    Gui* gui = static_cast<Gui*>(data);
-
-    /* Forward key event to gnash */
-    gnash::key::code   c = gdk_to_gnash_key(event->keyval);
-    int mod = gdk_to_gnash_modifier(event->state);
-    
-    if (c != gnash::key::INVALID) {
-        gui->notify_key_event(c, mod, true);
-    }
-        
-    return true;
-}
-
-gboolean
-GtkGui::key_release_event(GtkWidget *const /*widget*/,
-                GdkEventKey *const event,
-                const gpointer data)
-{
-    //GNASH_REPORT_FUNCTION;
-
-    Gui* gui = static_cast<Gui*>(data);
-
-    /* Forward key event to gnash */
-    gnash::key::code   c = gdk_to_gnash_key(event->keyval);
-    int mod = gdk_to_gnash_modifier(event->state);
-    
-    if (c != gnash::key::INVALID) {
-        gui->notify_key_event(c, mod, false);
-    }
-    
-    return true;
-}
-
-gboolean
-GtkGui::button_press_event(GtkWidget *const /*widget*/,
-                           GdkEventButton *const event,
-                           const gpointer data)
-{
-
-    /// Double- and triple-clicks should not send an extra event!
-    /// Flash has no built-in double click.
-    if (event->type != GDK_BUTTON_PRESS) return false;
-
-    GtkGui *obj = static_cast<GtkGui *>(data);
-
-    obj->grabFocus();
-
-    int        mask = 1 << (event->button - 1);
-    obj->notify_mouse_clicked(true, mask);
-    return true;
-}
-
-gboolean
-GtkGui::button_release_event(GtkWidget * const /*widget*/,
-                             GdkEventButton * const event,
-                             const gpointer data)
-{
-    //GNASH_REPORT_FUNCTION;
-    Gui *obj = static_cast<Gui *>(data);
-
-    int        mask = 1 << (event->button - 1);
-    obj->notify_mouse_clicked(false, mask);
-    return true;
-}
-
-gboolean
-GtkGui::motion_notify_event(GtkWidget *const /*widget*/,
-                            GdkEventMotion *const event,
-                            const gpointer data)
-{
-//    GNASH_REPORT_FUNCTION;
-    Gui *obj = static_cast<Gui *>(data);
-
-    obj->notify_mouse_moved(event->x, event->y);
-    return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-///                                                                         ///
-///                                Menus                                    ///
-///                                                                         ///
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-
-// Create a File menu that can be used from the menu bar or the popup.
-void
-GtkGui::createFileMenu(GtkWidget *obj)
-{
-//    GNASH_REPORT_FUNCTION;
-    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_File"));
-    gtk_widget_show (menuitem);
-    gtk_container_add (GTK_CONTAINER (obj), menuitem);
-    
-    GtkWidget *menu = gtk_menu_new ();
-    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
-
-// Open    
-    GtkWidget *open =
-       gtk_image_menu_item_new_from_stock ("gtk-open", NULL);
-    gtk_widget_show (open);
-    gtk_container_add (GTK_CONTAINER (menu), open);
-    g_signal_connect ((gpointer) open, "activate",
-                      G_CALLBACK (&menuitem_openfile_callback),
-                      this);
-
-// Save    
-    GtkWidget *save =
-       gtk_image_menu_item_new_from_stock ("gtk-save", NULL);
-    gtk_widget_show (save);
-    gtk_container_add (GTK_CONTAINER (menu), save);
-    // Disabled until save functionality is implemented:
-    gtk_widget_set_sensitive(save,FALSE); 
-
-// Save as
-    GtkWidget *save_as =
-       gtk_image_menu_item_new_from_stock ("gtk-save-as", NULL);
-    gtk_widget_show (save_as);
-    gtk_container_add (GTK_CONTAINER (menu), save_as);
-    // Disabled until save-as functionality is implemented:
-    gtk_widget_set_sensitive(save_as,FALSE);
-    
-    GtkWidget *separatormenuitem1 = gtk_separator_menu_item_new ();
-    gtk_widget_show (separatormenuitem1);
-    gtk_container_add (GTK_CONTAINER (menu), separatormenuitem1);
-
-// Properties
-    GtkWidget *properties =
-       gtk_image_menu_item_new_from_stock ("gtk-properties", NULL);
-    gtk_widget_show (properties);
-    gtk_container_add (GTK_CONTAINER (menu), properties);
-    g_signal_connect ((gpointer) properties, "activate",
-                      G_CALLBACK (&menuitem_movieinfo_callback),
-                      this);
-
-    GtkWidget *separator2 = gtk_separator_menu_item_new ();
-    gtk_widget_show (separator2);
-    gtk_container_add (GTK_CONTAINER (menu), separator2);
-
-    GtkWidget *quit = gtk_image_menu_item_new_from_stock ("gtk-quit", NULL);
-    gtk_widget_show (quit);
-    gtk_container_add (GTK_CONTAINER (menu), quit);
-
-    g_signal_connect ((gpointer) quit, "activate",
-                      G_CALLBACK (&menuitem_quit_callback),
-                      this);
-}
-
-// Create an Edit menu that can be used from the menu bar or the popup.
-void
-GtkGui::createEditMenu(GtkWidget *obj)
-{
-//    GNASH_REPORT_FUNCTION;
-    
-    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_Edit"));
-    gtk_widget_show (menuitem);
-    gtk_container_add (GTK_CONTAINER (obj), menuitem);
-    
-    GtkWidget *menu = gtk_menu_new ();
-    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
-
-    GtkWidget *preferences1 =
-       gtk_image_menu_item_new_from_stock ("gtk-preferences", NULL);
-    gtk_widget_show (preferences1);
-    gtk_container_add (GTK_CONTAINER (menu), preferences1);
-
-    g_signal_connect ((gpointer) preferences1, "activate",
-                      G_CALLBACK (&menuitem_preferences_callback),
-                      this);
-}
-
-// Create a Help menu that can be used from the menu bar or the popup.
-void
-GtkGui::createHelpMenu(GtkWidget *obj)
-{
-//    GNASH_REPORT_FUNCTION;
-    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_Help"));
-    gtk_widget_show (menuitem);
-    gtk_container_add (GTK_CONTAINER (obj), menuitem);
-    
-    GtkWidget *menu = gtk_menu_new ();
-    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
-
-    GtkWidget *about = gtk_image_menu_item_new_from_stock ("gtk-about", NULL);
-    gtk_widget_show (about);
-    gtk_container_add (GTK_CONTAINER (menu), about);
-    
-    g_signal_connect ((gpointer) about, "activate",
-                      G_CALLBACK (&menuitem_about_callback),
-                      this);
-}
-
-// Create a View menu that can be used from the menu bar or the popup.
-void
-GtkGui::createViewMenu(GtkWidget *obj)
-{
-
-//    GNASH_REPORT_FUNCTION;
-    GtkWidget *menuitem = gtk_menu_item_new_with_mnemonic (_("_View"));
-    gtk_widget_show (menuitem);
-    gtk_container_add (GTK_CONTAINER (obj), menuitem);
-    
-    GtkWidget *menu = gtk_menu_new ();
-    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
-
-    // Refresh
-    GtkImageMenuItem *menuitem_refresh =
-       GTK_IMAGE_MENU_ITEM(
-           gtk_image_menu_item_new_with_label(_("Redraw")));
-    gtk_image_menu_item_set_image (menuitem_refresh,
-                                  gtk_image_new_from_stock("gtk-refresh",
-                                                            
GTK_ICON_SIZE_MENU));
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_refresh));
-    gtk_widget_show(GTK_WIDGET(menuitem_refresh));
-    g_signal_connect ((gpointer) menuitem_refresh, "activate",
-        G_CALLBACK (&menuitem_refresh_view_callback), this);
-
-    // Fullscreen
-#if GTK_CHECK_VERSION(2,8,0)
-    GtkImageMenuItem *menuitem_fullscreen = GTK_IMAGE_MENU_ITEM(
-           gtk_image_menu_item_new_with_label(_("Toggle fullscreen")));
-    gtk_image_menu_item_set_image (menuitem_fullscreen,
-                                  gtk_image_new_from_stock("gtk-fullscreen",
-                                                            
GTK_ICON_SIZE_MENU));
-#else
-    GtkMenuItem *menuitem_fullscreen =
-       GTK_MENU_ITEM(gtk_menu_item_new_with_label(_("Toggle fullscreen")));
-#endif
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_fullscreen));
-    gtk_widget_show(GTK_WIDGET(menuitem_fullscreen));
-    g_signal_connect(GTK_OBJECT(menuitem_fullscreen), "activate",
-                         G_CALLBACK(&menuitem_fullscreen_callback), this);
-
-// Can be disabled at compile time.
-#ifndef DISABLE_REGION_UPDATES_DEBUGGING
-    GtkCheckMenuItem *menuitem_show_updated_regions =
-        GTK_CHECK_MENU_ITEM(gtk_check_menu_item_new_with_label(_("Show updated 
ranges")));
-   
-    gtk_check_menu_item_set_active 
(GTK_CHECK_MENU_ITEM(menuitem_show_updated_regions),
-                                    showUpdatedRegions() );
-
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_show_updated_regions));
-    gtk_widget_show(GTK_WIDGET(menuitem_show_updated_regions));
-    g_signal_connect(GTK_OBJECT(menuitem_show_updated_regions), "activate",
-                     G_CALLBACK(&menuitem_show_updated_regions_callback), 
this);
-#endif
-
-}
-
-// Create a Control menu that can be used from the menu bar or the popup.
-void
-GtkGui::createControlMenu(GtkWidget *obj)
-{
-//    GNASH_REPORT_FUNCTION;
-
-// Movie Control Menu
-    GtkWidget *menuitem_control =
-       gtk_menu_item_new_with_mnemonic (_("Movie _Control"));
-    gtk_widget_show (menuitem_control);
-    gtk_container_add (GTK_CONTAINER (obj), menuitem_control);
-    
-    GtkWidget *menu = gtk_menu_new ();
-    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem_control), menu);
-
-// Play
-#if GTK_CHECK_VERSION(2,6,0)
-    GtkMenuItem *menuitem_play = GTK_MENU_ITEM(
-       gtk_image_menu_item_new_from_stock ("gtk-media-play", NULL));
-#else
-    GtkMenuItem *menuitem_play =
-       GTK_MENU_ITEM(gtk_menu_item_new_with_label(_("Play")));
-#endif
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_play));
-    gtk_widget_show(GTK_WIDGET(menuitem_play));    
-    g_signal_connect ((gpointer) menuitem_play, "activate",
-        G_CALLBACK (&menuitem_play_callback), this);
-
-// Pause
-#if GTK_CHECK_VERSION(2,6,0)
-    GtkMenuItem *menuitem_pause = GTK_MENU_ITEM(
-       gtk_image_menu_item_new_from_stock ("gtk-media-pause", NULL));
-#else
-    GtkMenuItem *menuitem_pause =
-       GTK_MENU_ITEM(gtk_menu_item_new_with_label(_("Pause")));
-#endif
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_pause));
-    gtk_widget_show(GTK_WIDGET(menuitem_pause));
-    g_signal_connect ((gpointer) menuitem_pause, "activate",
-        G_CALLBACK (&menuitem_pause_callback), this);
-
-// Stop
-#if GTK_CHECK_VERSION(2,6,0)
-    GtkMenuItem *menuitem_stop = GTK_MENU_ITEM(
-       gtk_image_menu_item_new_from_stock ("gtk-media-stop", NULL));
-#else
-    GtkMenuItem *menuitem_stop =
-       GTK_MENU_ITEM(gtk_menu_item_new_with_label(_("Stop")));
-#endif
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_stop));
-    gtk_widget_show(GTK_WIDGET(menuitem_stop));
-    g_signal_connect ((gpointer) menuitem_stop, "activate",
-        G_CALLBACK (&menuitem_stop_callback), this);
-
-    GtkWidget *separator1 = gtk_separator_menu_item_new ();
-    gtk_widget_show (separator1);
-    gtk_container_add (GTK_CONTAINER (menu), separator1);
-
-// Restart
-// 
-    GtkImageMenuItem *menuitem_restart =
-       GTK_IMAGE_MENU_ITEM(
-            gtk_image_menu_item_new_with_label(_("Restart Movie")));
-// Suitable image?
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_restart));
-    gtk_widget_show(GTK_WIDGET(menuitem_restart));
-    g_signal_connect ((gpointer) menuitem_restart, "activate",
-        G_CALLBACK (&menuitem_restart_callback), this);
-
-#if 0 // Presently disabled
-
-    GtkWidget *separator2 = gtk_separator_menu_item_new ();
-    gtk_widget_show (separator1);
-    gtk_container_add (GTK_CONTAINER (menu), separator2);
-
-// Step Forward
-    GtkImageMenuItem *menuitem_step_forward =
-       GTK_IMAGE_MENU_ITEM(
-           gtk_image_menu_item_new_with_label(_("Step Forward Frame")));
-    gtk_image_menu_item_set_image (menuitem_step_forward,
-                                  gtk_image_new_from_stock("gtk-go-forward",
-                                                            
GTK_ICON_SIZE_MENU));
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_step_forward));
-    gtk_widget_show(GTK_WIDGET(menuitem_step_forward));
-//     gtk_widget_add_accelerator (GTK_WIDGET(menuitem_step_forward), 
"activate", accel_group,
-//                                 GDK_bracketleft, GDK_CONTROL_MASK, 
GTK_ACCEL_VISIBLE);
-
-// Step Backward
-    GtkImageMenuItem *menuitem_step_backward =
-       GTK_IMAGE_MENU_ITEM(
-           gtk_image_menu_item_new_with_label(_("Step Backward Frame")));
-    gtk_image_menu_item_set_image (menuitem_step_backward,
-                                  gtk_image_new_from_stock("gtk-go-back",
-                                                            
GTK_ICON_SIZE_MENU));
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_step_backward));
-    gtk_widget_show(GTK_WIDGET(menuitem_step_backward));
-//     gtk_widget_add_accelerator (GTK_WIDGET(menuitem_step_forward), 
"activate", accel_group,
-//                                 GDK_bracketright, GDK_CONTROL_MASK, 
GTK_ACCEL_VISIBLE);
-
-// Jump Forward
-// Stock image from Gtk-2.6 should be ignored in earlier versions.
-    GtkImageMenuItem *menuitem_jump_forward =
-        GTK_IMAGE_MENU_ITEM(
-           gtk_image_menu_item_new_with_label(_("Jump Forward 10 Frames")));
-    gtk_image_menu_item_set_image (menuitem_jump_forward,
-                                  gtk_image_new_from_stock("gtk-media-forward",
-                                                            
GTK_ICON_SIZE_MENU));
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_jump_forward));
-    gtk_widget_show(GTK_WIDGET(menuitem_jump_forward));
-
-// Jump Backward
-// Stock image from Gtk-2.6 should be ignored in earlier versions.
-    GtkImageMenuItem *menuitem_jump_backward =
-       GTK_IMAGE_MENU_ITEM(gtk_image_menu_item_new_with_label(_("Jump Backward 
10 Frames")));
-    gtk_image_menu_item_set_image (menuitem_jump_backward,
-                                  gtk_image_new_from_stock("gtk-media-rewind",
-                                                            
GTK_ICON_SIZE_MENU));
-    gtk_menu_append(menu, GTK_WIDGET(menuitem_jump_backward));
-    gtk_widget_show(GTK_WIDGET(menuitem_jump_backward));
-
-#endif
-
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-///                                                                         ///
-///                             Other stuff                                 ///
-///                                                                         ///
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-gnash::key::code
-GtkGui::gdk_to_gnash_key(guint key)
-{
-    gnash::key::code  c(gnash::key::INVALID);
-
-    // ascii 32-126 in one range:    
-    if (key >= GDK_space && key <= GDK_asciitilde) {
-        c = (gnash::key::code) ((key - GDK_space) + gnash::key::SPACE);
-    }
-
-    // Function keys:
-    else if (key >= GDK_F1 && key <= GDK_F15)  {
-        c = (gnash::key::code) ((key - GDK_F1) + gnash::key::F1);
-    }
-
-    // Keypad:
-    else if (key >= GDK_KP_0 && key <= GDK_KP_9) {
-        c = (gnash::key::code) ((key - GDK_KP_0) + gnash::key::KP_0);
-    }
-
-    // Extended ascii:
-    else if (key >= GDK_nobreakspace && key <= GDK_ydiaeresis) {
-        c = (gnash::key::code) ((key - GDK_nobreakspace) + 
gnash::key::NOBREAKSPACE);
-    }
-
-    // non-character keys don't correlate, so use a look-up table.
-    else {
-        struct {
-            guint             gdk;
-            gnash::key::code  gs;
-        } table[] = {
-            { GDK_BackSpace, gnash::key::BACKSPACE },
-            { GDK_Tab, gnash::key::TAB },
-            { GDK_Clear, gnash::key::CLEAR },
-            { GDK_Return, gnash::key::ENTER },
-            
-            { GDK_Shift_L, gnash::key::SHIFT },
-            { GDK_Shift_R, gnash::key::SHIFT },
-            { GDK_Control_L, gnash::key::CONTROL },
-            { GDK_Control_R, gnash::key::CONTROL },
-            { GDK_Alt_L, gnash::key::ALT },
-            { GDK_Alt_R, gnash::key::ALT },
-            { GDK_Caps_Lock, gnash::key::CAPSLOCK },
-            
-            { GDK_Escape, gnash::key::ESCAPE },
-            
-            { GDK_Page_Down, gnash::key::PGDN },
-            { GDK_Page_Up, gnash::key::PGUP },
-            { GDK_Home, gnash::key::HOME },
-            { GDK_End, gnash::key::END },
-            { GDK_Left, gnash::key::LEFT },
-            { GDK_Up, gnash::key::UP },
-            { GDK_Right, gnash::key::RIGHT },
-            { GDK_Down, gnash::key::DOWN },
-            { GDK_Insert, gnash::key::INSERT },
-            { GDK_Delete, gnash::key::DELETEKEY },
-            
-            { GDK_Help, gnash::key::HELP },
-            { GDK_Num_Lock, gnash::key::NUM_LOCK },
-
-            { GDK_VoidSymbol, gnash::key::INVALID }
-        };
-        
-        for (int i = 0; table[i].gdk != GDK_VoidSymbol; i++) {
-            if (key == table[i].gdk) {
-                c = table[i].gs;
-                break;
-            }
-        }
-    }
-    
-    return c;
-}
-
-int
-GtkGui::gdk_to_gnash_modifier(int state)
-{
-    int modifier = gnash::key::GNASH_MOD_NONE;
-
-    if (state & GDK_SHIFT_MASK) {
-      modifier = modifier | gnash::key::GNASH_MOD_SHIFT;
-    }
-    if (state & GDK_CONTROL_MASK) {
-      modifier = modifier | gnash::key::GNASH_MOD_CONTROL;
-    }
-    if (state & GDK_MOD1_MASK) {
-      modifier = modifier | gnash::key::GNASH_MOD_ALT;
-    }
-
-    return modifier;
-}
-
-bool
-lirc_handler(void*, int, void* /*data*/)
-{ 
-    GNASH_REPORT_FUNCTION;
-//    int* fd = static_cast<int*>(data);
-    
-    // want to remove this handler. You may want to close fd.
-    log_debug("%s\n", lirc->getButton());
-  
-    // Want to keep this handler
-    return true;
-}
-
-// This assumes that the parent of _drawingArea is _window, which
-// isn't the case in the plugin fullscreen (it's _overlay). Currently
-// we return from fullscreen when Gui::stop() is called, which
-// seems like a good idea, and also avoids this problem.
-void
-GtkGui::stopHook()
-{
-
-    // Assert they're either both initialised or both uninitialised
-    assert ((_resumeButton && _vbox) || !(_resumeButton || _vbox));
-    if (_resumeButton) {
-        gtk_box_pack_start(GTK_BOX(_vbox), _resumeButton, FALSE, FALSE, 0);
-    }
-}
-
-void
-GtkGui::playHook()
-{
-    assert ((_resumeButton && _vbox) || !(_resumeButton || _vbox));
-    if (_resumeButton) {
-        gtk_container_remove(GTK_CONTAINER(_vbox), _resumeButton);
-    }
-}
+    if (!gui->showUpdatedRegions()) gui->refreshView();
+}
+
+} // anonymous namespace
 
 } // end of namespace gnash
 

=== modified file 'gui/gtksup.h'
--- a/gui/gtksup.h      2009-02-09 12:30:31 +0000
+++ b/gui/gtksup.h      2009-02-11 14:10:33 +0000
@@ -41,20 +41,27 @@
 namespace gnash
 {
 
-typedef bool (*callback_t)(void*, int, void *data);
 
 class GtkGui : public Gui
 {
- public:
+public:
+
+    /// For the Gtk GUI FD listener, whatever that might be for.
+    typedef bool (*callback_t)(void*, int, void *data);
+
     GtkGui(unsigned long xid, float scale, bool loop, unsigned int depth);
+    
     virtual ~GtkGui();
+    
+    /// GUI interface implementation
+
     virtual bool init(int argc, char **argv[]);
     virtual bool createWindow(int width, int height);
     virtual bool createWindow(const char *title, int width, int height);
 
     virtual bool run();
 
-    void quit();
+    virtual void quit();
 
     virtual bool createMenu();
     
@@ -118,69 +125,6 @@
     // Display an About dialogue
     void showAboutDialog();
 
-    // Menu Item callbacks
-    static void menuitem_sound_callback(GtkMenuItem *menuitem,
-                                   gpointer instance);
-    static void menuitem_fullscreen_callback(GtkMenuItem *menuitem,
-                                   gpointer instance);
-    static void menuitem_restart_callback(GtkMenuItem *menuitem,
-                                   gpointer instance);
-    static void menuitem_quit_callback(GtkMenuItem *menuitem,
-                                       gpointer instance);
-    static void menuitem_play_callback(GtkMenuItem *menuitem,
-                                       gpointer instance);
-    static void menuitem_pause_callback(GtkMenuItem *menuitem,
-                                        gpointer instance);
-    static void menuitem_stop_callback(GtkMenuItem *menuitem,
-                                       gpointer instance);
-    static void menuitem_step_forward_callback(GtkMenuItem *menuitem,
-                                        gpointer instance);
-    static void menuitem_step_backward_callback(GtkMenuItem *menuitem,
-                                         gpointer instance);
-    static void menuitem_jump_forward_callback(GtkMenuItem *menuitem,
-                                        gpointer instance);
-    static void menuitem_jump_backward_callback(GtkMenuItem *menuitem,
-                                                gpointer instance);
-    static void menuitem_about_callback(GtkMenuItem *menuitem,
-                                        gpointer instance);
-    static void menuitem_openfile_callback(GtkMenuItem *menuitem,
-                                           gpointer instance);
-    static void menuitem_preferences_callback(GtkMenuItem *menuitem,
-                                              gpointer instance);
-    static void menuitem_movieinfo_callback(GtkMenuItem *menuitem,
-                                              gpointer instance);
-
-    /// Force redraw (Ctrl-L)
-    static void menuitem_refresh_view_callback(GtkMenuItem *menuitem,
-                                   gpointer instance);
-    static void menuitem_show_updated_regions_callback(GtkMenuItem *menuitem,
-                                   gpointer instance); 
-
-    // GTK Event handlers
-    static gboolean realize_event(GtkWidget *widget, GdkEvent *event,
-                                  gpointer data);
-    static gboolean delete_event(GtkWidget *widget, GdkEvent *event,
-                                 gpointer data);
-    static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event,
-                                 gpointer data);
-    static gboolean configure_event(GtkWidget *widget, GdkEventConfigure 
*event,
-                                    gpointer data);
-    static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
-                                    gpointer data);
-    static gboolean key_release_event(GtkWidget *widget, GdkEventKey *event,
-                                    gpointer data);
-    static gboolean button_press_event(GtkWidget *widget, GdkEventButton 
*event,
-                                       gpointer data);
-    static gboolean button_release_event(GtkWidget *widget, GdkEventButton 
*event,
-                                         gpointer data);
-    static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion 
*event,
-                                        gpointer data);
-    static gint popup_handler(GtkWidget *widget, GdkEvent *event);    
-    
-    void add_pixmap_directory(const gchar *directory);
-
-    static gchar* find_pixmap_file(const gchar *filename);
-    
     void expose(const GdkRegion* region);
 
     void setInvalidatedRegions(const InvalidatedRanges& ranges);
@@ -195,25 +139,26 @@
 
     virtual void error(const std::string& msg);
 
-    // Adds the gnash icon to a window.
-    static void addGnashIcon(GtkWindow* window);
-
- private:
+    GtkGlue& rendererGlue() { return *_glue; }
+
+private:
+
 #ifdef GUI_HILDON
     HildonProgram *_hildon_program;
 #endif
-    GtkWidget   *_window;
-    GtkWidget  *_resumeButton;
+
+    GtkWidget* _window;
+    GtkWidget* _resumeButton;
     
     // A window only for rendering the plugin as fullscreen.
-    GtkWidget  *_overlay;
+    GtkWidget* _overlay;
     
     // The area rendered into by Gnash
-    GtkWidget   *_drawingArea;    
+    GtkWidget* _drawingArea;    
 
-    GtkMenu     *_popup_menu;
-    GtkWidget   *_menubar;
-    GtkWidget   *_vbox;
+    GtkMenu* _popup_menu;
+    GtkWidget* _menubar;
+    GtkWidget* _vbox;
 
     /// Add key press events to the toplevel window.
     //
@@ -221,20 +166,13 @@
     /// window, so this function must be called every time
     /// the drawing area is reparented.
     void setupWindowEvents();
-    
-    static GdkPixbuf* createPixbuf(const gchar *filename);
 
 #ifdef USE_SWFTREE
     // Create a tree model for displaying movie info
     GtkTreeModel* makeTreeModel (std::auto_ptr<InfoTree> treepointer);
 #endif
 
-    std::auto_ptr<GtkGlue>     _glue;
-
-    static gnash::key::code gdk_to_gnash_key(guint key);
-    static int gdk_to_gnash_modifier(int state);
-
-    static void openFile(GtkWidget* dialog, gpointer data);
+    std::auto_ptr<GtkGlue> _glue;
 
     void stopHook();
     void playHook();
@@ -242,8 +180,6 @@
     guint _advanceSourceTimer;
 };
 
-// end of namespace gnash 
-}
+} // namespace gnash
 
-// end of __GTKSUP_H__
 #endif

=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp       2009-02-06 15:28:57 +0000
+++ b/gui/gui.cpp       2009-02-11 09:25:41 +0000
@@ -396,7 +396,6 @@
 void
 Gui::resize_view(int width, int height)
 {
-       GNASH_REPORT_FUNCTION;
 
        assert(width>0);
        assert(height>0);
@@ -422,34 +421,6 @@
 
 
 void
-Gui::menu_step_forward()
-{
-       movie_root& m = VM::get().getRoot();
-       m.goto_frame(m.get_current_frame()+1);
-}
-
-void
-Gui::menu_step_backward()
-{
-       movie_root& m = VM::get().getRoot();
-       m.goto_frame(m.get_current_frame()-1);
-}
-
-void
-Gui::menu_jump_forward()
-{
-       movie_root& m = VM::get().getRoot();
-       m.goto_frame(m.get_current_frame()+10);
-}
-
-void
-Gui::menu_jump_backward()
-{
-       movie_root& m = VM::get().getRoot();
-       m.goto_frame(m.get_current_frame()-10);
-}
-
-void
 Gui::toggleSound()
 {
     assert (_stage);
@@ -592,19 +563,13 @@
                                case gnash::key::F:
                                        toggleFullscreen();
                                        break;
-                               case gnash::key::RIGHT_BRACKET:
-                                       menu_step_forward();
-                                       break;
-                               case gnash::key::LEFT_BRACKET:
-                                       menu_step_backward();
-                                       break;
                                case gnash::key::MINUS:
                                {
                                        // Max interval allowed: 1 second (1FPS)
                                        unsigned int ni = std::min(_interval+2, 
1000u);
                                        setInterval(ni);
                                        break;
-                                }
+                }
                                case gnash::key::PLUS:
                                {
                                        // Min interval allowed: 1/100 second 
(100FPS)
@@ -1079,7 +1044,7 @@
     InfoTree::iterator topIter = tr->begin();
     InfoTree::iterator firstLevelIter;
 
-    VM& vm = VM::get();
+    VM& vm = _stage->getVM();
 
     std::ostringstream os;
 

=== modified file 'gui/gui.h'
--- a/gui/gui.h 2009-02-09 12:30:31 +0000
+++ b/gui/gui.h 2009-02-11 11:49:44 +0000
@@ -319,11 +319,6 @@
     /// state.
     void restart();
 
-    void menu_step_forward();
-    void menu_step_backward();
-    void menu_jump_forward();
-    void menu_jump_backward();
-
     /// Toggle sound state between muted and unmuted. If
     /// there is no active sound handler this does nothing.
     void toggleSound();
@@ -382,6 +377,8 @@
     ///
     virtual bool yesno(const std::string& question);
 
+    movie_root* getStage() const { return _stage; }
+
 protected:
 
     /// Default constructor. Initialises members to safe defaults.

=== modified file 'libbase/IOChannel.cpp'
--- a/libbase/IOChannel.cpp     2008-06-13 17:37:37 +0000
+++ b/libbase/IOChannel.cpp     2009-02-10 11:33:38 +0000
@@ -83,7 +83,7 @@
 int
 IOChannel::read_string(char* dst, int max_length) 
 {
-       int i=0;
+       int i = 0;
        while (i<max_length)
        {
                dst[i] = read_byte();
@@ -141,8 +141,8 @@
        write(&u, 1); // will trhow on error it seems
 }
 
-int
-IOChannel::write(const void* /*src*/, int /*num*/)
+std::streamsize
+IOChannel::write(const void* /*src*/, std::streamsize /*num*/)
 {
        throw IOException("This IOChannel implementation doesn't support 
output");
 }

=== modified file 'libbase/IOChannel.h'
--- a/libbase/IOChannel.h       2009-01-22 20:10:39 +0000
+++ b/libbase/IOChannel.h       2009-02-10 11:33:38 +0000
@@ -21,22 +21,10 @@
 #define GNASH_IOCHANNEL_H
 
 #include "dsodefs.h" // DSOEXPORT
-
 #include "GnashException.h" // for IOException inheritance
 
 #include <boost/cstdint.hpp> // for boost int types
-
-// temp hack to avoid changing all callers
-// TODO: update all callers ...
-enum
-{
-    TU_FILE_NO_ERROR = 0,
-    TU_FILE_OPEN_ERROR = -1,
-    TU_FILE_READ_ERROR = -1,
-    TU_FILE_WRITE_ERROR = -1,
-    TU_FILE_SEEK_ERROR = -1,
-    TU_FILE_CLOSE_ERROR = -1
-};
+#include <ios>
 
 namespace gnash {
 
@@ -107,7 +95,7 @@
        ///
        /// Throw IOException on error
        ///
-       virtual int read(void* dst, int num)=0;
+       virtual std::streamsize read(void* dst, std::streamsize num)=0;
 
        /// Read at most the given number of bytes w/out blocking
        //
@@ -120,7 +108,7 @@
        /// Default implementation proxies the call to the
        /// blocking version.
        ///
-       virtual int readNonBlocking(void* dst, int num)
+       virtual std::streamsize readNonBlocking(void* dst, std::streamsize num)
        {
                return read(dst, num);
        }
@@ -129,7 +117,7 @@
        //
        /// Throw IOException on error/unsupported op.
        ///
-       virtual int write(const void* src, int num);
+       virtual std::streamsize write(const void* src, std::streamsize num);
 
        /// \brief Write a 0-terminated string to a stream.
        //
@@ -154,69 +142,65 @@
 
        /// Write a 32-bit float to a stream in little-endian order.
        //
-       /// NOTE: this currently relies on host FP format being the same as the 
Flash one
-       ///       (presumably IEEE 754).
+       /// NOTE: this currently relies on host FP format being the same
+    ///       as the Flash one (presumably IEEE 754).
        ///
        /// Throw IOException on error
        ///
-       void    write_float32(float value);
+       void write_float32(float value);
 
        /// Read a 32-bit float from a little-endian stream.
        //
-       /// NOTE: this currently relies on host FP format being the same as the 
Flash one
-       /// (presumably IEEE 754).
+       /// NOTE: this currently relies on host FP format being the
+    ///       same as the Flash one (presumably IEEE 754).
        ///
        /// Throw IOException on error
        ///
-       float   read_float32();
+       float read_float32();
 
        /// Return current stream position
        //
        /// Throw IOException on error
        ///
-       virtual int tell() const=0;
+       virtual std::streampos tell() const = 0;
 
        /// Seek to the specified position
        //
        /// 
        /// Throw IOException on error
        ///
-       /// @return 0 on success, or -1 on failure.
+       /// @return true on success, or false on failure.
        ///
-       virtual int seek(int p)=0;
+       virtual bool seek(std::streampos p) = 0;
 
        /// Seek to the end of the stream
        //
        /// Throw IOException on error
        ///
-       virtual void go_to_end()=0;
+       virtual void go_to_end() = 0;
 
        /// Return true if the end of the stream has been reached.
        //
        /// Throw IOException on error
        ///
-       virtual bool eof() const=0;
+       virtual bool eof() const = 0;
     
-       /// Return non-zero if the stream is in an error state
+       /// Return true if the stream is in an error state
        //
        /// When the stream is in an error state there's nothing
        /// you can do about it, just delete it and log the error.
-       ///
-       /// There are some rough meaning for possible returned values
-       /// but I don't think they make much sense currently.
-       ///
-       virtual int get_error() const=0;
+       virtual bool bad() const = 0;
     
        /// Get the size of the stream (unreliably).
        //
-       /// Size of steram is unreliable as not all input
+       /// Size of stream is unreliable as not all input
        /// channels have a mechanism to advertise size,
        /// and some have one but isn't necessarely truthful
        /// (a few HTTP severs are bogus in this reguard).
        ///
-       /// @return unreliable input size, -1 if not known. 
+       /// @return unreliable input size, (size_t)-1 if not known. 
        ///
-       virtual int size() const { return -1; }
+       virtual size_t size() const { return static_cast<size_t>(-1); }
    
 };
 

=== modified file 'libbase/curl_adapter.cpp'
--- a/libbase/curl_adapter.cpp  2009-01-27 13:53:00 +0000
+++ b/libbase/curl_adapter.cpp  2009-02-11 07:48:07 +0000
@@ -409,24 +409,24 @@
        ~CurlStreamFile();
 
        // See dox in IOChannel.h
-       virtual int read(void *dst, int bytes);
+       virtual std::streamsize read(void *dst, std::streamsize bytes);
 
        // See dox in IOChannel.h
-       virtual int readNonBlocking(void *dst, int bytes);
+       virtual std::streamsize readNonBlocking(void *dst, std::streamsize 
bytes);
 
        // See dox in IOChannel.h
        virtual bool eof() const;
 
        // See dox in IOChannel.h
-       virtual int get_error() const {
+       virtual bool bad() const {
                return _error;
        }
 
        /// Report global position within the file
-       virtual int tell() const;
+       virtual std::streampos tell() const;
 
        /// Put read pointer at given position
-       virtual int seek(int pos);
+       virtual bool seek(std::streampos pos);
 
        /// Put read pointer at eof
        virtual void go_to_end();
@@ -440,7 +440,7 @@
        /// Another approach might be filling the cache ourselves
        /// aiming at obtaining a useful value.
        ///
-       virtual int size() const;
+       virtual size_t size() const;
 
 private:
 
@@ -467,27 +467,27 @@
        int _running;
 
        // stream error
-       // 0 on no error.
+       // false on no error.
        // Example of errors would be:
        //      404 - file not found
        //      timeout occurred
-       int _error;
+       bool _error;
 
        // Post data. Empty if no POST has been requested
        std::string _postdata;
 
        // Current size of cached data
-       long unsigned _cached;
+    size_t _cached;
 
        /// Total stream size.
        //
        /// This will be 0 until known
        ///
-       mutable int _size;
+       mutable size_t _size;
 
        // Attempt at filling the cache up to the given size.
        // Will call libcurl routines to fetch data.
-       void fillCache(long unsigned size);
+       void fillCache(std::streamsize size);
 
        // Process pending curl messages (handles 404)
        void processMessages();
@@ -497,12 +497,11 @@
        void fillCacheNonBlocking();
 
        // Append sz bytes to the cache
-       size_t cache(void *from, size_t sz);
+    std::streamsize cache(void *from, std::streamsize sz);
 
        // Callback for libcurl, will be called
        // by fillCache() and will call cache()
-       static size_t recv(void *buf, size_t  size,
-               size_t  nmemb, void *userp);
+       static size_t recv(void *buf, size_t size, size_t nmemb, void *userp);
 
     // List of custom headers for this stream.
     struct curl_slist *_customHeaders;
@@ -517,8 +516,7 @@
 
 /*static private*/
 size_t
-CurlStreamFile::recv(void *buf, size_t  size,  size_t  nmemb,
-       void *userp)
+CurlStreamFile::recv(void *buf, size_t size, size_t nmemb, void *userp)
 {
 #ifdef GNASH_CURL_VERBOSE
        log_debug("curl write callback called for (%d) bytes",
@@ -530,8 +528,8 @@
 
 
 /*private*/
-size_t
-CurlStreamFile::cache(void *from, size_t size)
+std::streamsize
+CurlStreamFile::cache(void *from, std::streamsize size)
 {
        // take note of current position
        long curr_pos = std::ftell(_cache);
@@ -539,7 +537,7 @@
        // seek to the end
        std::fseek(_cache, 0, SEEK_END);
 
-       size_t wrote = std::fwrite(from, 1, size, _cache);
+    std::streamsize wrote = std::fwrite(from, 1, size, _cache);
        if ( wrote < 1 )
        {
 
@@ -589,14 +587,16 @@
 
 /*private*/
 void
-CurlStreamFile::fillCache(long unsigned size)
+CurlStreamFile::fillCache(std::streamsize size)
 {
 
 #if GNASH_CURL_VERBOSE
     log_debug("fillCache(%d), called, currently cached: %d", size, _cached);
 #endif 
 
-       if ( ! _running || _cached >= size ) {
+    assert(size >= 0);
+
+       if ( ! _running || _cached >= static_cast<size_t>(size)) {
 #if GNASH_CURL_VERBOSE
         if (!_running) log_debug("Not running: returning");
         else log_debug("Already enough bytes cached: returning");
@@ -630,13 +630,15 @@
                // Do this here to avoid calling select()
                // when we have enough bytes anyway, or
                // we reached EOF
-               if (_cached >= size || !_running) break; // || _error ?
+               if (_cached >= static_cast<size_t>(size) || !_running) break; 
 
 #if GNASH_CURL_VERBOSE
                //log_debug("cached: %d, size: %d", _cached, size);
 #endif
 
-               mcode = curl_multi_fdset(_mhandle, &readfd, &writefd, 
&exceptfd, &maxfd);
+               mcode = curl_multi_fdset(_mhandle, &readfd, &writefd, 
+                &exceptfd, &maxfd);
+
                if (mcode != CURLM_OK) {
                        // This is a serious error, not just a failure to add 
any
                        // fds.
@@ -740,7 +742,7 @@
                                if ( code >= 400 ) {
                                        log_error ("HTTP response %ld from url 
%s",
                                                                    code, _url);
-                                       _error = TU_FILE_OPEN_ERROR;
+                                       _error = true;
                                        _running = false;
                                }
                                else {
@@ -754,7 +756,7 @@
                                // Transaction failed, pass on curl error.
                                log_error("CURL: %s", curl_easy_strerror(
                                                            
curl_msg->data.result));
-                               _error = TU_FILE_OPEN_ERROR;
+                               _error = true;
                        }
 
                }
@@ -771,7 +773,7 @@
 
        _url = url;
        _running = 1;
-       _error = 0;
+       _error = false;
 
        _cached = 0;
        _size = 0;
@@ -1039,8 +1041,8 @@
 }
 
 /*public*/
-int
-CurlStreamFile::read(void *dst, int bytes)
+std::streamsize
+CurlStreamFile::read(void *dst, std::streamsize bytes)
 {
        if ( eof() || _error ) return 0;
 
@@ -1060,13 +1062,14 @@
 }
 
 /*public*/
-int
-CurlStreamFile::readNonBlocking(void *dst, int bytes)
+std::streamsize
+CurlStreamFile::readNonBlocking(void *dst, std::streamsize bytes)
 {
        if ( eof() ) return 0;
        if ( _error )
        {
-               log_error("curl adaptor's readNonBlocking called while _error 
!= 0 - should we throw an exception?");
+               log_error("curl adaptor's readNonBlocking called while _error 
!= 0 "
+                "- should we throw an exception?");
                return 0;
        }
 
@@ -1078,11 +1081,12 @@
        if ( _error )
        {
                // I guess an exception would be thrown in this case ?
-               log_error("curl adaptor's fillCacheNonBlocking set _error 
rather then throwing an exception");
-               return -1; // error can be set by fillCacheNonBlocking 
(shouldn't an exception be thrown an exception?)
+               log_error("curl adaptor's fillCacheNonBlocking set _error "
+                "rather then throwing an exception");
+               return -1; 
        }
 
-       int actuallyRead = std::fread(dst, 1, bytes, _cache);
+    std::streamsize actuallyRead = std::fread(dst, 1, bytes, _cache);
        if ( _running )
        {
                // if we're still running drop any eof flag
@@ -1108,10 +1112,10 @@
 }
 
 /*public*/
-int
+std::streampos
 CurlStreamFile::tell() const
 {
-       int ret =  std::ftell(_cache);
+    std::streampos ret = std::ftell(_cache);
 
 #ifdef GNASH_CURL_VERBOSE
        log_debug("tell() returning %ld", ret);
@@ -1122,9 +1126,12 @@
 }
 
 /*public*/
-int
-CurlStreamFile::seek(int pos)
+bool
+CurlStreamFile::seek(std::streampos pos)
 {
+
+    assert(pos >= 0);
+
 #ifdef GNASH_CURL_WARN_SEEKSBACK
        if ( pos < tell() ) {
                log_debug("Warning: seek backward requested (%ld from %ld)",
@@ -1133,20 +1140,21 @@
 #endif
 
        fillCache(pos);
-       if ( _error ) return -1; // error can be set by fillCache
+       if (_error) return false; // error can be set by fillCache
 
-       if ( _cached < (unsigned int)pos )
+       if (_cached < static_cast<size_t>(pos))
        {
-               log_error ("Warning: could not cache anough bytes on seek: %d 
requested, %d cached", pos, _cached);
-               return -1; // couldn't cache so many bytes
+               log_error ("Warning: could not cache anough bytes on seek: %d "
+                "requested, %d cached", pos, _cached);
+               return false; 
        }
 
        if (std::fseek(_cache, pos, SEEK_SET) == -1) {
                log_error("Warning: fseek failed");
-               return -1;
-       } else {
-               return 0;
+               return false;
        }
+   
+    return true;
 
 }
 
@@ -1167,34 +1175,33 @@
                        throw IOException(curl_multi_strerror(mcode));
                }
 
-                long code;
-                curl_easy_getinfo(_handle, CURLINFO_RESPONSE_CODE, &code);
-                if ( code == 404 ) // file not found!
-                {
-                       throw IOException("File not found");
-                        //log_error(_("404 response from url %s"), _url);
-                        //_error = TU_FILE_OPEN_ERROR;
-                        //return;
-                }
+        long code;
+        curl_easy_getinfo(_handle, CURLINFO_RESPONSE_CODE, &code);
+        if (code == 404) // file not found!
+        {
+            throw IOException("File not found");
+        }
 
        }
 
        if (std::fseek(_cache, 0, SEEK_END) == -1) {
                throw IOException("NetworkAdapter: fseek to end failed");
-               //log_error("Warning: fseek to end failed");
-               //return -1;
        } 
 }
 
 /*public*/
-int
+size_t
 CurlStreamFile::size() const
 {
        if ( ! _size )
        {
                double size;
-               CURLcode ret = curl_easy_getinfo(_handle, 
CURLINFO_CONTENT_LENGTH_DOWNLOAD, &size);
-               if ( ret == CURLE_OK ) _size = int(size);
+               CURLcode ret = curl_easy_getinfo(_handle,
+                CURLINFO_CONTENT_LENGTH_DOWNLOAD, &size);
+               if (ret == CURLE_OK) {
+            assert(size <= std::numeric_limits<size_t>::max());
+            _size = static_cast<size_t>(size);
+        }
        }
 
 #ifdef GNASH_CURL_VERBOSE

=== modified file 'libbase/noseek_fd_adapter.cpp'
--- a/libbase/noseek_fd_adapter.cpp     2008-11-21 15:15:25 +0000
+++ b/libbase/noseek_fd_adapter.cpp     2009-02-10 11:33:38 +0000
@@ -21,26 +21,22 @@
 
 #include "noseek_fd_adapter.h"
 #include "IOChannel.h" // for inheritance
+#include "GnashSystemIOHeaders.h" // for read
 #include "utility.h"
 #include "log.h"
 
-#include "GnashSystemIOHeaders.h" // for ::read
-
 #include <boost/scoped_array.hpp>
-
-//#define GNASH_NOSEEK_FD_VERBOSE 1
-
-// define this if you want seeks back to be reported (on stderr)
-//#define GNASH_NOSEEK_FD_WARN_SEEKSBACK 1
-
 #include <cerrno>
 #include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-
 #include <string>
 #include <boost/format.hpp>
 
+//#define GNASH_NOSEEK_FD_VERBOSE 1
+
+// define this if you want seeks back to be reported (on stderr)
+//#define GNASH_NOSEEK_FD_WARN_SEEKSBACK 1
+
+
 namespace gnash {
 namespace noseek_fd_adapter {
 
@@ -74,19 +70,19 @@
        ~NoSeekFile();
 
        // See IOChannel.h for description
-       virtual int read(void *dst, int bytes);
+       virtual std::streamsize read(void *dst, std::streamsize bytes);
 
        // See IOChannel for description
        virtual bool eof() const;
 
        // See IOChannel for description
-       virtual int get_error() const { return 0; }
-
-       // See IOChannel for description
-       virtual int tell() const;
-
-       // See IOChannel for description
-       virtual int seek(int pos);
+       virtual bool bad() const { return false; }
+
+       // See IOChannel for description
+       virtual std::streampos tell() const;
+
+       // See IOChannel for description
+       virtual bool seek(std::streampos pos);
 
        // See IOChannel for description
        virtual void go_to_end() {
@@ -96,7 +92,7 @@
 private:
 
        /// Read buffer size
-       static const unsigned int chunkSize = 512;
+       static const std::streamsize chunkSize = 512;
 
        // Open either a temporary file or a named file
        // (depending on value of _cachefilename)
@@ -115,21 +111,24 @@
        const char* _cachefilename;
 
        // Current size of cached data
-       long unsigned _cached;
+    size_t _cached;
 
        // Current read buffer
        char _buf[chunkSize];
 
        // Attempt at filling the cache up to the given size.
-       void fill_cache(size_t size);
+       void fill_cache(std::streamsize size);
 
        // Append sz bytes to the cache
-       size_t cache(void *from, size_t sz);
+    std::streamsize cache(void *from, std::streamsize sz);
 
        void printInfo();
 
 };
 
+
+const std::streamsize NoSeekFile::chunkSize;
+
 /***********************************************************************
  *
  *  NoSeekFile implementation
@@ -138,34 +137,36 @@
 
 
 /*private*/
-size_t
-NoSeekFile::cache(void *from, size_t sz)
+std::streamsize
+NoSeekFile::cache(void *from, std::streamsize sz)
 {
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
        std::cerr << boost::format("cache(%p, %d) called") % from % sz << 
std::endl;
 #endif
        // take note of current position
-       long curr_pos = ftell(_cache);
+    std::streampos curr_pos = std::ftell(_cache);
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
        std::cerr << boost::format(" current position: %ld)") % curr_pos << 
std::endl;
 #endif
 
        // seek to the end
-       fseek(_cache, 0, SEEK_END);
+    std::fseek(_cache, 0, SEEK_END);
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
-       std::cerr << boost::format(" after SEEK_END, position: %ld") % 
ftell(_cache) << std::endl;
+       std::cerr << boost::format(" after SEEK_END, position: %ld") %
+        std::ftell(_cache) << std::endl;
 #endif
 
-       size_t wrote = fwrite(from, 1, sz, _cache);
+    std::streamsize wrote = std::fwrite(from, 1, sz, _cache);
 #ifdef GNASH_NOSEEK_FD_VERBOSE
     std::cerr << boost::format(" write %d bytes") % wrote;
 #endif
        if ( wrote < 1 )
        {
-        boost::format err = boost::format("writing to cache file: requested 
%d, wrote %d (%s)")
+        boost::format err = boost::format("writing to cache file: "
+                "requested %d, wrote %d (%s)")
             % sz % wrote % std::strerror(errno);
                        
                std::cerr << err << std::endl;
@@ -175,17 +176,19 @@
        _cached += sz;
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
-    std::cerr << boost::format(" after write, position: %ld") % 
std::ftell(_cache) << std::endl;
+    std::cerr << boost::format(" after write, position: %ld") % 
+        std::ftell(_cache) << std::endl;
 #endif
 
        // reset position for next read
-       fseek(_cache, curr_pos, SEEK_SET);
+    std::fseek(_cache, curr_pos, SEEK_SET);
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
-    std::cerr << boost::format(" after seek-back, position: %ld") % 
std::ftell(_cache) << std::endl;
+    std::cerr << boost::format(" after seek-back, position: %ld") % 
+        std::ftell(_cache) << std::endl;
 #endif
 
-       clearerr(_cache);
+    std::clearerr(_cache);
 
        return wrote;
 }
@@ -193,7 +196,7 @@
 
 /*private*/
 void
-NoSeekFile::fill_cache(size_t size)
+NoSeekFile::fill_cache(std::streamsize size)
 {
 #ifdef GNASH_NOSEEK_FD_VERBOSE
     std::cerr << boost::format(" fill_cache(%d) called") % size << std::endl;
@@ -203,40 +206,35 @@
        while ( _cached < size ) 
        {
 
-               // Let's see how many bytes are left to read
-               unsigned int bytesNeeded = size-_cached;
-               if ( bytesNeeded > chunkSize ) bytesNeeded = chunkSize;
-
-               bytesNeeded = chunkSize; // why read less ?
-
 #ifdef GNASH_NOSEEK_FD_VERBOSE
-       std::cerr << boost::format(" bytes needed = %d") % bytesNeeded << 
std::endl;
+        size_t bytesNeeded = size - _cached;
+               bytesNeeded = std::min<size_t>(bytesNeeded, chunkSize);
+        std::cerr << boost::format(" bytes needed = %d") % bytesNeeded <<
+            std::endl;
 #endif
 
-               ssize_t bytesRead = ::read(_fd, (void*)_buf, bytesNeeded);
-               if ( bytesRead < 0 )
+        std::streamsize bytesRead = ::read(_fd, (void*)_buf, chunkSize);
+               if (bytesRead < 0)
                {
-                       std::cerr << boost::format(_("Error reading %d bytes 
from input stream")) % bytesNeeded;
+                       std::cerr << boost::format(_("Error reading %d bytes 
from "
+                        "input stream")) % chunkSize << std::endl;
                        _running = false;
                        // this looks like a CRITICAL error (since we don't 
handle it..)
                        throw IOException("Error reading from input stream");
-                       return;
                }
 
-               if ( static_cast<size_t>(bytesRead) < bytesNeeded )
+               if (bytesRead < chunkSize)
                {
-                       if ( bytesRead == 0 )
+                       if (bytesRead == 0)
                        {
 #ifdef GNASH_NOSEEK_FD_VERBOSE
-    std::cerr << "EOF reached" << std::endl;
+                std::cerr << "EOF reached" << std::endl;
 #endif
                                _running = false;
                                return;
                        }
                }
-
-               cache(_buf, static_cast<size_t>(bytesRead));
-
+               cache(_buf, bytesRead);
        }
 }
 
@@ -256,7 +254,8 @@
                _cache = fopen(_cachefilename, "w+b");
                if ( ! _cache )
                {
-                       throw IOException("Could not create cache file " + 
std::string(_cachefilename));
+                       throw IOException("Could not create cache file " + 
+                    std::string(_cachefilename));
                }
        }
        else
@@ -284,18 +283,18 @@
 /*public*/
 NoSeekFile::~NoSeekFile()
 {
-       fclose(_cache);
+    std::fclose(_cache);
 }
 
 /*public*/
-int
-NoSeekFile::read(void *dst, int bytes)
+std::streamsize
+NoSeekFile::read(void *dst, std::streamsize bytes)
 {
 #ifdef GNASH_NOSEEK_FD_VERBOSE
        std::cerr << boost::format("read_cache(%d) called") % bytes << 
std::endl;
 #endif
 
-       if ( eof() )
+       if (eof())
        {
 #ifdef GNASH_NOSEEK_FD_VERBOSE
            std::cerr << "read_cache: at eof!" << std::endl;
@@ -304,22 +303,23 @@
        }
 
 
-       fill_cache(tell()+bytes);
+       fill_cache(tell() + bytes);
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
        printInfo();
 #endif
 
-       size_t ret = fread(dst, 1, bytes, _cache);
+    std::streamsize ret = std::fread(dst, 1, bytes, _cache);
 
-       if ( ret == 0 )
+       if (ret == 0)
        {
-               if ( ferror(_cache) )
+               if (std::ferror(_cache))
                {
-            std::cerr << "an error occurred while reading from cache" << 
std::endl;
+            std::cerr << "an error occurred while reading from cache" <<
+                std::endl;
                }
 #if GNASH_NOSEEK_FD_VERBOSE
-               if ( feof(_cache) )
+               if (std::feof(_cache))
                {
             std::cerr << "EOF reached while reading from cache" << std::endl;
                }
@@ -327,7 +327,8 @@
        }
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
-    std::cerr << boost::format("fread from _cache returned %d") % ret << 
std::endl;
+    std::cerr << boost::format("fread from _cache returned %d") % ret <<
+        std::endl;
 #endif
 
        return ret;
@@ -338,7 +339,7 @@
 bool
 NoSeekFile::eof() const
 {
-       bool ret = ( ! _running && feof(_cache) );
+       bool ret = ( ! _running && std::feof(_cache) );
        
 #ifdef GNASH_NOSEEK_FD_VERBOSE
        std::cerr << boost::format("eof() returning %d") % ret << std::endl;
@@ -348,10 +349,10 @@
 }
 
 /*public*/
-int
+std::streampos
 NoSeekFile::tell() const
 {
-       int ret = std::ftell(_cache);
+    std::streampos ret = std::ftell(_cache);
 
 #ifdef GNASH_NOSEEK_FD_VERBOSE
        std::cerr << boost::format("tell() returning %ld") % ret << std::endl;
@@ -362,11 +363,11 @@
 }
 
 /*public*/
-int
-NoSeekFile::seek(int pos)
+bool
+NoSeekFile::seek(std::streampos pos)
 {
 #ifdef GNASH_NOSEEK_FD_WARN_SEEKSBACK
-       if ( pos < tell() ) {
+       if (pos < tell()) {
                std::cerr << boost::format("Warning: seek backward requested "
                                "(%ld from %ld)") % pos % tell() << std::endl;
        }
@@ -374,12 +375,12 @@
 
        fill_cache(pos);
 
-       if ( std::fseek(_cache, pos, SEEK_SET) == -1 ) {
+       if (std::fseek(_cache, pos, SEEK_SET) == -1) {
                std::cerr << "Warning: fseek failed" << std::endl;
-               return -1;
-       } else {
-               return 0;
-       }
+               return false;
+       } 
+    
+    return true;
 
 }
 

=== modified file 'libbase/tu_file.cpp'
--- a/libbase/tu_file.cpp       2008-11-14 00:46:35 +0000
+++ b/libbase/tu_file.cpp       2009-02-10 11:33:38 +0000
@@ -10,13 +10,10 @@
 #endif
 
 #include "tu_file.h"
-#include "utility.h"
 #include "log.h"
 
 #include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#include "GnashFileUtilities.h"
 
 //
 // tu_file functions using FILE
@@ -25,8 +22,8 @@
 namespace gnash {
 
 
-int
-tu_file::read(void* dst, int bytes) 
+std::streamsize
+tu_file::read(void* dst, std::streamsize bytes) 
 // Return the number of bytes actually read.  EOF or an error would
 // cause that to not be equal to "bytes".
 {
@@ -36,96 +33,79 @@
     return fread( dst, 1, bytes, static_cast<FILE*>(m_data) );
 }
 
-int
-tu_file::write(const void* src, int bytes)
+std::streamsize
+tu_file::write(const void* src, std::streamsize bytes)
 // Return the number of bytes actually written.
 {
     assert(src);
     return std::fwrite( src, 1, bytes, static_cast<FILE*>(m_data));
 }
 
-int
-tu_file::seek(int pos)
+bool
+tu_file::seek(std::streampos pos)
 {
 
     // TODO: optimize this by caching total stream size ?
-    if (pos > size())
-    {
-           return TU_FILE_SEEK_ERROR;
-    }
+    if (pos > size()) return false;
 
     FILE* file = static_cast<FILE*>(m_data);
 
-    clearerr(file); // make sure EOF flag is cleared.
-    int        result = fseek(file, pos, SEEK_SET);
+    std::clearerr(file); // make sure EOF flag is cleared.
+    int        result = std::fseek(file, pos, SEEK_SET);
     if (result == EOF) {
-       // @@ TODO should set m_error to something relevant based on errno.
-       return TU_FILE_SEEK_ERROR;
+        // @@ TODO should set m_error to something relevant based on errno.
+        return false;
     }
 
-    assert ( ftell(file) == pos );
+    assert (std::ftell(file) == pos);
 
-    return 0;
+    return true;
 }
 
 void
 tu_file::go_to_end()
-// Return 0 on success, TU_FILE_SEEK_ERROR on failure.
 {
-
-    int        result = fseek(static_cast<FILE*>(m_data), 0, SEEK_END);
-    if (result == EOF) {
-           // Can't do anything here
-    }
-
+    std::streampos s = std::fseek(static_cast<FILE*>(m_data), 0, SEEK_END);
+    if (s != EOF) throw IOException("Error while seeking to end");
 }
 
-int
+std::streampos
 tu_file::tell() const
-// Return the file position, or -1 on failure.
 {
     FILE* f = static_cast<FILE*>(m_data);
 
-    //if ( feof(f) )
-    //assert ( ! feof(f) ); // I guess it's legal to call tell() while at eof.
+    std::streampos ret = std::ftell(f);
+    if (ret < 0) throw IOException("Error getting stream position");
 
-    int ret = ftell(f);
     assert(ret <= size());
     return ret;
 }
 
 bool
 tu_file::eof() const
-// Return true if we're at EOF.
-{
-    if (feof((FILE*) m_data)) {
-       return true;
-    } else {
-       return false;
-    }
-}
-
-int
-tu_file::get_error() const
-// Return true if we're at EOF.
-{
-    if ( ! m_data ) return TU_FILE_OPEN_ERROR;
-    return (ferror((FILE*) m_data));
-}
-
-int
+{
+    return std::feof(static_cast<FILE*>(m_data));
+}
+
+bool
+tu_file::bad() const
+{
+    if (!m_data) return true;
+    return std::ferror(static_cast<FILE*>(m_data));
+}
+
+size_t
 tu_file::size() const
-// Return -1 on failure, or the size
 {
     assert(m_data);
 
     FILE* f = static_cast<FILE*>(m_data);
 
     struct stat statbuf;
-    if ( -1 == fstat(fileno(f), &statbuf) )
+    if (fstat(fileno(f), &statbuf) < 0)
     {
            log_error("Could not fstat file");
-           return 0;
+           return static_cast<size_t>(-1);
     }
     return statbuf.st_size;
 }

=== modified file 'libbase/tu_file.h'
--- a/libbase/tu_file.h 2008-08-22 15:11:39 +0000
+++ b/libbase/tu_file.h 2009-02-10 11:33:38 +0000
@@ -34,7 +34,7 @@
     ///        returning it as a native-endian word.
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition.
     ///
     boost::uint32_t read_le32() 
     {
@@ -50,7 +50,7 @@
        /// returning it as a native-endian word.
        //
        /// TODO: define what happens when the stream is in
-       ///       error condition, see get_error().
+       ///       error condition, see bad().
        /// TODO: define a platform-neutral type for 64 bits.
        long double read_le_double64()
        {
@@ -63,7 +63,7 @@
     /// \brief Read a 16-bit word from a little-endian stream.
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
     boost::uint16_t read_le16()
     {
@@ -75,7 +75,7 @@
     /// \brief Write a 32-bit word to a little-endian stream.
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
     void       write_le32(boost::uint32_t u)
     {
@@ -88,7 +88,7 @@
     /// \brief Write a 16-bit word to a little-endian stream.
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
     void write_le16(boost::uint16_t u)
     {
@@ -99,37 +99,37 @@
     /// \brief Read a single byte from the stream
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
     boost::uint8_t read_byte() { return read8(); }
 
     /// \brief write a single byte to the stream
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
     void write_byte(boost::uint8_t u) { write8(u); }
     
     /// \brief Read the given number of bytes from the stream
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
-    int read(void* dst, int num);
+    std::streamsize read(void* dst, std::streamsize num);
 
     /// \brief Write the given number of bytes to the stream
     //
     /// TODO: define what happens when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
-    int write(const void* src, int num);
+    std::streamsize write(const void* src, std::streamsize num);
 
     /// \brief Return current stream position
     //
     /// TODO: define what to return when the stream
-    ///       is in error condition, see get_error().
+    ///       is in error condition, see bad().
     ///
-    int        tell() const;
+    std::streampos tell() const;
 
     /// \brief Seek to the specified position
     //
@@ -137,9 +137,9 @@
     /// TODO: define what happens when an error occurs, or
     ///       when we're already in an error condition
     ///
-    /// @return 0 on success, or TU_FILE_SEEK_ERROR on failure.
+    /// @return true on success, or false on failure.
     ///
-    int        seek(int p);
+    bool seek(std::streampos p);
 
     /// \brief Seek to the end of the stream
     //
@@ -150,7 +150,7 @@
     /// \brief Return true if the end of the stream has been reached.
     //
     /// TODO: define what to return when in error condition
-    /// see get_error().
+    /// see bad().
     ///
     bool eof() const;
     
@@ -162,11 +162,10 @@
     /// There are some rough meaning for possible returned values
     /// but I don't think they make much sense currently.
     ///
-    int        get_error() const;
+    bool bad() const;
     
-
-    /// \brief Get the size of the stream
-    int size() const;
+    /// Get the size of the stream
+    size_t size() const;
     
 private:
 

=== modified file 'libbase/zlib_adapter.cpp'
--- a/libbase/zlib_adapter.cpp  2008-06-10 11:30:25 +0000
+++ b/libbase/zlib_adapter.cpp  2009-02-10 11:33:38 +0000
@@ -48,8 +48,6 @@
 namespace zlib_adapter
 {
 
-const int      ZBUF_SIZE = 4096;
-
 class InflaterIOChannel : public IOChannel 
 {
 public:
@@ -63,10 +61,10 @@
        }
 
        // See dox in IOChannel
-       virtual int seek(int pos);
+       virtual bool seek(std::streampos pos);
 
        // See dox in IOChannel
-       virtual int read(void* dst, int bytes)
+       virtual std::streamsize read(void* dst, std::streamsize bytes)
        {
                if (m_error) return 0;
                return inflate_from_stream(dst, bytes);
@@ -76,7 +74,7 @@
        virtual void go_to_end();
 
        // See dox in IOChannel
-       virtual int tell() const
+       virtual std::streampos tell() const
        {
                return m_logical_stream_pos;
        }
@@ -88,23 +86,29 @@
        }
 
        // See dox in IOChannel
-       virtual int get_error() const
+       virtual bool bad() const
        {
                return m_error;
        }
 
 private:
 
-       std::auto_ptr<IOChannel>        m_in;
-       int             m_initial_stream_pos;   // position of the input stream 
where we started inflating.
-       unsigned char   m_rawdata[ZBUF_SIZE];
-       z_stream        m_zstream;
+    static const int ZBUF_SIZE = 4096;
+
+       std::auto_ptr<IOChannel> m_in;
+
+       // position of the input stream where we started inflating.
+    std::streampos m_initial_stream_pos;
+       
+    unsigned char m_rawdata[ZBUF_SIZE];
+       
+    z_stream m_zstream;
 
        // current stream position of uncompressed data.
-       int             m_logical_stream_pos;
+    std::streampos m_logical_stream_pos;
 
-       bool            m_at_eof;
-       int             m_error;
+       bool m_at_eof;
+       bool m_error;
 
        /// Discard current results and rewind to the beginning.
        //
@@ -114,17 +118,18 @@
        /// might throw a ParserException if unable to reset the uderlying
        /// stream to original position.
        ///
-       void    reset();
+       void reset();
 
-       int     inflate_from_stream(void* dst, int bytes);
+    std::streamsize inflate_from_stream(void* dst, std::streamsize bytes);
 
        // If we have unused bytes in our input buffer, rewind
        // to before they started.
-       void    rewind_unused_bytes();
-
+       void rewind_unused_bytes();
 
 };
 
+const int InflaterIOChannel::ZBUF_SIZE;
+
 void
 InflaterIOChannel::rewind_unused_bytes()
 {
@@ -148,7 +153,7 @@
        m_at_eof = 0;
        int     err = inflateReset(&m_zstream);
        if (err != Z_OK) {
-               gnash::log_error("inflater_impl::reset() inflateReset() 
returned %d", err);
+               log_error("inflater_impl::reset() inflateReset() returned %d", 
err);
                m_error = 1;
                return;
        }
@@ -160,20 +165,20 @@
        m_zstream.avail_out = 0;
 
        // Rewind the underlying stream.
-       if ( m_in->seek(m_initial_stream_pos) == TU_FILE_SEEK_ERROR )
+       if (!m_in->seek(m_initial_stream_pos))
        {
                std::stringstream ss;
-               ss << "inflater_impl::reset: unable to seek underlying stream 
to position " <<  m_initial_stream_pos;
-               throw gnash::ParserException(ss.str());
+               ss << "inflater_impl::reset: unable to seek underlying "
+            "stream to position " <<  m_initial_stream_pos;
+               throw ParserException(ss.str());
        }
 
        m_logical_stream_pos = m_initial_stream_pos;
 }
 
-int
-InflaterIOChannel::inflate_from_stream(void* dst, int bytes)
+std::streamsize
+InflaterIOChannel::inflate_from_stream(void* dst, std::streamsize bytes)
 {
-       using gnash::ParserException;
 
        assert(bytes);
 
@@ -210,8 +215,7 @@
                {
                        std::ostringstream ss;
                        ss << __FILE__ << ":" << __LINE__ << ": " << 
m_zstream.msg;
-                       // we should call inflate again... giving more input or 
output space !
-                       gnash::log_error("%s", ss.str());
+                       log_error("%s", ss.str());
                        break;
                }
                if (err == Z_DATA_ERROR)
@@ -270,7 +274,7 @@
        // Seek forwards.
        for (;;)
        {
-               int     bytes_read = inflate_from_stream(temp, ZBUF_SIZE);
+        std::streamsize bytes_read = inflate_from_stream(temp, ZBUF_SIZE);
                if (bytes_read == 0)
                {
                        // We've seeked as far as we can.
@@ -279,47 +283,48 @@
        }
 }
 
-int
-InflaterIOChannel::seek(int pos)
+bool
+InflaterIOChannel::seek(std::streampos pos)
 {
        if (m_error)
        {
-               gnash::log_debug("Inflater is in error condition");
-               return TU_FILE_SEEK_ERROR;
-               //return inf->m_logical_stream_pos;
+           log_debug("Inflater is in error condition");
+               return false;
        }
 
        // If we're seeking backwards, then restart from the beginning.
        if (pos < m_logical_stream_pos)
        {
-               log_debug("inflater reset due to seek back from %d to %d", 
m_logical_stream_pos, pos );
+               log_debug("inflater reset due to seek back from %d to %d",
+                m_logical_stream_pos, pos );
                reset();
        }
 
-       unsigned char   temp[ZBUF_SIZE];
+       unsigned char temp[ZBUF_SIZE];
 
        // Now seek forwards, by just reading data in blocks.
        while (m_logical_stream_pos < pos)
        {
-               int     to_read = pos - m_logical_stream_pos;
+        std::streamsize to_read = pos - m_logical_stream_pos;
                assert(to_read > 0);
-               int     to_read_this_time = std::min<int>(to_read, ZBUF_SIZE);
-               assert(to_read_this_time > 0);
-
-               int     bytes_read = inflate_from_stream(temp, 
to_read_this_time);
-               assert(bytes_read <= to_read_this_time);
+
+        std::streamsize readNow = std::min<std::streamsize>(to_read, 
ZBUF_SIZE);
+               assert(readNow > 0);
+
+        std::streamsize bytes_read = inflate_from_stream(temp, readNow);
+               assert(bytes_read <= readNow);
                if (bytes_read == 0)
                {
                        // Trouble; can't seek any further.
-                       gnash::log_debug("Trouble: can't seek any further.. ");
-                       return TU_FILE_SEEK_ERROR;
+                       log_debug("Trouble: can't seek any further.. ");
+                       return false;
                        break;
                }
        }
 
        assert(m_logical_stream_pos == pos);
 
-       return 0; // m_logical_stream_pos;
+       return true; 
 }
 
 InflaterIOChannel::InflaterIOChannel(std::auto_ptr<IOChannel> in)
@@ -344,7 +349,7 @@
 
        int     err = inflateInit(&m_zstream);
        if (err != Z_OK) {
-               gnash::log_error("inflater_impl::ctor() inflateInit() returned 
%d", err);
+               log_error("inflater_impl::ctor() inflateInit() returned %d", 
err);
                m_error = 1;
                return;
        }

=== modified file 'libcore/CharacterProxy.h'
--- a/libcore/CharacterProxy.h  2008-06-17 08:28:27 +0000
+++ b/libcore/CharacterProxy.h  2009-02-10 15:38:43 +0000
@@ -99,12 +99,14 @@
        {
                if ( skipRebinding ) return _ptr;
 
-               checkDangling(); // set _ptr to NULL and _tgt to original 
target if destroyed
+        // set _ptr to NULL and _tgt to original target if destroyed
+               checkDangling(); 
                if ( _ptr ) return _ptr;
                else return find_character_by_target(_tgt);
        }
 
-       /// Get the sprite target, either current (if not dangling) or 
bounded-to one.
+       /// Get the sprite target, either current (if not dangling) or
+    /// bound one.
        std::string getTarget() const;
 
        /// Return true if this sprite is dangling

=== modified file 'libcore/DisplayList.cpp'
--- a/libcore/DisplayList.cpp   2008-12-05 09:37:07 +0000
+++ b/libcore/DisplayList.cpp   2009-02-11 07:17:56 +0000
@@ -184,8 +184,7 @@
   ch->set_depth(depth);
 
   container_type::iterator it = std::find_if(
-      _charsByDepth.begin(), _charsByDepth.end(),
-      DepthGreaterOrEqual(depth));
+      _charsByDepth.begin(), _charsByDepth.end(), DepthGreaterOrEqual(depth));
 
   if ( it == _charsByDepth.end() || (*it)->get_depth() != depth )
   {
@@ -230,8 +229,8 @@
   int depth = ch->get_depth();
 
   container_type::iterator it = std::find_if(
-      _charsByDepth.begin(), _charsByDepth.end(),
-      DepthGreaterOrEqual(depth));
+      _charsByDepth.begin(), _charsByDepth.end(), DepthGreaterOrEqual(depth));
+
   if ( it == _charsByDepth.end() || (*it)->get_depth() != depth )
   {
     _charsByDepth.insert(it, DisplayItem(ch));
@@ -274,14 +273,15 @@
   ch->set_invalidated();
   ch->set_depth(depth);
 
-  // NOTE: currently, ::restart also cleans up all property, which include 
__proto__ !!
-  //       For this reason I commented it out. Since no tests in the testsuite 
are failing
-  //       I'm not sure what does this break. Udo: do you remember ? --strk;
+  // NOTE: currently, ::restart also cleans up all
+  // property, which include __proto__ !!
+  // For this reason I commented it out. Since no tests in
+  // the testsuite are failing
+  // I'm not sure what does this break. Udo: do you remember ? --strk;
   // ch->restart();
 
   container_type::iterator it = std::find_if(
-      _charsByDepth.begin(), _charsByDepth.end(),
-      DepthGreaterOrEqual(depth));
+      _charsByDepth.begin(), _charsByDepth.end(), DepthGreaterOrEqual(depth));
 
   DisplayItem di(ch);
 

=== modified file 'libcore/LoadVariablesThread.cpp'
--- a/libcore/LoadVariablesThread.cpp   2009-02-09 09:29:52 +0000
+++ b/libcore/LoadVariablesThread.cpp   2009-02-10 11:33:38 +0000
@@ -122,8 +122,14 @@
                parse(toparse);
        }
 
-       _stream->go_to_end();
-       _bytesLoaded = _stream->tell();
+       try {
+               _stream->go_to_end();
+       }
+    catch (IOException& ex) {
+               log_error("Stream couldn't seek to end: %s", ex.what());
+       }
+       
+    _bytesLoaded = _stream->tell();
        if ( _bytesTotal !=  _bytesLoaded )
        {
                log_error("Size of 'variables' stream advertised to be %d 
bytes,"

=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2009-02-09 09:29:52 +0000
+++ b/libcore/MovieClip.cpp     2009-02-10 15:38:43 +0000
@@ -262,7 +262,7 @@
 } // anonymous namespace
 
 
-MovieClip::MovieClip( movie_definition* def, movie_instance* r,
+MovieClip::MovieClip(movie_definition* def, movie_instance* r,
         character* parent, int id)
     :
     character(parent, id),
@@ -831,14 +831,6 @@
 MovieClip::set_member(string_table::key name,
         const as_value& val, string_table::key nsname, bool ifFound)
 {
-#ifdef DEBUG_DYNTEXT_VARIABLES
-    //log_debug(_("movieclip[%p]::set_member(%s, %s)"), (void*)this, 
VM::get().getStringTable().value(name), val);
-#endif
-
-    //if ( val.is_function() )
-    //{
-    //    checkForKeyOrMouseEvent(VM::get().getStringTable().value(name));
-    //}
 
     bool found = false;
 
@@ -2342,7 +2334,7 @@
                 as_object* super = get_super();
 
                 as_environment& env = get_environment();
-                fn_call call(this, &env);
+                fn_call call(this, env);
                 call.super = super;
 
                     // we don't use the constructor return (should we?)
@@ -2915,13 +2907,8 @@
 
     if ( cl == NULL )
     {
-        cl=new builtin_function(&movieclip_ctor, getMovieClipInterface());
-        VM::get().addStatic(cl.get());
-
-        // replicate all interface to class, to be able to access
-        // all methods as static functions
-        //attachMovieClipInterface(*cl);
-                 
+        cl = new builtin_function(&movieclip_ctor, getMovieClipInterface());
+        global.getVM().addStatic(cl.get());
     }
 
     // Register _global.MovieClip
@@ -5318,10 +5305,10 @@
     //int target_version = o.getVM().getSWFVersion();
 
     // This is a normal property, can be overridden, deleted and enumerated
-    // See swfdec/test/trace/movieclip-version-#.swf for why we only 
initialize this
-    // if we don't have a parent
-    if ( ! o.get_parent() ) o.init_member( "$version",
-            VM::get().getPlayerVersion(), 0); 
+    // See swfdec/test/trace/movieclip-version-#.swf for why we only
+    // initialize this if we don't have a parent
+    if (!o.get_parent()) o.init_member("$version",
+            o.getVM().getPlayerVersion(), 0); 
 
     as_c_function_ptr gettersetter;
 

=== modified file 'libcore/Property.cpp'
--- a/libcore/Property.cpp      2008-12-08 15:13:08 +0000
+++ b/libcore/Property.cpp      2009-02-10 15:38:43 +0000
@@ -28,7 +28,7 @@
        const GetterSetter* a = boost::get<const GetterSetter>(&mBound);
 
        as_environment env(this_ptr.getVM());
-       fn_call fn(const_cast<as_object*>(&this_ptr), &env);
+       fn_call fn(const_cast<as_object*>(&this_ptr), env);
        if (mDestructive)
        {
                as_value ret = a->get(fn);
@@ -54,7 +54,7 @@
        std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value> 
);
        args->push_back(value);
 
-       fn_call fn(&this_ptr, &env, args);
+       fn_call fn(&this_ptr, env, args);
 
        a->set(fn);
        a->setCache(value);

=== modified file 'libcore/PropertyList.cpp'
--- a/libcore/PropertyList.cpp  2008-12-08 15:13:08 +0000
+++ b/libcore/PropertyList.cpp  2009-02-10 15:38:43 +0000
@@ -43,7 +43,8 @@
 
 PropertyList::PropertyList(const PropertyList& pl)
        :
-       mDefaultOrder(pl.mDefaultOrder) // correct ?
+       mDefaultOrder(pl.mDefaultOrder),
+    _vm(pl._vm)
 {
        import(pl);
 }
@@ -141,7 +142,7 @@
        a.setOrder(slotId + 1);
        _props.insert(a);
 #ifdef GNASH_DEBUG_PROPERTY
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
        log_debug("Slot for AS property %s in namespace %s inserted with flags 
%s",
                st.value(name), st.value(nsId), a.getFlags());
 #endif
@@ -175,7 +176,7 @@
                a.setOrder(- ++mDefaultOrder - 1);
                _props.insert(a);
 #ifdef GNASH_DEBUG_PROPERTY
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_debug("Simple AS property %s in namespace %s inserted with 
flags %s",
                        st.value(key), st.value(nsId), a.getFlags());
 #endif
@@ -185,7 +186,7 @@
        const Property& prop = *found;
        if (prop.isReadOnly() && ! prop.isDestructive())
        {
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_error(_("Property %s (key %d) in namespace %s (key %d) is 
read-only %s, not setting it to %s"), 
                        st.value(key), key, st.value(nsId), nsId, 
prop.getFlags(), val);
                return false;
@@ -212,7 +213,7 @@
        return f.set_flags(setFlags, clearFlags);
 
 #ifdef GNASH_DEBUG_PROPERTY
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
        log_debug("Flags of property %s in namespace %s changed from %s to  %s",
                st.value(key), st.value(nsId), oldFlags, found->getFlags());
 #endif
@@ -225,7 +226,7 @@
        size_t failure=0;
 
 #ifdef GNASH_DEBUG_PROPERTY
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
 #endif
 
        for (container::iterator it=_props.begin(), far=_props.end(); it != 
far; ++it)
@@ -255,7 +256,6 @@
        container::iterator found = iterator_find(_props, key, nsId);
        if (found == _props.end())
        {
-               //log_error("getProperty(%s): not found", 
VM::get().getStringTable().value(key));
                return NULL;
        }
        return const_cast<Property*>(&(*found));
@@ -351,7 +351,7 @@
 void
 PropertyList::dump(as_object& this_ptr, std::map<std::string, as_value>& to) 
 {
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
 
        for (container::const_iterator i=_props.begin(), ie=_props.end();
             i != ie; ++i)
@@ -364,7 +364,7 @@
 void
 PropertyList::dump(as_object& this_ptr)
 {
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
        for (container::const_iterator it=_props.begin(), itEnd=_props.end(); 
it != itEnd; ++it )
        {
                log_debug("  %s: %s", st.value(it->mName),
@@ -386,7 +386,7 @@
                        a.setOrder(found->getOrder());
                        _props.replace(found, a);
 #ifdef GNASH_DEBUG_PROPERTY
-                       string_table& st = VM::get().getStringTable();
+                       string_table& st = _vm.getStringTable();
                        log_debug("Property %s in namespace %s replaced on 
import: new flags %s",
                                st.value(a.getName()), 
st.value(a.getNamespace()), a.getFlags());
 #endif
@@ -397,7 +397,7 @@
                        a.setOrder(- ++mDefaultOrder - 1);
                        _props.insert(a);
 #ifdef GNASH_DEBUG_PROPERTY
-                       string_table& st = VM::get().getStringTable();
+                       string_table& st = _vm.getStringTable();
                        log_debug("Property %s in namespace %s imported with 
flags %s",
                                st.value(a.getName()), 
st.value(a.getNamespace()), a.getFlags());
 #endif
@@ -423,7 +423,7 @@
 
                _props.replace(found, a);
 #ifdef GNASH_DEBUG_PROPERTY
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_debug("AS GetterSetter %s in namespace %s replaced copying "
                 "flags %s", st.value(key), st.value(nsId), a.getFlags());
 #endif
@@ -434,7 +434,7 @@
                a.setCache(cacheVal);
                _props.insert(a);
 #ifdef GNASH_DEBUG_PROPERTY
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_debug("AS GetterSetter %s in namespace %s inserted with 
flags %s",
                        st.value(key), st.value(nsId), a.getFlags());
 #endif
@@ -461,7 +461,7 @@
                _props.replace(found, a);
                //assert ( iterator_find(_props, key, nsId) != _props.end() );
 #ifdef GNASH_DEBUG_PROPERTY
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_debug("Native GetterSetter %s in namespace %s replaced "
                 "copying flags %s", st.value(key), st.value(nsId),
                 a.getFlags());
@@ -473,7 +473,7 @@
                _props.insert(a);
                //assert ( iterator_find(_props, key, nsId) != _props.end() );
 #ifdef GNASH_DEBUG_PROPERTY
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_debug("Native GetterSetter %s in namespace %s inserted with 
"
                 "flags %s", st.value(key), st.value(nsId), a.getFlags());
 #endif
@@ -490,7 +490,7 @@
        container::iterator found = iterator_find(_props, key, nsId);
        if (found != _props.end())
        {
-               string_table& st = VM::get().getStringTable();
+               string_table& st = _vm.getStringTable();
                log_error("Property %s in namespace %s already exists, "
                 "can't addDestructiveGetter", st.value(key), st.value(nsId));
                return false; // Already exists.
@@ -502,7 +502,7 @@
        _props.insert(a);
 
 #ifdef GNASH_DEBUG_PROPERTY
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
        log_debug("Destructive AS property %s (key %d) in namespace %s "
             "(key %d) inserted with flags %s",
                    st.value(key), key, st.value(nsId), nsId, a.getFlags());
@@ -524,7 +524,7 @@
        a.setOrder(- ++mDefaultOrder - 1);
        _props.insert(a);
 #ifdef GNASH_DEBUG_PROPERTY
-       string_table& st = VM::get().getStringTable();
+       string_table& st = _vm.getStringTable();
        log_debug("Destructive native property %s in namespace %s inserted "
             "with flags %s", st.value(key), st.value(nsId), a.getFlags());
 #endif

=== modified file 'libcore/PropertyList.h'
--- a/libcore/PropertyList.h    2009-01-22 20:10:39 +0000
+++ b/libcore/PropertyList.h    2009-02-10 15:38:43 +0000
@@ -57,13 +57,13 @@
     
 
     /// A tag type for multi-index
-       struct oType {/**/};
+       struct oType {};
 
        /// The actual container
        /// index 0 is the fully indexed name/namespace pairs, which are unique
-       /// Because of the way searching works, this index can also be used to 
search
-       /// for the names alone (composite keys are sorted lexographically, 
beginning
-       /// with the first element specified)
+       /// Because of the way searching works, this index can also be
+    /// used to search for the names alone (composite keys are sorted
+    /// lexographically, beginning with the first element specified)
        ///
        /// index 1 is an ordered sequence, and it is used for the AS3 style
        /// enumeration (which requires an order number for each property),
@@ -86,11 +86,17 @@
        > container;
 
        /// Construct the PropertyList 
-       PropertyList()
+    //
+    /// The constructor takes a VM reference because PropertyList
+    /// conceptually needs access to Virtual Machine resources
+    /// (string_table) but not to the Stage.
+       PropertyList(VM& vm)
                :
                _props(),
-               mDefaultOrder(0) // correct ?
-       {/**/}
+               mDefaultOrder(0),
+        _vm(vm)
+       {
+    }
 
        /// Copy constructor
        PropertyList(const PropertyList& pl);
@@ -165,8 +171,9 @@
     bool hasNonHiddenProperties() const
     {
         typedef container::nth_index<1>::type ContainerByOrder;
-        for (ContainerByOrder::const_reverse_iterator 
it=_props.get<1>().rbegin(),
-            ie=_props.get<1>().rend(); it != ie; ++it)
+        for (ContainerByOrder::const_reverse_iterator it = 
+                _props.get<1>().rbegin(), ie=_props.get<1>().rend();
+                it != ie; ++it)
                {
                if (! it->getFlags().get_dont_enum()) return true;
         }
@@ -458,8 +465,7 @@
        ///         of keys in the props argument not found in
        ///         this properties set.
        ///
-       std::pair<size_t,size_t> setFlagsAll(
-                       const PropertyList& props,
+       std::pair<size_t,size_t> setFlagsAll( const PropertyList& props,
                        int setTrue, int setFalse);
 
        /// \brief
@@ -551,8 +557,13 @@
        void setReachable() const;
 
 private:
-       container _props;
-       unsigned short mDefaultOrder;
+
+    container _props;
+
+    unsigned short mDefaultOrder;
+    
+    VM& _vm;
+
 };
 
 

=== modified file 'libcore/SWFStream.cpp'
--- a/libcore/SWFStream.cpp     2009-01-22 20:10:39 +0000
+++ b/libcore/SWFStream.cpp     2009-02-10 11:33:38 +0000
@@ -49,13 +49,15 @@
 {
 #ifndef GNASH_TRUST_SWF_INPUT
 
-    if ( _tagBoundsStack.empty() ) return; // not in a tag (should we check 
file length ?)
+    // Not in a tag (should we check file length?)
+    if ( _tagBoundsStack.empty() ) return; 
 
     unsigned long int left = get_tag_end_position() - tell();
     if ( left < needed )
     {
         std::stringstream ss;
-        ss << "premature end of tag: need to read " << needed << " bytes, but 
only " << left << " left in this tag";
+        ss << "premature end of tag: need to read " << needed << 
+            " bytes, but only " << left << " left in this tag";
         throw ParserException(ss.str());
     }
 #endif
@@ -498,7 +500,7 @@
     }
 
     // Do the seek.
-    if ( m_input->seek(pos) == -1 )
+    if (!m_input->seek(pos))
     {
         // TODO: should we throw an exception ?
         //       we might be called from an exception handler
@@ -602,12 +604,12 @@
 {
 
     assert(_tagBoundsStack.size() > 0);
-    unsigned long endPos = _tagBoundsStack.back().second;
+    std::streampos endPos = _tagBoundsStack.back().second;
     _tagBoundsStack.pop_back();
 
     //log_debug("Close tag called at %d, stream size: %d", endPos);
 
-    if ( m_input->seek(endPos) == -1 )
+    if (!m_input->seek(endPos))
     {
         // We'll go on reading right past the end of the stream
         // if we don't throw an exception.
@@ -624,9 +626,10 @@
        // to possibly throw an exception (!)
        try {
                m_input->go_to_end();
-       } catch (IOException& ex) {
-               log_error("SWFStream::consumeInput: underlying stream couldn't 
go_to_end: %s",
-                       ex.what());
+       }
+    catch (IOException& ex) {
+               log_error("SWFStream::consumeInput: underlying stream couldn't "
+                "go_to_end: %s", ex.what());
                // eh.. and now ?!
        }
 }

=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp     2009-01-23 07:28:34 +0000
+++ b/libcore/TextField.cpp     2009-02-10 15:38:43 +0000
@@ -2727,11 +2727,12 @@
 
 /// This is called for 'new TextField()' only
 as_value
-textfield_ctor(const fn_call& /* fn */)
+textfield_ctor(const fn_call& fn)
 {
-    as_object* proto = getTextFieldInterface(VM::get());
-
-    VM& vm = VM::get(); // TODO: ask fn about VM !
+
+    VM& vm = fn.getVM();
+
+    as_object* proto = getTextFieldInterface(vm);
 
     as_object* obj = 0;
 

=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp   2009-01-22 20:10:39 +0000
+++ b/libcore/as_function.cpp   2009-02-10 16:01:43 +0000
@@ -78,7 +78,10 @@
 
                VM::get().addStatic(proto.get());
 
-               int 
flags=as_prop_flags::dontDelete|as_prop_flags::dontEnum|as_prop_flags::onlySWF6Up;
 
+               const int flags = as_prop_flags::dontDelete | 
+                          as_prop_flags::dontEnum | 
+                          as_prop_flags::onlySWF6Up; 
+
                proto->init_member("apply", new 
builtin_function(function_apply), flags);
                proto->init_member("call", new builtin_function(function_call), 
flags);
        }
@@ -140,7 +143,7 @@
        as_object* newproto = new as_object(superclass.getPrototype().get());
        newproto->init_member(NSV::PROP_uuPROTOuu, 
superclass.getPrototype().get());
 
-    if (VM::get().getSWFVersion() > 5) {
+    if (_vm.getSWFVersion() > 5) {
         const int flags = as_prop_flags::dontEnum;
         newproto->init_member(NSV::PROP_uuCONSTRUCTORuu, &superclass, flags); 
     }
@@ -314,7 +317,8 @@
                        // 'object' but when compared to undefined matches !!
                        // See actionscript.all/Function.as
                        IF_VERBOSE_ASCODING_ERRORS(
-                       log_aserror(_("First argument to Function.call(%s) 
doesn't cast to object. "
+                       log_aserror(_("First argument to Function.call(%s) 
doesn't "
+                "cast to object. "
                                "Gnash will keep the current 'this' pointer as 
it is, "
                                "but this is known to not be the correct way to 
handle "
                                "such a malformed call."), this_val);
@@ -324,15 +328,16 @@
                {
                        new_fn_call.this_ptr = this_ptr;
                        as_object* proto = this_ptr->get_prototype().get();
-                        if ( proto )
-                        {
-                                new_fn_call.super = this_ptr->get_super();
-                        }
-                        else
-                        {
-                                // TODO: check this !
-                                log_debug("No prototype in 'this' pointer 
passed to Function.call");
-                                new_fn_call.super = function_obj->get_super();
+            if ( proto )
+            {
+                    new_fn_call.super = this_ptr->get_super();
+            }
+            else
+            {
+                // TODO: check this !
+                log_debug("No prototype in 'this' pointer "
+                        "passed to Function.call");
+                new_fn_call.super = function_obj->get_super();
                        }
                }
                new_fn_call.drop_bottom();
@@ -341,16 +346,12 @@
        // Call the function 
        return (*function_obj)(new_fn_call);
 
-       //log_debug(_("at function_call exit, stack: \n")); 
fn.env->dump_stack();
-
-       //log_debug(_("%s: tocheck \n"), __FUNCTION__);
 }
 
 boost::intrusive_ptr<as_object>
-as_function::constructInstance( as_environment& env,
+as_function::constructInstance(as_environment& env,
        std::auto_ptr< std::vector<as_value> > args)
 {
-//     GNASH_REPORT_FUNCTION;
 
 #ifndef GNASH_USE_GC
        assert(get_ref_count() > 0);
@@ -375,9 +376,9 @@
     {
                IF_VERBOSE_ACTION (
             log_action(_("it's a built-in class"));
-               );
+               )
 
-               fn_call fn(0, &env, args);
+               fn_call fn(0, env, args);
                as_value ret;
 
                try {
@@ -455,7 +456,7 @@
                // Call the actual constructor function; new_obj is its 'this'.
 
                // We don't need the function result.
-               fn_call fn(newobj.get(), &env, args, super);
+               fn_call fn(newobj.get(), env, args, super);
                call(fn);
        }
 

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2009-01-22 20:10:39 +0000
+++ b/libcore/as_object.cpp     2009-02-10 15:38:43 +0000
@@ -654,7 +654,8 @@
                Property* prop = _members.getProperty(key);
                if ( ! prop )
                {
-                       log_debug("Property %s deleted by trigger on create", 
_vm.getStringTable().value(key));
+                       log_debug("Property %s deleted by trigger on create", 
+                    _vm.getStringTable().value(key));
                }
                else
                {
@@ -677,7 +678,6 @@
 as_object::init_member(string_table::key key, const as_value& val, int flags,
        string_table::key nsname, int order)
 {
-       //log_debug(_("Initializing member %s for object %p"), 
_vm.getStringTable().value(key), (void*) this);
 
        if (order >= 0 && !_members.
                reserveSlot(static_cast<unsigned short>(order), key, nsname))
@@ -1055,25 +1055,33 @@
 
 }
 
+as_object::as_object(movie_root& mr)
+       :
+       _vm(mr.getVM()),
+       _members(_vm)
+{
+}
+
+
 as_object::as_object()
        :
-       _members(),
-       _vm(VM::get())
+       _vm(VM::get()),
+       _members(_vm)
 {
 }
 
 as_object::as_object(as_object* proto)
        :
-       _members(),
-       _vm(VM::get())
+       _vm(VM::get()),
+       _members(_vm)
 {
        init_member(NSV::PROP_uuPROTOuu, as_value(proto));
 }
 
 as_object::as_object(boost::intrusive_ptr<as_object> proto)
        :
-       _members(),
-       _vm(VM::get())
+       _vm(VM::get()),
+       _members(_vm)
 {
        init_member(NSV::PROP_uuPROTOuu, as_value(proto));
 }
@@ -1085,9 +1093,8 @@
 #else
        GcResource(), 
 #endif
-       _members(other._members),
-       _vm(VM::get())
-       //, m_prototype(other.m_prototype) // done by _members copy
+       _vm(VM::get()),
+       _members(other._members)
 {
 }
 
@@ -1389,7 +1396,7 @@
                args->push_back(newval);
                args->push_back(_customArg);
 
-               fn_call fn(&this_obj, &env, args);
+               fn_call fn(&this_obj, env, args);
 
                as_value ret = _func->call(fn);
 

=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h       2009-01-22 20:10:39 +0000
+++ b/libcore/as_object.h       2009-02-10 15:38:43 +0000
@@ -47,12 +47,13 @@
        class Machine;
        class IOChannel;
     class event_id;
+    class movie_root;
+    class asClass;
+    class asName;
 }
 
 namespace gnash {
 
-class asClass;
-class asName;
 
 /// An abstract property visitor
 class AbstractPropertyVisitor {
@@ -104,7 +105,8 @@
        /// @param this_obj
        ///     Object of which the property is being changed
        ///
-       as_value call(const as_value& oldval, const as_value& newval, 
as_object& this_obj);
+       as_value call(const as_value& oldval, const as_value& newval, 
+            as_object& this_obj);
 
        void setReachable() const;
 
@@ -133,27 +135,6 @@
 
     typedef PropertyList::SortedPropertyList SortedPropertyList;
 
-private:
-       /// Properties of this objects 
-       PropertyList _members;
-
-       /// Don't allow implicit copy, must think about behaviour
-       as_object& operator=(const as_object&);
-
-       /// \brief
-       /// Find an existing property for update, only scanning the
-    /// inheritance chain for getter/setters or statics.
-       //
-       /// NOTE: updatable here doesn't mean the property isn't protected
-    /// from update but only that a set_member will NOT create a new
-    /// property (either completely new or as an override).
-       ///
-       /// @returns a property if found, NULL if not found
-       ///          or not visible in current VM version
-       ///
-       Property* findUpdatableProperty(string_table::key name, 
-               string_table::key nsname = 0);
-
 public:
 
     /// Is any non-hidden property in this object ?
@@ -204,6 +185,8 @@
        ///
        void dump_members(std::map<std::string, as_value>& to);
 
+    as_object(movie_root& mr);
+
        /// Construct an ActionScript object with no prototype associated.
        as_object();
 
@@ -1083,14 +1066,30 @@
 
 private:
 
+    /// Properties of this objects 
+       PropertyList _members;
+
+       /// Don't allow implicit copy, must think about behaviour
+       as_object& operator=(const as_object&);
+
+       /// \brief
+       /// Find an existing property for update, only scanning the
+    /// inheritance chain for getter/setters or statics.
+       //
+       /// NOTE: updatable here doesn't mean the property isn't protected
+    /// from update but only that a set_member will NOT create a new
+    /// property (either completely new or as an override).
+       ///
+       /// @returns a property if found, NULL if not found
+       ///          or not visible in current VM version
+       ///
+       Property* findUpdatableProperty(string_table::key name, 
+               string_table::key nsname = 0);
+
        /// The constructors of the objects which are the interfaces
        /// implemented by this one.
        std::list<as_object*> mInterfaces;
 
-       /// Reference to this object's '__proto__'
-       //boost::intrusive_ptr<as_object> m_prototype;
-
-
        typedef std::pair< string_table::key, string_table::key > FQkey;
        typedef std::map< FQkey, Trigger > TriggerContainer;
        TriggerContainer _trigs;

=== modified file 'libcore/as_value.h'
--- a/libcore/as_value.h        2009-01-22 20:10:39 +0000
+++ b/libcore/as_value.h        2009-02-10 15:38:43 +0000
@@ -155,9 +155,11 @@
 
        /// Construct a BOOLEAN value
        template <typename T>
-       as_value(T val, typename boost::enable_if<boost::is_same<bool, T> 
>::type* dummy = 0)
-               : m_type(BOOLEAN),
-                 _value(val)
+       as_value(T val, typename boost::enable_if<boost::is_same<bool, T> 
>::type*
+            dummy = 0)
+               :
+        m_type(BOOLEAN),
+               _value(val)
        {
                UNUSED(dummy);
        }

=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp  2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp  2009-02-10 15:38:43 +0000
@@ -111,9 +111,9 @@
                init_member("constructor", 
as_function::getFunctionConstructor().get());
        }
 
-       virtual as_value operator()(const fn_call& /*fn*/)
+       virtual as_value operator()(const fn_call& fn)
        {
-               string_table& st = VM::get().getStringTable();
+               string_table& st = fn.getVM().getStringTable();
                log_debug("Loading extension class %s", 
st.value(mDeclaration.name));
 
                as_value super;
@@ -361,7 +361,8 @@
        // TODO
 }
 
-std::ostream& operator << (std::ostream& os, const 
ClassHierarchy::nativeClass& c)
+std::ostream&
+operator<<(std::ostream& os, const ClassHierarchy::nativeClass& c)
 {
        string_table& st = VM::get().getStringTable();
 
@@ -375,7 +376,8 @@
        return os;
 }
 
-std::ostream& operator << (std::ostream& os, const 
ClassHierarchy::extensionClass& c)
+std::ostream&
+operator<<(std::ostream& os, const ClassHierarchy::extensionClass& c)
 {
        string_table& st = VM::get().getStringTable();
 

=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp  2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/Global.cpp  2009-02-10 16:01:43 +0000
@@ -523,12 +523,6 @@
 as_global_asnative(const fn_call& fn)
 {
 
-    // Note: it's possible for 'this' to be undefined in ActionScript,
-    // which would make this call return undefined. TODO: test it in
-    // the testsuite! It's not even certain whether Gnash has implemented
-    // an undefined this pointer.
-    boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
-
     as_value ret;
 
     if (fn.nargs < 2)
@@ -561,7 +555,7 @@
     const unsigned int x = static_cast<unsigned int>(sx);
     const unsigned int y = static_cast<unsigned int>(sy);
 
-    VM& vm = ptr->getVM();
+    VM& vm = fn.getVM();
     as_function* fun = vm.getNative(x, y);
     if ( ! fun ) {
         log_debug(_("No ASnative(%d, %d) registered with the VM"), x, y);

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2009-02-10 15:38:43 +0000
@@ -29,6 +29,7 @@
 #include "VM.h"
 #include "Object.h" // for getObjectInterface
 #include "namedStrings.h"
+#include "PropertyList.h"
 
 #include <list>
 #include <boost/algorithm/string/case_conv.hpp>

=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp  2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/LoadableObject.cpp  2009-02-10 15:38:43 +0000
@@ -180,7 +180,7 @@
                return;
                // TODO: check if this is correct
                //as_value nullValue; nullValue.set_null();
-               
//callMethod(VM::get().getStringTable().find(PROPNAME("onData")), nullValue);
+               //callMethod(_vm.getStringTable().find(PROPNAME("onData")), 
nullValue);
        }
 
        log_security(_("Loading from url: '%s'"), url.str());
@@ -207,7 +207,7 @@
                return;
                // TODO: check if this is correct
                //as_value nullValue; nullValue.set_null();
-               
//callMethod(VM::get().getStringTable().find(PROPNAME("onData")), nullValue);
+               //callMethod(_vm.getStringTable().find(PROPNAME("onData")), 
nullValue);
        }
 
        log_security(_("Loading from url: '%s'"), url.str());

=== modified file 'libcore/asobj/Math_as.cpp'
--- a/libcore/asobj/Math_as.cpp 2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/Math_as.cpp 2009-02-10 15:38:43 +0000
@@ -212,7 +212,7 @@
     if (fn.nargs) fn.arg(0).to_number();
     if (fn.nargs > 1) fn.arg(1).to_number();
 
-       VM::RNG& rnd = VM::get().randomNumberGenerator();
+       VM::RNG& rnd = fn.getVM().randomNumberGenerator();
 
        // Produces double ( 0 <= n < 1)
        boost::uniform_real<> uni_dist(0, 1);

=== modified file 'libcore/asobj/NetConnection_as.cpp'
--- a/libcore/asobj/NetConnection_as.cpp        2009-02-09 09:29:52 +0000
+++ b/libcore/asobj/NetConnection_as.cpp        2009-02-10 11:33:38 +0000
@@ -370,7 +370,7 @@
         // the buffer is full, 2) when we have a "length in bytes" value
         // thas is satisfied
 
-        if(_connection->get_error())
+        if (_connection->bad())
         {
             log_debug("connection is in error condition, calling "
                     "NetConnection.onStatus");

=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp  2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/Object.cpp  2009-02-10 15:38:43 +0000
@@ -290,9 +290,8 @@
 
        // TODO: check to *which* definition should we ask the export
        //       this code uses the *relative* root of current environment's 
target
-       //       and don't use VM::get() if this code is ever reactivated.
 #if 0
-       movie_definition* def = VM::get().getRoot().get_movie_definition();
+       movie_definition* def = _vm.getRoot().get_movie_definition();
 #else
        // Using definition of current target fixes the youtube beta case
        // https://savannah.gnu.org/bugs/index.php?23130

=== modified file 'libcore/asobj/SharedObject_as.cpp'
--- a/libcore/asobj/SharedObject_as.cpp 2009-01-27 12:23:12 +0000
+++ b/libcore/asobj/SharedObject_as.cpp 2009-02-10 15:38:43 +0000
@@ -46,7 +46,6 @@
 #include "builtin_function.h" // need builtin_function
 #include "Object.h" // for getObjectInterface
 #include "VM.h"
-#include "PropertyList.h"
 #include "Property.h"
 #include "string_table.h"
 #include "URLAccessManager.h"

=== modified file 'libcore/asobj/XMLSocket_as.cpp'
--- a/libcore/asobj/XMLSocket_as.cpp    2008-12-11 08:18:23 +0000
+++ b/libcore/asobj/XMLSocket_as.cpp    2009-02-10 15:38:43 +0000
@@ -506,10 +506,11 @@
                        std::string& s = *it;
                        as_value datain( s );
 
-                       std::auto_ptr< std::vector<as_value> > args ( new 
std::vector<as_value> );
+                       std::auto_ptr<std::vector<as_value> > args(
+                    new std::vector<as_value>);
                        args->push_back(datain);
                        
-                       fn_call call(this, &env, args);
+                       fn_call call(this, env, args);
 
                        onDataHandler->call(call);
 

=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp  2009-02-09 09:29:52 +0000
+++ b/libcore/impl.cpp  2009-02-10 11:33:38 +0000
@@ -336,7 +336,8 @@
       log_error(_("failed to open '%s'; can't create movie"), url);
       return NULL;
   }
-  else if ( in->get_error() )
+  
+  if (in->bad())
   {
       log_error(_("streamProvider opener can't open '%s'"), url);
       return NULL;
@@ -363,7 +364,7 @@
 
     char buf[3];
     
-    if (3 > in.read(buf, 3))
+    if (in.read(buf, 3) < 3)
     {
         log_error(_("Can't read file header"));
         in.seek(0);
@@ -426,7 +427,7 @@
                 return GNASH_FILETYPE_UNKNOWN;
             }
         }
-        in.seek(in.tell() - 3); // position to start of the swf itself
+        in.seek(in.tell() - static_cast<std::streamoff>(3));
         return GNASH_FILETYPE_SWF;
     }
 

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2009-02-09 12:30:31 +0000
+++ b/libcore/movie_root.h      2009-02-10 14:04:14 +0000
@@ -363,6 +363,9 @@
         return m_background_color.m_a / 255.0f;
     }
 
+    /// Return the VM used by this movie_root
+    VM& getVM() { return _vm; }
+ 
     /// Main and only callback from hosting application.
     /// Expected to be called at 10ms resolution.
     void advance();

=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp     2009-01-22 20:10:39 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp     2009-02-10 12:26:18 +0000
@@ -76,8 +76,6 @@
 
 MovieLoader::~MovieLoader()
 {
-       //cout << "MovieLoader dtor called" << endl;
-
        // we should assert _movie_def._loadingCanceled
        // but we're not friend yet (anyone introduce us ?)
        if ( _thread.get() )
@@ -147,19 +145,22 @@
 /// Log the contents of the current tag, in hex to the output strream
 static void    dumpTagBytes(SWFStream& in, std::ostream& os)
 {
-    const unsigned int rowlength = 16;
+    const std::streamsize rowlength = 16;
     os << std::endl;
     
     // This decremented until we reach the end of the stream.
-    unsigned int toRead = in.get_tag_end_position() - in.tell();
+    std::streamsize toRead = in.get_tag_end_position() - in.tell();
     in.ensureBytes(toRead);
 
     unsigned char buf[rowlength];    
     while (toRead)
     {
         // Read in max row length or remainder of stream.
-        const unsigned int thisRow = std::min<unsigned int>(toRead, rowlength);
-        const unsigned int got = in.read(reinterpret_cast<char*>(&buf), 
thisRow);
+        const std::streamsize thisRow = 
+            std::min<std::streamsize>(toRead, rowlength);
+        
+        const std::streamsize got = 
+            in.read(reinterpret_cast<char*>(&buf), thisRow);
         
         // Check that we read all the bytes we expected.
         if (got < thisRow)
@@ -245,7 +246,7 @@
         _dictionary.get_character(character_id);
 #ifndef GNASH_USE_GC
        assert(ch == NULL || ch->get_ref_count() > 1);
-#endif // ndef GNASH_USE_GC
+#endif 
        return ch.get(); // mm... why don't we return the boost::intrusive_ptr?
 }
 
@@ -266,7 +267,8 @@
 }
 
 Font*
-SWFMovieDefinition::get_font(const std::string& name, bool bold, bool italic) 
const
+SWFMovieDefinition::get_font(const std::string& name, bool bold, bool italic)
+    const
 {
 
     for (FontMap::const_iterator it=m_fonts.begin(), itEnd=m_fonts.end(); it 
!= itEnd; ++it)
@@ -281,8 +283,9 @@
 SWFMovieDefinition::getBitmap(int character_id)
 {
     Bitmaps::iterator it = _bitmaps.find(character_id);
-    if ( it == _bitmaps.end() ) return 0;
-    else return it->second.get();
+    if (it == _bitmaps.end()) return 0;
+    
+    return it->second.get();
 }
 
 void
@@ -301,7 +304,7 @@
     boost::intrusive_ptr<sound_sample> ch = it->second;
 #ifndef GNASH_USE_GC
     assert(ch->get_ref_count() > 1);
-#endif // ndef GNASH_USE_GC
+#endif 
 
     return ch.get();
 }
@@ -312,7 +315,7 @@
     IF_VERBOSE_PARSE(
     log_parse(_("Add sound sample %d assigning id %d"),
                character_id, sam->m_sound_handler_id);
-    );
+    )
     m_sound_samples.insert(std::make_pair(character_id,
                            boost::intrusive_ptr<sound_sample>(sam)));
 }
@@ -326,10 +329,9 @@
        _in = in;
 
        // we only read a movie once
-       assert(_str.get() == NULL);
+       assert(!_str.get());
 
-       if ( url == "" ) _url = "<anonymous>";
-       else _url = url;
+       _url = url.empty() ? "<anonymous>" : url;
 
        boost::uint32_t file_start_pos = _in->tell();
        boost::uint32_t header = _in->read_le32();
@@ -345,21 +347,19 @@
                        "file does not start with a SWF header"));
                return false;
         }
-       bool    compressed = (header & 255) == 'C';
+       const bool compressed = (header & 255) == 'C';
 
        IF_VERBOSE_PARSE(
-               log_parse(_("version = %d, file_length = %d"),
-                       m_version, m_file_length);
-       );
+               log_parse(_("version: %d, file_length: %d"), m_version, 
m_file_length);
+    )
 
-       if ( m_version > 7 )
+       if (m_version > 7)
        {
                log_unimpl(_("SWF%d is not fully supported, trying anyway "
                        "but don't expect it to work"), m_version);
        }
 
-       if (compressed)
-        {
+       if (compressed) {
 #ifndef HAVE_ZLIB_H
                log_error(_("SWFMovieDefinition::read(): unable to read "
                        "zipped SWF data; gnash was compiled without zlib 
support"));
@@ -372,7 +372,7 @@
                // Uncompress the input as we read it.
                _in = zlib_adapter::make_inflater(_in);
 #endif
-        }
+    }
 
        assert(_in.get());
 
@@ -390,7 +390,8 @@
        }
 
        // It seems frame rate is limited to a max 
-       // 84 was found by testing the pp, might be turned into a compile-time 
define
+       // 84 was found by testing the pp, might be turned into a
+    // compile-time define
        static const int maxfps = 84;
        
        _str->ensureBytes(2 + 2); // frame rate, frame count.
@@ -413,10 +414,8 @@
 
        m_frame_count = _str->read_u16();
 
-       /* Markus: Probably this is better anyways */
-
        // TODO: This seems dangerous, check closely
-       if(m_frame_count == 0) m_frame_count++;
+       if (!m_frame_count) ++m_frame_count;
 
        IF_VERBOSE_PARSE(
                log_parse(_("frame size = %s, frame rate = %f, frames = %d"),
@@ -440,7 +439,7 @@
        assert ( VM::isInitialized() );
 
        // should call readHeader before this
-       assert( _str.get() != NULL );
+       assert(_str.get());
 
 #ifdef LOAD_MOVIES_IN_A_SEPARATE_THREAD
 
@@ -475,19 +474,16 @@
        boost::mutex::scoped_lock lock(_frames_loaded_mutex);
 
 #ifndef LOAD_MOVIES_IN_A_SEPARATE_THREAD
-       return ( framenum <= _frames_loaded );
+       return (framenum <= _frames_loaded);
 #endif
 
        if ( framenum <= _frames_loaded ) return true;
 
        _waiting_for_frame = framenum;
-        //log_debug(_("Waiting for frame %u to be loaded"), framenum);
 
        // TODO: return false on timeout
        _frame_reached_condition.wait(lock);
 
-        //log_debug(_("Condition reached (_frames_loaded=%u)"), 
_frames_loaded);
-
        return ( framenum <= _frames_loaded );
 }
 
@@ -506,8 +502,8 @@
 operator<<(std::ostream& o, const CharacterDictionary& cd)
 {
 
-       for (CharacterDictionary::CharacterConstIterator it = cd.begin(), endIt 
= cd.end();
-               it != endIt; it++)
+       for (CharacterDictionary::CharacterConstIterator it = cd.begin(), 
+            endIt = cd.end(); it != endIt; it++)
        {
            o << std::endl
              << "Character: " << it->first
@@ -524,15 +520,17 @@
        if ( it == _map.end() )
        {
                IF_VERBOSE_PARSE(
-               log_parse(_("Could not find char %d, dump is: %s"), id, *this);
+            log_parse(_("Could not find char %d, dump is: %s"), id, *this);
                );
                return boost::intrusive_ptr<character_def>();
        }
-       else return it->second;
+       
+    return it->second;
 }
 
 void
-CharacterDictionary::add_character(int id, boost::intrusive_ptr<character_def> 
c)
+CharacterDictionary::add_character(int id,
+        boost::intrusive_ptr<character_def> c)
 {
        //log_debug(_("CharacterDictionary: add char %d"), id);
        _map[id] = c;
@@ -556,87 +554,81 @@
 
        try {
 
-       //size_t it=0;
-       while ( (boost::uint32_t) str.tell() < _swf_end_pos )
-       {
-               if ( _loadingCanceled )
-               {
-                       log_debug("Loading thread cancelation requested, 
returning from read_all_swf");
-                       return;
-               }
-
-               //log_debug(_("Loading thread iteration %u"), it++);
-
-               SWF::TagType tag = str.open_tag();
+        while (str.tell() < _swf_end_pos)
+        {
+            if (_loadingCanceled)
+            {
+                log_debug("Loading thread cancelation requested, "
+                        "returning from read_all_swf");
+                return;
+            }
+
+            SWF::TagType tag = str.open_tag();
 
 parse_tag:
 
-               if (tag == SWF::END)
-                {
-                       if ((unsigned int) str.tell() != _swf_end_pos)
-                        {
+            if (tag == SWF::END) {
+                if (str.tell() != _swf_end_pos) {
                                IF_VERBOSE_MALFORMED_SWF(
-                               // Safety break, so we don't read past
-                               // the end of the  movie.
-                               log_swferror(_("Hit stream-end tag, "
-                                       "but not at the advertised SWF end; "
-                                       "stopping for safety."));
-                               )
-                               break;
-                       }
-               }
-
-               SWF::TagLoadersTable::loader_function lf = NULL;
-
-               if (tag == SWF::SHOWFRAME)
-               {
-                       // show frame tag -- advance to the next frame.
-
-                       IF_VERBOSE_PARSE(
-                               log_parse("  show_frame");
-                       );
-
-                       size_t floaded = incrementLoadedFrames();
-                       if ( floaded == m_frame_count )
-                       {
-                               str.close_tag();
-                               tag = str.open_tag();
-                               if (tag != SWF::END )
-                               {
-                                       IF_VERBOSE_MALFORMED_SWF(
-                                       log_swferror(_("last expected SHOWFRAME 
"
-                                               "in SWF stream '%s' isn't "
-                                               "followed by an END (%d)."),
-                                               get_url(), tag);
-                                       );
-                               }
-                               goto parse_tag;
-                       }
-
-               }
-               else if (_tag_loaders.get(tag, &lf))
+                        // Safety break, so we don't read past
+                        // the end of the  movie.
+                        log_swferror(_("Hit stream-end tag, "
+                            "but not at the advertised SWF end; "
+                            "stopping for safety."));
+                        )
+                        break;
+                }
+            }
+
+            SWF::TagLoadersTable::loader_function lf = NULL;
+
+            if (tag == SWF::SHOWFRAME)
+            {
+                // show frame tag -- advance to the next frame.
+
+                IF_VERBOSE_PARSE(
+                    log_parse("  show_frame");
+                );
+
+                size_t floaded = incrementLoadedFrames();
+                if (floaded == m_frame_count)
                 {
-                       // call the tag loader.  The tag loader should add
-                       // characters or tags to the movie data structure.
-                       (*lf)(str, tag, *this, _runInfo);
-               }
-               else
-               {
-                       // no tag loader for this tag type.
-            log_error(_("*** no tag loader for type %d (movie)"), tag);
-            IF_VERBOSE_PARSE(
-                std::ostringstream ss;
-                dumpTagBytes(str, ss);
-                log_error("tag dump follows: %s", ss.str());
-            );
-               }
-
-               str.close_tag();
-
-               setBytesLoaded(str.tell());
-       }
-
-       } catch (const std::exception& e) {
+                    str.close_tag();
+                    tag = str.open_tag();
+                    if (tag != SWF::END )
+                    {
+                        IF_VERBOSE_MALFORMED_SWF(
+                        log_swferror(_("last expected SHOWFRAME "
+                            "in SWF stream '%s' isn't "
+                            "followed by an END (%d)."),
+                            get_url(), tag);
+                        );
+                    }
+                    goto parse_tag;
+                }
+
+            }
+            else if (_tag_loaders.get(tag, &lf)) {
+                // call the tag loader.  The tag loader should add
+                // characters or tags to the movie data structure.
+                (*lf)(str, tag, *this, _runInfo);
+            }
+            else {
+                // no tag loader for this tag type.
+                log_error(_("*** no tag loader for type %d (movie)"), tag);
+                IF_VERBOSE_PARSE(
+                    std::ostringstream ss;
+                    dumpTagBytes(str, ss);
+                    log_error("tag dump follows: %s", ss.str());
+                );
+            }
+
+            str.close_tag();
+
+            setBytesLoaded(str.tell());
+        }
+
+       } catch (const ParserException& e) {
                // FIXME: we should be setting some variable
                //        so that it is possible for clients
                //        to check the parser status
@@ -644,14 +636,20 @@
                //        and make sure any wait_for_frame call is
                //        released (condition set and false result)
                log_error(_("Parsing exception: %s"), e.what());
+
        }
 
        // Make sure we won't leave any pending writers
        // on any eventual fd-based IOChannel.
        str.consumeInput();
+    
+    // Set bytesLoaded to the current stream position unless it's greater
+    // than the reported length. TODO: should we be trying to continue
+    // parsing after an exception?
+    setBytesLoaded(std::min<size_t>(str.tell(), _swf_end_pos));
 
        size_t floaded = get_loading_frame();
-       if ( ! m_playlist[floaded].empty() )
+       if (!m_playlist[floaded].empty())
        {
                IF_VERBOSE_MALFORMED_SWF(
                log_swferror(_("%d control tags are NOT followed by"
@@ -662,8 +660,9 @@
        if ( m_frame_count > floaded )
        {
                IF_VERBOSE_MALFORMED_SWF(
-               log_swferror(_("%d frames advertised in header, but only %d 
SHOWFRAME tags "
-                       "found in stream. Pretending we loaded all advertised 
frames"), m_frame_count, floaded);
+               log_swferror(_("%d frames advertised in header, but only %d "
+                "SHOWFRAME tags found in stream. Pretending we loaded "
+                "all advertised frames"), m_frame_count, floaded);
                );
                boost::mutex::scoped_lock lock(_frames_loaded_mutex);
                _frames_loaded = m_frame_count;
@@ -694,17 +693,15 @@
                                "the advertised number in header (%d)."),
                                get_url(), _frames_loaded,
                                m_frame_count);
-               );
-               //m_playlist.resize(_frames_loaded+1);
+               )
        }
 
 #ifdef DEBUG_FRAMES_LOAD
-       log_debug(_("Loaded frame %u/%u"),
-               _frames_loaded, m_frame_count);
+       log_debug(_("Loaded frame %u/%u"), _frames_loaded, m_frame_count);
 #endif
 
        // signal load of frame if anyone requested it
-       // FIXME: _waiting_form_frame needs mutex ?
+       // FIXME: _waiting_for_frame needs mutex ?
        if (_waiting_for_frame && _frames_loaded >= _waiting_for_frame )
        {
                // or should we notify_one ?
@@ -731,7 +728,8 @@
 SWFMovieDefinition::get_exported_resource(const std::string& symbol) const
 {
 #ifdef DEBUG_EXPORTS
-       log_debug("get_exported_resource(%s) called, loading frame:%u", symbol, 
m_frame_count);
+       log_debug("get_exported_resource(%s) called, loading frame:%u",
+            symbol, m_frame_count);
 #endif
 
        // Don't call get_exported_resource() from this movie loader

=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h       2008-12-18 11:25:16 +0000
+++ b/libcore/parser/SWFMovieDefinition.h       2009-02-10 12:23:27 +0000
@@ -43,6 +43,7 @@
 #include <boost/thread/thread.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/thread/barrier.hpp>
+#include <boost/scoped_ptr.hpp>
 
 //
 // Forward declarations
@@ -506,12 +507,13 @@
 
        std::string _url;
 
-       std::auto_ptr<SWFStream> _str;
+    /// Non transferable stream.
+    boost::scoped_ptr<SWFStream> _str;
 
        std::auto_ptr<IOChannel> _in;
 
        /// swf end position (as read from header)
-       unsigned int _swf_end_pos;
+    size_t _swf_end_pos;
 
        /// asyncronous SWF loader and parser
        MovieLoader _loader;

=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp       2009-01-22 20:10:39 +0000
+++ b/libcore/swf/tag_loaders.cpp       2009-02-10 11:33:38 +0000
@@ -81,11 +81,11 @@
 class StreamAdapter : public IOChannel
 {
     SWFStream& s;
-    unsigned long startPos;
-    unsigned long endPos;
-    unsigned long currPos;
+    std::streampos startPos;
+    std::streampos endPos;
+    std::streampos currPos;
 
-    StreamAdapter(SWFStream& str, unsigned long maxPos)
+    StreamAdapter(SWFStream& str, std::streampos maxPos)
         :
         s(str),
         startPos(s.tell()),
@@ -99,16 +99,16 @@
     {
     }
 
-    virtual int read(void* dst, int bytes) 
+    virtual std::streamsize read(void* dst, std::streamsize bytes) 
     {
-        unsigned bytesLeft = endPos - currPos;
-        if ( bytesLeft < (unsigned)bytes )
+        std::streamsize bytesLeft = endPos - currPos;
+        if ( bytesLeft < bytes )
         {
             if ( ! bytesLeft ) return 0;
             //log_debug("Requested to read past end of stream range");
             bytes = bytesLeft;
         }
-        unsigned actuallyRead = s.read((char*)dst, bytes);
+        std::streamsize actuallyRead = s.read(static_cast<char*>(dst), bytes);
         currPos += actuallyRead;
         return actuallyRead;
     }
@@ -123,38 +123,39 @@
         return (currPos == endPos);
     }
 
-    // Return -1 on failure, 0 on success
-    virtual int seek(int pos)
+    // Return false on failure, true on success
+    virtual bool seek(std::streampos pos)
     {
         // SWFStream::seek() returns true on success
         if (s.seek(pos))
         {
             currPos = pos;
-            return 0;
+            return true;
         }
-        return -1;
+        return false;
     }
 
-    virtual int size() const
+    virtual size_t size() const
     {
         return (endPos - startPos);
     }
 
-    virtual int tell() const
+    virtual std::streampos tell() const
     {
         return currPos;
     }
     
-    virtual int get_error() const
+    virtual bool bad() const
     {
         // Is there any point in this?
-        return TU_FILE_NO_ERROR;
+        return false;
     }
 
 public:
 
     /// Get an IOChannel from a gnash::SWFStream
-    static std::auto_ptr<IOChannel> getFile(SWFStream& str, unsigned long 
endPos)
+    static std::auto_ptr<IOChannel> getFile(SWFStream& str,
+            unsigned long endPos)
     {
         std::auto_ptr<IOChannel> ret (new StreamAdapter(str, endPos));
         return ret;
@@ -232,8 +233,8 @@
         log_parse(_("  jpeg_tables_loader"));
     );
 
-    const unsigned long currPos = in.tell();
-    const unsigned long endPos = in.get_tag_end_position();
+    const std::streampos currPos = in.tell();
+    const std::streampos endPos = in.get_tag_end_position();
 
     assert(endPos >= currPos);
 
@@ -257,7 +258,7 @@
     // of gnash::SWFStream::read(), so this is not a problem.
     //
         boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
-                    std::numeric_limits<unsigned long>::max()).release());
+                    std::numeric_limits<std::streamsize>::max()).release());
         //  transfer ownership to the JpegImageInput
         input = JpegImageInput::createSWFJpeg2HeaderOnly(ad, jpegHeaderSize);
 

=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp  2008-12-30 15:28:13 +0000
+++ b/libcore/swf_function.cpp  2009-02-10 15:38:43 +0000
@@ -150,7 +150,7 @@
        log_debug("  first_arg_bottom_index: %d\n", fn.first_arg_bottom_index);
 #endif
        // Some features are version-dependant.
-       unsigned swfversion = VM::get().getSWFVersion();
+       unsigned swfversion = vm.getSWFVersion();
        as_object *super = NULL;
        if (swfversion > 5)
        {
@@ -319,7 +319,7 @@
                if (m_function2_flags & PRELOAD_GLOBAL)
                {
                        // Put '_global' in a register.
-                       as_object* global = VM::get().getGlobal();
+                       as_object* global = vm.getGlobal();
                        
//our_env->local_register(current_reg).set_as_object(global);
                        our_env->setRegister(current_reg, as_value(global));
                        current_reg++;

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-01-22 20:10:39 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-02-10 15:38:43 +0000
@@ -2928,7 +2928,7 @@
     assert(array_size >= 0); // TODO: trigger this !!
 
     // Call the array constructor, to create an empty array.
-    as_value result = array_new(fn_call(NULL, &env));
+    as_value result = array_new(fn_call(NULL, env));
 
     boost::intrusive_ptr<as_object> ao = result.to_object();
     assert(ao);
@@ -2936,7 +2936,8 @@
     // Fill the elements with the initial values from the stack.
     for (int i = 0; i < array_size; i++) {
         // @@ TODO a set_member that takes an int or as_value?
-        thread.setObjectMember(*ao, boost::lexical_cast<std::string>(i), 
env.pop());
+        thread.setObjectMember(*ao, boost::lexical_cast<std::string>(i),
+                env.pop());
     }
 
     env.push(result);

=== modified file 'libcore/vm/ExecutableCode.h'
--- a/libcore/vm/ExecutableCode.h       2008-10-27 10:39:37 +0000
+++ b/libcore/vm/ExecutableCode.h       2009-02-10 15:38:43 +0000
@@ -236,7 +236,7 @@
     virtual void execute()
     {
         as_environment env(func->getVM()); env.set_target(target.get());
-        func->call(fn_call(target.get(), &env));
+        func->call(fn_call(target.get(), env));
     }
 
 #ifdef GNASH_USE_GC

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2008-12-27 19:56:32 +0000
+++ b/libcore/vm/Machine.cpp    2009-02-10 15:38:43 +0000
@@ -2403,6 +2403,8 @@
        as_value& storage, unsigned char stack_in, short stack_out)
 {
        // TODO: Set up the fn, or remove the need.
+
+#if 0
        fn_call fn(NULL, NULL, 0, 0);
        mStack.drop(stack_in - stack_out);
        saveState();
@@ -2411,6 +2413,7 @@
        mStack.setDownstop(stack_in);
        storage = const_cast<as_function*>(to_call)->call(fn);
        restoreState();
+#endif
 }
 
 void

=== modified file 'libcore/vm/action.cpp'
--- a/libcore/vm/action.cpp     2008-12-28 09:40:28 +0000
+++ b/libcore/vm/action.cpp     2009-02-10 15:38:43 +0000
@@ -53,7 +53,7 @@
         const movie_definition* callerDef)
 {
        as_value val;
-       fn_call call(this_ptr, env, args);
+       fn_call call(this_ptr, *env, args);
        call.super = super;
     call.callerDef = callerDef;
 

=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h      2008-12-18 22:39:32 +0000
+++ b/libcore/vm/fn_call.h      2009-02-10 15:38:43 +0000
@@ -15,8 +15,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#ifndef _GNASH_FN_CALL_H_
-#define _GNASH_FN_CALL_H_
+#ifndef GNASH_FN_CALL_H
+#define GNASH_FN_CALL_H
 
 #ifdef HAVE_CONFIG_H
 #include "gnashconfig.h"
@@ -61,26 +61,34 @@
     /// Definition containing caller code. 0 if spontaneous (system event).
     const movie_definition* callerDef;
 
-public:
-       fn_call(const fn_call& fn) : this_ptr(fn.this_ptr), super(fn.super),
-               nargs(fn.nargs), callerDef(fn.callerDef), _env(fn._env)
+    fn_call(const fn_call& fn)
+        :
+        this_ptr(fn.this_ptr),
+        super(fn.super),
+               nargs(fn.nargs),
+        callerDef(fn.callerDef),
+        _env(fn._env)
        {
-               if ( fn._args.get() )
+               if (fn._args.get()) {
                        _args.reset(new std::vector<as_value>(*fn._args));
+        }
        }
 
-       fn_call(const fn_call& fn, as_object* this_in, as_object* sup=NULL)
-               : this_ptr(this_in), super(sup), nargs(fn.nargs),
+       fn_call(const fn_call& fn, as_object* this_in, as_object* sup = 0)
+               :
+        this_ptr(this_in),
+        super(sup),
+        nargs(fn.nargs),
         callerDef(fn.callerDef),
                _env(fn._env)
        {
-               if ( fn._args.get() )
+               if (fn._args.get()) {
                        _args.reset(new std::vector<as_value>(*fn._args));
+        }
        }
 
-       fn_call(as_object* this_in,
-                       as_environment* env_in,
-                       int nargs_in, size_t first_in, as_object* sup=NULL)
+       fn_call(as_object* this_in, as_environment& env_in,
+                       int nargs_in, size_t first_in, as_object* sup = 0)
                :
                this_ptr(this_in),
                super(sup),
@@ -88,13 +96,12 @@
         callerDef(0),
                _env(env_in)
        {
-               assert(first_in + 1 == env_in->stack_size());
+               assert(first_in + 1 == env_in.stack_size());
                readArgs(env_in, first_in, nargs);
        }
 
-       fn_call(as_object* this_in,
-                       as_environment* env_in,
-                       std::auto_ptr<std::vector<as_value> > args, as_object* 
sup=NULL)
+       fn_call(as_object* this_in, as_environment& env_in,
+                       std::auto_ptr<std::vector<as_value> > args, as_object* 
sup = 0)
                :
                this_ptr(this_in),
                super(sup),
@@ -105,8 +112,7 @@
        {
        }
 
-       fn_call(as_object* this_in,
-                       as_environment* env_in)
+       fn_call(as_object* this_in, as_environment& env_in)
                :
                this_ptr(this_in),
                super(0),
@@ -117,6 +123,12 @@
        {
        }
 
+    /// Return the VM this fn_call is running from
+    VM& getVM() const
+    {
+        return _env.getVM();
+    }
+
        /// Return true if this call is an object instantiation
        bool isInstantiation() const
        {
@@ -133,7 +145,7 @@
        const as_value& arg(unsigned int n) const
        {
                assert(n < nargs);
-               return (*_args)[n]; // _env->bottom(_stack_offset - n);
+               return (*_args)[n]; 
        }
 
     const std::vector<as_value>& getArgs() const {
@@ -153,7 +165,7 @@
 
        as_environment& env() const
        {
-               return *_env;
+               return _env;
        }
 
        /// Dump arguments to given output stream
@@ -190,16 +202,16 @@
 
        /// The ActionScript environment in which the function call is taking
        /// place. This contains, among other things, the function arguments.
-       as_environment* _env;
+       as_environment& _env;
 
        /// The actual arguments
        std::auto_ptr< std::vector<as_value> > _args;
 
-       void readArgs(as_environment* env, int first_in, int nargs)
+       void readArgs(as_environment& env, int first_in, int nargs)
        {
                _args.reset(new std::vector<as_value>);
                for (int i=0; i<nargs; ++i)
-                       _args->push_back(env->bottom(first_in - i));
+                       _args->push_back(env.bottom(first_in - i));
        }
 
 };

=== modified file 'libmedia/FLVParser.cpp'
--- a/libmedia/FLVParser.cpp    2009-01-22 20:10:39 +0000
+++ b/libmedia/FLVParser.cpp    2009-02-10 11:33:38 +0000
@@ -338,7 +338,7 @@
 
        // Seek to next frame and skip the tag size 
        //log_debug("FLVParser::parseNextTag seeking to %d", thisTagPos+4);
-       if ( _stream->seek(thisTagPos+4) )
+       if (!_stream->seek(thisTagPos+4))
        {
                log_error("FLVParser::parseNextTag: can't seek to %d", 
thisTagPos+4);
 

=== modified file 'plugin/plugin.cpp'
--- a/plugin/plugin.cpp 2009-01-22 20:10:39 +0000
+++ b/plugin/plugin.cpp 2009-02-10 11:33:38 +0000
@@ -54,6 +54,7 @@
 //  2: informational messages
 //
 #define GNASH_PLUGIN_DEBUG 1
+//#define WRITE_FILE
 
 #include <sys/param.h>
 #include "plugin.h" 
@@ -704,7 +705,8 @@
 #ifdef WRITE_FILE
     write(_filefd, buffer, len);
 #endif
-    return write(_streamfd, buffer, len);
+    int written = write(_streamfd, buffer, len);
+    return written;
 }
 
 bool

=== modified file 'testsuite/libbase/CurlStreamTest.cpp'
--- a/testsuite/libbase/CurlStreamTest.cpp      2008-09-16 17:45:34 +0000
+++ b/testsuite/libbase/CurlStreamTest.cpp      2009-02-10 11:33:38 +0000
@@ -64,7 +64,7 @@
 {
        tu_file* reader = new tu_file(url, "r");
        assert(reader);
-       if (!reader->get_error() == TU_FILE_NO_ERROR) return;
+       if (reader->bad()) return;
 
        char buf[CHUNK_SIZE];
 

=== modified file 'testsuite/libcore.all/PropertyListTest.cpp'
--- a/testsuite/libcore.all/PropertyListTest.cpp        2008-10-28 15:32:20 
+0000
+++ b/testsuite/libcore.all/PropertyListTest.cpp        2009-02-10 15:38:43 
+0000
@@ -66,12 +66,12 @@
 
     root.setRootMovie( md5->create_movie_instance() );
 
-    VM& vm = VM::get();
+    VM& vm = root.getVM();
 
        log_debug("VM version %d", vm.getSWFVersion());
 
        as_object obj;
-       PropertyList props;
+       PropertyList props(vm);
 
        as_value val("value");
        as_value val2("value2");

=== modified file 'testsuite/libcore.all/StreamTest.cpp'
--- a/testsuite/libcore.all/StreamTest.cpp      2008-11-21 15:15:25 +0000
+++ b/testsuite/libcore.all/StreamTest.cpp      2009-02-10 11:33:38 +0000
@@ -68,11 +68,11 @@
                b=by;
        }
 
-       int read(void* dst, int bytes) 
+    std::streamsize read(void* dst, std::streamsize bytes) 
        {
 
                unsigned char* ptr = static_cast<unsigned char*>(dst);
-               for (int i=0; i<bytes; ++i)
+               for (std::streamsize i=0; i<bytes; ++i)
                {
                        memcpy(ptr+i, &b, sizeof(unsigned char));
                }
@@ -81,15 +81,15 @@
                return bytes;
        }
 
-       int tell() const
+    std::streampos tell() const
        {
                return pos;
        }
 
-       int seek(int newPos)
+    bool seek(std::streampos newPos)
        {
                pos=newPos;
-               return 0; // ok, no error (urgh)
+               return true; 
        }
        
        
@@ -99,9 +99,9 @@
 
        bool eof() const { abort(); return false; }
     
-       int get_error() const { return 0; }
+       bool bad() const { return false; }
 
-       int size() const { abort(); return -1; }
+    size_t size() const { abort(); return -1; }
        
 };
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]