]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/theme.cpp
Uniformize source files encoding
[vlc] / modules / gui / skins2 / src / theme.cpp
index 32b8da0484f8a6c575878c0b370d3163b783b5f4..a0ac0b4485276553dcf4755e3c366b054a32c20a 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * theme.cpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN (Centrale Réseaux) and its contributors
+ * Copyright (C) 2003 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "theme.hpp"
@@ -51,7 +51,7 @@ void Theme::loadConfig()
     if( !strcmp( save, "" ) )
     {
         // Show the windows
-        m_windowManager.showAll();
+        m_windowManager.showAll( true );
         return;
     }
 
@@ -126,14 +126,47 @@ void Theme::saveConfig()
     } \
     return (*it).second.get();
 
+// This macro takes an ID of the form "id1;id2;id3", and returns the object
+// corresponding to the first valid ID. If no ID is valid, it returns NULL.
+// XXX: should we use a template method instead?
+#define FIND_FIRST_OBJECT( mapDataPtr, mapName ) \
+    string rightPart = id; \
+    string::size_type pos; \
+    do \
+    { \
+        pos = rightPart.find( ";" ); \
+        string leftPart = rightPart.substr( 0, pos ); \
+        map<string, mapDataPtr>::const_iterator it = mapName.find( leftPart ); \
+        if( it != mapName.end() ) \
+        { \
+            return (*it).second.get(); \
+            break; \
+        } \
+ \
+        if( pos != string::npos ) \
+        { \
+            rightPart = rightPart.substr( pos, rightPart.size() ); \
+            rightPart = \
+                rightPart.substr( rightPart.find_first_not_of( " \t;" ), \
+                                  rightPart.size() ); \
+        } \
+    } \
+    while( pos != string::npos ); \
+    return NULL;
+
 GenericBitmap *Theme::getBitmapById( const string &id )
 {
-    FIND_OBJECT( GenericBitmapPtr, m_bitmaps );
+    FIND_FIRST_OBJECT( GenericBitmapPtr, m_bitmaps );
 }
 
 GenericFont *Theme::getFontById( const string &id )
 {
-    FIND_OBJECT( GenericFontPtr, m_fonts );
+    FIND_FIRST_OBJECT( GenericFontPtr, m_fonts );
+}
+
+Popup *Theme::getPopupById( const string &id )
+{
+    FIND_OBJECT( PopupPtr, m_popups );
 }
 
 TopWindow *Theme::getWindowById( const string &id )