X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fskins2%2Fsrc%2Fskin_main.cpp;h=3e1a007f42445e13bc68ad15f6d0e8c879766264;hb=88f22433f672be32b1488e22a5b30a693ccff500;hp=62468b25fb91ea2f740dd22e59bc2620ffc82983;hpb=af10ead71f24220479ad5be2f153cfa60b787367;p=vlc diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp index 62468b25fb..3e1a007f42 100644 --- a/modules/gui/skins2/src/skin_main.cpp +++ b/modules/gui/skins2/src/skin_main.cpp @@ -5,7 +5,7 @@ * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière + * Olivier Teulière * * 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,11 +19,20 @@ * * 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 -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + #include "dialogs.hpp" #include "os_factory.hpp" #include "os_loop.hpp" @@ -36,7 +45,7 @@ #include "../commands/async_queue.hpp" #include "../commands/cmd_quit.hpp" #include "../commands/cmd_dialogs.hpp" - +#include "../commands/cmd_minimize.hpp" //--------------------------------------------------------------------------- // Exported interface functions. @@ -48,7 +57,7 @@ extern "C" __declspec( dllexport ) //--------------------------------------------------------------------------- -// Local prototypes. +// Local prototypes //--------------------------------------------------------------------------- static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); @@ -58,6 +67,16 @@ static int DemuxOpen( vlc_object_t * ); static int Demux( demux_t * ); static int DemuxControl( demux_t *, int, va_list ); +//--------------------------------------------------------------------------- +// Prototypes for configuration callbacks +//--------------------------------------------------------------------------- +static 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 ); + //--------------------------------------------------------------------------- // Open: initialize interface @@ -80,14 +99,7 @@ static int Open( vlc_object_t *p_this ) p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 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; - } + p_intf->p_sys->p_playlist = pl_Yield( p_intf ); // Initialize "singleton" objects p_intf->p_sys->p_logger = NULL; @@ -109,35 +121,35 @@ static int Open( vlc_object_t *p_this ) // Initialize singletons if( OSFactory::instance( p_intf ) == NULL ) { - msg_Err( p_intf, "Cannot initialize OSFactory" ); + 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" ); + 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" ); + 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" ); + 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" ); + 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; @@ -145,8 +157,9 @@ static int Open( vlc_object_t *p_this ) Dialogs::instance( p_intf ); ThemeRepository::instance( p_intf ); - // We support play on start - p_intf->b_play = VLC_TRUE; +#ifdef WIN32 + p_intf->b_should_run_on_first_thread = true; +#endif return( VLC_SUCCESS ); } @@ -186,6 +199,7 @@ static void Close( vlc_object_t *p_this ) //--------------------------------------------------------------------------- static void Run( intf_thread_t *p_intf ) { + int canc = vlc_savecancel(); // Load a theme ThemeLoader *pLoader = new ThemeLoader( p_intf ); char *skin_last = config_GetPsz( p_intf, "skins2-last" ); @@ -223,33 +237,17 @@ static void Run( intf_thread_t *p_intf ) AsyncQueue *pQueue = AsyncQueue::instance( p_intf ); pQueue->push( CmdGenericPtr( pCmd ) ); msg_Err( p_intf, - "Cannot show the \"open skin\" dialog: exiting..."); + "cannot show the \"open skin\" dialog: exiting..."); } } } delete pLoader; - if( skin_last ) - { - free( skin_last ); - } + free( skin_last ); // Get the instance of OSLoop OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop(); - // Check if we need to start playing - if( p_intf->b_play ) - { - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( p_playlist ) - { - playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY ); - vlc_object_release( p_playlist ); - } - } - // Enter the main event loop loop->run(); @@ -260,9 +258,39 @@ static void Run( intf_thread_t *p_intf ) delete p_intf->p_sys->p_theme; p_intf->p_sys->p_theme = NULL; } + vlc_restorecancel(canc); +} + + +// Callbacks for vout requests +static int WindowOpen( vlc_object_t *p_this ) +{ + vout_window_t *pWnd = (vout_window_t *)p_this; + intf_thread_t *pIntf = (intf_thread_t *) + vlc_object_find_name( p_this, "skins2", FIND_ANYWHERE ); + + if( pIntf == NULL ) + return VLC_EGENERIC; + + /* FIXME: most probably not thread-safe, + * albeit no worse than ever before */ + pWnd->handle = VlcProc::getWindow( pIntf, pWnd->vout, + &pWnd->pos_x, &pWnd->pos_y, + &pWnd->width, &pWnd->height ); + pWnd->p_private = pIntf; + pWnd->control = &VlcProc::controlWindow; + return VLC_SUCCESS; } +static void WindowClose( vlc_object_t *p_this ) +{ + vout_window_t *pWnd = (vout_window_t *)p_this; + intf_thread_t *pIntf = (intf_thread_t *)p_this->p_private; + + VlcProc::releaseWindow( pIntf, pWnd->handle ); +} + //--------------------------------------------------------------------------- // DemuxOpen: initialize demux //--------------------------------------------------------------------------- @@ -291,16 +319,11 @@ static int DemuxOpen( vlc_object_t *p_this ) // Do nothing is skins2 is not the main interface if( var_Type( p_intf, "skin-to-load" ) == VLC_VAR_STRING ) { - playlist_t *p_playlist = - (playlist_t *) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( p_playlist != NULL ) - { - // Make sure the item is deleted afterwards - p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = - VLC_TRUE; - vlc_object_release( p_playlist ); - } + playlist_t *p_playlist = pl_Yield( p_this ); + // Make sure the item is deleted afterwards + /// \bug does not always work + p_playlist->status.p_item->i_flags |= PLAYLIST_REMOVE_FLAG; + vlc_object_release( p_playlist ); vlc_value_t val; val.psz_string = p_demux->psz_path; @@ -333,45 +356,135 @@ static int Demux( demux_t *p_demux ) //--------------------------------------------------------------------------- static int DemuxControl( demux_t *p_demux, int i_query, va_list args ) { - return demux2_vaControlHelper( p_demux->s, 0, 0, 0, 1, i_query, args ); + return demux_vaControlHelper( p_demux->s, 0, 0, 0, 1, i_query, args ); +} + + +//--------------------------------------------------------------------------- +// Callbacks +//--------------------------------------------------------------------------- + +/// Callback for the systray configuration option +static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, + vlc_value_t oldVal, vlc_value_t newVal, + void *pParam ) +{ + intf_thread_t *pIntf = + (intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE ); + + if( pIntf == NULL ) + { + return VLC_EGENERIC; + } + + // Check that we found the correct interface (same check as for the demux) + if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING ) + { + AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); + if( newVal.b_bool ) + { + CmdAddInTray *pCmd = new CmdAddInTray( pIntf ); + pQueue->push( CmdGenericPtr( pCmd ) ); + } + else + { + CmdRemoveFromTray *pCmd = new CmdRemoveFromTray( pIntf ); + pQueue->push( CmdGenericPtr( pCmd ) ); + } + } + + vlc_object_release( pIntf ); + return VLC_SUCCESS; +} + + +/// Callback for the systray configuration option +static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable, + vlc_value_t oldVal, vlc_value_t newVal, + void *pParam ) +{ + intf_thread_t *pIntf = + (intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE ); + + if( pIntf == NULL ) + { + return VLC_EGENERIC; + } + + // Check that we found the correct interface (same check as for the demux) + if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING ) + { + AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); + if( newVal.b_bool ) + { + CmdAddInTaskBar *pCmd = new CmdAddInTaskBar( pIntf ); + pQueue->push( CmdGenericPtr( pCmd ) ); + } + else + { + CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf ); + pQueue->push( CmdGenericPtr( pCmd ) ); + } + } + + vlc_object_release( pIntf ); + return VLC_SUCCESS; } //--------------------------------------------------------------------------- // Module descriptor //--------------------------------------------------------------------------- -#define SKINS2_LAST N_("Last skin used") -#define SKINS2_LAST_LONG N_("Select the path to the last skin used.") +#define SKINS2_LAST N_("Skin to use") +#define SKINS2_LAST_LONG N_("Path to the skin to use.") #define SKINS2_CONFIG N_("Config of last used skin") -#define SKINS2_CONFIG_LONG N_("Config of last used skin.") +#define SKINS2_CONFIG_LONG N_("Windows configuration of the last skin used. " \ + "This option is updated automatically, do not touch it." ) +#define SKINS2_SYSTRAY N_("Systray icon") +#define SKINS2_SYSTRAY_LONG N_("Show a systray icon for VLC") +#define SKINS2_TASKBAR N_("Show VLC on the taskbar") +#define SKINS2_TASKBAR_LONG N_("Show VLC on the taskbar") #define SKINS2_TRANSPARENCY N_("Enable transparency effects") #define SKINS2_TRANSPARENCY_LONG N_("You can disable all transparency effects"\ " if you want. This is mainly useful when moving windows does not behave" \ " correctly.") +#define SKINS2_PLAYLIST N_("Use a skinned playlist") +#define SKINS2_PLAYLIST_LONG N_("Use a skinned playlist") vlc_module_begin(); set_category( CAT_INTERFACE ); - set_subcategory( SUBCAT_INTERFACE_GENERAL ); - add_string( "skins2-last", "", NULL, SKINS2_LAST, SKINS2_LAST_LONG, - VLC_TRUE ); + set_subcategory( SUBCAT_INTERFACE_MAIN ); + add_file( "skins2-last", "", NULL, SKINS2_LAST, SKINS2_LAST_LONG, + true ); change_autosave(); add_string( "skins2-config", "", NULL, SKINS2_CONFIG, SKINS2_CONFIG_LONG, - VLC_TRUE ); + true ); change_autosave(); + change_internal(); #ifdef WIN32 - add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY, - SKINS2_TRANSPARENCY_LONG, VLC_FALSE ); + add_bool( "skins2-systray", false, onSystrayChange, SKINS2_SYSTRAY, + SKINS2_SYSTRAY_LONG, false ); + add_bool( "skins2-taskbar", true, onTaskBarChange, SKINS2_TASKBAR, + SKINS2_TASKBAR_LONG, false ); + add_bool( "skins2-transparency", false, NULL, SKINS2_TRANSPARENCY, + SKINS2_TRANSPARENCY_LONG, false ); #endif - set_shortname( _("Skins")); - set_description( _("Skinnable Interface") ); + + add_bool( "skinned-playlist", true, NULL, SKINS2_PLAYLIST, + SKINS2_PLAYLIST_LONG, false ); + set_shortname( N_("Skins")); + set_description( N_("Skinnable Interface") ); set_capability( "interface", 30 ); set_callbacks( Open, Close ); add_shortcut( "skins" ); - set_program( "svlc" ); add_submodule(); - set_description( _("Skins loader demux") ); - set_capability( "demux2", 5 ); + set_capability( "vout window", 51 ); + set_callbacks( WindowOpen, WindowClose ); + + add_submodule(); + set_description( N_("Skins loader demux") ); + set_capability( "demux", 5 ); set_callbacks( DemuxOpen, NULL ); vlc_module_end();