]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/dialogs.cpp
VLC update checker in the wxWidgets interface (in help menu)
[vlc] / modules / gui / wxwindows / dialogs.cpp
index b27b7734703b5d6c64e5486695f5cd9d7a9de773..287ea43bf18b774a03209cdfe24c3306a8f3ca70 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * 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>
@@ -32,7 +32,6 @@
 #include <vlc/vlc.h>
 #include <vlc/aout.h>
 #include <vlc/intf.h>
-#include "stream_control.h"
 
 #include "wxwindows.h"
 
@@ -51,17 +50,18 @@ private:
     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 );
@@ -82,14 +82,15 @@ public:
     /* 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 );
@@ -108,6 +109,8 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
                 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)
@@ -115,8 +118,6 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
                 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,
@@ -127,6 +128,8 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
                 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 )
@@ -149,9 +152,10 @@ DialogsProvider::DialogsProvider( 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 );
@@ -166,10 +170,50 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
 
     /* 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();
@@ -178,9 +222,9 @@ DialogsProvider::~DialogsProvider()
     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;
@@ -194,17 +238,17 @@ DialogsProvider::~DialogsProvider()
 
 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) )
@@ -255,28 +299,16 @@ void DialogsProvider::OnPreferences( 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;
 }
 
@@ -335,14 +367,6 @@ void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event )
         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++ )
@@ -354,14 +378,7 @@ void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event )
     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 )
@@ -399,6 +416,32 @@ 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() );
@@ -442,3 +485,15 @@ void DialogsProvider::OnExitThread( wxCommandEvent& WXUNUSED(event) )
 {
     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() );
+    }
+}