/* include the icon graphic */
#include "../../../share/vlc32x32.xpm"
+/* include a small icon graphic for the systray icon */
+#include "../../../share/vlc16x16.xpm"
/*****************************************************************************
* Local class declarations.
EVT_MOTION(wxVolCtrl::OnChange)
END_EVENT_TABLE()
+/* Systray integration */
+class Systray: public wxTaskBarIcon
+{
+public:
+ Systray( Interface* p_main_interface );
+ virtual ~Systray() {};
+ wxMenu* CreatePopupMenu();
+
+private:
+ void OnLeftClick( wxTaskBarIconEvent& event );
+ void OnPlayStream ( wxCommandEvent& event );
+ void OnStopStream ( wxCommandEvent& event );
+ void OnPrevStream ( wxCommandEvent& event );
+ void OnNextStream ( wxCommandEvent& event );
+ void OnExit( wxCommandEvent& event );
+ Interface* p_main_interface;
+ DECLARE_EVENT_TABLE()
+};
+
+
/*****************************************************************************
* Event Table.
*****************************************************************************/
/* it is important for the id corresponding to the "About" command to have
* this standard value as otherwise it won't be handled properly under Mac
* (where it is special and put into the "Apple" menu) */
- About_Event = wxID_ABOUT
+ About_Event = wxID_ABOUT,
+
+ Iconize_Event
};
BEGIN_EVENT_TABLE(Interface, wxFrame)
END_EVENT_TABLE()
+BEGIN_EVENT_TABLE(Systray, wxTaskBarIcon)
+ /* Mouse events */
+ EVT_TASKBAR_LEFT_DOWN(Systray::OnLeftClick)
+ /* Menu events */
+ EVT_MENU(Iconize_Event, Systray::OnLeftClick)
+ EVT_MENU(Exit_Event, Systray::OnExit)
+ EVT_MENU(PlayStream_Event, Systray::OnPlayStream)
+ EVT_MENU(NextStream_Event, Systray::OnNextStream)
+ EVT_MENU(PrevStream_Event, Systray::OnPrevStream)
+ EVT_MENU(StopStream_Event, Systray::OnStopStream)
+END_EVENT_TABLE()
+
/*****************************************************************************
* Constructor.
*****************************************************************************/
-Interface::Interface( intf_thread_t *_p_intf ):
+Interface::Interface( intf_thread_t *_p_intf, long style ):
wxFrame( NULL, -1, wxT("VLC media player"),
- wxDefaultPosition, wxSize(700,100), wxDEFAULT_FRAME_STYLE )
+ wxDefaultPosition, wxSize(700,100), style )
{
/* Initializations */
p_intf = _p_intf;
extra_window = NULL;
/* Give our interface a nice little icon */
- SetIcon( wxIcon( vlc_xpm ) );
+ SetIcon( wxIcon( vlc16x16_xpm ) );
/* Create a sizer for the main frame */
frame_sizer = new wxBoxSizer( wxVERTICAL );
p_dummy->SetFocus();
frame_sizer->Add( p_dummy, 0, 0 );
+ /* Systray integration */
+ p_systray = NULL;
+ if ( config_GetInt( p_intf, "wxwin-systray" ) )
+ {
+ p_systray = new Systray(this);
+ p_systray->SetIcon( wxIcon( vlc_xpm ), wxT("VLC media player") );
+ if ( (! p_systray->IsOk()) || (! p_systray->IsIconInstalled()) )
+ {
+ msg_Warn(p_intf, "Cannot set systray icon, weird things may happen");
+ }
+ }
+
/* Creation of the menu bar */
CreateOurMenuBar();
Interface::~Interface()
{
+ if( p_systray )
+ {
+ delete p_systray;
+ }
+
if( p_intf->p_sys->p_wxwindow )
{
delete p_intf->p_sys->p_wxwindow;
}
#endif
+
void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
+{
+ PlayStream();
+}
+
+void Interface::PlayStream()
{
wxCommandEvent dummy;
playlist_t *p_playlist =
}
void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
+{
+ StopStream();
+}
+void Interface::StopStream()
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
}
void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
+{
+ PrevStream();
+}
+
+void Interface::PrevStream()
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
}
void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
+{
+ NextStream();
+}
+
+void Interface::NextStream()
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
i_gauge_volume / 2 ) );
}
+
+/*****************************************************************************
+ * Definition of Systray class.
+ *****************************************************************************/
+
+Systray::Systray( Interface *_p_main_interface )
+{
+ p_main_interface = _p_main_interface;
+}
+
+/* Event handlers */
+void Systray::OnLeftClick( wxTaskBarIconEvent& event )
+{
+ p_main_interface->Show( ! p_main_interface->IsShown() );
+}
+
+void Systray::OnExit( wxCommandEvent& event )
+{
+ p_main_interface->Close(TRUE);
+}
+
+void Systray::OnPrevStream( wxCommandEvent& event )
+{
+ p_main_interface->PrevStream();
+}
+
+void Systray::OnNextStream( wxCommandEvent& event )
+{
+ p_main_interface->NextStream();
+}
+
+void Systray::OnPlayStream( wxCommandEvent& event )
+{
+ p_main_interface->PlayStream();
+}
+
+void Systray::OnStopStream( wxCommandEvent& event )
+{
+ p_main_interface->StopStream();
+}
+
+/* Systray popup menu */
+wxMenu* Systray::CreatePopupMenu()
+{
+ wxMenu* systray_menu = new wxMenu;
+ systray_menu->Append( Exit_Event, wxU(_("Quit VLC")) );
+ systray_menu->AppendSeparator();
+ systray_menu->Append( PlayStream_Event, wxU(_("Play/Pause")) );
+ systray_menu->Append( PrevStream_Event, wxU(_("Previous")) );
+ systray_menu->Append( NextStream_Event, wxU(_("Next")) );
+ systray_menu->Append( StopStream_Event, wxU(_("Stop")) );
+ systray_menu->AppendSeparator();
+ systray_menu->Append( Iconize_Event, wxU(_("Show/Hide interface")) );
+ return systray_menu;
+}
+
/*****************************************************************************
* wxwindows.cpp : wxWindows plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2004 VideoLAN
+ * Copyright (C) 2000-2005 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
#include "wxwindows.h"
/* Temporary hack */
-#if defined(WIN32) && defined(_WX_INIT_H_)
+#if defined(WIN32) && defined(_WX_INIT_H_)
#if (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 5) && (wxRELEASE_NUMBER < 3)
/* Hack to detect wxWindows 2.5 which has a different wxEntry() prototype */
extern int wxEntry( HINSTANCE hInstance, HINSTANCE hPrevInstance = NULL,
#define BOOKMARKS_TEXT N_("Show bookmarks dialog")
#define BOOKMARKS_LONGTEXT N_("Show bookmarks dialog when the interface " \
"starts.")
+#define TASKBAR_TEXT N_("Show taskbar entry")
+#define TASKBAR_LONGTEXT N_("Show taskbar entry")
+#define SYSTRAY_TEXT N_("Show systray icon")
+#define SYSTRAY_LONGTEXT N_("Show systray icon")
vlc_module_begin();
#ifdef WIN32
EMBED_TEXT, EMBED_LONGTEXT, VLC_FALSE );
add_bool( "wxwin-bookmarks", 0, NULL,
BOOKMARKS_TEXT, BOOKMARKS_LONGTEXT, VLC_FALSE );
+ add_bool( "wxwin-taskbar", 1, NULL,
+ TASKBAR_TEXT, TASKBAR_LONGTEXT, VLC_FALSE );
+ add_bool( "wxwin-systray", 0, NULL,
+ SYSTRAY_TEXT, SYSTRAY_LONGTEXT, VLC_FALSE );
add_submodule();
set_description( _("wxWindows dialogs provider") );
if( !p_intf->pf_show_dialog )
{
/* The module is used in interface mode */
- Interface *MainInterface = new Interface( p_intf );
+ long style = wxDEFAULT_FRAME_STYLE;
+ if ( ! config_GetInt( p_intf, "wxwin-taskbar" ) )
+ {
+ style = wxDEFAULT_FRAME_STYLE|wxFRAME_NO_TASKBAR;
+ }
+ Interface *MainInterface = new Interface( p_intf, style );
p_intf->p_sys->p_wxwindow = MainInterface;
/* Show the interface */