dialogs.cpp 19.7 KB
Newer Older
Gildas Bazin's avatar
 
Gildas Bazin committed
1
/*****************************************************************************
2
 * dialogs.cpp : wxWidgets plugin for vlc
Gildas Bazin's avatar
 
Gildas Bazin committed
3
 *****************************************************************************
4
 * Copyright (C) 2000-2004 the VideoLAN team
Gildas Bazin's avatar
Gildas Bazin committed
5
 * $Id$
Gildas Bazin's avatar
 
Gildas Bazin committed
6
 *
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
Gildas Bazin's avatar
 
Gildas Bazin 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
Antoine Cellerier's avatar
Antoine Cellerier committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Gildas Bazin's avatar
 
Gildas Bazin committed
22 23 24 25 26 27 28 29
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <errno.h>                                                 /* ENOMEM */

#include <vlc/vlc.h>
Clément Stenac's avatar
Clément Stenac committed
30 31
#include <vlc_aout.h>
#include <vlc_interface.h>
32

Clément Stenac's avatar
Clément Stenac committed
33
#include "vlc_charset.h"
Gildas Bazin's avatar
 
Gildas Bazin committed
34

35
//#include "dialogs/vlm/vlm_panel.hpp"
36 37 38 39 40 41 42 43 44
#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"
45
#include "dialogs/interaction.hpp"
46
#include "interface.hpp"
Gildas Bazin's avatar
 
Gildas Bazin committed
47 48 49 50

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

51

Gildas Bazin's avatar
Gildas Bazin committed
52
/* Dialogs Provider */
53 54
namespace wxvlc
{
Gildas Bazin's avatar
Gildas Bazin committed
55 56 57 58 59 60 61 62 63 64 65
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) */
66
#ifdef UPDATE_CHECK
67
    void OnUpdateVLC( wxCommandEvent& event );
68
#endif
69
    //void OnVLM( wxCommandEvent& event );
70
    void OnInteraction( wxCommandEvent& event );
Gildas Bazin's avatar
Gildas Bazin committed
71 72 73 74 75 76 77 78 79 80
    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 );
Clément Stenac's avatar
Clément Stenac committed
81
    void OnOpenDirectory( wxCommandEvent& event );
Gildas Bazin's avatar
Gildas Bazin committed
82 83 84 85 86 87 88
    void OnOpenFile( wxCommandEvent& event );
    void OnOpenDisc( wxCommandEvent& event );
    void OnOpenNet( wxCommandEvent& event );
    void OnOpenCapture( wxCommandEvent& event );
    void OnOpenSat( wxCommandEvent& event );

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

    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;
Clément Stenac's avatar
Clément Stenac committed
105
    wxDirDialog         *p_dir_dialog;
Gildas Bazin's avatar
Gildas Bazin committed
106 107 108 109 110
    Playlist            *p_playlist_dialog;
    Messages            *p_messages_dialog;
    FileInfo            *p_fileinfo_dialog;
    WizardDialog        *p_wizard_dialog;
    wxFrame             *p_prefs_dialog;
111
    wxFrame             *p_bookmarks_dialog;
Gildas Bazin's avatar
Gildas Bazin committed
112
    wxFileDialog        *p_file_generic_dialog;
113
#ifdef UPDATE_CHECK
114
    UpdateVLC           *p_updatevlc_dialog;
115
#endif
116
    //VLMFrame            *p_vlm_dialog;
Gildas Bazin's avatar
Gildas Bazin committed
117
};
118
}
Gildas Bazin's avatar
Gildas Bazin committed
119

Gildas Bazin's avatar
 
Gildas Bazin committed
120 121 122 123 124 125 126 127 128 129
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)
Gildas Bazin's avatar
Gildas Bazin committed
130 131
    EVT_COMMAND(INTF_DIALOG_CAPTURE, wxEVT_DIALOG,
                DialogsProvider::OnOpenCapture)
Gildas Bazin's avatar
 
Gildas Bazin committed
132 133
    EVT_COMMAND(INTF_DIALOG_FILE_SIMPLE, wxEVT_DIALOG,
                DialogsProvider::OnOpenFileSimple)
Gildas Bazin's avatar
 
Gildas Bazin committed
134 135
    EVT_COMMAND(INTF_DIALOG_FILE_GENERIC, wxEVT_DIALOG,
                DialogsProvider::OnOpenFileGeneric)
Clément Stenac's avatar
Clément Stenac committed
136 137
    EVT_COMMAND(INTF_DIALOG_DIRECTORY, wxEVT_DIALOG,
                DialogsProvider::OnOpenDirectory)
Gildas Bazin's avatar
 
Gildas Bazin committed
138 139 140 141 142 143 144

    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)
145 146
    EVT_COMMAND(INTF_DIALOG_WIZARD, wxEVT_DIALOG,
                DialogsProvider::OnWizardDialog)
Gildas Bazin's avatar
 
Gildas Bazin committed
147 148
    EVT_COMMAND(INTF_DIALOG_FILEINFO, wxEVT_DIALOG,
                DialogsProvider::OnFileInfo)
Gildas Bazin's avatar
Gildas Bazin committed
149 150
    EVT_COMMAND(INTF_DIALOG_BOOKMARKS, wxEVT_DIALOG,
                DialogsProvider::OnBookmarks)
151

Gildas Bazin's avatar
 
Gildas Bazin committed
152 153
    EVT_COMMAND(INTF_DIALOG_POPUPMENU, wxEVT_DIALOG,
                DialogsProvider::OnPopupMenu)
154 155 156 157 158 159 160
    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)

Gildas Bazin's avatar
 
Gildas Bazin committed
161 162
    EVT_COMMAND(INTF_DIALOG_EXIT, wxEVT_DIALOG,
                DialogsProvider::OnExitThread)
163
#ifdef UPDATE_CHECK
164 165
    EVT_COMMAND(INTF_DIALOG_UPDATEVLC, wxEVT_DIALOG,
                DialogsProvider::OnUpdateVLC)
166
#endif
167
#if 0
168 169
    EVT_COMMAND(INTF_DIALOG_VLM, wxEVT_DIALOG,
                DialogsProvider::OnVLM)
170
#endif
171 172
    EVT_COMMAND( INTF_DIALOG_INTERACTION, wxEVT_DIALOG,
                DialogsProvider::OnInteraction )
Gildas Bazin's avatar
 
Gildas Bazin committed
173 174
END_EVENT_TABLE()

Gildas Bazin's avatar
Gildas Bazin committed
175 176 177 178 179
wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent )
{
    return new DialogsProvider( p_intf, p_parent );
}

Gildas Bazin's avatar
 
Gildas Bazin committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193
/*****************************************************************************
 * 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;
Gildas Bazin's avatar
 
Gildas Bazin committed
194
    p_file_generic_dialog = NULL;
195
    p_wizard_dialog = NULL;
Gildas Bazin's avatar
Gildas Bazin committed
196
    p_bookmarks_dialog = NULL;
197
    p_dir_dialog = NULL;
198
#ifdef UPDATE_CHECK
199
    p_updatevlc_dialog = NULL;
200
#endif
201
    //p_vlm_dialog = NULL;
Gildas Bazin's avatar
 
Gildas Bazin committed
202 203

    /* Give our interface a nice little icon */
Rafaël Carré's avatar
Rafaël Carré committed
204
    p_intf->p_sys->p_icon = new wxIcon( (const char**) vlc_xpm );
Gildas Bazin's avatar
 
Gildas Bazin committed
205 206 207

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

Gildas Bazin's avatar
Gildas Bazin committed
209 210
    /* Check if user wants to show the bookmarks dialog by default */
    wxCommandEvent dummy_event;
211
    if( config_GetInt( p_intf, "wx-bookmarks" ) )
Gildas Bazin's avatar
Gildas Bazin committed
212 213
        OnBookmarks( dummy_event );

Gildas Bazin's avatar
 
Gildas Bazin committed
214 215
    /* Intercept all menu events in our custom event handler */
    PushEventHandler( new MenuEvtHandler( p_intf, NULL ) );
216 217 218 219 220 221 222 223 224 225 226 227 228


    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 );        \
229
        w->Move( p );           \
230 231 232 233 234 235
        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 );
236
    INIT( ID_BOOKMARKS, p_bookmarks_dialog, new BookmarksDialog(p_intf,this), Show);
237
#undef INIT
Gildas Bazin's avatar
 
Gildas Bazin committed
238 239 240 241
}

DialogsProvider::~DialogsProvider()
{
242 243 244 245
    WindowSettings *ws = p_intf->p_sys->p_window_settings;

#define UPDATE(id,w)                                        \
  {                                                         \
246
    if( w && w->IsShown() && !w->IsIconized() )             \
247 248 249 250 251 252 253 254 255 256 257 258 259
        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

260
    PopEventHandler(true);
261

Gildas Bazin's avatar
 
Gildas Bazin committed
262 263 264 265 266 267 268
    /* 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;
Gildas Bazin's avatar
 
Gildas Bazin committed
269
    if( p_file_generic_dialog ) delete p_file_generic_dialog;
270
    if( p_wizard_dialog ) delete p_wizard_dialog;
Gildas Bazin's avatar
Gildas Bazin committed
271
    if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
272
#ifdef UPDATE_CHECK
273
    if( p_updatevlc_dialog ) delete p_updatevlc_dialog;
274
#endif
275
    //if( p_vlm_dialog ) delete p_vlm_dialog;
276

Gildas Bazin's avatar
 
Gildas Bazin committed
277 278

    if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
279 280 281 282 283 284

    /* 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;
Gildas Bazin's avatar
 
Gildas Bazin committed
285 286 287 288
}

void DialogsProvider::OnIdle( wxIdleEvent& WXUNUSED(event) )
{
289 290 291
    /* Update the log window */
    if( p_messages_dialog )
        p_messages_dialog->UpdateLog();
Gildas Bazin's avatar
 
Gildas Bazin committed
292

293 294 295
    /* Update the playlist */
    if( p_playlist_dialog )
        p_playlist_dialog->UpdatePlaylist();
Gildas Bazin's avatar
 
Gildas Bazin committed
296

297 298
    /* Update the fileinfo windows */
    if( p_fileinfo_dialog )
299
        p_fileinfo_dialog->Update();
Gildas Bazin's avatar
 
Gildas Bazin committed
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 341 342 343 344 345 346 347 348 349
}

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() );
    }
}

350 351
void DialogsProvider::OnWizardDialog( wxCommandEvent& WXUNUSED(event) )
{
352
    p_wizard_dialog = new WizardDialog( p_intf, this, NULL, 0, 0 );
353 354 355 356

    if( p_wizard_dialog )
    {
        p_wizard_dialog->Run();
357
        delete p_wizard_dialog;
358 359 360 361 362
    }

    p_wizard_dialog = NULL;
}

Gildas Bazin's avatar
Gildas Bazin committed
363 364 365 366
void DialogsProvider::OnBookmarks( wxCommandEvent& WXUNUSED(event) )
{
    /* Show/hide the open dialog */
    if( !p_bookmarks_dialog )
367
        p_bookmarks_dialog = new BookmarksDialog( p_intf, this );
Gildas Bazin's avatar
Gildas Bazin committed
368 369 370 371 372 373 374

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

Gildas Bazin's avatar
 
Gildas Bazin committed
375 376 377 378 379 380 381 382 383 384 385
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 )
386
        p_file_generic_dialog = new wxFileDialog( NULL );
Gildas Bazin's avatar
 
Gildas Bazin committed
387 388 389 390 391

    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) );
392 393
        p_file_generic_dialog->SetWindowStyle( (p_arg->b_save ? wxSAVE : wxOPEN) |
                                               (p_arg->b_multiple ? wxMULTIPLE:0) );
Gildas Bazin's avatar
 
Gildas Bazin committed
394 395 396 397 398 399 400 401 402 403 404 405 406 407
    }

    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++ )
        {
408
            p_arg->psz_results[i] = strdup( paths[i].mb_str(wxConvUTF8) );
Gildas Bazin's avatar
 
Gildas Bazin committed
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
        }
    }

    /* 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 );
428

429
    free( p_arg );
Gildas Bazin's avatar
 
Gildas Bazin committed
430 431
}

Gildas Bazin's avatar
 
Gildas Bazin committed
432 433 434 435 436 437 438 439 440 441 442
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 )
443
        p_file_dialog = new wxFileDialog( NULL, wxU(_("Open File")),
Gildas Bazin's avatar
 
Gildas Bazin committed
444 445
            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );

446 447 448 449
    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
450 451
        "|Subtitle Files (*.srt, *.sub, etc.)|" EXTENSIONS_SUBTITLE)));

Gildas Bazin's avatar
 
Gildas Bazin committed
452 453 454 455 456 457 458
    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++ )
459
        {
460
            char *psz_utf8 = wxFromLocale( paths[i] );
Gildas Bazin's avatar
 
Gildas Bazin committed
461
            if( event.GetInt() )
462
                playlist_Add( p_playlist, psz_utf8, NULL,
463 464
                              PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
                              (i ? PLAYLIST_PREPARSE : 0 ),
465
                              PLAYLIST_END, VLC_TRUE, VLC_FALSE );
Gildas Bazin's avatar
 
Gildas Bazin committed
466
            else
467
                playlist_Add( p_playlist, psz_utf8, NULL,
468
                              PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE, VLC_FALSE );
469
            wxLocaleFree( psz_utf8 );
470
        }
Gildas Bazin's avatar
 
Gildas Bazin committed
471 472 473 474 475
    }

    vlc_object_release( p_playlist );
}

Clément Stenac's avatar
Clément Stenac committed
476 477 478 479 480 481 482 483 484 485 486
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 )
487
        p_dir_dialog = new wxDirDialog( NULL, wxU(_("Select a directory")) );
Clément Stenac's avatar
Clément Stenac committed
488 489 490 491

    if( p_dir_dialog && p_dir_dialog->ShowModal() == wxID_OK )
    {
        wxString path = p_dir_dialog->GetPath();
492
        char *psz_utf8 = wxFromLocale( path );
493
        playlist_Add( p_playlist, psz_utf8, NULL,
494
                      PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
495
                      PLAYLIST_END, VLC_TRUE, VLC_FALSE );
496
        wxLocaleFree( psz_utf8 );
Clément Stenac's avatar
Clément Stenac committed
497 498 499 500 501
    }

    vlc_object_release( p_playlist );
}

Gildas Bazin's avatar
 
Gildas Bazin committed
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
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() );
}

Gildas Bazin's avatar
Gildas Bazin committed
517 518 519 520 521
void DialogsProvider::OnOpenCapture( wxCommandEvent& event )
{
    Open( CAPTURE_ACCESS, event.GetInt() );
}

Gildas Bazin's avatar
 
Gildas Bazin committed
522 523 524 525
void DialogsProvider::Open( int i_access_method, int i_arg )
{
    /* Show/hide the open dialog */
    if( !p_open_dialog )
Gildas Bazin's avatar
 
Gildas Bazin committed
526 527
        p_open_dialog = new OpenDialog( p_intf, this, i_access_method, i_arg,
                                        OPEN_NORMAL );
Gildas Bazin's avatar
 
Gildas Bazin committed
528 529 530 531 532 533

    if( p_open_dialog )
    {
        p_open_dialog->Show( i_access_method, i_arg );
    }
}
Gildas Bazin's avatar
 
Gildas Bazin committed
534 535 536

void DialogsProvider::OnPopupMenu( wxCommandEvent& event )
{
537
    wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
Gildas Bazin's avatar
 
Gildas Bazin committed
538
    ::PopupMenu( p_intf, this, mousepos );
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
}

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 );
Gildas Bazin's avatar
 
Gildas Bazin committed
555
}
Gildas Bazin's avatar
 
Gildas Bazin committed
556 557 558 559 560

void DialogsProvider::OnExitThread( wxCommandEvent& WXUNUSED(event) )
{
    wxTheApp->ExitMainLoop();
}
561

562
#ifdef UPDATE_CHECK
563 564 565 566 567 568 569 570 571 572 573
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() );
    }
}
574
#endif
575

576
#if 0
577 578 579 580 581 582 583 584 585 586 587
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() );
    }
}
588
#endif
589 590 591 592 593 594 595

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;

596 597
    return;

598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
    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);
Clément Stenac's avatar
Clément Stenac committed
618 619
        if( p_wxdialog)
            p_wxdialog->Update();
620 621 622
        break;
    case INTERACT_HIDE:
        p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
Clément Stenac's avatar
Clément Stenac committed
623 624
        if( p_wxdialog )
            p_wxdialog->Hide();
Clément Stenac's avatar
Clément Stenac committed
625 626 627 628 629 630
        p_dialog->i_status = HIDDEN_DIALOG;
        break;
    case INTERACT_DESTROY:
        p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
        /// \todo
        p_dialog->i_status = DESTROYED_DIALOG;
631 632 633
        break;
    }
}