From: Olivier Teulière Date: Fri, 22 Apr 2005 22:25:10 +0000 (+0000) Subject: * skins2: Added support for multiple actions (separated by ";"), X-Git-Tag: 0.8.2~433 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=52d743a2f60f2892ce419ae42ec016fcd50a915c;p=vlc * skins2: Added support for multiple actions (separated by ";"), wherever one action was allowed --- diff --git a/modules/gui/skins2/Modules.am b/modules/gui/skins2/Modules.am index b744b0a7e2..a189dc468e 100644 --- a/modules/gui/skins2/Modules.am +++ b/modules/gui/skins2/Modules.am @@ -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 index 0000000000..b5938cb901 --- /dev/null +++ b/modules/gui/skins2/commands/cmd_muxer.cpp @@ -0,0 +1,34 @@ +/***************************************************************************** + * cmd_muxer.cpp + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * $Id$ + * + * Authors: Olivier Teulière + * + * 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::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 index 0000000000..f79e1ba454 --- /dev/null +++ b/modules/gui/skins2/commands/cmd_muxer.hpp @@ -0,0 +1,50 @@ +/***************************************************************************** + * cmd_muxer.hpp + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * $Id$ + * + * Authors: Olivier Teulière + * + * 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 + + +/// This command only contains other commands (composite pattern) +class CmdMuxer: public CmdGeneric +{ + public: + CmdMuxer( intf_thread_t *pIntf, const list &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 m_list; +}; + +#endif diff --git a/modules/gui/skins2/parser/interpreter.cpp b/modules/gui/skins2/parser/interpreter.cpp index cdc39598f7..6deffcce53 100644 --- a/modules/gui/skins2/parser/interpreter.cpp +++ b/modules/gui/skins2/parser/interpreter.cpp @@ -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 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; }