]> git.sesse.net Git - vlc/commitdiff
* skins2: The skins2-systray option can now be changed on the fly
authorOlivier Teulière <ipkiss@videolan.org>
Sat, 13 May 2006 17:09:21 +0000 (17:09 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sat, 13 May 2006 17:09:21 +0000 (17:09 +0000)
modules/gui/skins2/commands/cmd_minimize.cpp
modules/gui/skins2/commands/cmd_minimize.hpp
modules/gui/skins2/macosx/macosx_factory.cpp
modules/gui/skins2/macosx/macosx_factory.hpp
modules/gui/skins2/src/os_factory.hpp
modules/gui/skins2/src/skin_main.cpp
modules/gui/skins2/win32/win32_factory.cpp
modules/gui/skins2/win32/win32_factory.hpp
modules/gui/skins2/x11/x11_factory.cpp
modules/gui/skins2/x11/x11_factory.hpp

index ec774148a4e11972e70fb2a7371933877e9e09c1..dfdf2d54ca715c6a9c65511af5a3e2ea0c3907a0 100644 (file)
@@ -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();
+}
+
index 262003d19948d90ed0cfcad65033f9f43fbc6032..6cf78c0eaa62256c12b2cdadfda30bc69ff3797e 100644 (file)
@@ -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
index ce360e757bd7b3fe7dde7778684518cbf2c22287..cf07bbc877be91a9b628ba06804ed565a5d2d9b3 100644 (file)
@@ -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 );
 }
 
 
index 5ebc273f43bed6a0377f313d44bad3fa11a32276..30f7bfef9d8ec5acb30a94d46eac0090f497aa67 100644 (file)
@@ -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,
index 15272699da6d4725741d465d37ce25fdca041d3a..f01fba01ecc66bfe21b9546562d91309428773c5 100644 (file)
@@ -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;
 
index 352923a51bfff3ca53e29980722f725552c0bd60..f6511d14305ce367e577ff516c83057a7f383e4d 100644 (file)
@@ -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 );
index b6bef7d59efa7d164fc81e101202614ef6cc6069..b94227b0bf4ce2d1b3283b2e42d673a9b69744ce 100644 (file)
@@ -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 );
index feee25725fe3c3a3560ffb2741b63fc5d12703b7..f0815bbf1bfb40ad341d8f2dee48bc845bb8665c 100644 (file)
@@ -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 );
 
index 53e70f98336ff3db86d6f0f11ae3a470e8277daf..38e38a402db55e16c68e303fd4f2175107807ac0 100644 (file)
@@ -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 );
index f0498eee6ed2132bdbefbb07d417f3269470c71c..9a7ce7b9fbfb3a4b15aafb9a00ee28223b384940 100644 (file)
@@ -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,