]> 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 1dab4ede2cd1cdd7a5335f555ca25e82fac4160a..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>
@@ -50,6 +50,7 @@ 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 );
@@ -89,6 +90,7 @@ public:
     wxFrame             *p_prefs_dialog;
     wxWindow            *p_bookmarks_dialog;
     wxFileDialog        *p_file_generic_dialog;
+    UpdateVLC           *p_updatevlc_dialog;
 };
 
 DEFINE_LOCAL_EVENT_TYPE( wxEVT_DIALOG );
@@ -126,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 )
@@ -150,6 +154,8 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
     p_file_generic_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 );
@@ -164,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,6 +224,7 @@ DialogsProvider::~DialogsProvider()
     if( p_file_generic_dialog ) delete p_file_generic_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;
@@ -191,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) )
@@ -384,17 +431,12 @@ void DialogsProvider::OnOpenDirectory( wxCommandEvent& event )
 
     if( p_dir_dialog && p_dir_dialog->ShowModal() == wxID_OK )
     {
-        playlist_item_t *p_item;
         wxString path = p_dir_dialog->GetPath();
 
-        int i_id = playlist_Add( p_playlist, (const char *)path.mb_str(),
-                                             (const char *)path.mb_str(),
-                                             PLAYLIST_APPEND, PLAYLIST_END );
-        p_item = playlist_ItemGetById( p_playlist, i_id );
-        if( p_item )
-        {
-            input_CreateThread( p_intf, &p_item->input );
-        }
+        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 );
@@ -443,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() );
+    }
+}