dialogs.cpp 19.6 KB
Newer Older
gbazin's avatar
 
gbazin committed
1
/*****************************************************************************
2
 * dialogs.cpp : wxWidgets plugin for vlc
gbazin's avatar
 
gbazin committed
3
 *****************************************************************************
4
 * Copyright (C) 2000-2004 the VideoLAN team
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
13
14
15
16
17
18
19
20
 *
 * 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.
 *
 * 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
dionoea's avatar
dionoea committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
gbazin's avatar
 
gbazin committed
22
23
24
25
26
27
28
29
30
31
32
33
34
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <stdlib.h>                                      /* malloc(), free() */
#include <errno.h>                                                 /* ENOMEM */
#include <string.h>                                            /* strerror() */
#include <stdio.h>

#include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/intf.h>
35

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
36
#include "charset.h"
gbazin's avatar
 
gbazin committed
37

38
39
40
41
42
43
44
45
46
47
#include "dialogs/vlm/vlm_panel.hpp"
#include "dialogs/bookmarks.hpp"
#include "dialogs/wizard.hpp"
#include "dialogs/playlist.hpp"
#include "dialogs/open.hpp"
#include "dialogs/updatevlc.hpp"
#include "dialogs/fileinfo.hpp"
#include "dialogs/iteminfo.hpp"
#include "dialogs/preferences.hpp"
#include "dialogs/messages.hpp"
zorglub's avatar
zorglub committed
48
#include "dialogs/interaction.hpp"
49
#include "interface.hpp"
gbazin's avatar
 
gbazin committed
50
51
52
53

/* include the icon graphic */
#include "../../../share/vlc32x32.xpm"

54

gbazin's avatar
gbazin committed
55
/* Dialogs Provider */
56
57
namespace wxvlc
{
gbazin's avatar
gbazin committed
58
59
60
61
62
63
64
65
66
67
68
class DialogsProvider: public wxFrame
{
public:
    /* Constructor */
    DialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
    virtual ~DialogsProvider();

private:
    void Open( int i_access_method, int i_arg );

    /* Event handlers (these functions should _not_ be virtual) */
69
    void OnUpdateVLC( wxCommandEvent& event );
70
    void OnVLM( wxCommandEvent& event );
zorglub's avatar
zorglub committed
71
    void OnInteraction( wxCommandEvent& event );
gbazin's avatar
gbazin committed
72
73
74
75
76
77
78
79
80
81
    void OnExit( wxCommandEvent& event );
    void OnPlaylist( wxCommandEvent& event );
    void OnMessages( wxCommandEvent& event );
    void OnFileInfo( wxCommandEvent& event );
    void OnPreferences( wxCommandEvent& event );
    void OnWizardDialog( wxCommandEvent& event );
    void OnBookmarks( wxCommandEvent& event );

    void OnOpenFileGeneric( wxCommandEvent& event );
    void OnOpenFileSimple( wxCommandEvent& event );
zorglub's avatar
zorglub committed
82
    void OnOpenDirectory( wxCommandEvent& event );
gbazin's avatar
gbazin committed
83
84
85
86
87
88
89
    void OnOpenFile( wxCommandEvent& event );
    void OnOpenDisc( wxCommandEvent& event );
    void OnOpenNet( wxCommandEvent& event );
    void OnOpenCapture( wxCommandEvent& event );
    void OnOpenSat( wxCommandEvent& event );

    void OnPopupMenu( wxCommandEvent& event );
90
91
92
    void OnAudioPopupMenu( wxCommandEvent& event );
    void OnVideoPopupMenu( wxCommandEvent& event );
    void OnMiscPopupMenu( wxCommandEvent& event );
gbazin's avatar
gbazin committed
93
94
95
96
97
98
99
100
101
102
103
104
105

    void OnIdle( wxIdleEvent& event );

    void OnExitThread( wxCommandEvent& event );

    DECLARE_EVENT_TABLE();

    intf_thread_t *p_intf;

public:
    /* Secondary windows */
    OpenDialog          *p_open_dialog;
    wxFileDialog        *p_file_dialog;
zorglub's avatar
zorglub committed
106
    wxDirDialog         *p_dir_dialog;
gbazin's avatar
gbazin committed
107
108
109
110
111
    Playlist            *p_playlist_dialog;
    Messages            *p_messages_dialog;
    FileInfo            *p_fileinfo_dialog;
    WizardDialog        *p_wizard_dialog;
    wxFrame             *p_prefs_dialog;
112
    wxFrame             *p_bookmarks_dialog;
gbazin's avatar
gbazin committed
113
    wxFileDialog        *p_file_generic_dialog;
114
    UpdateVLC           *p_updatevlc_dialog;
115
    VLMFrame            *p_vlm_dialog;
gbazin's avatar
gbazin committed
116
};
117
}
gbazin's avatar
gbazin committed
118

gbazin's avatar
 
gbazin committed
119
120
121
122
123
124
125
126
127
128
DEFINE_LOCAL_EVENT_TYPE( wxEVT_DIALOG );

BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
    /* Idle loop used to update some of the dialogs */
    EVT_IDLE(DialogsProvider::OnIdle)

    /* Custom wxDialog events */
    EVT_COMMAND(INTF_DIALOG_FILE, wxEVT_DIALOG, DialogsProvider::OnOpenFile)
    EVT_COMMAND(INTF_DIALOG_DISC, wxEVT_DIALOG, DialogsProvider::OnOpenDisc)
    EVT_COMMAND(INTF_DIALOG_NET, wxEVT_DIALOG, DialogsProvider::OnOpenNet)
gbazin's avatar
gbazin committed
129
130
    EVT_COMMAND(INTF_DIALOG_CAPTURE, wxEVT_DIALOG,
                DialogsProvider::OnOpenCapture)
gbazin's avatar
 
gbazin committed
131
132
    EVT_COMMAND(INTF_DIALOG_FILE_SIMPLE, wxEVT_DIALOG,
                DialogsProvider::OnOpenFileSimple)
gbazin's avatar
   
gbazin committed
133
134
    EVT_COMMAND(INTF_DIALOG_FILE_GENERIC, wxEVT_DIALOG,
                DialogsProvider::OnOpenFileGeneric)
zorglub's avatar
zorglub committed
135
136
    EVT_COMMAND(INTF_DIALOG_DIRECTORY, wxEVT_DIALOG,
                DialogsProvider::OnOpenDirectory)
gbazin's avatar
 
gbazin committed
137
138
139
140
141
142
143

    EVT_COMMAND(INTF_DIALOG_PLAYLIST, wxEVT_DIALOG,
                DialogsProvider::OnPlaylist)
    EVT_COMMAND(INTF_DIALOG_MESSAGES, wxEVT_DIALOG,
                DialogsProvider::OnMessages)
    EVT_COMMAND(INTF_DIALOG_PREFS, wxEVT_DIALOG,
                DialogsProvider::OnPreferences)
144
145
    EVT_COMMAND(INTF_DIALOG_WIZARD, wxEVT_DIALOG,
                DialogsProvider::OnWizardDialog)
gbazin's avatar
 
gbazin committed
146
147
    EVT_COMMAND(INTF_DIALOG_FILEINFO, wxEVT_DIALOG,
                DialogsProvider::OnFileInfo)
gbazin's avatar
gbazin committed
148
149
    EVT_COMMAND(INTF_DIALOG_BOOKMARKS, wxEVT_DIALOG,
                DialogsProvider::OnBookmarks)
150

gbazin's avatar
   
gbazin committed
151
152
    EVT_COMMAND(INTF_DIALOG_POPUPMENU, wxEVT_DIALOG,
                DialogsProvider::OnPopupMenu)
153
154
155
156
157
158
159
    EVT_COMMAND(INTF_DIALOG_AUDIOPOPUPMENU, wxEVT_DIALOG,
                DialogsProvider::OnAudioPopupMenu)
    EVT_COMMAND(INTF_DIALOG_VIDEOPOPUPMENU, wxEVT_DIALOG,
                DialogsProvider::OnVideoPopupMenu)
    EVT_COMMAND(INTF_DIALOG_MISCPOPUPMENU, wxEVT_DIALOG,
                DialogsProvider::OnMiscPopupMenu)

gbazin's avatar
   
gbazin committed
160
161
    EVT_COMMAND(INTF_DIALOG_EXIT, wxEVT_DIALOG,
                DialogsProvider::OnExitThread)
162
163
    EVT_COMMAND(INTF_DIALOG_UPDATEVLC, wxEVT_DIALOG,
                DialogsProvider::OnUpdateVLC)
164
165
    EVT_COMMAND(INTF_DIALOG_VLM, wxEVT_DIALOG,
                DialogsProvider::OnVLM)
zorglub's avatar
zorglub committed
166
167
    EVT_COMMAND( INTF_DIALOG_INTERACTION, wxEVT_DIALOG,
                DialogsProvider::OnInteraction )
gbazin's avatar
 
gbazin committed
168
169
END_EVENT_TABLE()

gbazin's avatar
gbazin committed
170
171
172
173
174
wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent )
{
    return new DialogsProvider( p_intf, p_parent );
}

gbazin's avatar
 
gbazin committed
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
  :  wxFrame( p_parent, -1, wxT("") )
{
    /* Initializations */
    p_intf = _p_intf;
    p_open_dialog = NULL;
    p_file_dialog = NULL;
    p_playlist_dialog = NULL;
    p_messages_dialog = NULL;
    p_fileinfo_dialog = NULL;
    p_prefs_dialog = NULL;
gbazin's avatar
   
gbazin committed
189
    p_file_generic_dialog = NULL;
190
    p_wizard_dialog = NULL;
gbazin's avatar
gbazin committed
191
    p_bookmarks_dialog = NULL;
192
    p_dir_dialog = NULL;
193
    p_updatevlc_dialog = NULL;
194
    p_vlm_dialog = NULL;
gbazin's avatar
 
gbazin committed
195
196
197
198
199
200

    /* Give our interface a nice little icon */
    p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );

    /* Create the messages dialog so it can begin storing logs */
    p_messages_dialog = new Messages( p_intf, p_parent ? p_parent : this );
gbazin's avatar
   
gbazin committed
201

gbazin's avatar
gbazin committed
202
203
    /* Check if user wants to show the bookmarks dialog by default */
    wxCommandEvent dummy_event;
204
    if( config_GetInt( p_intf, "wx-bookmarks" ) )
gbazin's avatar
gbazin committed
205
206
        OnBookmarks( dummy_event );

gbazin's avatar
   
gbazin committed
207
208
    /* Intercept all menu events in our custom event handler */
    PushEventHandler( new MenuEvtHandler( p_intf, NULL ) );
209
210
211
212
213
214
215
216
217
218
219
220
221


    WindowSettings *ws = p_intf->p_sys->p_window_settings;
    wxPoint p;
    wxSize  s;
    bool    b_shown;

#define INIT( id, w, N, S ) \
    if( ws->GetSettings( WindowSettings::id, b_shown, p, s ) && b_shown ) \
    {                           \
        if( !w )                \
            w = N;              \
        w->SetSize( s );        \
222
        w->Move( p );           \
223
224
225
226
227
228
        w->S( true );           \
    }

    INIT( ID_PLAYLIST, p_playlist_dialog, new Playlist(p_intf,this), ShowPlaylist );
    INIT( ID_MESSAGES, p_messages_dialog, new Messages(p_intf,this), Show );
    INIT( ID_FILE_INFO, p_fileinfo_dialog, new FileInfo(p_intf,this), Show );
229
    INIT( ID_BOOKMARKS, p_bookmarks_dialog, new BookmarksDialog(p_intf,this), Show);
230
#undef INIT
gbazin's avatar
 
gbazin committed
231
232
233
234
}

DialogsProvider::~DialogsProvider()
{
235
236
237
238
    WindowSettings *ws = p_intf->p_sys->p_window_settings;

#define UPDATE(id,w)                                        \
  {                                                         \
239
    if( w && w->IsShown() && !w->IsIconized() )             \
240
241
242
243
244
245
246
247
248
249
250
251
252
        ws->SetSettings(  WindowSettings::id, true,         \
                          w->GetPosition(), w->GetSize() ); \
    else                                                    \
        ws->SetSettings(  WindowSettings::id, false );      \
  }

    UPDATE( ID_PLAYLIST,  p_playlist_dialog );
    UPDATE( ID_MESSAGES,  p_messages_dialog );
    UPDATE( ID_FILE_INFO, p_fileinfo_dialog );
    UPDATE( ID_BOOKMARKS, p_bookmarks_dialog );

#undef UPDATE

253
    PopEventHandler(true);
254

gbazin's avatar
 
gbazin committed
255
256
257
258
259
260
261
    /* Clean up */
    if( p_open_dialog )     delete p_open_dialog;
    if( p_prefs_dialog )    p_prefs_dialog->Destroy();
    if( p_file_dialog )     delete p_file_dialog;
    if( p_playlist_dialog ) delete p_playlist_dialog;
    if( p_messages_dialog ) delete p_messages_dialog;
    if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
gbazin's avatar
   
gbazin committed
262
    if( p_file_generic_dialog ) delete p_file_generic_dialog;
263
    if( p_wizard_dialog ) delete p_wizard_dialog;
gbazin's avatar
gbazin committed
264
    if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
265
    if( p_updatevlc_dialog ) delete p_updatevlc_dialog;
266
    if( p_vlm_dialog ) delete p_vlm_dialog;
zorglub's avatar
zorglub committed
267

gbazin's avatar
 
gbazin committed
268
269

    if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
270
271
272
273
274
275

    /* We must set this here because on win32 this destructor will be
     * automatically called so we must not call it again on wxApp->OnExit().
     * There shouldn't be any race conditions as all this should be done
     * from the same thread. */
    p_intf->p_sys->p_wxwindow = NULL;
gbazin's avatar
 
gbazin committed
276
277
278
279
}

void DialogsProvider::OnIdle( wxIdleEvent& WXUNUSED(event) )
{
280
281
282
    /* Update the log window */
    if( p_messages_dialog )
        p_messages_dialog->UpdateLog();
gbazin's avatar
 
gbazin committed
283

284
285
286
    /* Update the playlist */
    if( p_playlist_dialog )
        p_playlist_dialog->UpdatePlaylist();
gbazin's avatar
 
gbazin committed
287

288
289
    /* Update the fileinfo windows */
    if( p_fileinfo_dialog )
zorglub's avatar
zorglub committed
290
        p_fileinfo_dialog->Update();
gbazin's avatar
 
gbazin committed
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
}

void DialogsProvider::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the playlist window */
    if( !p_playlist_dialog )
        p_playlist_dialog = new Playlist( p_intf, this );

    if( p_playlist_dialog )
    {
        p_playlist_dialog->ShowPlaylist( !p_playlist_dialog->IsShown() );
    }
}

void DialogsProvider::OnMessages( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the log window */
    if( !p_messages_dialog )
        p_messages_dialog = new Messages( p_intf, this );

    if( p_messages_dialog )
    {
        p_messages_dialog->Show( !p_messages_dialog->IsShown() );
    }
}

void DialogsProvider::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the file info window */
    if( !p_fileinfo_dialog )
        p_fileinfo_dialog = new FileInfo( p_intf, this );

    if( p_fileinfo_dialog )
    {
        p_fileinfo_dialog->Show( !p_fileinfo_dialog->IsShown() );
    }
}

void DialogsProvider::OnPreferences( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the open dialog */
    if( !p_prefs_dialog )
        p_prefs_dialog = new PrefsDialog( p_intf, this );

    if( p_prefs_dialog )
    {
        p_prefs_dialog->Show( !p_prefs_dialog->IsShown() );
    }
}

341
342
void DialogsProvider::OnWizardDialog( wxCommandEvent& WXUNUSED(event) )
{
343
    p_wizard_dialog = new WizardDialog( p_intf, this, NULL, 0, 0 );
344
345
346
347

    if( p_wizard_dialog )
    {
        p_wizard_dialog->Run();
348
        delete p_wizard_dialog;
349
350
351
352
353
    }

    p_wizard_dialog = NULL;
}

gbazin's avatar
gbazin committed
354
355
356
357
void DialogsProvider::OnBookmarks( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the open dialog */
    if( !p_bookmarks_dialog )
358
        p_bookmarks_dialog = new BookmarksDialog( p_intf, this );
gbazin's avatar
gbazin committed
359
360
361
362
363
364
365

    if( p_bookmarks_dialog )
    {
        p_bookmarks_dialog->Show( !p_bookmarks_dialog->IsShown() );
    }
}

gbazin's avatar
   
gbazin committed
366
367
368
369
370
371
372
373
374
375
376
void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event )
{
    intf_dialog_args_t *p_arg = (intf_dialog_args_t *)event.GetClientData();

    if( p_arg == NULL )
    {
        msg_Dbg( p_intf, "OnOpenFileGeneric() called with NULL arg" );
        return;
    }

    if( p_file_generic_dialog == NULL )
377
        p_file_generic_dialog = new wxFileDialog( NULL );
gbazin's avatar
   
gbazin committed
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418

    if( p_file_generic_dialog )
    {
        p_file_generic_dialog->SetMessage( wxU(p_arg->psz_title) );
        p_file_generic_dialog->SetWildcard( wxU(p_arg->psz_extensions) );
        p_file_generic_dialog->SetStyle( (p_arg->b_save ? wxSAVE : wxOPEN) |
                                         (p_arg->b_multiple ? wxMULTIPLE:0) );
    }

    if( p_file_generic_dialog &&
        p_file_generic_dialog->ShowModal() == wxID_OK )
    {
        wxArrayString paths;

        p_file_generic_dialog->GetPaths( paths );

        p_arg->i_results = paths.GetCount();
        p_arg->psz_results = (char **)malloc( p_arg->i_results *
                                              sizeof(char *) );
        for( size_t i = 0; i < paths.GetCount(); i++ )
        {
            p_arg->psz_results[i] = strdup( paths[i].mb_str() );
        }
    }

    /* Callback */
    if( p_arg->pf_callback )
    {
        p_arg->pf_callback( p_arg );
    }

    if( p_arg->psz_results )
    {
        for( int i = 0; i < p_arg->i_results; i++ )
        {
            free( p_arg->psz_results[i] );
        }
        free( p_arg->psz_results );
    }
    if( p_arg->psz_title ) free( p_arg->psz_title );
    if( p_arg->psz_extensions ) free( p_arg->psz_extensions );
419

420
    free( p_arg );
gbazin's avatar
   
gbazin committed
421
422
}

gbazin's avatar
 
gbazin committed
423
424
425
426
427
428
429
430
431
432
433
void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    if( p_file_dialog == NULL )
434
        p_file_dialog = new wxFileDialog( NULL, wxU(_("Open File")),
gbazin's avatar
 
gbazin committed
435
436
            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );

437
438
439
440
441
442
	p_file_dialog->SetWildcard(wxU(_("All Files (*.*)|*"
        "|Sound Files (*.mp3, *.ogg, etc.)|" EXTENSIONS_AUDIO 
        "|Video Files (*.avi, *.mpg, etc.)|" EXTENSIONS_VIDEO 
        "|Playlist Files (*.m3u, *.pls, etc.)|" EXTENSIONS_PLAYLIST 
        "|Subtitle Files (*.srt, *.sub, etc.)|" EXTENSIONS_SUBTITLE)));

gbazin's avatar
 
gbazin committed
443
444
445
446
447
448
449
    if( p_file_dialog && p_file_dialog->ShowModal() == wxID_OK )
    {
        wxArrayString paths;

        p_file_dialog->GetPaths( paths );

        for( size_t i = 0; i < paths.GetCount(); i++ )
450
        {
451
            char *psz_utf8 = wxFromLocale( paths[i] );
gbazin's avatar
 
gbazin committed
452
            if( event.GetInt() )
453
                playlist_PlaylistAdd( p_playlist, psz_utf8, NULL,
454
455
                              PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
                              (i ? PLAYLIST_PREPARSE : 0 ),
gbazin's avatar
 
gbazin committed
456
457
                              PLAYLIST_END );
            else
458
                playlist_PlaylistAdd( p_playlist, psz_utf8, NULL,
459
                              PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END );
460
            wxLocaleFree( psz_utf8 );
461
        }
gbazin's avatar
 
gbazin committed
462
463
464
465
466
    }

    vlc_object_release( p_playlist );
}

zorglub's avatar
zorglub committed
467
468
469
470
471
472
473
474
475
476
477
void DialogsProvider::OnOpenDirectory( wxCommandEvent& event )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    if( p_dir_dialog == NULL )
478
        p_dir_dialog = new wxDirDialog( NULL, wxU(_("Select a directory")) );
zorglub's avatar
zorglub committed
479
480
481
482

    if( p_dir_dialog && p_dir_dialog->ShowModal() == wxID_OK )
    {
        wxString path = p_dir_dialog->GetPath();
483
        char *psz_utf8 = wxFromLocale( path );
484
        playlist_PlaylistAdd( p_playlist, psz_utf8, NULL,
485
                      PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
486
                      PLAYLIST_END );
487
        wxLocaleFree( psz_utf8 );
zorglub's avatar
zorglub committed
488
489
490
491
492
    }

    vlc_object_release( p_playlist );
}

gbazin's avatar
 
gbazin committed
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
void DialogsProvider::OnOpenFile( wxCommandEvent& event )
{
    Open( FILE_ACCESS, event.GetInt() );
}

void DialogsProvider::OnOpenDisc( wxCommandEvent& event )
{
    Open( DISC_ACCESS, event.GetInt() );
}

void DialogsProvider::OnOpenNet( wxCommandEvent& event )
{
    Open( NET_ACCESS, event.GetInt() );
}

gbazin's avatar
gbazin committed
508
509
510
511
512
void DialogsProvider::OnOpenCapture( wxCommandEvent& event )
{
    Open( CAPTURE_ACCESS, event.GetInt() );
}

gbazin's avatar
 
gbazin committed
513
514
515
516
void DialogsProvider::Open( int i_access_method, int i_arg )
{
    /* Show/hide the open dialog */
    if( !p_open_dialog )
gbazin's avatar
   
gbazin committed
517
518
        p_open_dialog = new OpenDialog( p_intf, this, i_access_method, i_arg,
                                        OPEN_NORMAL );
gbazin's avatar
 
gbazin committed
519
520
521
522
523
524

    if( p_open_dialog )
    {
        p_open_dialog->Show( i_access_method, i_arg );
    }
}
gbazin's avatar
   
gbazin committed
525
526
527

void DialogsProvider::OnPopupMenu( wxCommandEvent& event )
{
528
    wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
gbazin's avatar
   
gbazin committed
529
    ::PopupMenu( p_intf, this, mousepos );
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
}

void DialogsProvider::OnAudioPopupMenu( wxCommandEvent& event )
{
    wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
    ::AudioPopupMenu( p_intf, this, mousepos );
}
void DialogsProvider::OnVideoPopupMenu( wxCommandEvent& event )
{
    wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
    ::VideoPopupMenu( p_intf, this, mousepos );
}
void DialogsProvider::OnMiscPopupMenu( wxCommandEvent& event )
{
    wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
    ::MiscPopupMenu( p_intf, this, mousepos );
gbazin's avatar
   
gbazin committed
546
}
gbazin's avatar
   
gbazin committed
547
548
549
550
551

void DialogsProvider::OnExitThread( wxCommandEvent& WXUNUSED(event) )
{
    wxTheApp->ExitMainLoop();
}
552
553
554
555
556
557
558
559
560
561
562
563

void DialogsProvider::OnUpdateVLC( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the file info window */
    if( !p_updatevlc_dialog )
        p_updatevlc_dialog = new UpdateVLC( p_intf, this );

    if( p_updatevlc_dialog )
    {
        p_updatevlc_dialog->Show( !p_updatevlc_dialog->IsShown() );
    }
}
564
565
566
567
568
569
570
571
572
573
574
575

void DialogsProvider::OnVLM( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the file info window */
    if( !p_vlm_dialog )
        p_vlm_dialog = new VLMFrame( p_intf, this );

    if( p_vlm_dialog )
    {
        p_vlm_dialog->Show( !p_vlm_dialog->IsShown() );
    }
}
zorglub's avatar
zorglub committed
576
577
578
579
580
581
582

void DialogsProvider::OnInteraction( wxCommandEvent& event )
{
    intf_dialog_args_t *p_arg = (intf_dialog_args_t *)event.GetClientData();
    interaction_dialog_t *p_dialog;
    InteractionDialog *p_wxdialog;

583
584
    return;

zorglub's avatar
zorglub committed
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
    if( p_arg == NULL )
    {
        msg_Dbg( p_intf, "OnInteraction() called with NULL arg" );
        return;
    }
    p_dialog = p_arg->p_dialog;

    /** \bug We store the interface object for the dialog in the p_private
     * field of the core dialog object. This is not safe if we change
     * interface while a dialog is loaded */

    switch( p_dialog->i_action )
    {
    case INTERACT_NEW:
        p_wxdialog = new InteractionDialog( p_intf, this, p_dialog );
        p_dialog->p_private = (void*)p_wxdialog;
        p_wxdialog->Show();
        break;
    case INTERACT_UPDATE:
        p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
zorglub's avatar
zorglub committed
605
606
        if( p_wxdialog)
            p_wxdialog->Update();
zorglub's avatar
zorglub committed
607
608
609
        break;
    case INTERACT_HIDE:
        p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
zorglub's avatar
zorglub committed
610
611
        if( p_wxdialog )
            p_wxdialog->Hide();
zorglub's avatar
zorglub committed
612
613
614
615
616
617
        p_dialog->i_status = HIDDEN_DIALOG;
        break;
    case INTERACT_DESTROY:
        p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
        /// \todo
        p_dialog->i_status = DESTROYED_DIALOG;
zorglub's avatar
zorglub committed
618
619
620
        break;
    }
}