Commit c7dfbd11 authored by Erwan Tulou's avatar Erwan Tulou

skins2: list of skins improved some more.

This patch also takes into account opening a new skins at any time
(not just at initialization)
parent a2fa93d5
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "../src/os_loop.hpp" #include "../src/os_loop.hpp"
#include "../src/theme.hpp" #include "../src/theme.hpp"
#include "../src/theme_loader.hpp" #include "../src/theme_loader.hpp"
#include "../src/theme_repository.hpp"
#include "../src/window_manager.hpp" #include "../src/window_manager.hpp"
#include "../src/vout_manager.hpp" #include "../src/vout_manager.hpp"
#include "../src/vlcproc.hpp" #include "../src/vlcproc.hpp"
...@@ -72,5 +73,8 @@ void CmdChangeSkin::execute() ...@@ -72,5 +73,8 @@ void CmdChangeSkin::execute()
CmdQuit cmd( getIntf() ); CmdQuit cmd( getIntf() );
cmd.execute(); cmd.execute();
} }
// update the repository
ThemeRepository::instance( getIntf() )->updateRepository();
} }
...@@ -88,7 +88,7 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -88,7 +88,7 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
itdefault = itmap; itdefault = itmap;
} }
// retrieve the current skin // retrieve last skins stored or skins requested by user
char* psz_current = config_GetPsz( getIntf(), "skins2-last" ); char* psz_current = config_GetPsz( getIntf(), "skins2-last" );
string current = string( psz_current ? psz_current : "" ); string current = string( psz_current ? psz_current : "" );
...@@ -99,28 +99,14 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -99,28 +99,14 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
config_PutPsz( getIntf(), "skins2-last", current.c_str() ); config_PutPsz( getIntf(), "skins2-last", current.c_str() );
} }
// add an extra item if needed and set the current skins to 'checked'
itmap = m_skinsMap.find( current );
if( itmap == m_skinsMap.end() )
{
val.psz_string = (char*) current.c_str();
text.psz_string = (char*) current.c_str();
var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val,
&text );
var_Change( getIntf(), "intf-skins", VLC_VAR_SETVALUE, &val, NULL );
}
else
{
val.psz_string = (char*) current.c_str();
var_Change( getIntf(), "intf-skins", VLC_VAR_SETVALUE, &val, NULL );
}
free( psz_current ); free( psz_current );
m_skinsMap.clear();
// Update repository
updateRepository();
// Set the callback // Set the callback
var_AddCallback( pIntf, "intf-skins", changeSkin, this ); var_AddCallback( pIntf, "intf-skins", changeSkin, this );
// variable for opening a dialog box to change skins // variable for opening a dialog box to change skins
var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID | var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID |
VLC_VAR_ISCOMMAND ); VLC_VAR_ISCOMMAND );
...@@ -135,6 +121,8 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -135,6 +121,8 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
ThemeRepository::~ThemeRepository() ThemeRepository::~ThemeRepository()
{ {
m_skinsMap.clear();
var_DelCallback( getIntf(), "intf-skins", changeSkin, this ); var_DelCallback( getIntf(), "intf-skins", changeSkin, this );
var_DelCallback( getIntf(), "intf-skins-interactive", changeSkin, this ); var_DelCallback( getIntf(), "intf-skins-interactive", changeSkin, this );
...@@ -212,3 +200,30 @@ int ThemeRepository::changeSkin( vlc_object_t *pIntf, char const *pVariable, ...@@ -212,3 +200,30 @@ int ThemeRepository::changeSkin( vlc_object_t *pIntf, char const *pVariable,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
void ThemeRepository::updateRepository()
{
vlc_value_t val, text;
// retrieve the current skin
char* psz_current = config_GetPsz( getIntf(), "skins2-last" );
if( !psz_current )
return;
val.psz_string = psz_current;
text.psz_string = psz_current;
// add this new skins if not yet present in repository
string current( psz_current );
if( m_skinsMap.find( current ) == m_skinsMap.end() )
{
var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val,
&text );
}
// mark this current skins as 'checked' in list
var_Change( getIntf(), "intf-skins", VLC_VAR_SETVALUE, &val, NULL );
free( psz_current );
}
...@@ -39,6 +39,9 @@ public: ...@@ -39,6 +39,9 @@ public:
/// Delete the instance of ThemeRepository /// Delete the instance of ThemeRepository
static void destroy( intf_thread_t *pIntf ); static void destroy( intf_thread_t *pIntf );
/// Update repository
void updateRepository();
protected: protected:
// Protected because it is a singleton // Protected because it is a singleton
ThemeRepository( intf_thread_t *pIntf ); ThemeRepository( intf_thread_t *pIntf );
......
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