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