Ok, there I go changing my mind again. Now that it's merged in CVS, I backported the latest version of my patch, along with pointer initialisation fixes made by Sandro in upstream.
Also added the "startStopped" default setting toggle (to true). So here's my latest patch. I tested it with 0.8.2 and looks in good shape. -- Robert Millan "The technological evasion of the license is as unacceptable as the legal evasion of the license [...]. That's the provision in section 1 regarding keys. [...] We say one thing: when you sell somebody a home... give him the keys" -- Eben Moglen on GPLv3
diff -ur gnash-0.8.2/gui/gtk.cpp gnash-0.8.2.new/gui/gtk.cpp --- gnash-0.8.2/gui/gtk.cpp 2008-02-20 22:42:14.000000000 +0100 +++ gnash-0.8.2.new/gui/gtk.cpp 2008-04-27 12:53:11.000000000 +0200 @@ -78,6 +78,18 @@ GtkGui::GtkGui(unsigned long xid, float scale, bool loop, unsigned int depth) : Gui(xid, scale, loop, depth) +#ifdef GUI_HILDON + ,_hildon_program(0) +#endif + ,_window(0) + ,_overlay(0) + ,_drawingArea(0) + ,_resumeButton(0) + ,_popup_menu(0) + ,_menubar(0) + ,_vbox(0) + ,_drawbounds() + ,_glue() { } @@ -125,6 +137,19 @@ _drawingArea = gtk_drawing_area_new(); + // Increase reference count to prevent its destruction (which could happen + // later if we remove it from its container). + g_object_ref(G_OBJECT(_drawingArea)); + + _resumeButton = gtk_button_new(); + gtk_container_add(GTK_CONTAINER(_resumeButton), gtk_label_new(_("Click to play"))); + + // Same here. + 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); + // IF we don't set this flag we won't be able to grab focus // ( grabFocus() would be a no-op ) GTK_WIDGET_SET_FLAGS (GTK_WIDGET(_drawingArea), GTK_CAN_FOCUS); @@ -210,6 +235,11 @@ g_timeout_add_full (G_PRIORITY_LOW, _interval, (GSourceFunc)advance_movie, this, NULL); + // The first time stop() was called, stopHook() might not have had a chance + // to do anything, because GTK+ wasn't garanteed to be initialised. + if (isStopped()) + stopHook(); + gtk_main(); return true; } @@ -2142,5 +2172,44 @@ return true; } + +void +GtkGui::stopHook() +{ + // FIXME: this can't work for the stand-alone player, because _drawingArea is + // packed into a vbox. + if (! _xid) + return; + + // Assert they're either both initialised or both uninitialised + assert ((_resumeButton && _drawingArea) || !(_resumeButton || _drawingArea)); + + if (_drawingArea) + gtk_container_remove(GTK_CONTAINER(_window), _drawingArea); + if (_resumeButton) + gtk_container_add(GTK_CONTAINER(_window), _resumeButton); + + gtk_widget_show_all(_resumeButton); +} + +void +GtkGui::playHook() +{ + // FIXME: this can't work for the stand-alone player, because _drawingArea is + // packed into a vbox. + if (! _xid) + return; + + // Assert they're either both initialised or both uninitialised + assert ((_resumeButton && _drawingArea) || !(_resumeButton || _drawingArea)); + + if (_resumeButton) + gtk_container_remove(GTK_CONTAINER(_window), _resumeButton); + if (_drawingArea) + gtk_container_add(GTK_CONTAINER(_window), _drawingArea); + + gtk_widget_show_all(_drawingArea); +} + } // end of namespace gnash diff -ur gnash-0.8.2/gui/gtksup.h gnash-0.8.2.new/gui/gtksup.h --- gnash-0.8.2/gui/gtksup.h 2008-02-14 14:27:56.000000000 +0100 +++ gnash-0.8.2.new/gui/gtksup.h 2008-04-27 12:52:46.000000000 +0200 @@ -185,6 +185,7 @@ HildonProgram *_hildon_program; #endif GtkWidget *_window; + GtkWidget *_resumeButton; // A window only for rendering the plugin as fullscreen. GtkWidget *_overlay; @@ -248,6 +249,8 @@ static void handlePrefs(GtkWidget* widget, gint response, gpointer data); static void openFile(GtkWidget* dialog, gpointer data); + void stopHook(); + void playHook(); }; // end of namespace gnash diff -ur gnash-0.8.2/gui/gui.cpp gnash-0.8.2.new/gui/gui.cpp --- gnash-0.8.2/gui/gui.cpp 2008-02-19 20:20:49.000000000 +0100 +++ gnash-0.8.2.new/gui/gui.cpp 2008-04-27 12:52:46.000000000 +0200 @@ -656,6 +656,8 @@ _stopped = false; if ( ! _started ) start(); + + playHook (); } void @@ -664,6 +666,8 @@ if ( _stopped ) return; _stopped = true; + + stopHook (); } void diff -ur gnash-0.8.2/gui/gui.h gnash-0.8.2.new/gui/gui.h --- gnash-0.8.2/gui/gui.h 2008-01-21 21:55:42.000000000 +0100 +++ gnash-0.8.2.new/gui/gui.h 2008-04-27 12:52:46.000000000 +0200 @@ -364,6 +364,12 @@ // True if Gnash is running in fullscreen bool _fullscreen; + /// Called by Gui::stop(). This can be used by GUIs to implement pause + /// widgets (so that resuming a stopped animation is more user-friendly) + virtual void stopHook() {} + /// Called by Gui::play(). + virtual void playHook() {} + private: bool display(movie_root* m); diff -ur gnash-0.8.2/libbase/rc.cpp gnash-0.8.2.new/libbase/rc.cpp --- gnash-0.8.2/libbase/rc.cpp 2008-04-27 13:20:04.000000000 +0200 +++ gnash-0.8.2.new/libbase/rc.cpp 2008-02-20 20:03:57.000000000 +0100 @@ -91,7 +91,7 @@ _sound(true), _pluginSound(true), _extensionsEnabled(false), - _startStopped(true), + _startStopped(false), _insecureSSL(false), _streamsTimeout(DEFAULT_STREAMS_TIMEOUT), _solreadonly(false),