* xmlparser.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
- * $Id: xmlparser.cpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
+ * $Id: xmlparser.cpp,v 1.4 2004/01/25 23:04:01 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
{
msg_Err( getIntf(), "Failed to open %s for parsing",
rFileName.c_str() );
+ return;
}
// Activate DTD validation
{
if( !m_pReader )
{
- return -1;
+ return false;
}
m_errors = false;
{
// Error
case -1:
- return -1;
+ return false;
break;
// Begin element
const xmlChar *eltName = xmlTextReaderConstName( m_pReader );
if( !eltName )
{
- return -1;
+ return false;
}
// Read the attributes
AttrList_t attributes;
const xmlChar *value = xmlTextReaderConstValue( m_pReader );
if( !name || !value )
{
- return -1;
+ return false;
}
attributes[(const char*)name] = (const char*)value;
}
const xmlChar *eltName = xmlTextReaderConstName( m_pReader );
if( !eltName )
{
- return -1;
+ return false;
}
handleEndElement( (const char*)eltName );
break;
* skin_main.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: skin_main.cpp,v 1.4 2004/01/25 17:20:19 kuehne Exp $
+ * $Id: skin_main.cpp,v 1.5 2004/01/25 23:04:06 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
*****************************************************************************/
#include <stdlib.h>
-#include "generic_window.hpp"
#include "dialogs.hpp"
#include "os_factory.hpp"
#include "os_loop.hpp"
-#include "window_manager.hpp"
#include "var_manager.hpp"
#include "vlcproc.hpp"
-#include "theme.hpp"
#include "theme_loader.hpp"
+#include "theme.hpp"
#include "../parser/interpreter.hpp"
#include "../commands/async_queue.hpp"
+#include "../commands/cmd_quit.hpp"
//---------------------------------------------------------------------------
{
// Load a theme
ThemeLoader *pLoader = new ThemeLoader( p_intf );
- char *skin_last = config_GetPsz( p_intf, "skin_last2" );
+ char *skin_last = config_GetPsz( p_intf, "skin_last" );
if( skin_last == NULL || !pLoader->load( skin_last ) )
{
{
// Last chance: the user can select a new theme file (blocking call)
Dialogs *pDialogs = Dialogs::instance( p_intf );
- pDialogs->showChangeSkin();
+ if( pDialogs )
+ {
+ pDialogs->showChangeSkin();
+ }
+ else
+ {
+ // No dialogs provider, just quit...
+ CmdQuit *pCmd = new CmdQuit( p_intf );
+ AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
+ pQueue->push( CmdGenericPtr( pCmd ) );
+ msg_Err( p_intf, "Cannot show the \"open skin\" dialog: exiting...");
+ }
}
}
delete pLoader;
// Get the instance of OSLoop
OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop();
+
+ // Enter the main event loop
loop->run();
// Delete the theme
//---------------------------------------------------------------------------
#define DEFAULT_SKIN N_("Last skin used")
#define DEFAULT_SKIN_LONG N_("Select the path to the last skin used.")
+#define SKIN_CONFIG N_("Config of last used skin")
+#define SKIN_CONFIG_LONG N_("Config of last used skin.")
vlc_module_begin();
-// XXX
- add_string( "skin_last2", "", NULL, DEFAULT_SKIN, DEFAULT_SKIN_LONG,
+ add_string( "skin_last", "", NULL, DEFAULT_SKIN, DEFAULT_SKIN_LONG,
+ VLC_TRUE );
+ add_string( "skin_config", "", NULL, SKIN_CONFIG, SKIN_CONFIG_LONG,
VLC_TRUE );
set_description( _("Skinnable Interface") );
set_capability( "interface", 30 );
* theme.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: theme.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * $Id: theme.cpp,v 1.2 2004/01/25 23:04:06 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
Theme::~Theme()
{
+ saveConfig();
+
// Be sure things are destroyed in the right order (XXX check)
m_layouts.clear();
m_controls.clear();
}
+void Theme::loadConfig()
+{
+ msg_Dbg( getIntf(), "Loading theme configuration");
+
+ // Get config from vlcrc file
+ char *save = config_GetPsz( getIntf(), "skin_config" );
+ if( save == NULL )
+ return;
+
+ // Initialization
+ map<string, GenericWindowPtr>::const_iterator it;
+ int i = 0;
+ int x, y, v, scan;
+
+ // Get config for each window
+ for( it = m_windows.begin(); it != m_windows.end(); it++ )
+ {
+ GenericWindow *pWin = (*it).second.get();
+ // Get config
+ scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v );
+
+ // If config has the correct number of arguments
+ if( scan > 2 )
+ {
+ pWin->move( x, y );
+ if( v ) pWin->show();
+ }
+
+ // Next window
+ i++;
+ }
+}
+
+
+void Theme::saveConfig()
+{
+ msg_Dbg( getIntf(), "Saving theme configuration");
+
+ // Initialize char where config is stored
+ char *save = new char[400];
+ map<string, GenericWindowPtr>::const_iterator it;
+ int i = 0;
+ int x, y;
+
+ // Save config of every window
+ for( it = m_windows.begin(); it != m_windows.end(); it++ )
+ {
+ GenericWindow *pWin = (*it).second.get();
+ // Print config
+ x = pWin->getLeft();
+ y = pWin->getTop();
+ sprintf( &save[i * 13], "(%4d,%4d,%1d)", x, y,
+ pWin->getVisibleVar().get() );
+ i++;
+ }
+
+ // Save config to file
+ config_PutPsz( getIntf(), "skin_config", save );
+ config_SaveConfigFile( getIntf(), "skins" );
+
+ // Free memory
+ delete[] save;
+}
+
+
// Useful macro
#define FIND_OBJECT( mapData, mapName ) \
map<string, mapData>::const_iterator it; \
} \
return (*it).second.get();
-
GenericBitmap *Theme::getBitmapById( const string &id )
{
FIND_OBJECT( GenericBitmapPtr, m_bitmaps );
FIND_OBJECT( CtrlGenericPtr, m_controls );
}
+
+
* theme.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: theme.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * $Id: theme.hpp,v 1.2 2004/01/25 23:04:06 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
m_windowManager( getIntf() ) {}
virtual ~Theme();
+ void loadConfig();
+ void saveConfig();
+
GenericBitmap *getBitmapById( const string &id );
GenericFont *getFontById( const string &id );
GenericWindow *getWindowById( const string &id );
* theme_loader.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: theme_loader.cpp,v 1.7 2004/01/25 11:44:19 asmax Exp $
+ * $Id: theme_loader.cpp,v 1.8 2004/01/25 23:04:06 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
return false;
#endif
-#if 0
+ 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(), "skin_last" );
if( skin_last != NULL && fileName == (string)skin_last )
{
- getIntf()->p_sys->p_theme->LoadConfig();
+ // Used to anchor the windows at the beginning
+ pNewTheme->getWindowManager().stopMove();
+ // Restore the theme configuration
+ getIntf()->p_sys->p_theme->loadConfig();
}
else
{
config_PutPsz( getIntf(), "skin_last", fileName.c_str() );
- config_SaveConfigFile( getIntf(), "skins" );
- }
-#endif
- Theme *pNewTheme = getIntf()->p_sys->p_theme;
- if( pNewTheme )
- {
- // Used to anchor the windows at the beginning
- pNewTheme->getWindowManager().stopMove();
// Show the windows
pNewTheme->getWindowManager().showAll();
}