gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10567: Initial (and very basic) sup


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10567: Initial (and very basic) support for transferring error messages to
Date: Mon, 09 Feb 2009 13:54:49 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10567
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-02-09 13:54:49 +0100
message:
  Initial (and very basic) support for transferring error messages to
  GUI popups, with ability to turn popups off.
modified:
  gui/Player.cpp
  gui/Player.h
  gui/gtk.cpp
  gui/gtksup.h
  gui/gui.h
  libbase/rc.cpp
  libbase/rc.h
  libcore/asobj/NetStream_as.cpp
  libcore/movie_root.cpp
  libcore/movie_root.h
    ------------------------------------------------------------
    revno: 10565.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2009-02-09 13:30:31 +0100
    message:
      Add an optional error() function to the AbstractIFaceCallback for
      sending important errors to the hosting application.
      
      Report media decoder creation problems to the hosting application.
      
      Pop up a window in the GTK gui warning about problems. This is quite 
helpful
      for ffmpeg, not very helpful for gstreamer (no codec information).
      
      Allow turning off GUI popups in the rc file.
    modified:
      gui/Player.cpp
      gui/Player.h
      gui/gtk.cpp
      gui/gtksup.h
      gui/gui.h
      libbase/rc.cpp
      libbase/rc.h
      libcore/asobj/NetStream_as.cpp
      libcore/movie_root.cpp
      libcore/movie_root.h
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp    2009-02-09 10:08:23 +0000
+++ b/gui/Player.cpp    2009-02-09 12:30:31 +0000
@@ -483,10 +483,17 @@
     return EXIT_SUCCESS;
 }
 
+
+void
+Player::CallbacksHandler::error(const std::string& msg)
+{
+    _gui->error(msg);
+}
+
 bool
 Player::CallbacksHandler::yesNo(const std::string& query)
 {
-    return _gui->yesno(query);
+return _gui->yesno(query);
 }
 
 std::string

=== modified file 'gui/Player.h'
--- a/gui/Player.h      2009-02-09 09:29:52 +0000
+++ b/gui/Player.h      2009-02-09 12:30:31 +0000
@@ -149,9 +149,8 @@
        
 private:
 
-       class CallbacksHandler
-               : public movie_root::AbstractIfaceCallback,
-                 public movie_root::AbstractFsCallback
+       class CallbacksHandler : public movie_root::AbstractIfaceCallback,
+                                    public movie_root::AbstractFsCallback
        {
        public:
                CallbacksHandler(Gui* gui)
@@ -161,8 +160,11 @@
 
                std::string call(const std::string& event,
                                const std::string& arg);
+
                bool yesNo(const std::string& query);
 
+        void error(const std::string& msg);
+
                // For handling notification callbacks from ActionScript.
                // The callback is always sent to a hosting application
                // (i.e. if a file descriptor is supplied). It is never

=== modified file 'gui/gtk.cpp'
--- a/gui/gtk.cpp       2009-02-09 10:18:56 +0000
+++ b/gui/gtk.cpp       2009-02-09 12:30:31 +0000
@@ -265,6 +265,31 @@
 }
 
 void
+GtkGui::error(const std::string& msg)
+{
+    
+    RcInitFile& rcfile = RcInitFile::getDefaultInstance();
+    
+    if (!rcfile.popupMessages()) return;
+
+    GtkWidget* popup = gtk_dialog_new_with_buttons("Gnash Error",
+            GTK_WINDOW(_window),
+            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);
+
+    GtkWidget* content = gtk_dialog_get_content_area(GTK_DIALOG(popup));
+    GtkWidget* label = gtk_label_new(msg.c_str());
+    gtk_widget_set_size_request(label, 400, 200);
+    gtk_label_set_line_wrap(GTK_LABEL(label), true);
+    gtk_box_pack_start(GTK_BOX(content), label, false, false, 0);
+    gtk_widget_show_all(popup);
+}
+
+void
 GtkGui::setFullscreen()
 {
 
@@ -315,7 +340,7 @@
     
     // Plugin
     if (_xid) {
-        gtk_widget_reparent (_vbox, _window);
+        gtk_widget_reparent(_vbox, _window);
         
         // Apply key event callbacks to the plugin instance.
         setupWindowEvents();
@@ -477,12 +502,12 @@
 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(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);
 }
 
 // public virtual
@@ -569,7 +594,7 @@
 //     hildon_window_add_toolbar(HILDON_WINDOW(_window),
 //                               GTK_TOOLBAR(_hildon_toolbar));
 #else
-    gtk_box_pack_start(GTK_BOX (_vbox), _menubar, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(_vbox), _menubar, FALSE, FALSE, 0);
 #endif
 
     createFileMenu(_menubar);
@@ -1045,10 +1070,10 @@
 
     PrefWidgets *prefs = static_cast<PrefWidgets*>(data);
 
+    RcInitFile& _rcfile = RcInitFile::getDefaultInstance();
+
     if (response == GTK_RESPONSE_OK) {
 
-        // If 'Save' was clicked, set all the values in _rcfile
-        RcInitFile& _rcfile = RcInitFile::getDefaultInstance();
         // For getting from const gchar* to std::string&
         std::string tmp;
     

=== modified file 'gui/gtksup.h'
--- a/gui/gtksup.h      2009-02-06 15:28:57 +0000
+++ b/gui/gtksup.h      2009-02-09 12:30:31 +0000
@@ -193,6 +193,8 @@
 
     virtual void showMenu(bool show);
 
+    virtual void error(const std::string& msg);
+
     // Adds the gnash icon to a window.
     static void addGnashIcon(GtkWindow* window);
 

=== modified file 'gui/gui.h'
--- a/gui/gui.h 2009-02-06 15:28:57 +0000
+++ b/gui/gui.h 2009-02-09 12:30:31 +0000
@@ -364,6 +364,12 @@
     /// Set the stage to advance/display
     void setStage(movie_root* stage);
 
+    /// Handle error message from the core
+    //
+    /// @param msg        The error message recieved
+    ///
+    virtual void error(const std::string& /*msg*/) {}
+
     /// Prompt user with a question she can answer with yes/no
     //
     /// @param question

=== modified file 'libbase/rc.cpp'
--- a/libbase/rc.cpp    2009-01-27 13:53:00 +0000
+++ b/libbase/rc.cpp    2009-02-09 12:30:31 +0000
@@ -103,7 +103,8 @@
     _ignoreFSCommand(true),
     _quality(-1),
     _saveStreamingMedia(false),
-    _saveLoadedMedia(false)
+    _saveLoadedMedia(false),
+    _popups(true)
 {
     expandPath(_solsandbox);
 
@@ -473,6 +474,8 @@
             ||
                  extractSetting(_writeLog, "writelog", variable, value)
             ||
+                 extractSetting(_popups, "popupMessages", variable, value)
+            ||
                  extractSetting(_sound, "sound", variable, value)
             ||
                  extractSetting(_pluginSound, "pluginsound", variable, value)
@@ -653,6 +656,7 @@
     cmd << "parserDump " << _parserDump << endl <<
     cmd << "writeLog " << _writeLog << endl <<
     cmd << "sound " << _sound << endl <<
+    cmd << "popupMessages " << _popups << endl <<
     cmd << "pluginSound " << _pluginSound << endl <<
     cmd << "ASCodingErrorsVerbosity " << _verboseASCodingErrors << endl <<
     cmd << "malformedSWFVerbosity " << _verboseMalformedSWF << endl <<

=== modified file 'libbase/rc.h'
--- a/libbase/rc.h      2009-01-27 13:53:00 +0000
+++ b/libbase/rc.h      2009-02-09 12:30:31 +0000
@@ -129,6 +129,9 @@
     bool usePluginSound() const { return _pluginSound; }
     void usePluginSound(bool value) { _pluginSound = value; }
 
+    bool popupMessages() const { return _popups; }
+    void interfacePopups(bool value) { _popups = value; }
+
     bool useLocalDomain() const { return _localdomainOnly; }
     void useLocalDomain(bool value);
  
@@ -501,6 +504,8 @@
 
     std::string _mediaCacheDir;
 
+    bool _popups;
+
 };
 
 // End of gnash namespace 

=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp    2009-01-25 11:53:43 +0000
+++ b/libcore/asobj/NetStream_as.cpp    2009-02-09 12:30:31 +0000
@@ -510,6 +510,10 @@
     }
     catch (MediaException& e) {
         log_error("NetStream: Could not create Video decoder: %s", e.what());
+
+        // This is important enough to let the user know.
+        movie_root& m = _vm.getRoot();
+        m.errorInterface(e.what());
     }
 
 }
@@ -534,6 +538,10 @@
     }
     catch (MediaException& e) {
         log_error("Could not create Audio decoder: %s", e.what());
+
+        // This is important enough to let the user know.
+        movie_root& m = _vm.getRoot();
+        m.errorInterface(e.what());
     }
 
 }

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2009-01-22 20:10:39 +0000
+++ b/libcore/movie_root.cpp    2009-02-09 12:30:31 +0000
@@ -1488,7 +1488,7 @@
 movie_root::setStageAlignment(short s)
 {
     _alignMode = s;
-    callInterface("Stage.align", "");
+    callInterface("Stage.align");
 }
 
 /// Returns a pair of enum values giving the actual alignment
@@ -1549,7 +1549,7 @@
     }
 
     _scaleMode = sm;
-    callInterface("Stage.align", "");    
+    callInterface("Stage.align");    
 
     if ( notifyResize )
     {
@@ -2486,6 +2486,12 @@
        if ( _fsCommandHandler ) _fsCommandHandler->notify(cmd, arg);
 }
 
+void
+movie_root::errorInterface(const std::string& msg) const
+{
+       if (_interfaceHandler) _interfaceHandler->error(msg);
+}
+
 std::string
 movie_root::callInterface(const std::string& cmd, const std::string& arg) const
 {

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2009-01-22 20:10:39 +0000
+++ b/libcore/movie_root.h      2009-02-09 12:30:31 +0000
@@ -748,6 +748,12 @@
         /// Ask the hosting application for a yes / no answer to
         /// a question.
         virtual bool yesNo(const std::string& cmd) = 0;
+
+        /// Send an error message to the hosting application.
+        //
+        /// This does not have to be implemented; the default is a no-op.
+        virtual void error(const std::string& /*msg*/) {}
+
         virtual ~AbstractIfaceCallback() {}
     };
 
@@ -766,7 +772,9 @@
     ///
     /// Will use callback set with registerEventCallback
     DSOEXPORT std::string callInterface(const std::string& cmd,
-            const std::string& arg) const;
+            const std::string& arg = std::string()) const;
+
+    DSOEXPORT void errorInterface(const std::string& msg) const;
 
     /// Called from the ScriptLimits tag parser to set the
     /// global script limits. It is expected behaviour that


reply via email to

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