]> git.sesse.net Git - vlc/commitdiff
* skins2: Added support for multiple actions (separated by ";"),
authorOlivier Teulière <ipkiss@videolan.org>
Fri, 22 Apr 2005 22:25:10 +0000 (22:25 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Fri, 22 Apr 2005 22:25:10 +0000 (22:25 +0000)
           wherever one action was allowed

modules/gui/skins2/Modules.am
modules/gui/skins2/commands/cmd_muxer.cpp [new file with mode: 0644]
modules/gui/skins2/commands/cmd_muxer.hpp [new file with mode: 0644]
modules/gui/skins2/parser/interpreter.cpp

index b744b0a7e2c5301070a69ac2088314ecf440bbe5..a189dc468ea16298674d6b9d32425be73f07a6ad 100644 (file)
@@ -14,6 +14,8 @@ SOURCES_skins2 = \
        commands/cmd_input.hpp \
        commands/cmd_layout.cpp \
        commands/cmd_layout.hpp \
+       commands/cmd_muxer.cpp \
+       commands/cmd_muxer.hpp \
        commands/cmd_on_top.cpp \
        commands/cmd_on_top.hpp \
        commands/cmd_playlist.cpp \
diff --git a/modules/gui/skins2/commands/cmd_muxer.cpp b/modules/gui/skins2/commands/cmd_muxer.cpp
new file mode 100644 (file)
index 0000000..b5938cb
--- /dev/null
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * cmd_muxer.cpp
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ * $Id$
+ *
+ * Authors: Olivier Teulière <ipkiss@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include "cmd_muxer.hpp"
+
+
+void CmdMuxer::execute()
+{
+    list<CmdGeneric*>::const_iterator it;
+    for( it = m_list.begin(); it != m_list.end(); it++ )
+    {
+        (*it)->execute();
+    }
+}
diff --git a/modules/gui/skins2/commands/cmd_muxer.hpp b/modules/gui/skins2/commands/cmd_muxer.hpp
new file mode 100644 (file)
index 0000000..f79e1ba
--- /dev/null
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * cmd_muxer.hpp
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ * $Id$
+ *
+ * Authors: Olivier Teulière <ipkiss@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#ifndef CMD_MUXER_HPP
+#define CMD_MUXER_HPP
+
+#include "cmd_generic.hpp"
+#include <list>
+
+
+/// This command only contains other commands (composite pattern)
+class CmdMuxer: public CmdGeneric
+{
+    public:
+        CmdMuxer( intf_thread_t *pIntf, const list<CmdGeneric*> &rList ):
+            CmdGeneric( pIntf ), m_list( rList ) {}
+        virtual ~CmdMuxer() {}
+
+        /// This method does the real job of the command
+        virtual void execute();
+
+        /// Return the type of the command
+        virtual string getType() const { return "muxer"; }
+
+    private:
+        /// List of commands we will execute sequentially
+        list<CmdGeneric*> m_list;
+};
+
+#endif
index cdc39598f7ce61fd8cda972de22c380c5d48f286..6deffcce537ba81faa4978f49f87c9712f8e02f4 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "interpreter.hpp"
 #include "expr_evaluator.hpp"
+#include "../commands/cmd_muxer.hpp"
 #include "../commands/cmd_playlist.hpp"
 #include "../commands/cmd_dialogs.hpp"
 #include "../commands/cmd_dummy.hpp"
@@ -133,7 +134,35 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
 
     CmdGeneric *pCommand = NULL;
 
-    if( rAction.find( ".setLayout(" ) != string::npos )
+    if( rAction.find( ";" ) != string::npos )
+    {
+        // Several actions are defined...
+        list<CmdGeneric *> actionList;
+        string rightPart = rAction;
+        string::size_type pos = rightPart.find( ";" );
+        while( pos != string::npos )
+        {
+            string leftPart = rightPart.substr( 0, rightPart.find( ";" ) );
+            // Remove any whitespace at the end of the left part, and parse it
+            leftPart =
+                leftPart.substr( 0, leftPart.find_last_not_of( " \t" ) + 1 );
+            actionList.push_back( parseAction( leftPart, pTheme ) );
+            // Now remove any whitespace at the beginning of the right part,
+            // and go on checking for further actions in it...
+            rightPart = rightPart.substr( pos, rightPart.size() );
+            rightPart =
+                rightPart.substr( rightPart.find_first_not_of( " \t;" ),
+                                  rightPart.size() );
+            pos = rightPart.find( ";" );
+        }
+        actionList.push_back( parseAction( rightPart, pTheme ) );
+
+        // The list is filled, we remove NULL pointers from it, just in case...
+        actionList.remove( NULL );
+
+        pCommand = new CmdMuxer( getIntf(), actionList );
+    }
+    else if( rAction.find( ".setLayout(" ) != string::npos )
     {
         int leftPos = rAction.find( ".setLayout(" );
         string windowId = rAction.substr( 0, leftPos );
@@ -179,6 +208,10 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
         // Add the command in the pool
         pTheme->m_commands.push_back( CmdGenericPtr( pCommand ) );
     }
+    else
+    {
+        msg_Warn( getIntf(), "Unknown action: %s", rAction.c_str() );
+    }
 
     return pCommand;
 }