1 /*****************************************************************************
2 * interface.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: interface.cpp,v 1.41 2003/06/19 12:21:53 gbazin Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
35 #ifdef WIN32 /* mingw32 hack */
40 /* Let vlc take care of the i18n stuff */
41 #define WXINTL_NO_GETTEXT_MACRO
43 #include <wx/wxprec.h>
47 #include "stream_control.h"
49 #include "wxwindows.h"
51 /* include the toolbar graphics */
52 #include "bitmaps/file.xpm"
53 #include "bitmaps/disc.xpm"
54 #include "bitmaps/net.xpm"
56 #include "bitmaps/sat.xpm"
58 #include "bitmaps/play.xpm"
59 #include "bitmaps/pause.xpm"
60 #include "bitmaps/stop.xpm"
61 #include "bitmaps/previous.xpm"
62 #include "bitmaps/next.xpm"
63 #include "bitmaps/playlist.xpm"
64 #include "bitmaps/fast.xpm"
65 #include "bitmaps/slow.xpm"
67 #define TOOLBAR_BMP_WIDTH 36
68 #define TOOLBAR_BMP_HEIGHT 36
70 /* include the icon graphic */
71 #include "share/vlc32x32.xpm"
73 /*****************************************************************************
74 * Local class declarations.
75 *****************************************************************************/
76 class wxMenuExt: public wxMenu
80 wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
81 const wxString& helpString, wxItemKind kind,
82 char *_psz_var, int _i_object_id, vlc_value_t _val,
85 virtual ~wxMenuExt() {};
96 class wxVolCtrl: public wxGauge
100 wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
101 virtual ~wxVolCtrl() {};
103 void Change( int i_volume );
105 void OnChange( wxMouseEvent& event );
108 intf_thread_t *p_intf;
110 DECLARE_EVENT_TABLE();
113 BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
115 EVT_LEFT_DOWN(wxVolCtrl::OnChange)
118 /*****************************************************************************
120 *****************************************************************************/
122 /* IDs for the controls and the menu commands */
126 Exit_Event = wxID_HIGHEST,
147 /* it is important for the id corresponding to the "About" command to have
148 * this standard value as otherwise it won't be handled properly under Mac
149 * (where it is special and put into the "Apple" menu) */
150 About_Event = wxID_ABOUT
153 BEGIN_EVENT_TABLE(Interface, wxFrame)
155 EVT_MENU(Exit_Event, Interface::OnExit)
156 EVT_MENU(About_Event, Interface::OnAbout)
157 EVT_MENU(Playlist_Event, Interface::OnPlaylist)
158 EVT_MENU(Logs_Event, Interface::OnLogs)
159 EVT_MENU(FileInfo_Event, Interface::OnFileInfo)
160 EVT_MENU(Prefs_Event, Interface::OnPreferences)
162 EVT_MENU_OPEN(Interface::OnMenuOpen)
164 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
165 EVT_CONTEXT_MENU(Interface::OnContextMenu2)
167 EVT_RIGHT_UP(Interface::OnContextMenu)
170 EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
171 EVT_MENU(OpenDisc_Event, Interface::OnOpenDisc)
172 EVT_MENU(OpenNet_Event, Interface::OnOpenNet)
173 EVT_MENU(OpenSat_Event, Interface::OnOpenSat)
174 EVT_MENU(StopStream_Event, Interface::OnStopStream)
175 EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
176 EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
177 EVT_MENU(NextStream_Event, Interface::OnNextStream)
178 EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
179 EVT_MENU(FastStream_Event, Interface::OnFastStream)
182 EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
185 /*****************************************************************************
187 *****************************************************************************/
188 Interface::Interface( intf_thread_t *_p_intf ):
189 wxFrame( NULL, -1, wxT("VLC media player"),
190 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
192 /* Initializations */
194 p_prefs_dialog = NULL;
195 i_old_playing_status = PAUSE_S;
196 p_open_dialog = NULL;
198 /* Give our interface a nice little icon */
199 p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
200 SetIcon( *p_intf->p_sys->p_icon );
202 /* Create a sizer for the main frame */
203 frame_sizer = new wxBoxSizer( wxHORIZONTAL );
204 SetSizer( frame_sizer );
206 /* Creation of the menu bar */
209 /* Creation of the tool bar */
212 /* Creation of the slider sub-window */
214 frame_sizer->Add( slider_frame, 1, wxGROW, 0 );
215 frame_sizer->Hide( slider_frame );
217 /* Creation of the status bar
218 * Helptext for menu items and toolbar tools will automatically get
220 int i_status_width[3] = {-6, -2, -9};
221 statusbar = CreateStatusBar( 3 ); /* 2 fields */
222 statusbar->SetStatusWidths( 3, i_status_width );
223 statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
226 /* Make sure we've got the right background colour */
227 SetBackgroundColour( slider_frame->GetBackgroundColour() );
229 /* Layout everything */
230 SetAutoLayout( TRUE );
231 frame_sizer->Layout();
232 frame_sizer->Fit(this);
234 #if !defined(__WXX11__)
235 /* Associate drop targets with the main interface */
236 SetDropTarget( new DragAndDrop( p_intf ) );
240 Interface::~Interface()
243 if( p_open_dialog ) delete p_open_dialog;
244 if( p_prefs_dialog ) p_prefs_dialog->Destroy();
245 if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
248 /*****************************************************************************
250 *****************************************************************************/
251 void Interface::CreateOurMenuBar()
253 #define HELP_FILE N_("Open a file")
254 #define HELP_DISC N_("Open a DVD or (S)VCD")
255 #define HELP_NET N_("Open a network stream")
256 #define HELP_SAT N_("Open a satellite stream")
257 #define HELP_EJECT N_("Eject the DVD/CD")
258 #define HELP_EXIT N_("Exit this program")
260 #define HELP_PLAYLIST N_("Open the playlist")
261 #define HELP_LOGS N_("Show the program logs")
262 #define HELP_FILEINFO N_("Show information about the file being played")
264 #define HELP_PREFS N_("Go to the preferences menu")
266 #define HELP_ABOUT N_("About this program")
268 /* Create the "File" menu */
269 wxMenu *file_menu = new wxMenu;
270 file_menu->Append( OpenFile_Event, wxU(_("&Open File...")),
272 file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")),
274 file_menu->Append( OpenNet_Event, wxU(_("&Network Stream...")),
277 file_menu->Append( OpenSat_Event, wxU(_("&Satellite Stream...")),
281 file_menu->AppendSeparator();
282 file_menu->Append( EjectDisc_Event, wxU(_("&Eject Disc")),
283 wxU(_(HELP_EJECT)) );
285 file_menu->AppendSeparator();
286 file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) );
288 /* Create the "View" menu */
289 wxMenu *view_menu = new wxMenu;
290 view_menu->Append( Playlist_Event, wxU(_("&Playlist...")),
291 wxU(_(HELP_PLAYLIST)) );
292 view_menu->Append( Logs_Event, wxU(_("&Messages...")), wxU(_(HELP_LOGS)) );
293 view_menu->Append( FileInfo_Event, wxU(_("&File info...")),
294 wxU(_(HELP_FILEINFO)) );
296 /* Create the "Settings" menu */
297 wxMenu *settings_menu = new wxMenu;
298 settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
299 wxU(_(HELP_PREFS)) );
301 /* Create the "Audio" menu */
302 p_audio_menu = new wxMenu;
305 /* Create the "Video" menu */
306 p_video_menu = new wxMenu;
309 /* Create the "Navigation" menu */
310 p_navig_menu = new wxMenu;
313 /* Create the "Help" menu */
314 wxMenu *help_menu = new wxMenu;
315 help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
317 /* Append the freshly created menus to the menu bar... */
318 wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
319 menubar->Append( file_menu, wxU(_("&File")) );
320 menubar->Append( view_menu, wxU(_("&View")) );
321 menubar->Append( settings_menu, wxU(_("&Settings")) );
322 menubar->Append( p_audio_menu, wxU(_("&Audio")) );
323 menubar->Append( p_video_menu, wxU(_("&Video")) );
324 menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
325 menubar->Append( help_menu, wxU(_("&Help")) );
327 /* Attach the menu bar to the frame */
328 SetMenuBar( menubar );
330 /* Intercept all menu events in our custom event handler */
331 PushEventHandler( new MenuEvtHandler( p_intf, this ) );
333 #if !defined(__WXX11__)
334 /* Associate drop targets with the menubar */
335 menubar->SetDropTarget( new DragAndDrop( p_intf ) );
339 void Interface::CreateOurToolBar()
341 #define HELP_STOP N_("Stop current playlist item")
342 #define HELP_PLAY N_("Play current playlist item")
343 #define HELP_PAUSE N_("Pause current playlist item")
344 #define HELP_PLO N_("Open playlist")
345 #define HELP_PLP N_("Previous playlist item")
346 #define HELP_PLN N_("Next playlist item")
347 #define HELP_SLOW N_("Play slower")
348 #define HELP_FAST N_("Play faster")
350 wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
351 * version because we don't include wx.rc */
353 wxToolBar *toolbar = CreateToolBar(
354 wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
356 toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
358 toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ),
360 toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ),
362 toolbar->AddTool( OpenNet_Event, wxU(_("Net")), wxBitmap( net_xpm ),
365 toolbar->AddTool( OpenSat_Event, wxU(_("Sat")), wxBitmap( sat_xpm ),
368 toolbar->AddSeparator();
369 toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ),
371 toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ),
373 toolbar->AddSeparator();
374 toolbar->AddTool( Playlist_Event, wxU(_("Playlist")),
375 wxBitmap( playlist_xpm ), wxU(_(HELP_PLO)) );
376 toolbar->AddTool( PrevStream_Event, wxU(_("Prev")),
377 wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
378 toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
380 toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
382 toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
387 /* Place the toolbar in a sizer, so we can calculate the width of the
388 * toolbar and set this as the minimum for the main frame size. */
389 wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
390 toolbar_sizer->Add( toolbar, 0, 0, 0 );
391 toolbar_sizer->Layout();
394 frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
396 frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
397 toolbar->GetToolsCount(), -1 );
400 #if !defined(__WXX11__)
401 /* Associate drop targets with the toolbar */
402 toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
406 void Interface::CreateOurSlider()
408 /* Create a new frame and sizer containing the slider */
409 slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
410 slider_frame->SetAutoLayout( TRUE );
411 wxBoxSizer *frame_sizer =
412 new wxBoxSizer( wxHORIZONTAL );
414 /* Create static box to surround the slider */
415 slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
417 /* Create sizer for slider frame */
418 wxStaticBoxSizer *slider_sizer =
419 new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
420 slider_sizer->SetMinSize( -1, 50 );
423 slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
424 SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
425 slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
428 volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
430 /* Add everything to the frame */
431 frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
432 frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
433 slider_frame->SetSizer( frame_sizer );
434 frame_sizer->Layout();
435 frame_sizer->SetSizeHints(slider_frame);
437 /* Hide the slider by default */
438 slider_frame->Hide();
441 void Interface::Open( int i_access_method )
443 /* Show/hide the open dialog */
444 if( p_open_dialog == NULL )
445 p_open_dialog = new OpenDialog( p_intf, this, i_access_method );
448 p_open_dialog->ShowModal( i_access_method ) == wxID_OK )
450 /* Update the playlist */
451 playlist_t *p_playlist =
452 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
454 if( p_playlist == NULL )
459 for( size_t i = 0; i < p_open_dialog->mrl.GetCount(); i++ )
461 playlist_Add( p_playlist,
462 (const char *)p_open_dialog->mrl[i].mb_str(),
463 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
466 TogglePlayButton( PLAYING_S );
468 vlc_object_release( p_playlist );
472 /*****************************************************************************
474 *****************************************************************************/
475 /* Work-around helper for buggy wxGTK */
476 void RecursiveDestroy( wxMenu *menu )
478 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
481 wxMenuItem *item = node->GetData();
482 node = node->GetNext();
484 /* Delete the submenus */
485 wxMenu *submenu = item->GetSubMenu();
488 RecursiveDestroy( submenu );
490 menu->Delete( item );
494 void Interface::OnMenuOpen(wxMenuEvent& event)
496 #if !defined( __WXMSW__ )
497 if( event.GetEventObject() == p_audio_menu )
501 p_audio_menu = AudioMenu( p_intf, this );
503 /* Work-around for buggy wxGTK */
504 wxMenu *menu = GetMenuBar()->GetMenu( 3 );
505 RecursiveDestroy( menu );
506 /* End work-around */
509 GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
510 if( menu ) delete menu;
514 else b_audio_menu = 1;
516 else if( event.GetEventObject() == p_video_menu )
520 p_video_menu = VideoMenu( p_intf, this );
522 /* Work-around for buggy wxGTK */
523 wxMenu *menu = GetMenuBar()->GetMenu( 4 );
524 RecursiveDestroy( menu );
525 /* End work-around */
528 GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
529 if( menu ) delete menu;
533 else b_video_menu = 1;
535 else if( event.GetEventObject() == p_navig_menu )
539 p_navig_menu = NavigMenu( p_intf, this );
541 /* Work-around for buggy wxGTK */
542 wxMenu *menu = GetMenuBar()->GetMenu( 5 );
543 RecursiveDestroy( menu );
544 /* End work-around */
547 GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
548 if( menu ) delete menu;
552 else b_navig_menu = 1;
556 p_audio_menu = AudioMenu( p_intf, this );
557 wxMenu *menu = GetMenuBar()->Replace( 3, p_audio_menu, wxU(_("&Audio")) );
558 if( menu ) delete menu;
560 p_video_menu = VideoMenu( p_intf, this );
561 menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
562 if( menu ) delete menu;
564 p_navig_menu = NavigMenu( p_intf, this );
565 menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
566 if( menu ) delete menu;
571 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
572 void Interface::OnContextMenu2(wxContextMenuEvent& event)
574 ::PopupMenu( p_intf, this, ScreenToClient(event.GetPosition()) );
577 void Interface::OnContextMenu(wxMouseEvent& event)
579 ::PopupMenu( p_intf, this, event.GetPosition() );
582 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
584 /* TRUE is to force the frame to close. */
588 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
591 msg.Printf( wxString(wxT("VLC media player")) +
592 wxU(_(" (wxWindows interface)\n\n")) +
593 wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
594 wxU(_("The VideoLAN team <videolan@videolan.org>\n"
595 "http://www.videolan.org/\n\n")) +
596 wxU(_("This is the VideoLAN Client, a DVD, MPEG and DivX player."
597 "\nIt can play MPEG and MPEG2 files from a file or from a "
598 "network source.")) );
600 wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
601 wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
604 void Interface::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
606 /* Show/hide the playlist window */
607 Playlist *p_playlist_window = p_intf->p_sys->p_playlist_window;
608 if( p_playlist_window )
610 p_playlist_window->ShowPlaylist( ! p_playlist_window->IsShown() );
614 void Interface::OnLogs( wxCommandEvent& WXUNUSED(event) )
616 /* Show/hide the log window */
617 wxFrame *p_messages_window = p_intf->p_sys->p_messages_window;
618 if( p_messages_window )
620 p_messages_window->Show( ! p_messages_window->IsShown() );
624 void Interface::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
626 /* Show/hide the file info window */
627 wxFrame *p_fileinfo_window = p_intf->p_sys->p_fileinfo_window;
628 if( p_fileinfo_window )
630 p_fileinfo_window->Show( ! p_fileinfo_window->IsShown() );
634 void Interface::OnPreferences( wxCommandEvent& WXUNUSED(event) )
636 /* Show/hide the open dialog */
637 if( p_prefs_dialog == NULL )
639 p_prefs_dialog = new PrefsDialog( p_intf, this );
644 p_prefs_dialog->Show( true );
648 void Interface::OnOpenFile( wxCommandEvent& WXUNUSED(event) )
653 void Interface::OnOpenDisc( wxCommandEvent& WXUNUSED(event) )
658 void Interface::OnOpenNet( wxCommandEvent& WXUNUSED(event) )
663 void Interface::OnOpenSat( wxCommandEvent& WXUNUSED(event) )
668 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
670 wxCommandEvent dummy;
671 playlist_t *p_playlist =
672 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
674 if( p_playlist == NULL )
676 /* If the playlist is empty, open a file requester instead */
681 vlc_mutex_lock( &p_playlist->object_lock );
682 if( p_playlist->i_size )
684 vlc_mutex_unlock( &p_playlist->object_lock );
686 input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
689 if( p_input == NULL )
691 /* No stream was playing, start one */
692 playlist_Play( p_playlist );
693 TogglePlayButton( PLAYING_S );
694 vlc_object_release( p_playlist );
698 if( p_input->stream.control.i_status != PAUSE_S )
700 /* A stream is being played, pause it */
701 input_SetStatus( p_input, INPUT_STATUS_PAUSE );
702 TogglePlayButton( PAUSE_S );
703 vlc_object_release( p_playlist );
704 vlc_object_release( p_input );
708 /* Stream is paused, resume it */
709 playlist_Play( p_playlist );
710 TogglePlayButton( PLAYING_S );
711 vlc_object_release( p_input );
712 vlc_object_release( p_playlist );
716 vlc_mutex_unlock( &p_playlist->object_lock );
717 vlc_object_release( p_playlist );
722 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
724 playlist_t * p_playlist =
725 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
727 if( p_playlist == NULL )
732 playlist_Stop( p_playlist );
733 TogglePlayButton( PAUSE_S );
734 vlc_object_release( p_playlist );
737 void Interface::OnSliderUpdate( wxScrollEvent& event )
739 vlc_mutex_lock( &p_intf->change_lock );
742 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
743 || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
746 if( p_intf->p_sys->i_slider_pos != event.GetPosition()
747 && p_intf->p_sys->p_input )
749 p_intf->p_sys->i_slider_pos = event.GetPosition();
750 input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos *
751 100 / SLIDER_MAX_POS,
752 INPUT_SEEK_PERCENT | INPUT_SEEK_SET );
756 p_intf->p_sys->b_slider_free = VLC_TRUE;
760 p_intf->p_sys->b_slider_free = VLC_FALSE;
762 if( p_intf->p_sys->p_input )
764 /* Update stream date */
765 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
766 char psz_time[ OFFSETTOTIME_MAX_SIZE ];
768 slider_box->SetLabel(
769 wxU(input_OffsetToTime( p_intf->p_sys->p_input,
771 p_area->i_size * event.GetPosition()
772 / SLIDER_MAX_POS )) );
778 vlc_mutex_unlock( &p_intf->change_lock );
781 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
783 playlist_t * p_playlist =
784 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
786 if( p_playlist == NULL )
791 playlist_Prev( p_playlist );
792 vlc_object_release( p_playlist );
795 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
797 playlist_t * p_playlist =
798 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
800 if( p_playlist == NULL )
805 playlist_Next( p_playlist );
806 vlc_object_release( p_playlist );
809 void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
811 input_thread_t *p_input =
812 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
816 input_SetStatus( p_input, INPUT_STATUS_SLOWER );
817 vlc_object_release( p_input );
821 void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
823 input_thread_t *p_input =
824 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
828 input_SetStatus( p_input, INPUT_STATUS_FASTER );
829 vlc_object_release( p_input );
833 void Interface::TogglePlayButton( int i_playing_status )
835 if( i_playing_status == i_old_playing_status )
838 GetToolBar()->DeleteTool( PlayStream_Event );
840 if( i_playing_status == PLAYING_S )
842 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Pause")),
843 wxBitmap( pause_xpm ), wxNullBitmap,
844 wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
848 GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Play")),
849 wxBitmap( play_xpm ), wxNullBitmap,
850 wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
853 GetToolBar()->Realize();
855 i_old_playing_status = i_playing_status;
858 #if !defined(__WXX11__)
859 /*****************************************************************************
860 * Definition of DragAndDrop class.
861 *****************************************************************************/
862 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
867 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
868 const wxArrayString& filenames )
870 /* Add dropped files to the playlist */
872 playlist_t *p_playlist =
873 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
875 if( p_playlist == NULL )
880 for( size_t i = 0; i < filenames.GetCount(); i++ )
881 playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
882 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
884 vlc_object_release( p_playlist );
890 /*****************************************************************************
891 * Definition of wxVolCtrl class.
892 *****************************************************************************/
893 wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
894 : wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize,
895 wxGA_VERTICAL | wxGA_SMOOTH )
900 void wxVolCtrl::OnChange( wxMouseEvent& event )
902 int i_volume = (GetRect().height - event.GetY()) * 200 / GetRect().height;
906 void wxVolCtrl::Change( int i_volume )
908 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
909 SetValue( i_volume );
910 SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),