Commit a05b23aa authored by Olivier Teulière's avatar Olivier Teulière

* skins2: The skins2-systray option can now be changed on the fly

parent 660cc33f
......@@ -24,6 +24,7 @@
#include "cmd_minimize.hpp"
#include "../src/os_factory.hpp"
void CmdMinimize::execute()
{
// Get the instance of OSFactory
......@@ -31,3 +32,27 @@ void CmdMinimize::execute()
pOsFactory->minimize();
}
void CmdRestore::execute()
{
// Get the instance of OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
pOsFactory->restore();
}
void CmdAddInTray::execute()
{
// Get the instance of OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
pOsFactory->addInTray();
}
void CmdRemoveFromTray::execute()
{
// Get the instance of OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
pOsFactory->removeFromTray();
}
......@@ -29,5 +29,8 @@
/// Command to minimize VLC
DEFINE_COMMAND(Minimize, "minimize" )
DEFINE_COMMAND(Restore, "restore" )
DEFINE_COMMAND(AddInTray, "add in tray" )
DEFINE_COMMAND(RemoveFromTray, "remove from tray" )
#endif
......@@ -74,6 +74,21 @@ void MacOSXFactory::minimize()
// TODO
}
void MacOSXFactory::restore()
{
// TODO
}
void MacOSXFactory::addInTray()
{
// TODO
}
void MacOSXFactory::removeFromTray()
{
// TODO
}
OSTimer *MacOSXFactory::createOSTimer( const Callback &rCallback )
{
return new MacOSXTimer( getIntf(), rCallback );
......@@ -84,7 +99,7 @@ OSWindow *MacOSXFactory::createOSWindow( GenericWindow &rWindow, bool dragDrop,
bool playOnDrop, OSWindow *pParent )
{
return new MacOSXWindow( getIntf(), rWindow, dragDrop,
playOnDrop, (MacOSXWindow*)pParent );
playOnDrop, (MacOSXWindow*)pParent );
}
......
......@@ -49,9 +49,18 @@ class MacOSXFactory: public OSFactory
/// Instantiate an OSTimer with the given callback
virtual OSTimer *createOSTimer( const Callback &rCallback );
///
/// Minimize all the windows
virtual void minimize();
/// Restore the minimized windows
virtual void restore();
/// Add an icon in the system tray
virtual void addInTray();
/// Remove the icon from the system tray
virtual void removeFromTray();
/// Instantiate an OSWindow object
virtual OSWindow *createOSWindow( GenericWindow &rWindow,
bool dragDrop, bool playOnDrop,
......
......@@ -78,9 +78,18 @@ class OSFactory: public SkinObject
/// Destroy the instance of OSLoop
virtual void destroyOSLoop() = 0;
///
/// Minimize all the windows
virtual void minimize() = 0;
/// Restore the minimized windows
virtual void restore() = 0;
/// Add an icon in the system tray
virtual void addInTray() = 0;
/// Remove the icon from the system tray
virtual void removeFromTray() = 0;
/// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd ) = 0;
......
......@@ -36,6 +36,7 @@
#include "../commands/async_queue.hpp"
#include "../commands/cmd_quit.hpp"
#include "../commands/cmd_dialogs.hpp"
#include "../commands/cmd_minimize.hpp"
//---------------------------------------------------------------------------
......@@ -48,7 +49,7 @@ extern "C" __declspec( dllexport )
//---------------------------------------------------------------------------
// Local prototypes.
// Local prototypes
//---------------------------------------------------------------------------
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
......@@ -58,6 +59,13 @@ 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 );
//---------------------------------------------------------------------------
// Open: initialize interface
......@@ -337,6 +345,39 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list 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;
}
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 );
}
//---------------------------------------------------------------------------
// Module descriptor
//---------------------------------------------------------------------------
......@@ -362,7 +403,7 @@ vlc_module_begin();
VLC_TRUE );
change_autosave();
#ifdef WIN32
add_bool( "skins2-systray", VLC_FALSE, NULL, SKINS2_SYSTRAY,
add_bool( "skins2-systray", VLC_FALSE, onSystrayChange, SKINS2_SYSTRAY,
SKINS2_SYSTRAY_LONG, VLC_FALSE );
add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY,
SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
......
......@@ -33,7 +33,8 @@
#include "win32_loop.hpp"
#include "../src/theme.hpp"
#include "../src/window_manager.hpp"
#include "commands/cmd_dialogs.hpp"
#include "../commands/cmd_dialogs.hpp"
#include "../commands/cmd_minimize.hpp"
// Custom message for the notifications of the system tray
#define MY_WSTRAYACTION (WM_APP + 1)
......@@ -92,7 +93,8 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
}
else if( (UINT)lParam == WM_LBUTTONDBLCLK )
{
ShowWindow( hwnd, SW_RESTORE );
CmdRestore aCmdRestore( p_intf );
aCmdRestore.execute();
}
}
}
......@@ -172,7 +174,7 @@ bool Win32Factory::init()
// Show the systray icon if needed
if( config_GetInt( getIntf(), "skins2-systray" ) )
{
Shell_NotifyIcon( NIM_ADD, &m_trayIcon );
addInTray();
}
// We do it this way otherwise CreateWindowEx will fail
......@@ -242,7 +244,7 @@ Win32Factory::~Win32Factory()
OleUninitialize();
// Remove the systray icon
Shell_NotifyIcon( NIM_DELETE, &m_trayIcon );
removeFromTray();
if( m_hParentWindow ) DestroyWindow( m_hParentWindow );
......@@ -279,6 +281,21 @@ void Win32Factory::minimize()
ShowWindow( m_hParentWindow, SW_MINIMIZE );
}
void Win32Factory::restore()
{
ShowWindow( m_hParentWindow, SW_RESTORE );
}
void Win32Factory::addInTray()
{
Shell_NotifyIcon( NIM_ADD, &m_trayIcon );
}
void Win32Factory::removeFromTray()
{
Shell_NotifyIcon( NIM_DELETE, &m_trayIcon );
}
OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd )
{
return new Win32Timer( getIntf(), rCmd, m_hParentWindow );
......
......@@ -54,9 +54,18 @@ class Win32Factory: public OSFactory
/// Destroy the instance of OSLoop
virtual void destroyOSLoop();
///
/// Minimize all the windows
virtual void minimize();
/// Restore the minimized windows
virtual void restore();
/// Add an icon in the system tray
virtual void addInTray();
/// Remove the icon from the system tray
virtual void removeFromTray();
/// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
......
......@@ -103,6 +103,21 @@ void X11Factory::minimize()
DefaultScreen( m_pDisplay->getDisplay() ) );
}
void X11Factory::restore()
{
// TODO
}
void X11Factory::addInTray()
{
// TODO
}
void X11Factory::removeFromTray()
{
// TODO
}
OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
{
return new X11Timer( getIntf(), rCmd );
......
......@@ -62,9 +62,18 @@ class X11Factory: public OSFactory
/// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
///
/// Minimize all the windows
virtual void minimize();
/// Restore the minimized windows
virtual void restore();
/// Add an icon in the system tray
virtual void addInTray();
/// Remove the icon from the system tray
virtual void removeFromTray();
/// Instantiate an OSWindow object
virtual OSWindow *createOSWindow( GenericWindow &rWindow,
bool dragDrop, bool playOnDrop,
......
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