]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/interface.cpp
* src/misc/variables.c, ALL: improvements to the object variables api.
[vlc] / modules / gui / wxwindows / interface.cpp
1 /*****************************************************************************
2  * interface.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: interface.cpp,v 1.22 2003/05/04 22:42:16 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.h>
44
45 #include <vlc/intf.h>
46 #include "stream_control.h"
47
48 #include "wxwindows.h"
49
50 /* include the toolbar graphics */
51 #include "bitmaps/file.xpm"
52 #include "bitmaps/disc.xpm"
53 #include "bitmaps/net.xpm"
54 #if 0
55 #include "bitmaps/sat.xpm"
56 #endif
57 #include "bitmaps/play.xpm"
58 #include "bitmaps/pause.xpm"
59 #include "bitmaps/stop.xpm"
60 #include "bitmaps/previous.xpm"
61 #include "bitmaps/next.xpm"
62 #include "bitmaps/playlist.xpm"
63 #define TOOLBAR_BMP_WIDTH 24
64 #define TOOLBAR_BMP_HEIGHT 24
65
66 /* include the icon graphic */
67 #include "share/vlc32x32.xpm"
68
69 /*****************************************************************************
70  * Local class declarations.
71  *****************************************************************************/
72 class wxMenuExt: public wxMenu
73 {
74 public:
75     /* Constructor */
76     wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
77                    const wxString& helpString, wxItemKind kind,
78                    char *_psz_var, int _i_object_id, vlc_value_t _val,
79                    int _i_val_type );
80
81     virtual ~wxMenuExt() {};
82
83     char *psz_var;
84     int  i_val_type;
85     int  i_object_id;
86     vlc_value_t val;
87
88 private:
89
90 };
91
92 /*****************************************************************************
93  * Event Table.
94  *****************************************************************************/
95
96 /* IDs for the controls and the menu commands */
97 enum
98 {
99     /* menu items */
100     Exit_Event = wxID_HIGHEST,
101     OpenFile_Event,
102     OpenDisc_Event,
103     OpenNet_Event,
104     OpenSat_Event,
105     EjectDisc_Event,
106
107     Playlist_Event,
108     Logs_Event,
109     FileInfo_Event,
110
111     Audio_Event,
112     Subtitles_Event,
113     Prefs_Event,
114
115     SliderScroll_Event,
116     StopStream_Event,
117     PlayStream_Event,
118     PrevStream_Event,
119     NextStream_Event,
120
121     /* it is important for the id corresponding to the "About" command to have
122      * this standard value as otherwise it won't be handled properly under Mac
123      * (where it is special and put into the "Apple" menu) */
124     About_Event = wxID_ABOUT
125 };
126
127 BEGIN_EVENT_TABLE(Interface, wxFrame)
128     /* Menu events */
129     EVT_MENU(Exit_Event, Interface::OnExit)
130     EVT_MENU(About_Event, Interface::OnAbout)
131     EVT_MENU(Playlist_Event, Interface::OnPlaylist)
132     EVT_MENU(Logs_Event, Interface::OnLogs)
133     EVT_MENU(FileInfo_Event, Interface::OnFileInfo)
134     EVT_MENU(Prefs_Event, Interface::OnPreferences)
135
136     EVT_MENU_OPEN(Interface::OnMenuOpen)
137     EVT_MENU_CLOSE(Interface::OnMenuClose)
138
139
140     /* Toolbar events */
141     EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
142     EVT_MENU(OpenDisc_Event, Interface::OnOpenDisc)
143     EVT_MENU(OpenNet_Event, Interface::OnOpenNet)
144     EVT_MENU(OpenSat_Event, Interface::OnOpenSat)
145     EVT_MENU(StopStream_Event, Interface::OnStopStream)
146     EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
147     EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
148     EVT_MENU(NextStream_Event, Interface::OnNextStream)
149
150     /* Slider events */
151     EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
152 END_EVENT_TABLE()
153
154 /*****************************************************************************
155  * Constructor.
156  *****************************************************************************/
157 Interface::Interface( intf_thread_t *_p_intf ):
158     wxFrame( NULL, -1, VOUT_TITLE,
159              wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
160 {
161     /* Initializations */
162     p_intf = _p_intf;
163     p_prefs_dialog = NULL;
164     i_old_playing_status = PAUSE_S;
165
166     /* Give our interface a nice little icon */
167     p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
168     SetIcon( *p_intf->p_sys->p_icon );
169
170     /* Create a sizer for the main frame */
171     frame_sizer = new wxBoxSizer( wxHORIZONTAL );
172     SetSizer( frame_sizer );
173
174     /* Creation of the menu bar */
175     CreateOurMenuBar();
176
177     /* Creation of the tool bar */
178     CreateOurToolBar();
179
180     /* Creation of the slider sub-window */
181     CreateOurSlider();
182     frame_sizer->Add( slider_frame, 1, wxGROW, 0 );
183     frame_sizer->Hide( slider_frame );
184
185     /* Creation of the status bar
186      * Helptext for menu items and toolbar tools will automatically get
187      * displayed here. */
188     int i_status_width[2] = {-2,-3};
189     statusbar = CreateStatusBar( 2 );                            /* 2 fields */
190     statusbar->SetStatusWidths( 2, i_status_width );
191
192     /* Make sure we've got the right background colour */
193     SetBackgroundColour( slider_frame->GetBackgroundColour() );
194
195     /* Layout everything */
196     SetAutoLayout( TRUE );
197     frame_sizer->Layout();
198     frame_sizer->Fit(this);
199
200 #if !defined(__WXX11__)
201     /* Associate drop targets with the main interface */
202     SetDropTarget( new DragAndDrop( p_intf ) );
203 #endif
204 }
205
206 Interface::~Interface()
207 {
208     if( p_prefs_dialog ) p_prefs_dialog->Destroy();
209 }
210
211 /*****************************************************************************
212  * Private methods.
213  *****************************************************************************/
214 void Interface::CreateOurMenuBar()
215 {
216 #define HELP_FILE  N_("Open a file")
217 #define HELP_DISC  N_("Open a DVD or (S)VCD")
218 #define HELP_NET   N_("Open a network stream")
219 #define HELP_SAT   N_("Open a satellite stream")
220 #define HELP_EJECT N_("Eject the DVD/CD")
221 #define HELP_EXIT  N_("Exit this program")
222
223 #define HELP_PLAYLIST   N_("Open the playlist")
224 #define HELP_LOGS       N_("Show the program logs")
225 #define HELP_FILEINFO       N_("Show information about the file being played")
226
227 #define HELP_AUDIO N_("Change the current audio track")
228 #define HELP_SUBS  N_("Change the current subtitles stream")
229 #define HELP_PREFS N_("Go to the preferences menu")
230
231 #define HELP_ABOUT N_("About this program")
232
233     /* Create the "File" menu */
234     wxMenu *file_menu = new wxMenu;
235     file_menu->Append( OpenFile_Event, _("&Open File..."), HELP_FILE );
236     file_menu->Append( OpenDisc_Event, _("Open &Disc..."), HELP_DISC );
237     file_menu->Append( OpenNet_Event, _("&Network Stream..."), HELP_NET );
238 #if 0
239     file_menu->Append( OpenSat_Event, _("&Satellite Stream..."), HELP_NET );
240 #endif
241     file_menu->AppendSeparator();
242     file_menu->Append( EjectDisc_Event, _("&Eject Disc"), HELP_EJECT );
243     file_menu->AppendSeparator();
244     file_menu->Append( Exit_Event, _("E&xit"), HELP_EXIT );
245
246     /* Create the "View" menu */
247     wxMenu *view_menu = new wxMenu;
248     view_menu->Append( Playlist_Event, _("&Playlist..."), HELP_PLAYLIST );
249     view_menu->Append( Logs_Event, _("&Logs..."), HELP_LOGS );
250     view_menu->Append( FileInfo_Event, _("&File info..."), HELP_FILEINFO );
251
252     /* Create the "Settings" menu */
253     wxMenu *settings_menu = new wxMenu;
254     settings_menu->Append( Subtitles_Event, _("&Subtitles"), HELP_SUBS );
255     settings_menu->AppendSeparator();
256     settings_menu->Append( Prefs_Event, _("&Preferences..."), HELP_PREFS );
257
258     /* Create the "Audio" menu */
259     p_audio_menu = new wxMenu;
260     b_audio_menu = 1;
261
262     /* Create the "Video" menu */
263     p_video_menu = new wxMenu;
264     b_video_menu = 1;
265
266     /* Create the "Help" menu */
267     wxMenu *help_menu = new wxMenu;
268     help_menu->Append( About_Event, _("&About..."), HELP_ABOUT );
269
270     /* Append the freshly created menus to the menu bar... */
271     wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
272     menubar->Append( file_menu, _("&File") );
273     menubar->Append( view_menu, _("&View") );
274     menubar->Append( settings_menu, _("&Settings") );
275     menubar->Append( p_audio_menu, _("&Audio") );
276     menubar->Append( p_video_menu, _("&Video") );
277     menubar->Append( help_menu, _("&Help") );
278
279     /* Attach the menu bar to the frame */
280     SetMenuBar( menubar );
281
282     /* Intercept all menu events in our custom event handler */
283     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
284
285 #if !defined(__WXX11__)
286     /* Associate drop targets with the menubar */
287     menubar->SetDropTarget( new DragAndDrop( p_intf ) );
288 #endif
289 }
290
291 void Interface::CreateOurToolBar()
292 {
293 #define HELP_STOP N_("Stop current playlist item")
294 #define HELP_PLAY N_("Play current playlist item")
295 #define HELP_PAUSE N_("Pause current playlist item")
296 #define HELP_PLO N_("Open playlist")
297 #define HELP_PLP N_("Previous playlist item")
298 #define HELP_PLN N_("Next playlist item")
299
300     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
301                          * version because we don't include wx.rc */
302
303     wxToolBar *toolbar = CreateToolBar(
304         wxTB_HORIZONTAL | wxTB_TEXT | wxTB_FLAT | wxTB_DOCKABLE );
305
306     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
307
308     toolbar->AddTool( OpenFile_Event, _("File"), wxBitmap( file_xpm ),
309                       HELP_FILE );
310     toolbar->AddTool( OpenDisc_Event, _("Disc"), wxBitmap( disc_xpm ),
311                       HELP_DISC );
312     toolbar->AddTool( OpenNet_Event, _("Net"), wxBitmap( net_xpm ),
313                       HELP_NET );
314 #if 0
315     toolbar->AddTool( OpenSat_Event, _("Sat"), wxBitmap( sat_xpm ),
316                       HELP_SAT );
317 #endif
318     toolbar->AddSeparator();
319     toolbar->AddTool( StopStream_Event, _("Stop"), wxBitmap( stop_xpm ),
320                       HELP_STOP );
321     toolbar->AddTool( PlayStream_Event, _("Play"), wxBitmap( play_xpm ),
322                       HELP_PLAY );
323     toolbar->AddSeparator();
324     toolbar->AddTool( Playlist_Event, _("Playlist"), wxBitmap( playlist_xpm ),
325                       HELP_PLO );
326     toolbar->AddTool( PrevStream_Event, _("Prev"), wxBitmap( previous_xpm ),
327                       HELP_PLP );
328     toolbar->AddTool( NextStream_Event, _("Next"), wxBitmap( next_xpm ),
329                       HELP_PLN );
330
331     toolbar->Realize();
332
333     /* Place the toolbar in a sizer, so we can calculate the width of the
334      * toolbar and set this as the minimum for the main frame size. */
335     wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
336     toolbar_sizer->Add( toolbar, 0, 0, 0 );
337     toolbar_sizer->Layout();
338
339 #ifndef WIN32
340     frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
341 #else
342     frame_sizer->SetMinSize( toolbar->GetToolSize().GetWidth() *
343                              toolbar->GetToolsCount(), -1 );
344 #endif
345
346 #if !defined(__WXX11__)
347     /* Associate drop targets with the toolbar */
348     toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
349 #endif
350 }
351
352 void Interface::CreateOurSlider()
353 {
354     /* Create a new frame containing the slider */
355     slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
356     slider_frame->SetAutoLayout( TRUE );
357
358     /* Create static box to surround the slider */
359     slider_box = new wxStaticBox( slider_frame, -1, "" );
360
361     /* Create sizer for slider frame */
362     wxStaticBoxSizer *slider_sizer =
363         new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
364     slider_frame->SetSizer( slider_sizer );
365     slider_sizer->SetMinSize( -1, 50 );
366
367     /* Create slider */
368     slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
369                            SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
370     slider_sizer->Add( slider, 1, wxGROW | wxALL, 5 );
371     slider_sizer->Layout();
372     slider_sizer->SetSizeHints(slider_frame);
373
374     /* Hide the slider by default */
375     slider_frame->Hide();
376 }
377
378 void Interface::Open( int i_access_method )
379 {
380     /* Show/hide the open dialog */
381     OpenDialog dialog( p_intf, this, i_access_method );
382
383     if( dialog.ShowModal() == wxID_OK )
384     {
385         /* Update the playlist */
386         playlist_t *p_playlist =
387             (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
388                                            FIND_ANYWHERE );
389         if( p_playlist == NULL )
390         {
391             return;
392         }
393
394         playlist_Add( p_playlist, (char *)dialog.mrl.c_str(),
395                       PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
396
397         TogglePlayButton( PLAYING_S );
398
399         /* Rebuild the playlist */
400         p_intf->p_sys->p_playlist_window->Rebuild();
401
402         vlc_object_release( p_playlist );
403     }
404 }
405
406 /*****************************************************************************
407  * Event Handlers.
408  *****************************************************************************/
409 void Interface::OnMenuOpen(wxMenuEvent& event)
410 {
411     if( event.GetEventObject() == p_audio_menu )
412     {
413         if( b_audio_menu )
414         {
415             p_audio_menu = AudioMenu( p_intf, this );
416             wxMenu *menu =
417                 GetMenuBar()->Replace( 3, p_audio_menu, _("&Audio") );
418             if( menu ) delete menu;
419
420             b_audio_menu = 0;
421         }
422         else b_audio_menu = 1;
423     }
424     else if( event.GetEventObject() == p_video_menu )
425     {
426         if( b_video_menu )
427         {
428             p_video_menu = VideoMenu( p_intf, this );
429             wxMenu *menu =
430                 GetMenuBar()->Replace( 4, p_video_menu, _("&Video") );
431             if( menu ) delete menu;
432
433             b_video_menu = 0;
434         }
435         else b_video_menu = 1;
436     }
437 }
438
439 void Interface::OnMenuClose(wxMenuEvent& event)
440 {
441 }
442
443 void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
444 {
445     /* TRUE is to force the frame to close. */
446     Close(TRUE);
447 }
448
449 void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
450 {
451     wxString msg;
452     msg.Printf( VOUT_TITLE + wxString(_(" (wxWindows interface)\n\n")) +
453         wxString(_("(C) 1996-2003 - the VideoLAN Team\n\n")) +
454         wxString(_("The VideoLAN team <videolan@videolan.org>\n"
455                    "http://www.videolan.org/\n\n")) +
456         wxString(_("This is the VideoLAN Client, a DVD, MPEG and DivX player."
457           "\nIt can play MPEG and MPEG2 files from a file or from a "
458           "network source.")) );
459
460     wxMessageBox( msg, wxString::Format(_("About %s"), VOUT_TITLE),
461                   wxOK | wxICON_INFORMATION, this );
462 }
463
464 void Interface::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
465 {
466     /* Show/hide the playlist window */
467     wxFrame *p_playlist_window = p_intf->p_sys->p_playlist_window;
468     if( p_playlist_window )
469     {
470         p_playlist_window->Show( ! p_playlist_window->IsShown() );
471     }
472 }
473
474 void Interface::OnLogs( wxCommandEvent& WXUNUSED(event) )
475 {
476     /* Show/hide the log window */
477     wxFrame *p_messages_window = p_intf->p_sys->p_messages_window;
478     if( p_messages_window )
479     {
480         p_messages_window->Show( ! p_messages_window->IsShown() );
481     }
482 }
483
484 void Interface::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
485 {
486     /* Show/hide the file info window */
487     wxFrame *p_fileinfo_window = p_intf->p_sys->p_fileinfo_window;
488     if( p_fileinfo_window )
489     {
490         p_fileinfo_window->Show( ! p_fileinfo_window->IsShown() );
491     }
492 }
493
494 void Interface::OnPreferences( wxCommandEvent& WXUNUSED(event) )
495 {
496     /* Show/hide the open dialog */
497     if( p_prefs_dialog == NULL )
498     {
499         p_prefs_dialog = new PrefsDialog( p_intf, this );
500     }
501
502     if( p_prefs_dialog )
503     {
504         p_prefs_dialog->Show( true );
505     }
506 }
507
508 void Interface::OnOpenFile( wxCommandEvent& WXUNUSED(event) )
509 {
510     Open( FILE_ACCESS );
511 }
512
513 void Interface::OnOpenDisc( wxCommandEvent& WXUNUSED(event) )
514 {
515     Open( DISC_ACCESS );
516 }
517
518 void Interface::OnOpenNet( wxCommandEvent& WXUNUSED(event) )
519 {
520     Open( NET_ACCESS );
521 }
522
523 void Interface::OnOpenSat( wxCommandEvent& WXUNUSED(event) )
524 {
525     Open( SAT_ACCESS );
526 }
527
528 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
529 {
530     wxCommandEvent dummy;
531     playlist_t *p_playlist =
532         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
533                                        FIND_ANYWHERE );
534     if( p_playlist == NULL )
535     {
536         /* If the playlist is empty, open a file requester instead */
537         OnOpenFile( dummy );
538         return;
539     }
540
541     vlc_mutex_lock( &p_playlist->object_lock );
542     if( p_playlist->i_size )
543     {
544         vlc_mutex_unlock( &p_playlist->object_lock );
545
546         input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
547                                                        VLC_OBJECT_INPUT,
548                                                        FIND_ANYWHERE );
549         if( p_input == NULL )
550         {
551             /* No stream was playing, start one */
552             playlist_Play( p_playlist );
553             TogglePlayButton( PLAYING_S );
554             vlc_object_release( p_playlist );
555             return;
556         }
557
558         if( p_input->stream.control.i_status != PAUSE_S )
559         {
560             /* A stream is being played, pause it */
561             input_SetStatus( p_input, INPUT_STATUS_PAUSE );
562             TogglePlayButton( PAUSE_S );
563             vlc_object_release( p_playlist );
564             vlc_object_release( p_input );
565             return;
566         }
567
568         /* Stream is paused, resume it */
569         playlist_Play( p_playlist );
570         TogglePlayButton( PLAYING_S );
571         vlc_object_release( p_input );
572         vlc_object_release( p_playlist );
573     }
574     else
575     {
576         vlc_mutex_unlock( &p_playlist->object_lock );
577         vlc_object_release( p_playlist );
578         OnOpenFile( dummy );
579     }
580 }
581
582 void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
583 {
584     playlist_t * p_playlist =
585         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
586                                        FIND_ANYWHERE );
587     if( p_playlist == NULL )
588     {
589         return;
590     }
591
592     playlist_Stop( p_playlist );
593     TogglePlayButton( PAUSE_S );
594     vlc_object_release( p_playlist );
595 }
596
597 void Interface::OnSliderUpdate( wxScrollEvent& event )
598 {
599     vlc_mutex_lock( &p_intf->change_lock );
600
601 #ifdef WIN32
602     if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
603         || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
604     {
605 #endif
606         if( p_intf->p_sys->i_slider_pos != event.GetPosition()
607             && p_intf->p_sys->p_input )
608         {
609             p_intf->p_sys->i_slider_pos = event.GetPosition();
610             input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos *
611                         100 / SLIDER_MAX_POS,
612                         INPUT_SEEK_PERCENT | INPUT_SEEK_SET );
613         }
614
615 #ifdef WIN32
616         p_intf->p_sys->b_slider_free = VLC_TRUE;
617     }
618     else
619     {
620         p_intf->p_sys->b_slider_free = VLC_FALSE;
621
622         if( p_intf->p_sys->p_input )
623         {
624             /* Update stream date */
625 #define p_area p_intf->p_sys->p_input->stream.p_selected_area
626             char psz_time[ OFFSETTOTIME_MAX_SIZE ];
627
628             slider_box->SetLabel(
629                 input_OffsetToTime( p_intf->p_sys->p_input,
630                                     psz_time,
631                                     p_area->i_size * event.GetPosition()
632                                     / SLIDER_MAX_POS ) );
633 #undef p_area
634         }
635     }
636 #endif
637
638     vlc_mutex_unlock( &p_intf->change_lock );
639 }
640
641 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
642 {
643     playlist_t * p_playlist =
644         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
645                                        FIND_ANYWHERE );
646     if( p_playlist == NULL )
647     {
648         return;
649     }
650
651     playlist_Prev( p_playlist );
652     vlc_object_release( p_playlist );
653 }
654
655 void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
656 {
657     playlist_t * p_playlist =
658         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
659                                        FIND_ANYWHERE );
660     if( p_playlist == NULL )
661     {
662         return;
663     }
664
665     playlist_Next( p_playlist );
666     vlc_object_release( p_playlist );
667 }
668
669 void Interface::TogglePlayButton( int i_playing_status )
670 {
671     if( i_playing_status == i_old_playing_status )
672         return;
673
674     GetToolBar()->DeleteTool( PlayStream_Event );
675
676     if( i_playing_status == PLAYING_S )
677     {
678         GetToolBar()->InsertTool( 5, PlayStream_Event, _("Pause"),
679                                   wxBitmap( pause_xpm ) );
680     }
681     else
682     {
683         GetToolBar()->InsertTool( 5, PlayStream_Event, _("Play"),
684                                   wxBitmap( play_xpm ) );
685     }
686
687     GetToolBar()->Realize();
688
689     i_old_playing_status = i_playing_status;
690 }
691
692 #if !defined(__WXX11__)
693 /*****************************************************************************
694  * Definition of DragAndDrop class.
695  *****************************************************************************/
696 DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
697 {
698     p_intf = _p_intf;
699 }
700
701 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
702                                const wxArrayString& filenames )
703 {
704     unsigned int i;
705
706     /* Add dropped files to the playlist */
707
708     playlist_t *p_playlist =
709         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
710                                        FIND_ANYWHERE );
711     if( p_playlist == NULL )
712     {
713         return FALSE;
714     }
715
716     for( i = 0; i < filenames.GetCount(); i++ )
717         playlist_Add( p_playlist, (char *)filenames[i].c_str(),
718                       PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
719
720     /* Rebuild the playlist */
721     p_intf->p_sys->p_playlist_window->Rebuild();
722
723     vlc_object_release( p_playlist );
724
725     return TRUE;
726 }
727 #endif