Commit 852f3863 authored by Cyril Deguet's avatar Cyril Deguet

* all: skeleton of a popup menu entry for skin selection

parent d5225a43
...@@ -117,6 +117,8 @@ SOURCES_skins2 = \ ...@@ -117,6 +117,8 @@ SOURCES_skins2 = \
src/theme.hpp \ src/theme.hpp \
src/theme_loader.cpp \ src/theme_loader.cpp \
src/theme_loader.hpp \ src/theme_loader.hpp \
src/theme_repository.cpp \
src/theme_repository.hpp \
src/tooltip.cpp \ src/tooltip.cpp \
src/tooltip.hpp \ src/tooltip.hpp \
src/top_window.cpp \ src/top_window.cpp \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* skin_common.hpp * skin_common.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: skin_common.hpp,v 1.3 2004/02/27 13:24:12 gbazin Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
...@@ -40,6 +40,7 @@ class OSLoop; ...@@ -40,6 +40,7 @@ class OSLoop;
class VarManager; class VarManager;
class VlcProc; class VlcProc;
class Theme; class Theme;
class ThemeRepository;
#ifndef M_PI #ifndef M_PI
# define M_PI 3.14159265358979323846 # define M_PI 3.14159265358979323846
...@@ -89,6 +90,8 @@ struct intf_sys_t ...@@ -89,6 +90,8 @@ struct intf_sys_t
VarManager *p_varManager; VarManager *p_varManager;
/// VLC state handler /// VLC state handler
VlcProc *p_vlcProc; VlcProc *p_vlcProc;
/// Theme repository
ThemeRepository *p_repository;
/// Current theme /// Current theme
Theme *p_theme; Theme *p_theme;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "vlcproc.hpp" #include "vlcproc.hpp"
#include "theme_loader.hpp" #include "theme_loader.hpp"
#include "theme.hpp" #include "theme.hpp"
#include "theme_repository.hpp"
#include "../parser/interpreter.hpp" #include "../parser/interpreter.hpp"
#include "../commands/async_queue.hpp" #include "../commands/async_queue.hpp"
#include "../commands/cmd_quit.hpp" #include "../commands/cmd_quit.hpp"
...@@ -95,6 +96,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -95,6 +96,7 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_osLoop = NULL; p_intf->p_sys->p_osLoop = NULL;
p_intf->p_sys->p_varManager = NULL; p_intf->p_sys->p_varManager = NULL;
p_intf->p_sys->p_vlcProc = NULL; p_intf->p_sys->p_vlcProc = NULL;
p_intf->p_sys->p_repository = NULL;
// No theme yet // No theme yet
p_intf->p_sys->p_theme = NULL; p_intf->p_sys->p_theme = NULL;
...@@ -129,6 +131,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -129,6 +131,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
Dialogs::instance( p_intf ); Dialogs::instance( p_intf );
ThemeRepository::instance( p_intf );
// We support play on start // We support play on start
p_intf->b_play = VLC_TRUE; p_intf->b_play = VLC_TRUE;
...@@ -145,6 +148,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -145,6 +148,7 @@ static void Close( vlc_object_t *p_this )
// Destroy "singleton" objects // Destroy "singleton" objects
OSFactory::instance( p_intf )->destroyOSLoop(); OSFactory::instance( p_intf )->destroyOSLoop();
ThemeRepository::destroy( p_intf );
Dialogs::destroy( p_intf ); Dialogs::destroy( p_intf );
Interpreter::destroy( p_intf ); Interpreter::destroy( p_intf );
AsyncQueue::destroy( p_intf ); AsyncQueue::destroy( p_intf );
......
/*****************************************************************************
* theme_repository.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#include "theme_repository.hpp"
ThemeRepository *ThemeRepository::instance( intf_thread_t *pIntf )
{
if( pIntf->p_sys->p_repository == NULL )
{
pIntf->p_sys->p_repository = new ThemeRepository( pIntf );
}
return pIntf->p_sys->p_repository;
}
void ThemeRepository::destroy( intf_thread_t *pIntf )
{
if( pIntf->p_sys->p_repository )
{
delete pIntf->p_sys->p_repository;
pIntf->p_sys->p_repository = NULL;
}
}
ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
{
vlc_value_t val, text;
/* // Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pTimer = pOsFactory->createOSTimer( Callback( this, &doManage ) );
m_pTimer->start( 100, false );
// Create and register VLC variables
VarManager *pVarManager = VarManager::instance( getIntf() );
#define REGISTER_VAR( var, type, name ) \
var = VariablePtr( new type( getIntf() ) ); \
pVarManager->registerVar( var, name );
REGISTER_VAR( m_cPlaylist, Playlist, "playlist" )
pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(),
"playlist.slider" );
REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
REGISTER_VAR( m_cVarTime, StreamTime, "time" )
REGISTER_VAR( m_cVarVolume, Volume, "volume" )
REGISTER_VAR( m_cVarStream, Stream, "stream" )
REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
#undef REGISTER_VAR
// XXX WARNING XXX
// The object variable callbacks are called from other VLC threads,
// so they must put commands in the queue and NOT do anything else
// (X11 calls are not reentrant)
// Called when the playlist changes
var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
onIntfChange, this );
// Called when the current played item changes
var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
onPlaylistChange, this );
// Called when a playlist item changed
var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
onItemChange, this );
// Called when our skins2 demux wants us to load a new skin
var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
// Callbacks for vout requests
getIntf()->pf_request_window = &getWindow;
getIntf()->pf_release_window = &releaseWindow;
getIntf()->pf_control_window = &controlWindow;
getIntf()->p_sys->p_input = NULL;*/
var_Create( pIntf, "intf-skins", VLC_VAR_STRING |
VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND );
text.psz_string = _("Select skin");
var_Change( pIntf, "intf-skins", VLC_VAR_SETTEXT, &text, NULL );
val.psz_string = "test";
text.psz_string = "test";
var_Change( pIntf, "intf-skins", VLC_VAR_ADDCHOICE,
&val, &text );
/* Only fill the list with available modules */
/* p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( ppsz_parser = ppsz_interfaces; *ppsz_parser; ppsz_parser += 2 )
{
for( i = 0; i < p_list->i_count; i++ )
{
module_t *p_module = (module_t *)p_list->p_values[i].p_object;
if( !strcmp( p_module->psz_object_name, ppsz_parser[0] ) )
{
val.psz_string = ppsz_parser[0];
text.psz_string = ppsz_parser[1];
var_Change( p_intf, "intf-switch", VLC_VAR_ADDCHOICE,
&val, &text );
break;
}
}
}
vlc_list_release( p_list );
*/
var_AddCallback( pIntf, "intf-skins", changeSkin, this );
}
ThemeRepository::~ThemeRepository()
{
/* m_pTimer->stop();
delete( m_pTimer );
if( getIntf()->p_sys->p_input )
{
vlc_object_release( getIntf()->p_sys->p_input );
}
// Callbacks for vout requests
getIntf()->pf_request_window = NULL;
getIntf()->pf_release_window = NULL;
getIntf()->pf_control_window = NULL;
var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
onIntfChange, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
onPlaylistChange, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
onItemChange, this );*/
}
int ThemeRepository::changeSkin( vlc_object_t *pThis, char const *pCmd,
vlc_value_t oldval, vlc_value_t newval,
void *pData )
{
/* intf_thread_t *p_intf = (intf_thread_t *)p_this;
p_intf->psz_switch_intf =
malloc( strlen(newval.psz_string) + sizeof(",none") );
sprintf( p_intf->psz_switch_intf, "%s,none", newval.psz_string );
p_intf->b_die = VLC_TRUE;
*/
return VLC_SUCCESS;
}
/*****************************************************************************
* theme_repository.hpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#ifndef THEME_REPOSITORY_HPP
#define THEME_REPOSITORY_HPP
#include "skin_common.hpp"
/// Singleton object handling the list of available themes
class ThemeRepository: public SkinObject
{
public:
/// Get the instance of ThemeRepository
/// Returns NULL if the initialization of the object failed
static ThemeRepository *instance( intf_thread_t *pIntf );
/// Delete the instance of ThemeRepository
static void destroy( intf_thread_t *pIntf );
protected:
// Protected because it is a singleton
ThemeRepository( intf_thread_t *pIntf );
virtual ~ThemeRepository();
private:
/// Callback for menu item selection
static int changeSkin( vlc_object_t *pThis, char const *pCmd,
vlc_value_t oldval, vlc_value_t newval,
void *pData );
};
#endif
...@@ -255,6 +255,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, ...@@ -255,6 +255,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "intf-add"; ppsz_varnames[i] = "intf-add";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "intf-skins";
pi_objects[i++] = p_object->i_object_id;
vlc_object_release( p_object ); vlc_object_release( p_object );
} }
......
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