[vlc-devel] commit: Skins2 will at least start. (Laurent Aimar )

git version control git at videolan.org
Mon Jan 5 21:26:47 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Jan  4 16:41:52 2009 +0100| [a4fb617901f096b0f738c15bc7445bf1e08af6cb] | committer: Laurent Aimar 

Skins2 will at least start.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a4fb617901f096b0f738c15bc7445bf1e08af6cb
---

 modules/gui/skins2/Modules.am                   |    2 +
 modules/gui/skins2/commands/cmd_update_item.cpp |   72 +++++++++++++++++++++++
 modules/gui/skins2/commands/cmd_update_item.hpp |   49 +++++++++++++++
 modules/gui/skins2/src/vlcproc.cpp              |   48 +++------------
 modules/gui/skins2/src/vlcproc.hpp              |    2 +-
 5 files changed, 134 insertions(+), 39 deletions(-)

diff --git a/modules/gui/skins2/Modules.am b/modules/gui/skins2/Modules.am
index 923fd91..934f73f 100644
--- a/modules/gui/skins2/Modules.am
+++ b/modules/gui/skins2/Modules.am
@@ -35,6 +35,8 @@ SOURCES_skins2 = \
 	commands/cmd_snapshot.cpp \
 	commands/cmd_snapshot.hpp \
 	commands/cmd_show_window.hpp \
+	commands/cmd_update_item.cpp \
+	commands/cmd_update_item.hpp \
 	commands/cmd_vars.cpp \
 	commands/cmd_vars.hpp \
 	\
diff --git a/modules/gui/skins2/commands/cmd_update_item.cpp b/modules/gui/skins2/commands/cmd_update_item.cpp
new file mode 100644
index 0000000..ae9878b
--- /dev/null
+++ b/modules/gui/skins2/commands/cmd_update_item.cpp
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * cmd_update_item.cpp
+ *****************************************************************************
+ * Copyright (C) 2003-2009 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax at via.ecp.fr>
+ *          Olivier Teulière <ipkiss at via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_playlist.h>
+#include "../src/os_factory.hpp"
+#include "async_queue.hpp"
+#include "cmd_vars.hpp"
+#include "cmd_update_item.hpp"
+
+void CmdUpdateItem::execute()
+{
+    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
+    if( pPlaylist == NULL )
+        return;
+
+	input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
+    if( !p_input )
+        return;
+
+	// Get playlist item information
+	input_item_t *pItem = input_GetItem( p_input );
+
+	// XXX: we should not need to access p_input->psz_source directly, a
+	// getter should be provided by VLC core
+	string name = pItem->psz_name;
+	// XXX: This should be done in VLC core, not here...
+	// Remove path information if any
+	OSFactory *pFactory = OSFactory::instance( getIntf() );
+	string::size_type pos = name.rfind( pFactory->getDirSeparator() );
+	if( pos != string::npos )
+	{
+		name = name.substr( pos + 1, name.size() - pos + 1 );
+	}
+	UString srcName( getIntf(), name.c_str() );
+	UString srcURI( getIntf(), pItem->psz_uri );
+
+   // Create commands to update the stream variables
+	CmdSetText *pCmd1 = new CmdSetText( getIntf(), m_rStreamName, srcName );
+	CmdSetText *pCmd2 = new CmdSetText( getIntf(), m_rStreamURI, srcURI );
+	// Push the commands in the asynchronous command queue
+	AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+	pQueue->push( CmdGenericPtr( pCmd1 ), false );
+	pQueue->push( CmdGenericPtr( pCmd2 ), false );
+	vlc_object_release( p_input );
+}
+
diff --git a/modules/gui/skins2/commands/cmd_update_item.hpp b/modules/gui/skins2/commands/cmd_update_item.hpp
new file mode 100644
index 0000000..80c25c1
--- /dev/null
+++ b/modules/gui/skins2/commands/cmd_update_item.hpp
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * cmd_update_item.hpp
+ *****************************************************************************
+ * Copyright (C) 2003-2009 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax at via.ecp.fr>
+ *          Olivier Teulière <ipkiss at via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef CMD_UPDATE_ITEM_HPP
+#define CMD_UPDATE_ITEM_HPP
+
+#include "cmd_generic.hpp"
+#include <string>
+
+/// Udate item command
+class CmdUpdateItem: public CmdGeneric
+{
+    public:
+        CmdUpdateItem( intf_thread_t *pIntf, VarText &rStreamName, VarText &rStreamURI ) :
+            CmdGeneric( pIntf ), m_rStreamName(rStreamName), m_rStreamURI(rStreamURI) {}
+        virtual ~CmdUpdateItem() {}
+
+        /// This method does the real job of the command
+        virtual void execute();
+
+        /// Return the type of the command
+        virtual string getType() const { return "update item"; }
+
+    private:
+        VarText &m_rStreamName;
+        VarText &m_rStreamURI;
+};
+#endif
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index be8fee8..fb42c1a 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -45,6 +45,7 @@
 #include "../commands/cmd_resize.hpp"
 #include "../commands/cmd_vars.hpp"
 #include "../commands/cmd_dialogs.hpp"
+#include "../commands/cmd_update_item.hpp"
 #include "../utils/var_bool.hpp"
 #include <sstream>
 
@@ -403,8 +404,7 @@ int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
     // Create a playtree notify command (for new style playtree)
     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
@@ -445,8 +445,7 @@ int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
     // Create a playtree notify command
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
@@ -512,8 +511,7 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
     // Create two playtree notify commands: one for old item, one for new
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
@@ -557,42 +555,16 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
 }
 
 
-void VlcProc::updateStreamName( playlist_t *p_playlist )
+void VlcProc::updateStreamName()
 {
-    if( p_playlist )
-    {
-        input_thread_t * p_input = playlist_CurrentInput( p_playlist );
-        // Get playlist item information
-        input_item_t *pItem = input_GetItem( p_input );
-
-        VarText &rStreamName = getStreamNameVar();
-        VarText &rStreamURI = getStreamURIVar();
-        // XXX: we should not need to access p_input->psz_source directly, a
-        // getter should be provided by VLC core
-        string name = pItem->psz_name;
-        // XXX: This should be done in VLC core, not here...
-        // Remove path information if any
-        OSFactory *pFactory = OSFactory::instance( getIntf() );
-        string::size_type pos = name.rfind( pFactory->getDirSeparator() );
-        if( pos != string::npos )
-        {
-            name = name.substr( pos + 1, name.size() - pos + 1 );
-        }
-        UString srcName( getIntf(), name.c_str() );
-        UString srcURI( getIntf(), pItem->psz_uri );
+    // Create a update item command
+    CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
 
-       // Create commands to update the stream variables
-        CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
-        CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
-        // Push the commands in the asynchronous command queue
-        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd1 ), false );
-        pQueue->push( CmdGenericPtr( pCmd2 ), false );
-        vlc_object_release( p_input );
-    }
+    // Push the command in the asynchronous command queue
+    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+    pQueue->push( CmdGenericPtr( pCmdItem ) );
 }
 
-
 void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
                           int *pXHint, int *pYHint,
                           unsigned int *pWidthHint,
diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp
index 8db9b07..c69b2e6 100644
--- a/modules/gui/skins2/src/vlcproc.hpp
+++ b/modules/gui/skins2/src/vlcproc.hpp
@@ -166,7 +166,7 @@ class VlcProc: public SkinObject
         void refreshInput();
 
         /// Update the stream name variable
-        void updateStreamName( playlist_t *p_playlist );
+        void updateStreamName();
 
         /// Callback for intf-change variable
         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,




More information about the vlc-devel mailing list