Commit 52d743a2 authored by Olivier Teulière's avatar Olivier Teulière

* skins2: Added support for multiple actions (separated by ";"),

           wherever one action was allowed
parent 77cbc1da
......@@ -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 \
......
/*****************************************************************************
* 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();
}
}
/*****************************************************************************
* 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
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment