Example #1
0
bool ThemeLoader::load( const string &fileName )
{
    string path = getFilePath( fileName );

    //Before all, let's see if the file is present
    struct stat p_stat;
    if( vlc_stat( path.c_str(), &p_stat ) )
        return false;

    // First, we try to un-targz the file, and if it fails we hope it's a XML
    // file...

#if defined( HAVE_ZLIB_H )
    if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) )
        return false;
#else
    if( ! parse( path, fileName ) )
        return false;
#endif

    Theme *pNewTheme = getIntf()->p_sys->p_theme;
    if( !pNewTheme )
    {
        return false;
    }

    // Check if the skin to load is in the config file, to load its config
    char *skin_last = config_GetPsz( getIntf(), "skins2-last" );
    if( skin_last != NULL && fileName == (string)skin_last )
    {
        // Restore the theme configuration
        getIntf()->p_sys->p_theme->loadConfig();
        // Used to anchor the windows at the beginning
        pNewTheme->getWindowManager().stopMove();
    }
    else
    {
        config_PutPsz( getIntf(), "skins2-last", fileName.c_str() );
        // Show the windows
        pNewTheme->getWindowManager().showAll( true );
    }
    free( skin_last );

    return true;
}
Example #2
0
void CmdChangeSkin::execute()
{
    // Save the old theme to restore it in case of problem
    Theme *pOldTheme = getIntf()->p_sys->p_theme;

    if( pOldTheme )
    {
        pOldTheme->getWindowManager().saveVisibility();
        pOldTheme->getWindowManager().hideAll();
    }

    VoutManager::instance( getIntf() )->saveVoutConfig();

    ThemeLoader loader( getIntf() );
    if( loader.load( m_file ) )
    {
        // Everything went well
        msg_Info( getIntf(), "new theme successfully loaded (%s)",
                 m_file.c_str() );
        delete pOldTheme;

        // restore vout config
        VoutManager::instance( getIntf() )->restoreVoutConfig( true );
    }
    else if( pOldTheme )
    {
        msg_Warn( getIntf(), "a problem occurred when loading the new theme,"
                  " restoring the previous one" );
        getIntf()->p_sys->p_theme = pOldTheme;
        VoutManager::instance( getIntf() )->restoreVoutConfig( false );
        pOldTheme->getWindowManager().restoreVisibility();
    }
    else
    {
        msg_Err( getIntf(), "cannot load the theme, aborting" );
        // Quit
        CmdQuit cmd( getIntf() );
        cmd.execute();
    }

   // update the repository
   ThemeRepository::instance( getIntf() )->updateRepository();
}
Example #3
0
bool ThemeLoader::load( const string &fileName )
{
    // First, we try to un-targz the file, and if it fails we hope it's a XML
    // file...
    string path = getFilePath( fileName );
#if defined( HAVE_ZLIB_H )
    if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) )
        return false;
#else
    if( ! parse( path, fileName ) )
        return false;
#endif

    Theme *pNewTheme = getIntf()->p_sys->p_theme;
    if( !pNewTheme )
    {
        return false;
    }

    // Check if the skin to load is in the config file, to load its config
    char *skin_last = config_GetPsz( getIntf(), "skins2-last" );
    if( skin_last != NULL && fileName == (string)skin_last )
    {
        // Restore the theme configuration
        getIntf()->p_sys->p_theme->loadConfig();
        // Used to anchor the windows at the beginning
        pNewTheme->getWindowManager().stopMove();
    }
    else
    {
        config_PutPsz( getIntf(), "skins2-last", fileName.c_str() );
        // Show the windows
        pNewTheme->getWindowManager().showAll( true );
    }
    if( skin_last ) free( skin_last );

    // The new theme cannot embed a video output yet
    VlcProc::instance( getIntf() )->dropVout();

    return true;
}