[vlc-devel] commit: skins2: list of skins improved some more. (Erwan Tulou )
git version control
git at videolan.org
Thu Jan 7 19:59:59 CET 2010
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Jan 7 18:30:19 2010 +0100| [c7dfbd11f26de441c055c38011d62e6cb05462fd] | committer: 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)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c7dfbd11f26de441c055c38011d62e6cb05462fd
---
modules/gui/skins2/commands/cmd_change_skin.cpp | 4 ++
modules/gui/skins2/src/theme_repository.cpp | 51 +++++++++++++++--------
modules/gui/skins2/src/theme_repository.hpp | 3 +
3 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/modules/gui/skins2/commands/cmd_change_skin.cpp b/modules/gui/skins2/commands/cmd_change_skin.cpp
index 0d3347b..da59ec8 100644
--- a/modules/gui/skins2/commands/cmd_change_skin.cpp
+++ b/modules/gui/skins2/commands/cmd_change_skin.cpp
@@ -28,6 +28,7 @@
#include "../src/os_loop.hpp"
#include "../src/theme.hpp"
#include "../src/theme_loader.hpp"
+#include "../src/theme_repository.hpp"
#include "../src/window_manager.hpp"
#include "../src/vout_manager.hpp"
#include "../src/vlcproc.hpp"
@@ -72,5 +73,8 @@ void CmdChangeSkin::execute()
CmdQuit cmd( getIntf() );
cmd.execute();
}
+
+ // update the repository
+ ThemeRepository::instance( getIntf() )->updateRepository();
}
diff --git a/modules/gui/skins2/src/theme_repository.cpp b/modules/gui/skins2/src/theme_repository.cpp
index 13ed502..8b150f6 100644
--- a/modules/gui/skins2/src/theme_repository.cpp
+++ b/modules/gui/skins2/src/theme_repository.cpp
@@ -88,7 +88,7 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
itdefault = itmap;
}
- // retrieve the current skin
+ // retrieve last skins stored or skins requested by user
char* psz_current = config_GetPsz( getIntf(), "skins2-last" );
string current = string( psz_current ? psz_current : "" );
@@ -99,28 +99,14 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
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 );
- m_skinsMap.clear();
+
+ // Update repository
+ updateRepository();
// Set the callback
var_AddCallback( pIntf, "intf-skins", changeSkin, this );
-
// variable for opening a dialog box to change skins
var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID |
VLC_VAR_ISCOMMAND );
@@ -135,6 +121,8 @@ ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
ThemeRepository::~ThemeRepository()
{
+ m_skinsMap.clear();
+
var_DelCallback( getIntf(), "intf-skins", changeSkin, this );
var_DelCallback( getIntf(), "intf-skins-interactive", changeSkin, this );
@@ -212,3 +200,30 @@ int ThemeRepository::changeSkin( vlc_object_t *pIntf, char const *pVariable,
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 );
+}
+
diff --git a/modules/gui/skins2/src/theme_repository.hpp b/modules/gui/skins2/src/theme_repository.hpp
index 109ed24..7abacee 100644
--- a/modules/gui/skins2/src/theme_repository.hpp
+++ b/modules/gui/skins2/src/theme_repository.hpp
@@ -39,6 +39,9 @@ public:
/// Delete the instance of ThemeRepository
static void destroy( intf_thread_t *pIntf );
+ /// Update repository
+ void updateRepository();
+
protected:
// Protected because it is a singleton
ThemeRepository( intf_thread_t *pIntf );
More information about the vlc-devel
mailing list