📄 skin_main.cpp
字号:
/***************************************************************************** * skin_main.cpp ***************************************************************************** * Copyright (C) 2003 the VideoLAN team * $Id: skin_main.cpp 18266 2006-12-04 15:15:52Z damienf $ * * Authors: Cyril Deguet <asmax@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 * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/#include <stdlib.h>#include <vlc/input.h>#include "dialogs.hpp"#include "os_factory.hpp"#include "os_loop.hpp"#include "var_manager.hpp"#include "vlcproc.hpp"#include "theme_loader.hpp"#include "theme.hpp"#include "theme_repository.hpp"#include "../parser/interpreter.hpp"#include "../commands/async_queue.hpp"#include "../commands/cmd_quit.hpp"#include "../commands/cmd_dialogs.hpp"#include "../commands/cmd_minimize.hpp"//---------------------------------------------------------------------------// Exported interface functions.//---------------------------------------------------------------------------#ifdef WIN32_SKINSextern "C" __declspec( dllexport ) int __VLC_SYMBOL( vlc_entry ) ( module_t *p_module );#endif//---------------------------------------------------------------------------// Local prototypes//---------------------------------------------------------------------------static int Open ( vlc_object_t * );static void Close ( vlc_object_t * );static void Run ( intf_thread_t * );static int DemuxOpen( vlc_object_t * );static int Demux( demux_t * );static int DemuxControl( demux_t *, int, va_list );//---------------------------------------------------------------------------// Prototypes for configuration callbacks//---------------------------------------------------------------------------#ifdef WIN32static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, vlc_value_t oldVal, vlc_value_t newVal, void *pParam );static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable, vlc_value_t oldVal, vlc_value_t newVal, void *pParam );#endif//---------------------------------------------------------------------------// Open: initialize interface//---------------------------------------------------------------------------static int Open( vlc_object_t *p_this ){ intf_thread_t *p_intf = (intf_thread_t *)p_this; // Allocate instance and initialize some members p_intf->p_sys = (intf_sys_t *) malloc( sizeof( intf_sys_t ) ); if( p_intf->p_sys == NULL ) { msg_Err( p_intf, "out of memory" ); return( VLC_ENOMEM ); }; p_intf->pf_run = Run; // Suscribe to messages bank p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL ); p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_intf->p_sys->p_playlist == NULL ) { msg_Err( p_intf, "No playlist object found" ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); return VLC_EGENERIC; } // Initialize "singleton" objects p_intf->p_sys->p_logger = NULL; p_intf->p_sys->p_queue = NULL; p_intf->p_sys->p_dialogs = NULL; p_intf->p_sys->p_interpreter = NULL; p_intf->p_sys->p_osFactory = NULL; p_intf->p_sys->p_osLoop = NULL; p_intf->p_sys->p_varManager = NULL; p_intf->p_sys->p_vlcProc = NULL; p_intf->p_sys->p_repository = NULL; // No theme yet p_intf->p_sys->p_theme = NULL; // Create a variable to be notified of skins to be loaded var_Create( p_intf, "skin-to-load", VLC_VAR_STRING ); // Initialize singletons if( OSFactory::instance( p_intf ) == NULL ) { msg_Err( p_intf, "cannot initialize OSFactory" ); vlc_object_release( p_intf->p_sys->p_playlist ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); return VLC_EGENERIC; } if( AsyncQueue::instance( p_intf ) == NULL ) { msg_Err( p_intf, "cannot initialize AsyncQueue" ); vlc_object_release( p_intf->p_sys->p_playlist ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); return VLC_EGENERIC; } if( Interpreter::instance( p_intf ) == NULL ) { msg_Err( p_intf, "cannot instanciate Interpreter" ); vlc_object_release( p_intf->p_sys->p_playlist ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); return VLC_EGENERIC; } if( VarManager::instance( p_intf ) == NULL ) { msg_Err( p_intf, "cannot instanciate VarManager" ); vlc_object_release( p_intf->p_sys->p_playlist ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); return VLC_EGENERIC; } if( VlcProc::instance( p_intf ) == NULL ) { msg_Err( p_intf, "cannot initialize VLCProc" ); vlc_object_release( p_intf->p_sys->p_playlist ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); return VLC_EGENERIC; } Dialogs::instance( p_intf ); ThemeRepository::instance( p_intf ); // We support play on start p_intf->b_play = VLC_TRUE; return( VLC_SUCCESS );}//---------------------------------------------------------------------------// Close: destroy interface//---------------------------------------------------------------------------static void Close( vlc_object_t *p_this ){ intf_thread_t *p_intf = (intf_thread_t *)p_this; // Destroy "singleton" objects OSFactory::instance( p_intf )->destroyOSLoop(); ThemeRepository::destroy( p_intf ); Dialogs::destroy( p_intf ); Interpreter::destroy( p_intf ); AsyncQueue::destroy( p_intf ); VarManager::destroy( p_intf ); VlcProc::destroy( p_intf ); OSFactory::destroy( p_intf ); if( p_intf->p_sys->p_playlist ) { vlc_object_release( p_intf->p_sys->p_playlist ); } // Unsubscribe from messages bank msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); // Destroy structure free( p_intf->p_sys );}//---------------------------------------------------------------------------// Run: main loop//---------------------------------------------------------------------------static void Run( intf_thread_t *p_intf ){ // Load a theme ThemeLoader *pLoader = new ThemeLoader( p_intf ); char *skin_last = config_GetPsz( p_intf, "skins2-last" ); if( !skin_last || !*skin_last || !pLoader->load( skin_last ) ) { // Get the resource path and try to load the default skin OSFactory *pOSFactory = OSFactory::instance( p_intf ); const list<string> &resPath = pOSFactory->getResourcePath(); const string &sep = pOSFactory->getDirSeparator(); list<string>::const_iterator it; for( it = resPath.begin(); it != resPath.end(); it++ ) { string path = (*it) + sep + "default.vlt"; if( pLoader->load( path ) ) { // Theme loaded successfully break; } } if( it == resPath.end() ) { // Last chance: the user can select a new theme file if( Dialogs::instance( p_intf ) ) { CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf ); AsyncQueue *pQueue = AsyncQueue::instance( p_intf ); pQueue->push( CmdGenericPtr( pCmd ) ); } 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..."); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -