/*****************************************************************************
* dialogs.cpp : wxWindows plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2004 VideoLAN
+ * Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
#include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/intf.h>
-#include "stream_control.h"
#include "wxwindows.h"
void Open( int i_access_method, int i_arg );
/* Event handlers (these functions should _not_ be virtual) */
+ void OnUpdateVLC( wxCommandEvent& event );
void OnExit( wxCommandEvent& event );
void OnPlaylist( wxCommandEvent& event );
void OnMessages( wxCommandEvent& event );
void OnFileInfo( wxCommandEvent& event );
void OnPreferences( wxCommandEvent& event );
- void OnStreamWizardDialog( wxCommandEvent& event );
void OnWizardDialog( wxCommandEvent& event );
void OnBookmarks( wxCommandEvent& event );
void OnOpenFileGeneric( wxCommandEvent& event );
void OnOpenFileSimple( wxCommandEvent& event );
+ void OnOpenDirectory( wxCommandEvent& event );
void OnOpenFile( wxCommandEvent& event );
void OnOpenDisc( wxCommandEvent& event );
void OnOpenNet( wxCommandEvent& event );
/* Secondary windows */
OpenDialog *p_open_dialog;
wxFileDialog *p_file_dialog;
+ wxDirDialog *p_dir_dialog;
Playlist *p_playlist_dialog;
Messages *p_messages_dialog;
FileInfo *p_fileinfo_dialog;
- StreamDialog *p_streamwizard_dialog;
WizardDialog *p_wizard_dialog;
wxFrame *p_prefs_dialog;
wxWindow *p_bookmarks_dialog;
wxFileDialog *p_file_generic_dialog;
+ UpdateVLC *p_updatevlc_dialog;
};
DEFINE_LOCAL_EVENT_TYPE( wxEVT_DIALOG );
DialogsProvider::OnOpenFileSimple)
EVT_COMMAND(INTF_DIALOG_FILE_GENERIC, wxEVT_DIALOG,
DialogsProvider::OnOpenFileGeneric)
+ EVT_COMMAND(INTF_DIALOG_DIRECTORY, wxEVT_DIALOG,
+ DialogsProvider::OnOpenDirectory)
EVT_COMMAND(INTF_DIALOG_PLAYLIST, wxEVT_DIALOG,
DialogsProvider::OnPlaylist)
DialogsProvider::OnMessages)
EVT_COMMAND(INTF_DIALOG_PREFS, wxEVT_DIALOG,
DialogsProvider::OnPreferences)
- EVT_COMMAND(INTF_DIALOG_STREAMWIZARD, wxEVT_DIALOG,
- DialogsProvider::OnStreamWizardDialog)
EVT_COMMAND(INTF_DIALOG_WIZARD, wxEVT_DIALOG,
DialogsProvider::OnWizardDialog)
EVT_COMMAND(INTF_DIALOG_FILEINFO, wxEVT_DIALOG,
DialogsProvider::OnPopupMenu)
EVT_COMMAND(INTF_DIALOG_EXIT, wxEVT_DIALOG,
DialogsProvider::OnExitThread)
+ EVT_COMMAND(INTF_DIALOG_UPDATEVLC, wxEVT_DIALOG,
+ DialogsProvider::OnUpdateVLC)
END_EVENT_TABLE()
wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent )
p_fileinfo_dialog = NULL;
p_prefs_dialog = NULL;
p_file_generic_dialog = NULL;
- p_streamwizard_dialog = NULL;
p_wizard_dialog = NULL;
p_bookmarks_dialog = NULL;
+ p_dir_dialog = NULL;
+ p_updatevlc_dialog = NULL;
/* Give our interface a nice little icon */
p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
/* Intercept all menu events in our custom event handler */
PushEventHandler( new MenuEvtHandler( p_intf, NULL ) );
+
+
+ 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 ); \
+ w->Move( p ); \
+ 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 );
+ INIT( ID_BOOKMARKS, p_bookmarks_dialog, BookmarksDialog(p_intf,this), Show);
+#undef INIT
}
DialogsProvider::~DialogsProvider()
{
+ WindowSettings *ws = p_intf->p_sys->p_window_settings;
+
+#define UPDATE(id,w) \
+ { \
+ if( w && w->IsShown() ) \
+ 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
+
/* Clean up */
if( p_open_dialog ) delete p_open_dialog;
if( p_prefs_dialog ) p_prefs_dialog->Destroy();
if( p_messages_dialog ) delete p_messages_dialog;
if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
if( p_file_generic_dialog ) delete p_file_generic_dialog;
- if( p_streamwizard_dialog ) delete p_streamwizard_dialog;
if( p_wizard_dialog ) delete p_wizard_dialog;
if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
+ if( p_updatevlc_dialog ) delete p_updatevlc_dialog;
if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
void DialogsProvider::OnIdle( wxIdleEvent& WXUNUSED(event) )
{
- /* Update the log window */
- if( p_messages_dialog )
- p_messages_dialog->UpdateLog();
+ /* Update the log window */
+ if( p_messages_dialog )
+ p_messages_dialog->UpdateLog();
- /* Update the playlist */
- if( p_playlist_dialog )
- p_playlist_dialog->UpdatePlaylist();
+ /* Update the playlist */
+ if( p_playlist_dialog )
+ p_playlist_dialog->UpdatePlaylist();
- /* Update the fileinfo windows */
- if( p_fileinfo_dialog )
- p_fileinfo_dialog->UpdateFileInfo();
+ /* Update the fileinfo windows */
+ if( p_fileinfo_dialog )
+ p_fileinfo_dialog->UpdateFileInfo();
}
void DialogsProvider::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
}
}
-void DialogsProvider::OnStreamWizardDialog( wxCommandEvent& WXUNUSED(event) )
-{
- /* Show/hide the stream window */
- if( !p_streamwizard_dialog )
- p_streamwizard_dialog = new StreamDialog( p_intf, this );
-
- if( p_streamwizard_dialog )
- {
- p_streamwizard_dialog->Show( !p_streamwizard_dialog->IsShown() );
- }
-}
-
void DialogsProvider::OnWizardDialog( wxCommandEvent& WXUNUSED(event) )
{
- p_wizard_dialog = new WizardDialog( p_intf, this );
+ p_wizard_dialog = new WizardDialog( p_intf, this, NULL, 0, 0 );
if( p_wizard_dialog )
{
p_wizard_dialog->Run();
+ delete p_wizard_dialog;
}
- delete p_wizard_dialog;
p_wizard_dialog = NULL;
}
p_arg->pf_callback( p_arg );
}
- /* Blocking or not ? */
- if( p_arg->b_blocking )
- {
- vlc_mutex_lock( &p_arg->lock );
- p_arg->b_ready = 1;
- vlc_cond_signal( &p_arg->wait );
- }
-
if( p_arg->psz_results )
{
for( int i = 0; i < p_arg->i_results; i++ )
if( p_arg->psz_title ) free( p_arg->psz_title );
if( p_arg->psz_extensions ) free( p_arg->psz_extensions );
- if( p_arg->b_blocking )
- {
- vlc_mutex_unlock( &p_arg->lock );
- }
- else
- {
- free( p_arg );
- }
+ free( p_arg );
}
void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
vlc_object_release( p_playlist );
}
+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 )
+ p_dir_dialog = new wxDirDialog( NULL );
+
+ if( p_dir_dialog && p_dir_dialog->ShowModal() == wxID_OK )
+ {
+ wxString path = p_dir_dialog->GetPath();
+
+ playlist_Add( p_playlist, (const char *)path.mb_str(),
+ (const char *)path.mb_str(),
+ PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
+ PLAYLIST_END );
+ }
+
+ vlc_object_release( p_playlist );
+}
+
void DialogsProvider::OnOpenFile( wxCommandEvent& event )
{
Open( FILE_ACCESS, event.GetInt() );
{
wxTheApp->ExitMainLoop();
}
+
+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() );
+ }
+}