interface.cpp 33.6 KB
Newer Older
gbazin's avatar
   
gbazin committed
1
2
3
/*****************************************************************************
 * interface.cpp : wxWindows plugin for vlc
 *****************************************************************************
hartman's avatar
hartman committed
4
 * Copyright (C) 2000-2004, 2003 VideoLAN
gbazin's avatar
gbazin committed
5
 * $Id$
gbazin's avatar
   
gbazin committed
6
 *
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
gbazin's avatar
   
gbazin committed
8
9
10
11
12
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
13
 *
gbazin's avatar
   
gbazin committed
14
15
16
17
18
19
20
21
22
23
24
25
26
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
27
#include <vlc/vlc.h>
gbazin's avatar
   
gbazin committed
28
#include <vlc/aout.h>
29
#include <vlc/vout.h>
gbazin's avatar
   
gbazin committed
30
#include <vlc/intf.h>
gbazin's avatar
   
gbazin committed
31
32
33
34
35
36
37

#include "wxwindows.h"

/* include the toolbar graphics */
#include "bitmaps/play.xpm"
#include "bitmaps/pause.xpm"
#include "bitmaps/stop.xpm"
38
#include "bitmaps/prev.xpm"
gbazin's avatar
   
gbazin committed
39
#include "bitmaps/next.xpm"
40
#include "bitmaps/eject.xpm"
gbazin's avatar
   
gbazin committed
41
#include "bitmaps/slow.xpm"
42
#include "bitmaps/fast.xpm"
43
#include "bitmaps/playlist.xpm"
44
#include "bitmaps/speaker.xpm"
gbazin's avatar
   
gbazin committed
45

46
47
#define TOOLBAR_BMP_WIDTH 16
#define TOOLBAR_BMP_HEIGHT 16
gbazin's avatar
   
gbazin committed
48

gbazin's avatar
   
gbazin committed
49
/* include the icon graphic */
Sam Hocevar's avatar
Sam Hocevar committed
50
#include "../../../share/vlc32x32.xpm"
gbazin's avatar
   
gbazin committed
51
52
53
54

/*****************************************************************************
 * Local class declarations.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class wxMenuExt: public wxMenu
{
public:
    /* Constructor */
    wxMenuExt( wxMenu* parentMenu, int id, const wxString& text,
                   const wxString& helpString, wxItemKind kind,
                   char *_psz_var, int _i_object_id, vlc_value_t _val,
                   int _i_val_type );

    virtual ~wxMenuExt() {};

    char *psz_var;
    int  i_val_type;
    int  i_object_id;
    vlc_value_t val;

private:

};
gbazin's avatar
   
gbazin committed
74

gbazin's avatar
   
gbazin committed
75
76
77
78
class wxVolCtrl: public wxGauge
{
public:
    /* Constructor */
79
80
    wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id,
               wxPoint = wxDefaultPosition, wxSize = wxSize( 20, -1 ) );
gbazin's avatar
   
gbazin committed
81
82
    virtual ~wxVolCtrl() {};

83
    void UpdateVolume();
gbazin's avatar
   
gbazin committed
84
85
86
87
88
89
90
91
92
93
94
95

    void OnChange( wxMouseEvent& event );

private:
    intf_thread_t *p_intf;

    DECLARE_EVENT_TABLE();
};

BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
    /* Mouse events */
    EVT_LEFT_DOWN(wxVolCtrl::OnChange)
96
    EVT_MOTION(wxVolCtrl::OnChange)
gbazin's avatar
   
gbazin committed
97
98
END_EVENT_TABLE()

gbazin's avatar
   
gbazin committed
99
100
101
102
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

gbazin's avatar
gbazin committed
103
104
DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );

gbazin's avatar
   
gbazin committed
105
106
107
108
/* IDs for the controls and the menu commands */
enum
{
    /* menu items */
zorglub's avatar
zorglub committed
109
    MenuDummy_Event = wxID_HIGHEST + 1000,
gbazin's avatar
   
gbazin committed
110
    Exit_Event = wxID_HIGHEST,
gbazin's avatar
   
gbazin committed
111
    OpenFileSimple_Event,
zorglub's avatar
zorglub committed
112
    OpenAdv_Event,
gbazin's avatar
   
gbazin committed
113
114
115
    OpenFile_Event,
    OpenDisc_Event,
    OpenNet_Event,
gbazin's avatar
gbazin committed
116
    OpenCapture_Event,
gbazin's avatar
   
gbazin committed
117
    OpenSat_Event,
zorglub's avatar
zorglub committed
118
    OpenOther_Event,
gbazin's avatar
   
gbazin committed
119
120
    EjectDisc_Event,

121
    Wizard_Event,
zorglub's avatar
zorglub committed
122

123
    Playlist_Event,
gbazin's avatar
   
gbazin committed
124
    Logs_Event,
125
    FileInfo_Event,
gbazin's avatar
   
gbazin committed
126
127

    Prefs_Event,
gbazin's avatar
gbazin committed
128
    Extended_Event,
129
//    Undock_Event,
gbazin's avatar
gbazin committed
130
    Bookmarks_Event,
gbazin's avatar
   
gbazin committed
131
    Skins_Event,
gbazin's avatar
   
gbazin committed
132
133
134
135
136

    SliderScroll_Event,
    StopStream_Event,
    PlayStream_Event,
    PrevStream_Event,
gbazin's avatar
   
gbazin committed
137
    NextStream_Event,
gbazin's avatar
   
gbazin committed
138
139
    SlowStream_Event,
    FastStream_Event,
gbazin's avatar
   
gbazin committed
140
141
142
143

    /* 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) */
gbazin's avatar
   
gbazin committed
144
    About_Event = wxID_ABOUT
gbazin's avatar
   
gbazin committed
145
146
147
148
149
150
};

BEGIN_EVENT_TABLE(Interface, wxFrame)
    /* Menu events */
    EVT_MENU(Exit_Event, Interface::OnExit)
    EVT_MENU(About_Event, Interface::OnAbout)
gbazin's avatar
   
gbazin committed
151
152
153
154
155

    EVT_MENU(Playlist_Event, Interface::OnShowDialog)
    EVT_MENU(Logs_Event, Interface::OnShowDialog)
    EVT_MENU(FileInfo_Event, Interface::OnShowDialog)
    EVT_MENU(Prefs_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
156

gbazin's avatar
   
gbazin committed
157
158
    EVT_MENU_OPEN(Interface::OnMenuOpen)

159
160
    EVT_MENU( Extended_Event, Interface::OnExtended )
//    EVT_MENU( Undock_Event, Interface::OnUndock )
zorglub's avatar
zorglub committed
161

162
    EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
zorglub's avatar
zorglub committed
163

gbazin's avatar
   
gbazin committed
164
#if defined( __WXMSW__ ) || defined( __WXMAC__ )
gbazin's avatar
   
gbazin committed
165
    EVT_CONTEXT_MENU(Interface::OnContextMenu2)
gbazin's avatar
   
gbazin committed
166
#endif
gbazin's avatar
   
gbazin committed
167
    EVT_RIGHT_UP(Interface::OnContextMenu)
gbazin's avatar
   
gbazin committed
168

gbazin's avatar
   
gbazin committed
169
    /* Toolbar events */
gbazin's avatar
   
gbazin committed
170
    EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
zorglub's avatar
zorglub committed
171
    EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
172
173
174
    EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
    EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
    EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
gbazin's avatar
gbazin committed
175
    EVT_MENU(OpenCapture_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
176
    EVT_MENU(OpenSat_Event, Interface::OnShowDialog)
177
    EVT_MENU(Wizard_Event, Interface::OnShowDialog)
gbazin's avatar
   
gbazin committed
178
179
180
181
    EVT_MENU(StopStream_Event, Interface::OnStopStream)
    EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
    EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
    EVT_MENU(NextStream_Event, Interface::OnNextStream)
gbazin's avatar
   
gbazin committed
182
183
    EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
    EVT_MENU(FastStream_Event, Interface::OnFastStream)
gbazin's avatar
   
gbazin committed
184

gbazin's avatar
   
gbazin committed
185
186
    /* Slider events */
    EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
zorglub's avatar
zorglub committed
187

gbazin's avatar
gbazin committed
188
    /* Custom events */
189
190
    EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
    EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
gbazin's avatar
gbazin committed
191

gbazin's avatar
   
gbazin committed
192
193
194
195
196
197
END_EVENT_TABLE()

/*****************************************************************************
 * Constructor.
 *****************************************************************************/
Interface::Interface( intf_thread_t *_p_intf ):
gbazin's avatar
   
gbazin committed
198
    wxFrame( NULL, -1, wxT("VLC media player"),
199
             wxDefaultPosition, wxSize(700,100), wxDEFAULT_FRAME_STYLE )
gbazin's avatar
   
gbazin committed
200
201
202
{
    /* Initializations */
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
203
    i_old_playing_status = PAUSE_S;
zorglub's avatar
zorglub committed
204
    b_extra = VLC_FALSE;
205
206
207
//    b_undock = VLC_FALSE;

    extra_window = NULL;
gbazin's avatar
   
gbazin committed
208

gbazin's avatar
   
gbazin committed
209
    /* Give our interface a nice little icon */
gbazin's avatar
   
gbazin committed
210
    SetIcon( wxIcon( vlc_xpm ) );
gbazin's avatar
   
gbazin committed
211
212

    /* Create a sizer for the main frame */
zorglub's avatar
zorglub committed
213
    frame_sizer = new wxBoxSizer( wxVERTICAL );
gbazin's avatar
   
gbazin committed
214
215
    SetSizer( frame_sizer );

216
217
218
219
    /* Create a dummy widget that can get the keyboard focus */
    wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
                                      wxSize(0,0) );
    p_dummy->SetFocus();
220
    frame_sizer->Add( p_dummy, 0, 0 );
zorglub's avatar
zorglub committed
221

gbazin's avatar
   
gbazin committed
222
223
224
225
226
227
    /* Creation of the menu bar */
    CreateOurMenuBar();

    /* Creation of the tool bar */
    CreateOurToolBar();

zorglub's avatar
zorglub committed
228
    /* Create the extra panel */
229
    extra_frame = new ExtraPanel( p_intf, this );
zorglub's avatar
zorglub committed
230
231
232
    frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
    frame_sizer->Hide( extra_frame );

233
    /* Creation of the status bar
gbazin's avatar
   
gbazin committed
234
235
     * Helptext for menu items and toolbar tools will automatically get
     * displayed here. */
gbazin's avatar
   
gbazin committed
236
237
238
239
240
    int i_status_width[3] = {-6, -2, -9};
    statusbar = CreateStatusBar( 3 );                            /* 2 fields */
    statusbar->SetStatusWidths( 3, i_status_width );
    statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );

gbazin's avatar
gbazin committed
241
242
243
244
245
246
247
    /* Video window */
    if( config_GetInt( p_intf, "wxwin-embed" ) )
    {
        VideoWindow( p_intf, this );
        frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND , 0 );
    }

248
249
250
251
252
253
254
255
    /* Creation of the slider sub-window */
    CreateOurSlider();
    frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
    frame_sizer->Hide( slider_frame );

    /* Make sure we've got the right background colour */
    SetBackgroundColour( slider_frame->GetBackgroundColour() );

gbazin's avatar
   
gbazin committed
256
257
    /* Layout everything */
    frame_sizer->Layout();
gbazin's avatar
   
gbazin committed
258
    frame_sizer->Fit(this);
gbazin's avatar
   
gbazin committed
259

260
#if wxUSE_DRAG_AND_DROP
gbazin's avatar
   
gbazin committed
261
262
    /* Associate drop targets with the main interface */
    SetDropTarget( new DragAndDrop( p_intf ) );
gbazin's avatar
   
gbazin committed
263
#endif
264

265
    SetupHotkeys();
gbazin's avatar
   
gbazin committed
266
267
268

    /* Start timer */
    timer = new Timer( p_intf, this );
gbazin's avatar
   
gbazin committed
269
270
271
272
}

Interface::~Interface()
{
gbazin's avatar
   
gbazin committed
273
274
275
276
    if( p_intf->p_sys->p_wxwindow )
    {
        delete p_intf->p_sys->p_wxwindow;
    }
gbazin's avatar
   
gbazin committed
277

gbazin's avatar
   
gbazin committed
278
    /* Clean up */
gbazin's avatar
   
gbazin committed
279
    delete timer;
gbazin's avatar
   
gbazin committed
280
}
gbazin's avatar
   
gbazin committed
281

282
283
284
285
286
287
void Interface::Init()
{
    /* Misc init */
    SetupHotkeys();
}

288
289
290
291
292
293
void Interface::Update()
{
    /* Misc updates */
    ((wxVolCtrl *)volctrl)->UpdateVolume();
}

294
void Interface::OnControlEvent( wxCommandEvent& event )
gbazin's avatar
gbazin committed
295
{
296
297
298
299
300
301
302
303
304
305
306
307
308
309
    switch( event.GetId() )
    {
    case 0:
        frame_sizer->Layout();
        frame_sizer->Fit(this);
        break;

    case 1:
        long i_style = GetWindowStyle();
        if( event.GetInt() ) i_style |= wxSTAY_ON_TOP;
        else i_style &= ~wxSTAY_ON_TOP;
        SetWindowStyle( i_style );
        break;
    }
gbazin's avatar
gbazin committed
310
311
}

gbazin's avatar
   
gbazin committed
312
313
314
315
316
317
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
void Interface::CreateOurMenuBar()
{
    /* Create the "File" menu */
gbazin's avatar
   
gbazin committed
318
    wxMenu *file_menu = new wxMenu;
319
    file_menu->Append( OpenFileSimple_Event,
gbazin's avatar
gbazin committed
320
                       wxU(_("Quick &Open File...\tCtrl-O")) );
zorglub's avatar
zorglub committed
321
322

    file_menu->AppendSeparator();
gbazin's avatar
gbazin committed
323
324
    file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")) );
    file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")) );
325
    file_menu->Append( OpenNet_Event,
gbazin's avatar
gbazin committed
326
327
328
                       wxU(_("Open &Network Stream...\tCtrl-N")) );
    file_menu->Append( OpenCapture_Event,
                       wxU(_("Open &Capture Device...\tCtrl-C")) );
zorglub's avatar
zorglub committed
329

gbazin's avatar
   
gbazin committed
330
    file_menu->AppendSeparator();
331
    file_menu->Append( Wizard_Event, wxU(_("&Wizard...\tCtrl-W")) );
gbazin's avatar
   
gbazin committed
332
    file_menu->AppendSeparator();
gbazin's avatar
gbazin committed
333
    file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")) );
gbazin's avatar
   
gbazin committed
334

gbazin's avatar
   
gbazin committed
335
    /* Create the "View" menu */
gbazin's avatar
   
gbazin committed
336
    wxMenu *view_menu = new wxMenu;
gbazin's avatar
gbazin committed
337
338
    view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")) );
    view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );
339
    view_menu->Append( FileInfo_Event,
gbazin's avatar
gbazin committed
340
                       wxU(_("Stream and Media &info...\tCtrl-I")) );
gbazin's avatar
   
gbazin committed
341

342
343
344
345
346
    /* Create the "Auto-generated" menus */
    p_settings_menu = SettingsMenu( p_intf, this );
    p_audio_menu = AudioMenu( p_intf, this );
    p_video_menu = VideoMenu( p_intf, this );
    p_navig_menu = NavigMenu( p_intf, this );
gbazin's avatar
   
gbazin committed
347

gbazin's avatar
   
gbazin committed
348
    /* Create the "Help" menu */
gbazin's avatar
   
gbazin committed
349
    wxMenu *help_menu = new wxMenu;
gbazin's avatar
gbazin committed
350
    help_menu->Append( About_Event, wxU(_("About VLC media player")) );
gbazin's avatar
   
gbazin committed
351
352
353

    /* Append the freshly created menus to the menu bar... */
    wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
gbazin's avatar
   
gbazin committed
354
355
    menubar->Append( file_menu, wxU(_("&File")) );
    menubar->Append( view_menu, wxU(_("&View")) );
gbazin's avatar
   
gbazin committed
356
    menubar->Append( p_settings_menu, wxU(_("&Settings")) );
gbazin's avatar
   
gbazin committed
357
358
    menubar->Append( p_audio_menu, wxU(_("&Audio")) );
    menubar->Append( p_video_menu, wxU(_("&Video")) );
gbazin's avatar
   
gbazin committed
359
    menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
gbazin's avatar
   
gbazin committed
360
    menubar->Append( help_menu, wxU(_("&Help")) );
gbazin's avatar
   
gbazin committed
361
362
363
364

    /* Attach the menu bar to the frame */
    SetMenuBar( menubar );

365
366
    /* Find out size of menu bar */
    int i_size = 0;
367
    for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
368
369
370
    {
        int i_width, i_height;
        menubar->GetTextExtent( menubar->GetLabelTop(i), &i_width, &i_height );
371
372
        i_size += i_width +
#if defined(__WXGTK__)
373
            22 /* approximate margin */;
374
#else
375
#if (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 5) && (wxRELEASE_NUMBER < 3)
376
            4 /* approximate margin */;
377
378
379
#else
            15 /* approximate margin */;
#endif
380
#endif
381
382
383
    }
    frame_sizer->SetMinSize( i_size, -1 );

gbazin's avatar
   
gbazin committed
384
385
386
    /* Intercept all menu events in our custom event handler */
    PushEventHandler( new MenuEvtHandler( p_intf, this ) );

387
#if wxUSE_DRAG_AND_DROP
gbazin's avatar
   
gbazin committed
388
389
    /* Associate drop targets with the menubar */
    menubar->SetDropTarget( new DragAndDrop( p_intf ) );
gbazin's avatar
   
gbazin committed
390
#endif
gbazin's avatar
   
gbazin committed
391
392
}

393
394
395
396
397
398
399
400
401
402
class VLCVolCtrl : public wxControl
{
public:
    VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
    virtual ~VLCVolCtrl() {};

    virtual void OnPaint( wxPaintEvent &event );

  private:
    DECLARE_EVENT_TABLE()
403
    int i_y_offset;
404
405
406
407
408
409
};

BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
   EVT_PAINT(VLCVolCtrl::OnPaint)
END_EVENT_TABLE()

410
411
412
413
414
#if defined(__WXGTK__)
#define VLCVOL_HEIGHT p_parent->GetSize().GetHeight()
#else
#define VLCVOL_HEIGHT TOOLBAR_BMP_HEIGHT
#endif
415
416
VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
                        wxGauge **pp_volctrl )
417
418
419
  :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, VLCVOL_HEIGHT ),
              wxBORDER_NONE ),
   i_y_offset((VLCVOL_HEIGHT - TOOLBAR_BMP_HEIGHT) / 2)
420
{
421
422
    *pp_volctrl = new wxVolCtrl( p_intf, this, -1, wxPoint( 18, i_y_offset ),
                                 wxSize( 44, TOOLBAR_BMP_HEIGHT ) );
423
424
425
426
427
428
}

void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
{
    wxPaintDC dc( this );
    wxBitmap mPlayBitmap( speaker_xpm );
429
    dc.DrawBitmap( mPlayBitmap, 0, i_y_offset, TRUE );
430
431
}

gbazin's avatar
   
gbazin committed
432
433
void Interface::CreateOurToolBar()
{
434
#define HELP_OPEN N_("Open")
hartman's avatar
hartman committed
435
436
437
438
#define HELP_STOP N_("Stop")
#define HELP_PLAY N_("Play")
#define HELP_PAUSE N_("Pause")
#define HELP_PLO N_("Playlist")
gbazin's avatar
   
gbazin committed
439
440
#define HELP_PLP N_("Previous playlist item")
#define HELP_PLN N_("Next playlist item")
gbazin's avatar
   
gbazin committed
441
442
#define HELP_SLOW N_("Play slower")
#define HELP_FAST N_("Play faster")
gbazin's avatar
   
gbazin committed
443

gbazin's avatar
   
gbazin committed
444
445
    wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
                         * version because we don't include wx.rc */
gbazin's avatar
   
gbazin committed
446

447
448
    wxToolBar *toolbar =
        CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
gbazin's avatar
   
gbazin committed
449

gbazin's avatar
   
gbazin committed
450
451
    toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );

452
453
454
    toolbar->AddTool( OpenFile_Event, wxT(""),
                      wxBitmap( eject_xpm ), wxU(_(HELP_OPEN)) );
    toolbar->AddSeparator();
gbazin's avatar
   
gbazin committed
455
    toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( play_xpm ),
gbazin's avatar
   
gbazin committed
456
                      wxU(_(HELP_PLAY)) );
457
458
459
460
461
462
#if 0
    toolbar->AddTool( PlayStream_Event, wxT(""), wxBitmap( pause_xpm ),
                      wxU(_(HELP_PAUSE)) );
#endif
    toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
                      wxU(_(HELP_STOP)) );
gbazin's avatar
   
gbazin committed
463
    toolbar->AddSeparator();
gbazin's avatar
   
gbazin committed
464
    toolbar->AddTool( PrevStream_Event, wxT(""),
465
466
467
468
469
                      wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
    toolbar->AddTool( SlowStream_Event, wxT(""),
                      wxBitmap( slow_xpm ), wxU(_(HELP_SLOW)) );
    toolbar->AddTool( FastStream_Event, wxT(""),
                      wxBitmap( fast_xpm ), wxU(_(HELP_FAST)) );
gbazin's avatar
   
gbazin committed
470
    toolbar->AddTool( NextStream_Event, wxT(""), wxBitmap( next_xpm ),
gbazin's avatar
   
gbazin committed
471
                      wxU(_(HELP_PLN)) );
472
    toolbar->AddSeparator();
473
    toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( playlist_xpm ),
474
                      wxU(_(HELP_PLO)) );
gbazin's avatar
   
gbazin committed
475

476
    wxControl *p_dummy_ctrl =
477
        new wxControl( toolbar, -1, wxDefaultPosition,
478
                       wxSize(35, 16 ), wxBORDER_NONE );
479

480
    toolbar->AddControl( p_dummy_ctrl );
gbazin's avatar
   
gbazin committed
481

482
483
484
485
    VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
    toolbar->AddControl( sound_control );

    toolbar->Realize();
gbazin's avatar
   
gbazin committed
486

487
#if wxUSE_DRAG_AND_DROP
gbazin's avatar
   
gbazin committed
488
489
    /* Associate drop targets with the toolbar */
    toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
gbazin's avatar
   
gbazin committed
490
#endif
gbazin's avatar
   
gbazin committed
491
492
}

gbazin's avatar
   
gbazin committed
493
void Interface::CreateOurSlider()
gbazin's avatar
   
gbazin committed
494
{
gbazin's avatar
   
gbazin committed
495
    /* Create a new frame and sizer containing the slider */
gbazin's avatar
   
gbazin committed
496
    slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
gbazin's avatar
   
gbazin committed
497
    slider_frame->SetAutoLayout( TRUE );
498
499
    wxBoxSizer *frame_sizer = new wxBoxSizer( wxHORIZONTAL );
    //frame_sizer->SetMinSize( -1, 50 );
gbazin's avatar
   
gbazin committed
500
501
502
503

    /* Create slider */
    slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
                           SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
gbazin's avatar
   
gbazin committed
504
505

    /* Add everything to the frame */
506
    frame_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
507
508
509
    slider_frame->SetSizer( frame_sizer );
    frame_sizer->Layout();
    frame_sizer->SetSizeHints(slider_frame);
gbazin's avatar
   
gbazin committed
510
511
512

    /* Hide the slider by default */
    slider_frame->Hide();
gbazin's avatar
   
gbazin committed
513
514
}

zorglub's avatar
zorglub committed
515

516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
static int ConvertHotkeyModifiers( int i_hotkey )
{
    int i_accel_flags = 0;
    if( i_hotkey & KEY_MODIFIER_ALT ) i_accel_flags |= wxACCEL_ALT;
    if( i_hotkey & KEY_MODIFIER_CTRL ) i_accel_flags |= wxACCEL_CTRL;
    if( i_hotkey & KEY_MODIFIER_SHIFT ) i_accel_flags |= wxACCEL_SHIFT;
    if( !i_accel_flags ) i_accel_flags = wxACCEL_NORMAL;
    return i_accel_flags;
}

static int ConvertHotkey( int i_hotkey )
{
    int i_key = i_hotkey & ~KEY_MODIFIER;
    if( i_key & KEY_ASCII ) return i_key & KEY_ASCII;
    else if( i_key & KEY_SPECIAL )
    {
        switch ( i_key )
        {
        case KEY_LEFT: return WXK_LEFT;
        case KEY_RIGHT: return WXK_RIGHT;
        case KEY_UP: return WXK_UP;
        case KEY_DOWN: return WXK_DOWN;
        case KEY_SPACE: return WXK_SPACE;
        case KEY_ENTER: return WXK_RETURN;
        case KEY_F1: return WXK_F1;
        case KEY_F2: return WXK_F2;
        case KEY_F3: return WXK_F3;
        case KEY_F4: return WXK_F4;
        case KEY_F5: return WXK_F5;
        case KEY_F6: return WXK_F6;
        case KEY_F7: return WXK_F7;
        case KEY_F8: return WXK_F8;
        case KEY_F9: return WXK_F9;
        case KEY_F10: return WXK_F10;
        case KEY_F11: return WXK_F11;
        case KEY_F12: return WXK_F12;
        case KEY_HOME: return WXK_HOME;
        case KEY_END: return WXK_HOME;
        case KEY_MENU: return WXK_MENU;
        case KEY_ESC: return WXK_ESCAPE;
        case KEY_PAGEUP: return WXK_PRIOR;
        case KEY_PAGEDOWN: return WXK_NEXT;
        case KEY_TAB: return WXK_TAB;
        case KEY_BACKSPACE: return WXK_BACK;
        }
    }
    return WXK_F24;
}

565
void Interface::SetupHotkeys()
566
{
567
568
    struct vlc_t::hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
    int i_hotkeys;
569

570
571
572
573
574
575
576
577
578
    /* Count number of hoteys */
    for( i_hotkeys = 0; p_hotkeys[i_hotkeys].psz_action != NULL; i_hotkeys++ );

    p_intf->p_sys->i_first_hotkey_event = wxID_HIGHEST + 7000;
    p_intf->p_sys->i_hotkeys = i_hotkeys;

    wxAcceleratorEntry p_entries[i_hotkeys];

    /* Setup the hotkeys as accelerators */
579
    for( int i = 0; i < i_hotkeys; i++ )
580
581
582
583
584
    {
        p_entries[i].Set( ConvertHotkeyModifiers( p_hotkeys[i].i_key ),
                          ConvertHotkey( p_hotkeys[i].i_key ),
                          p_intf->p_sys->i_first_hotkey_event + i );
    }
zorglub's avatar
zorglub committed
585

586
    wxAcceleratorTable accel( i_hotkeys, p_entries );
zorglub's avatar
zorglub committed
587

588
589
590
591
592
593
594
595
596
    if( !accel.Ok() )
    {
        msg_Err( p_intf, "invalid accelerator table" );
    }
    else
    {
        SetAcceleratorTable( accel );
        msg_Dbg( p_intf, "accelerator table loaded" );
    }
597
598
}

gbazin's avatar
   
gbazin committed
599
/*****************************************************************************
gbazin's avatar
   
gbazin committed
600
 * Event Handlers.
gbazin's avatar
   
gbazin committed
601
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
602

gbazin's avatar
   
gbazin committed
603
604
void Interface::OnMenuOpen(wxMenuEvent& event)
{
605
606
#if defined( __WXMSW__ )
#   define GetEventObject GetMenu
607
#endif
608
609

    if( event.GetEventObject() == p_settings_menu )
gbazin's avatar
   
gbazin committed
610
    {
611
612
613
614
        p_settings_menu = SettingsMenu( p_intf, this, p_settings_menu );

        /* Add static items */
        p_settings_menu->AppendCheckItem( Extended_Event,
gbazin's avatar
gbazin committed
615
            wxU(_("&Extended GUI") ) );
616
        if( b_extra ) p_settings_menu->Check( Extended_Event, TRUE );
617
618
619
620
621
#if 0
        p_settings_menu->AppendCheckItem( Undock_Event,
            wxU(_("&Undock Ext. GUI") ) );
        if( b_undock ) p_settings_menu->Check( Undock_Event, TRUE );
#endif
622
        p_settings_menu->Append( Bookmarks_Event, wxU(_("&Bookmarks...") ) );
gbazin's avatar
gbazin committed
623
        p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")) );
gbazin's avatar
   
gbazin committed
624
    }
625

gbazin's avatar
   
gbazin committed
626
    else if( event.GetEventObject() == p_audio_menu )
gbazin's avatar
   
gbazin committed
627
    {
628
        p_audio_menu = AudioMenu( p_intf, this, p_audio_menu );
gbazin's avatar
   
gbazin committed
629
    }
630

gbazin's avatar
   
gbazin committed
631
632
    else if( event.GetEventObject() == p_video_menu )
    {
633
        p_video_menu = VideoMenu( p_intf, this, p_video_menu );
gbazin's avatar
   
gbazin committed
634
    }
635

gbazin's avatar
   
gbazin committed
636
637
    else if( event.GetEventObject() == p_navig_menu )
    {
638
        p_navig_menu = NavigMenu( p_intf, this, p_navig_menu );
gbazin's avatar
   
gbazin committed
639
    }
640
641
642
643

#if defined( __WXMSW__ )
#   undef GetEventObject
#endif
gbazin's avatar
   
gbazin committed
644
645
}

gbazin's avatar
   
gbazin committed
646
#if defined( __WXMSW__ ) || defined( __WXMAC__ )
gbazin's avatar
   
gbazin committed
647
void Interface::OnContextMenu2(wxContextMenuEvent& event)
gbazin's avatar
   
gbazin committed
648
{
gbazin's avatar
   
gbazin committed
649
650
651
652
653
654
655
    /* Only show the context menu for the main interface */
    if( GetId() != event.GetId() )
    {
        event.Skip();
        return;
    }

gbazin's avatar
   
gbazin committed
656
    if( p_intf->p_sys->pf_show_dialog )
657
        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
gbazin's avatar
   
gbazin committed
658
}
gbazin's avatar
   
gbazin committed
659
#endif
gbazin's avatar
   
gbazin committed
660
661
void Interface::OnContextMenu(wxMouseEvent& event)
{
gbazin's avatar
   
gbazin committed
662
    if( p_intf->p_sys->pf_show_dialog )
663
        p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU, 1, 0 );
gbazin's avatar
   
gbazin committed
664
}
gbazin's avatar
   
gbazin committed
665

gbazin's avatar
   
gbazin committed
666
667
668
669
670
671
672
673
674
void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
{
    /* TRUE is to force the frame to close. */
    Close(TRUE);
}

void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
{
    wxString msg;
Sam Hocevar's avatar
Sam Hocevar committed
675
    msg.Printf( wxString(wxT("VLC media player " PACKAGE_VERSION)) +
gbazin's avatar
   
gbazin committed
676
        wxU(_(" (wxWindows interface)\n\n")) +
hartman's avatar
hartman committed
677
        wxU(_("(c) 1996-2004 - the VideoLAN Team\n\n")) +
zorglub's avatar
zorglub committed
678
        wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") +
gbazin's avatar
   
gbazin committed
679
        wxU(_("The VideoLAN team <videolan@videolan.org>\n"
gbazin's avatar
   
gbazin committed
680
              "http://www.videolan.org/\n\n")) );
gbazin's avatar
   
gbazin committed
681

gbazin's avatar
   
gbazin committed
682
683
    wxMessageBox( msg, wxString::Format(wxU(_("About %s")),
                  wxT("VLC media player")), wxOK | wxICON_INFORMATION, this );
gbazin's avatar
   
gbazin committed
684
685
}

gbazin's avatar
   
gbazin committed
686
void Interface::OnShowDialog( wxCommandEvent& event )
gbazin's avatar
   
gbazin committed
687
{
gbazin's avatar
   
gbazin committed
688
    if( p_intf->p_sys->pf_show_dialog )
gbazin's avatar
   
gbazin committed
689
    {
gbazin's avatar
   
gbazin committed
690
        int i_id;
gbazin's avatar
   
gbazin committed
691

gbazin's avatar
   
gbazin committed
692
693
694
695
696
        switch( event.GetId() )
        {
        case OpenFileSimple_Event:
            i_id = INTF_DIALOG_FILE_SIMPLE;
            break;
zorglub's avatar
zorglub committed
697
698
        case OpenAdv_Event:
            i_id = INTF_DIALOG_FILE;
gbazin's avatar
   
gbazin committed
699
700
701
702
703
704
705
706
707
        case OpenFile_Event:
            i_id = INTF_DIALOG_FILE;
            break;
        case OpenDisc_Event:
            i_id = INTF_DIALOG_DISC;
            break;
        case OpenNet_Event:
            i_id = INTF_DIALOG_NET;
            break;
gbazin's avatar
gbazin committed
708
709
710
        case OpenCapture_Event:
            i_id = INTF_DIALOG_CAPTURE;
            break;
gbazin's avatar
   
gbazin committed
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
        case OpenSat_Event:
            i_id = INTF_DIALOG_SAT;
            break;
        case Playlist_Event:
            i_id = INTF_DIALOG_PLAYLIST;
            break;
        case Logs_Event:
            i_id = INTF_DIALOG_MESSAGES;
            break;
        case FileInfo_Event:
            i_id = INTF_DIALOG_FILEINFO;
            break;
        case Prefs_Event:
            i_id = INTF_DIALOG_PREFS;
            break;
726
727
728
        case Wizard_Event:
            i_id = INTF_DIALOG_WIZARD;
            break;
gbazin's avatar
gbazin committed
729
730
731
        case Bookmarks_Event:
            i_id = INTF_DIALOG_BOOKMARKS;
            break;
gbazin's avatar
   
gbazin committed
732
733
734
735
        default:
            i_id = INTF_DIALOG_FILE;
            break;
        }
gbazin's avatar
   
gbazin committed
736

gbazin's avatar
   
gbazin committed
737
        p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
gbazin's avatar
   
gbazin committed
738
    }
gbazin's avatar
   
gbazin committed
739
740
}

gbazin's avatar
gbazin committed
741
void Interface::OnExtended(wxCommandEvent& event)
zorglub's avatar
zorglub committed
742
{
743
744
745
    b_extra = (b_extra == VLC_TRUE ? VLC_FALSE : VLC_TRUE );

    if( b_extra == VLC_FALSE )
zorglub's avatar
zorglub committed
746
    {
747
748
        extra_frame->Hide();
        frame_sizer->Hide( extra_frame );
zorglub's avatar
zorglub committed
749
750
751
    }
    else
    {
752
753
        extra_frame->Show();
        frame_sizer->Show( extra_frame );
zorglub's avatar
zorglub committed
754
755
756
757
758
    }
    frame_sizer->Layout();
    frame_sizer->Fit(this);
}

759
760
#if 0
        if( b_undock == VLC_TRUE )
zorglub's avatar
zorglub committed
761
        {
762
763
764
765
766
767
                fprintf(stderr,"Deleting window\n");
            if( extra_window )
            {
                delete extra_window;
                extra_window = NULL;
            }
zorglub's avatar
zorglub committed
768
769
770
        }
        else
        {
771
772
773
774
            extra_frame->Hide();
            frame_sizer->Hide( extra_frame );
            frame_sizer->Layout();
            frame_sizer->Fit(this);
zorglub's avatar
zorglub committed
775
776
777
778
        }
    }
    else
    {
779
        if( b_undock == VLC_TRUE )
zorglub's avatar
zorglub committed
780
        {
781
782
783
784
785
786
787
788
789
790
791
792
                fprintf(stderr,"Creating window\n");
            extra_frame->Hide();
            frame_sizer->Hide( extra_frame );
            frame_sizer->Detach( extra_frame );
            frame_sizer->Layout();
            frame_sizer->Fit(this);
            extra_window = new ExtraWindow( p_intf, this, extra_frame );
        }
        else
        {
                fprintf(stderr,"Deleting window\n");
            if( extra_window )
793
            {
794
                delete extra_window;
795
            }
796
797
798
799
            extra_frame->Show();
            frame_sizer->Show( extra_frame );
            frame_sizer->Layout();
            frame_sizer->Fit(this);
zorglub's avatar
zorglub committed
800
801
802
803
        }
    }
}

804
void Interface::OnUndock(wxCommandEvent& event)
zorglub's avatar
zorglub committed
805
{
806
    b_undock = (b_undock == VLC_TRUE ? VLC_FALSE : VLC_TRUE );
zorglub's avatar
zorglub committed
807

808
809
810
    if( b_extra == VLC_TRUE )
    {
        if( b_undock == VLC_FALSE )
811
        {
812
813
814
815
816
817
818
819
820
821
                fprintf(stderr,"Deleting window\n");
            if( extra_window )
            {
                delete extra_window;
                extra_window = NULL;
            }
            extra_frame->Show();
            frame_sizer->Show( extra_frame );
            frame_sizer->Layout();
            frame_sizer->Fit(this);
822
        }
823
        else
824
        {
825
826
827
828
829
830
831
                fprintf(stderr,"Creating window\n");
            extra_frame->Hide();
            frame_sizer->Hide( extra_frame );
            frame_sizer->Detach( extra_frame );
            frame_sizer->Layout();
            frame_sizer->Fit(this);
            extra_window = new ExtraWindow( p_intf, this, extra_frame );
832
        }
zorglub's avatar
zorglub committed
833
834
    }
}
835
#endif
zorglub's avatar
zorglub committed
836

gbazin's avatar
   
gbazin committed
837
838
839
840
841
842
void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
{
    wxCommandEvent dummy;
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
gbazin's avatar
   
gbazin committed
843
    if( p_playlist == NULL ) return;
gbazin's avatar
   
gbazin committed
844

zorglub's avatar
zorglub committed
845
    if( p_playlist->i_size && p_playlist->i_enabled )
gbazin's avatar
   
gbazin committed
846
    {
847
848
        vlc_value_t state;

gbazin's avatar
   
gbazin committed
849
850
851
852
853
854
855
        input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf,
                                                       VLC_OBJECT_INPUT,
                                                       FIND_ANYWHERE );
        if( p_input == NULL )
        {
            /* No stream was playing, start one */
            playlist_Play( p_playlist );
gbazin's avatar
   
gbazin committed
856
            TogglePlayButton( PLAYING_S );
gbazin's avatar
   
gbazin committed
857
858
859
860
            vlc_object_release( p_playlist );
            return;
        }

861
862
863
        var_Get( p_input, "state", &state );

        if( state.i_int != PAUSE_S )
gbazin's avatar
   
gbazin committed
864
865
        {
            /* A stream is being played, pause it */
866
            state.i_int = PAUSE_S;
gbazin's avatar
   
gbazin committed
867
        }
868
869
870
871
872
873
        else
        {
            /* Stream is paused, resume it */
            state.i_int = PLAYING_S;
        }
        var_Set( p_input, "state", state );
gbazin's avatar
   
gbazin committed
874

875
        TogglePlayButton( state.i_int );
gbazin's avatar
   
gbazin committed
876
        vlc_object_release( p_input );
gbazin's avatar
   
gbazin committed
877
878
879
880
        vlc_object_release( p_playlist );
    }
    else
    {
gbazin's avatar
   
gbazin committed
881
        /* If the playlist is empty, open a file requester instead */
gbazin's avatar
   
gbazin committed
882
        vlc_object_release( p_playlist );
gbazin's avatar
   
gbazin committed
883
        OnShowDialog( dummy );
gbazin's avatar
   
gbazin committed
884
885
886
887
888
889
890
891
892
893
894
895
896
897
    }
}

void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) )
{
    playlist_t * p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    playlist_Stop( p_playlist );
gbazin's avatar
   
gbazin committed
898
    TogglePlayButton( PAUSE_S );
gbazin's avatar
   
gbazin committed
899
900
901
902
903
    vlc_object_release( p_playlist );
}

void Interface::OnSliderUpdate( wxScrollEvent& event )
{
gbazin's avatar
   
gbazin committed
904
905
    vlc_mutex_lock( &p_intf->change_lock );

gbazin's avatar
   
gbazin committed
906
#ifdef WIN32
gbazin's avatar
   
gbazin committed
907
    if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
gbazin's avatar
   
gbazin committed
908
        || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
gbazin's avatar
   
gbazin committed
909
    {
gbazin's avatar
   
gbazin committed
910
#endif
gbazin's avatar
   
gbazin committed
911
912
913
        if( p_intf->p_sys->i_slider_pos != event.GetPosition()
            && p_intf->p_sys->p_input )
        {
914
915
916
917
            vlc_value_t pos;
            pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;

            var_Set( p_intf->p_sys->p_input, "position", pos );
gbazin's avatar
   
gbazin committed
918
        }
gbazin's avatar
   
gbazin committed
919

gbazin's avatar
   
gbazin committed
920
#ifdef WIN32
gbazin's avatar
   
gbazin committed
921
922
923
924
925
926
        p_intf->p_sys->b_slider_free = VLC_TRUE;
    }
    else
    {
        p_intf->p_sys->b_slider_free = VLC_FALSE;

gbazin's avatar
   
gbazin committed
927
928
929
        if( p_intf->p_sys->p_input )
        {
            /* Update stream date */
930
931
932
933
            char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
            mtime_t i_seconds;
            vlc_value_t val;

934
935
            i_seconds = var_GetTime( p_intf->p_sys->p_input, "length" ) / I64C(1000000 );
            secstotimestr( psz_total, i_seconds );
gbazin's avatar
   
gbazin committed
936

937
938
939
940
            i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / I64C(1000000 );
            secstotimestr( psz_time, i_seconds );

            statusbar->SetStatusText( wxU(psz_time)+ wxString(wxT(" / ")) + wxU(psz_total), 0 );
gbazin's avatar
   
gbazin committed
941
        }
gbazin's avatar
   
gbazin committed
942
    }
gbazin's avatar
   
gbazin committed
943
#endif
gbazin's avatar
   
gbazin committed
944

945
#undef WIN32
gbazin's avatar
   
gbazin committed
946
    vlc_mutex_unlock( &p_intf->change_lock );
gbazin's avatar
   
gbazin committed
947
948
949
950
951
952
953
954
955
956
957
958
}

void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
{
    playlist_t * p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

Laurent Aimar's avatar
Laurent Aimar committed
959
960
    /* FIXME --fenrir */
#if 0
gbazin's avatar
   
gbazin committed
961
962
963
964
965
966
    if( p_playlist->p_input != NULL )
    {
        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
        if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
        {
            vlc_value_t val; val.b_bool = VLC_TRUE;
Sam Hocevar's avatar
Sam Hocevar committed
967
            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
gbazin's avatar
   
gbazin committed
968
            var_Set( p_playlist->p_input, "prev-title", val );
Sam Hocevar's avatar
Sam Hocevar committed
969
970
        } else
            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
gbazin's avatar
   
gbazin committed
971
972
    }
    vlc_mutex_unlock( &p_playlist->object_lock );
Laurent Aimar's avatar
Laurent Aimar committed
973
#endif
gbazin's avatar
   
gbazin committed
974

gbazin's avatar
   
gbazin committed
975
976
977
978
979
980
981
982
983
984
985
986
987
988
    playlist_Prev( p_playlist );
    vlc_object_release( p_playlist );
}

void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
{
    playlist_t * p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

Laurent Aimar's avatar
Laurent Aimar committed
989
990
991
    /* FIXME --fenrir */
#if 0
    var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
gbazin's avatar
   
gbazin committed
992
993
994
995
996
997
998
999
1000
    vlc_mutex_lock( &p_playlist->object_lock );
    if( p_playlist->p_input != NULL )
    {
        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
        if( p_playlist->p_input->stream.i_area_nb > 1 &&
            p_playlist->p_input->stream.p_selected_area->i_id <
              p_playlist->p_input->stream.i_area_nb - 1 )
        {
            vlc_value_t val; val.b_bool = VLC_TRUE;
Sam Hocevar's avatar
Sam Hocevar committed
1001
            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
gbazin's avatar
   
gbazin committed
1002
            var_Set( p_playlist->p_input, "next-title", val );
Sam Hocevar's avatar
Sam Hocevar committed
1003
1004
        } else
            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
gbazin's avatar
   
gbazin committed
1005
1006
    }
    vlc_mutex_unlock( &p_playlist->object_lock );
Laurent Aimar's avatar
Laurent Aimar committed
1007
#endif
gbazin's avatar
   
gbazin committed
1008
1009
1010
    playlist_Next( p_playlist );
    vlc_object_release( p_playlist );
}
gbazin's avatar
   
gbazin committed
1011

gbazin's avatar
   
gbazin committed
1012
1013
1014
1015
1016
1017
1018
void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
{
    input_thread_t *p_input =
        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
                                           FIND_ANYWHERE );
    if( p_input )
    {
1019
1020
1021
        vlc_value_t val; val.b_bool = VLC_TRUE;

        var_Set( p_input, "rate-slower", val );
gbazin's avatar
   
gbazin committed
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
        vlc_object_release( p_input );
    }
}

void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
{
    input_thread_t *p_input =
        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
                                           FIND_ANYWHERE );
    if( p_input )
    {
1033
1034
1035
        vlc_value_t val; val.b_bool = VLC_TRUE;

        var_Set( p_input, "rate-faster", val );
gbazin's avatar
   
gbazin committed
1036
1037
1038
1039
        vlc_object_release( p_input );
    }
}

gbazin's avatar
   
gbazin committed
1040
void Interface::TogglePlayButton( int i_playing_status )
gbazin's avatar
   
gbazin committed
1041
{
gbazin's avatar
   
gbazin committed
1042
1043
1044
    if( i_playing_status == i_old_playing_status )
        return;

gbazin's avatar
   
gbazin committed
1045
1046
1047
1048
    GetToolBar()->DeleteTool( PlayStream_Event );

    if( i_playing_status == PLAYING_S )
    {
1049
        GetToolBar()->InsertTool( 2, PlayStream_Event, wxU(_("Pause")),
gbazin's avatar
   
gbazin committed
1050
1051
                                  wxBitmap( pause_xpm ), wxNullBitmap,
                                  wxITEM_NORMAL, wxU(_(HELP_PAUSE)) );
gbazin's avatar
   
gbazin committed
1052
1053
1054
    }
    else
    {
1055
        GetToolBar()->InsertTool( 2, PlayStream_Event, wxU(_("Play")),
gbazin's avatar
   
gbazin committed
1056
1057
                                  wxBitmap( play_xpm ), wxNullBitmap,
                                  wxITEM_NORMAL, wxU(_(HELP_PLAY)) );
gbazin's avatar
   
gbazin committed
1058
1059
1060
    }

    GetToolBar()->Realize();
gbazin's avatar
   
gbazin committed
1061
1062

    i_old_playing_status = i_playing_status;
gbazin's avatar
   
gbazin committed
1063
1064
}

1065
#if wxUSE_DRAG_AND_DROP
gbazin's avatar
   
gbazin committed
1066
1067
1068
/*****************************************************************************
 * Definition of DragAndDrop class.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
1069
DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue )
gbazin's avatar
   
gbazin committed
1070
1071
{
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
1072
    b_enqueue = _b_enqueue;