]> git.sesse.net Git - vlc/commitdiff
* skins2: new skins2-systray option on Windows to activate an icon in the system...
authorOlivier Teulière <ipkiss@videolan.org>
Sat, 13 May 2006 11:42:20 +0000 (11:42 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sat, 13 May 2006 11:42:20 +0000 (11:42 +0000)
modules/gui/skins2/src/skin_main.cpp
modules/gui/skins2/win32/win32_factory.cpp
modules/gui/skins2/win32/win32_factory.hpp

index 19981c78e16e01717e12c5c3ed84eb3319e5cdc8..352923a51bfff3ca53e29980722f725552c0bd60 100644 (file)
@@ -343,10 +343,10 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
 #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")
-/// \bug [String] missing "skin". Remove "by the skins module". Add "do not touch"
-#define SKINS2_CONFIG_LONG N_("Windows configuration of the last used. " \
-        "This option is updated automatically by the skins module." )
-
+#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_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" \
@@ -362,6 +362,8 @@ vlc_module_begin();
                 VLC_TRUE );
         change_autosave();
 #ifdef WIN32
+    add_bool( "skins2-systray", VLC_FALSE, NULL, SKINS2_SYSTRAY,
+              SKINS2_SYSTRAY_LONG, VLC_FALSE );
     add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY,
               SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
 #endif
index 9e2a45083c8f7e5a0da1a108349a1cf3a08db9d1..b6bef7d59efa7d164fc81e101202614ef6cc6069 100644 (file)
 #include "win32_popup.hpp"
 #include "win32_loop.hpp"
 #include "../src/theme.hpp"
+#include "../src/window_manager.hpp"
+#include "commands/cmd_dialogs.hpp"
+
+// Custom message for the notifications of the system tray
+#define MY_WSTRAYACTION (WM_APP + 1)
 
 
 LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
@@ -73,6 +78,23 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
 //                ( (Event *)wParam )->SendEvent();
 //            return 0;
         }
+        // Handle systray notifications
+        else if( uMsg == MY_WSTRAYACTION )
+        {
+            if( (UINT)lParam == WM_LBUTTONDOWN )
+            {
+                p_intf->p_sys->p_theme->getWindowManager().raiseAll();
+            }
+            else if( (UINT)lParam == WM_RBUTTONDOWN )
+            {
+                CmdDlgShowPopupMenu aCmdPopup( p_intf );
+                aCmdPopup.execute();
+            }
+            else if( (UINT)lParam == WM_LBUTTONDBLCLK )
+            {
+                ShowWindow( hwnd, SW_RESTORE );
+            }
+        }
     }
 
     // If hwnd does not match any window or message not processed
@@ -135,14 +157,30 @@ bool Win32Factory::init()
         return false;
     }
 
+    // Store with it a pointer to the interface thread
+    SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );
+
+    // Initialize the systray icon
+    m_trayIcon.cbSize = sizeof( NOTIFYICONDATA );
+    m_trayIcon.hWnd = m_hParentWindow;
+    m_trayIcon.uID = 42;
+    m_trayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;
+    m_trayIcon.uCallbackMessage = MY_WSTRAYACTION;
+    m_trayIcon.hIcon = LoadIcon( m_hInst, _T("VLC_ICON") );
+    strcpy( m_trayIcon.szTip, "VLC media player" );
+
+    // Show the systray icon if needed
+    if( config_GetInt( getIntf(), "skins2-systray" ) )
+    {
+        Shell_NotifyIcon( NIM_ADD, &m_trayIcon );
+    }
+
     // We do it this way otherwise CreateWindowEx will fail
     // if WS_EX_LAYERED is not supported
     SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE,
                       GetWindowLong( m_hParentWindow, GWL_EXSTYLE ) |
                       WS_EX_LAYERED );
 
-    // Store with it a pointer to the interface thread
-    SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() );
     ShowWindow( m_hParentWindow, SW_SHOW );
 
     // Initialize the OLE library (for drag & drop)
@@ -203,6 +241,9 @@ Win32Factory::~Win32Factory()
     // Uninitialize the OLE library
     OleUninitialize();
 
+    // Remove the systray icon
+    Shell_NotifyIcon( NIM_DELETE, &m_trayIcon );
+
     if( m_hParentWindow ) DestroyWindow( m_hParentWindow );
 
     // Unload msimg32.dll and user32.dll
@@ -264,7 +305,7 @@ OSPopup *Win32Factory::createOSPopup()
     // In fact, the clean way would be to have in Builder::addPopup() a call
     // to pPopup->associateToWindow() (to be written)... but the problem is
     // that there is no way to access the OS-dependent window handle from a
-    // GenericWindow (we cannot eevn access the OSWindow).
+    // GenericWindow (we cannot even access the OSWindow).
     if( m_windowMap.begin() == m_windowMap.end() )
     {
         msg_Err( getIntf(), "no window has been created before the popup!" );
index bac7d647c174a184c0b5317e0377ba131e07c025..feee25725fe3c3a3560ffb2741b63fc5d12703b7 100644 (file)
@@ -30,6 +30,7 @@
 #endif
 
 #include <windows.h>
+#include <shellapi.h>
 #include "../src/os_factory.hpp"
 #include <map>
 
@@ -113,6 +114,8 @@ class Win32Factory: public OSFactory
         HINSTANCE m_hInst;
         /// Handle of the parent window
         HWND m_hParentWindow;
+        /// Structure for the system tray
+        NOTIFYICONDATA m_trayIcon;
         /// Handle on msimg32.dll (for TransparentBlt)
         HINSTANCE m_hMsimg32;
         /// Handle on user32.dll (for SetLayeredWindowAttributes)