]> git.sesse.net Git - vlc/commitdiff
skins2: list of skins improved some more.
authorErwan Tulou <erwan10@videolan.org>
Thu, 7 Jan 2010 17:30:19 +0000 (18:30 +0100)
committerErwan Tulou <erwan10@videolan.org>
Thu, 7 Jan 2010 18:56:31 +0000 (19:56 +0100)
This patch also takes into account opening a new skins at any time
(not just at initialization)

modules/gui/skins2/commands/cmd_change_skin.cpp
modules/gui/skins2/src/theme_repository.cpp
modules/gui/skins2/src/theme_repository.hpp

index 0d3347b7a61bc0b30435fb12bedb7023c7a23f06..da59ec89eafe9a55618f072a809633d976d5bda2 100644 (file)
@@ -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();
 }
 
index 13ed502f06d6f10e23aac12ac3030de67335a0b7..8b150f6fc9298122a43196bbc550629df4dc9bee 100644 (file)
@@ -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 );
+}
+
index 109ed24d38dc11c9bd09ceedc7000223c0fcb670..7abacee0575cd2c82d91c3ca22b7597bab6b6754 100644 (file)
@@ -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 );