]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/parser/interpreter.cpp
cosmetic: remove nullity test on free() and delete
[vlc] / modules / gui / skins2 / parser / interpreter.cpp
index 2ba41f6139b22242b5e005c0807af8a4414b6afb..56c9f11a85eac6da4b17f7f3ba69ffe4af1eeea5 100644 (file)
@@ -91,8 +91,11 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
     m_commandMap["playlist.setRepeat(false)"] =
         CmdGenericPtr( new CmdPlaylistRepeat( getIntf(), false ) );
     VarTree &rVarTree = VlcProc::instance( getIntf() )->getPlaytreeVar();
+    m_commandMap["playlist.del()"] =
+        CmdGenericPtr( new CmdPlaytreeDel( getIntf(), rVarTree ) );
     m_commandMap["playtree.del()"] =
         CmdGenericPtr( new CmdPlaytreeDel( getIntf(), rVarTree ) );
+    REGISTER_CMD( "playlist.sort()", CmdPlaytreeSort )
     REGISTER_CMD( "playtree.sort()", CmdPlaytreeSort )
     REGISTER_CMD( "vlc.fullscreen()", CmdFullscreen )
     REGISTER_CMD( "vlc.play()", CmdPlay )
@@ -138,11 +141,8 @@ Interpreter *Interpreter::instance( intf_thread_t *pIntf )
 
 void Interpreter::destroy( intf_thread_t *pIntf )
 {
-    if( pIntf->p_sys->p_interpreter )
-    {
-        delete pIntf->p_sys->p_interpreter;
-        pIntf->p_sys->p_interpreter = NULL;
-    }
+    delete pIntf->p_sys->p_interpreter;
+    pIntf->p_sys->p_interpreter = NULL;
 }
 
 
@@ -222,6 +222,40 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
             pCommand = new CmdLayout( getIntf(), *pWin, *pLayout );
         }
     }
+    else if( rAction.find( ".maximize()" ) != string::npos )
+    {
+        int leftPos = rAction.find( ".maximize()" );
+        string windowId = rAction.substr( 0, leftPos );
+
+        TopWindow *pWin = pTheme->getWindowById( windowId );
+        if( !pWin )
+        {
+            msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+        }
+        else
+        {
+            pCommand = new CmdMaximize( getIntf(),
+                                        pTheme->getWindowManager(),
+                                        *pWin );
+        }
+    }
+    else if( rAction.find( ".unmaximize()" ) != string::npos )
+    {
+        int leftPos = rAction.find( ".unmaximize()" );
+        string windowId = rAction.substr( 0, leftPos );
+
+        TopWindow *pWin = pTheme->getWindowById( windowId );
+        if( !pWin )
+        {
+            msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+        }
+        else
+        {
+            pCommand = new CmdUnmaximize( getIntf(),
+                                          pTheme->getWindowManager(),
+                                          *pWin );
+        }
+    }
     else if( rAction.find( ".show()" ) != string::npos )
     {
         int leftPos = rAction.find( ".show()" );
@@ -394,33 +428,74 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
             // Register this variable in the manager
             pVarManager->registerVar( VariablePtr( pNewVar ) );
         }
-        else if( token.find( ".isVisible" ) != string::npos )
+        else
         {
-            int leftPos = token.find( ".isVisible" );
-            string windowId = token.substr( 0, leftPos );
-            TopWindow *pWin = pTheme->getWindowById( windowId );
-            if( pWin )
+            // Try first to get the variable from the variable manager
+            // Indeed, if the skin designer is stupid enough to call a layout
+            // "dvd", we want "dvd.isActive" to resolve as the built-in action
+            // and not as the "layoutId.isActive" one.
+            VarBool *pVar = (VarBool*)pVarManager->getVar( token, "bool" );
+            if( pVar )
             {
-                // Push the visibility variable on the stack
-                varStack.push_back( &pWin->getVisibleVar() );
+                varStack.push_back( pVar );
             }
-            else
+            else if( token.find( ".isVisible" ) != string::npos )
             {
-                msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
-                return NULL;
+                int leftPos = token.find( ".isVisible" );
+                string windowId = token.substr( 0, leftPos );
+                TopWindow *pWin = pTheme->getWindowById( windowId );
+                if( pWin )
+                {
+                    // Push the visibility variable onto the stack
+                    varStack.push_back( &pWin->getVisibleVar() );
+                }
+                else
+                {
+                    msg_Err( getIntf(), "unknown window (%s)",
+                             windowId.c_str() );
+                    return NULL;
+                }
             }
-        }
-        else
-        {
-            // Try to get the variable from the variable manager
-            VarBool *pVar = (VarBool*)pVarManager->getVar( token, "bool" );
-            if( !pVar )
+            else if( token.find( ".isMaximized" ) != string::npos )
+            {
+                int leftPos = token.find( ".isMaximized" );
+                string windowId = token.substr( 0, leftPos );
+                TopWindow *pWin = pTheme->getWindowById( windowId );
+                if( pWin )
+                {
+                    // Push the "maximized" variable onto the stack
+                    varStack.push_back( &pWin->getMaximizedVar() );
+                }
+                else
+                {
+                    msg_Err( getIntf(), "unknown window (%s)",
+                             windowId.c_str() );
+                    return NULL;
+                }
+            }
+            else if( token.find( ".isActive" ) != string::npos )
+            {
+                int leftPos = token.find( ".isActive" );
+                string layoutId = token.substr( 0, leftPos );
+                GenericLayout *pLayout = pTheme->getLayoutById( layoutId );
+                if( pLayout )
+                {
+                    // Push the isActive variable onto the stack
+                    varStack.push_back( &pLayout->getActiveVar() );
+                }
+                else
+                {
+                    msg_Err( getIntf(), "unknown layout (%s)",
+                             layoutId.c_str() );
+                    return NULL;
+                }
+            }
+            else
             {
                 msg_Err( getIntf(), "cannot resolve boolean variable: %s",
                          token.c_str());
                 return NULL;
             }
-            varStack.push_back( pVar );
         }
         // Get the first token from the RPN stack
         token = evaluator.getToken();