]> git.sesse.net Git - vlc/commitdiff
Support interaction in skins2
authorClément Stenac <zorglub@videolan.org>
Mon, 12 Dec 2005 19:56:23 +0000 (19:56 +0000)
committerClément Stenac <zorglub@videolan.org>
Mon, 12 Dec 2005 19:56:23 +0000 (19:56 +0000)
modules/gui/skins2/commands/cmd_dialogs.hpp
modules/gui/skins2/src/dialogs.cpp
modules/gui/skins2/src/dialogs.hpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/wxwidgets/interface.cpp

index 508e765de4d3621a4b7846d958a803977f94adf2..f9c5b66244117306dcdba7ebffbc6546ba581866 100644 (file)
@@ -29,6 +29,7 @@
 #include "../src/dialogs.hpp"
 #include "cmd_change_skin.hpp"
 
+#include <vlc_interaction.h>
 
 template<int TYPE = 0> class CmdDialogs;
 
@@ -127,5 +128,36 @@ class CmdDialogs: public CmdGeneric
         virtual string getType() const { return "dialog"; }
 };
 
+class CmdInteraction: public CmdGeneric
+{
+    public:
+        CmdInteraction( intf_thread_t *pIntf, interaction_dialog_t *
+                        p_dialog ): CmdGeneric( pIntf ), m_pDialog( p_dialog )
+        {}
+        virtual ~CmdInteraction() {}
+
+        /// This method does the real job of the command
+        virtual void execute()
+        {
+            if( m_pDialog->i_type == INTERACT_PROGRESS )
+            {
+                 /// \todo Handle progress in the interface
+            }
+            else
+            {
+                /// Get the dialogs provider
+                Dialogs *pDialogs = Dialogs::instance( getIntf() );
+                if( pDialogs == NULL )
+                {
+                    return;
+                }
+                pDialogs->showInteraction( m_pDialog );
+            }
+        }
+
+        virtual string getType() const { return "interaction"; }
+    private:
+        interaction_dialog_t *m_pDialog;
+};
 
 #endif
index 7ba6829120cadcbfccf43831539641745d0d016a..823fa937c57b453504c25d4020818e149ef3755b 100644 (file)
@@ -336,3 +336,18 @@ void Dialogs::showPopupMenu( bool bShow )
     }
 }
 
+void Dialogs::showInteraction( interaction_dialog_t *p_dialog )
+{
+    intf_dialog_args_t *p_arg =
+            (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
+    memset( p_arg, 0, sizeof(intf_dialog_args_t) );
+
+    p_arg->p_dialog = p_dialog;
+    p_arg->p_intf = getIntf();
+
+    if( m_pProvider && m_pProvider->pf_show_dialog )
+    {
+        m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_INTERACTION,
+                                     0, p_arg );
+    }
+}
index d3689aeb25585968ecfd40be1c1ca457e0cc9b16..2ea76ef5d7a8d4aab3dc91436f9c2c8c2235d086 100644 (file)
@@ -28,6 +28,7 @@
 #include "skin_common.hpp"
 #include <string>
 
+struct interaction_dialog_t ;
 
 // Dialogs provider
 class Dialogs: public SkinObject
@@ -88,6 +89,9 @@ class Dialogs: public SkinObject
         /// Show the popup menu
         void showPopupMenu( bool bShow );
 
+        /// Show an interaction dialog
+        void showInteraction( interaction_dialog_t * );
+
     private:
         // Private because it's a singleton
         Dialogs( intf_thread_t *pIntf );
index 2ea2a19de385fde0d001cd17553ac89dc86eaf08..dba3721995222f8cc1eb14d08fe2f28427e1a2a3 100644 (file)
@@ -38,6 +38,7 @@
 #include "../commands/cmd_quit.hpp"
 #include "../commands/cmd_resize.hpp"
 #include "../commands/cmd_vars.hpp"
+#include "../commands/cmd_dialogs.hpp"
 #include "../utils/var_bool.hpp"
 #include <sstream>
 
@@ -140,6 +141,11 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     // Called when our skins2 demux wants us to load a new skin
     var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
 
+    // Called when we have an interaction dialog to display
+    var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
+    var_AddCallback( pIntf, "interaction", onInteraction, this );
+    pIntf->b_interaction = VLC_TRUE;
+
     // Callbacks for vout requests
     getIntf()->pf_request_window = &getWindow;
     getIntf()->pf_release_window = &releaseWindow;
@@ -483,6 +489,19 @@ int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
     return VLC_SUCCESS;
 }
 
+int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
+                            vlc_value_t oldVal, vlc_value_t newVal,
+                            void *pParam )
+{
+    VlcProc *pThis = (VlcProc*)pParam;
+    interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
+
+    CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
+    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+    pQueue->push( CmdGenericPtr( pCmd ) );
+    return VLC_SUCCESS;
+}
+
 
 void VlcProc::updateStreamName( playlist_t *p_playlist )
 {
index 5c72ed22b020941d9f84dccbfbb8a2e52ecf11db..eeeaad704712502121ca7a6f13829e68280d5ba9 100644 (file)
@@ -183,6 +183,11 @@ class VlcProc: public SkinObject
                                  vlc_value_t oldVal, vlc_value_t newVal,
                                  void *pParam );
 
+        /// Callback for interaction variable
+        static int onInteraction( vlc_object_t *pObj, const char *pVariable,
+                                  vlc_value_t oldVal, vlc_value_t newVal,
+                                  void *pParam );
+
         /// Callback to request a vout window
         static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
                                 int *pXHint, int *pYHint,
index 6db430e9b46f8a873809e70f5734b3b0dccb4099..619f841ba2cf1cb44e91e558727fa4dad66986f2 100644 (file)
@@ -1206,8 +1206,15 @@ void Interface::OnInteraction( wxCommandEvent& event )
     p_arg->p_dialog = p_dialog;
     p_arg->p_intf = p_intf;
 
-    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION,
-                                   0, p_arg );
+    if( p_dialog->i_type == INTERACT_PROGRESS )
+    {
+        /// \todo Handle progress in the interface
+    }
+    else
+    {
+        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION,
+                                       0, p_arg );
+    }
 }
 
 static int InteractCallback( vlc_object_t *p_this,