]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs/updatevlc.cpp
XCB: grey scale output support
[vlc] / modules / gui / wxwidgets / dialogs / updatevlc.cpp
index a0de89fd7e6c3a616301bdafc15dd58d09ece434..8f4fd2249c155c0eb9323fc36d079f7167819cfc 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "updatevlc.hpp"
+
+#ifdef UPDATE_CHECK
 #include <wx/imaglist.h>
 
 #include "bitmaps/update_ascii.xpm"
 #include "bitmaps/update_info.xpm"
 #include "bitmaps/update_source.xpm"
 
-#include "vlc_block.h"
-#include "vlc_stream.h"
-
-#define UPDATE_VLC_DOWNLOAD_BUFFER_SIZE 2048
-
 /*****************************************************************************
  * Event Table.
  *****************************************************************************/
@@ -55,9 +53,6 @@ BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
     EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
     EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)
 
-    /* CtrlList events */
-    EVT_LIST_ITEM_ACTIVATED( ChooseItem_Event, UpdateVLC::OnChooseItem )
-
     /* Hide the window when the user closes the window */
     EVT_CLOSE(UpdateVLC::OnClose)
 
@@ -67,9 +62,10 @@ END_EVENT_TABLE()
  * Constructor.
  *****************************************************************************/
 UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
-    wxFrame( p_parent, -1, wxU(_("VLC media player - Updates")),
+    wxFrame( p_parent, -1, wxU(_("Updates")),
              wxDefaultPosition, wxDefaultSize,
-         wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT|wxFRAME_TOOL_WINDOW)
+             wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT
+             |wxFRAME_TOOL_WINDOW|wxCAPTION )
 {
     /* Initializations */
     p_intf = _p_intf;
@@ -79,17 +75,17 @@ UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
     wxButton *update_button =
         new wxButton( this, CheckForUpdate_Event,
-                      wxU(_("Check for updates now !")) );
+                      wxU(_("Check for updates")) );
     main_sizer->Add( update_button );
     SetSizerAndFit( main_sizer );
 
-    p_u = update_New( p_intf );
+    p_update = update_New( p_intf );
 }
 
 
 UpdateVLC::~UpdateVLC()
 {
-    update_Delete( p_u );
+    update_Delete( p_update );
 }
 
 void UpdateVLC::OnButtonClose( wxCommandEvent& event )
@@ -105,97 +101,30 @@ void UpdateVLC::OnClose( wxCloseEvent& WXUNUSED(event) )
 
 void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
 {
-    update_Check( p_u, VLC_FALSE );
-    update_iterator_t *p_uit = update_iterator_New( p_u );
-    if( p_uit )
-    {
-        wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
-
-        p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
-        p_uit->i_t = UPDATE_FILE_TYPE_ALL;
-        update_iterator_Action( p_uit, UPDATE_MIRROR );
-
-        DestroyChildren();
-
-        wxListCtrl *list =
-            new wxListCtrl( this, ChooseItem_Event,
-                            wxDefaultPosition, wxSize( 400, 300 ),
-                            wxLC_AUTOARRANGE|wxLC_SINGLE_SEL );
-        wxImageList *images = new wxImageList( 32, 32, TRUE );
-        images->Add( wxIcon( update_ascii_xpm ) );
-        images->Add( wxIcon( update_info_xpm ) );
-        images->Add( wxIcon( update_source_xpm ) );
-        images->Add( wxIcon( update_binary_xpm ) );
-        images->Add( wxIcon( update_document_xpm ) );
-        list->AssignImageList( images, wxIMAGE_LIST_SMALL );
-        while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
-        {
-            /*wxButton *update_button =
-                new wxButton( this, Download_Event,
-                      wxU(p_uit->file.psz_description) );
-            main_sizer->Add( update_button, 0, wxALIGN_CENTER );*/
-            int i_image;
-            switch( p_uit->file.i_type )
-            {
-                case UPDATE_FILE_TYPE_INFO:
-                    i_image = 1;
-                    break;
-                case UPDATE_FILE_TYPE_SOURCE:
-                    i_image = 2;
-                    break;
-                case UPDATE_FILE_TYPE_BINARY:
-                    i_image = 3;
-                    break;
-                case UPDATE_FILE_TYPE_PLUGIN:
-                    i_image = 4;
-                    break;
-                default:
-                    i_image = 0;
-            }
-            list->InsertItem( list->GetItemCount(),
-                              wxU(p_uit->file.psz_description)+wxU("\n")
-                              + wxU(p_uit->release.psz_version)+wxU(" (")
-                              + wxU(p_uit->release.psz_svn_revision)+wxU(")"),
-                              i_image );
-        }
-
-        main_sizer->Add( new wxStaticText( this, -1, wxU( _("\nAvailable updates and related downloads:\n(Double click on a file to download it)\n" ) ) ) );
-        main_sizer->Add( list/*, 0, wxEXPAND */);
-        SetSizerAndFit( main_sizer );
-        Layout();
-        update_iterator_Delete( p_uit );
-    }
-}
+    update_Check( p_update, NULL, this );
+    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
 
-void UpdateVLC::OnChooseItem( wxListEvent& event )
-{
-    update_iterator_t *p_uit = update_iterator_New( p_u );
-    if( p_uit )
+    DestroyChildren();
+
+    /*list->InsertItem( list->GetItemCount(),
+                      wxU(p_uit->file.psz_description)+wxU("\n")
+                      + wxU(p_uit->release.psz_version)+wxU(" ")
+                      + wxU(psz_tmp),
+                      i_image );*/
+
+    if( update_NeedUpgrade( p_update ) )
     {
-        p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
-        p_uit->i_t = UPDATE_FILE_TYPE_ALL;
-        update_iterator_Action( p_uit, UPDATE_MIRROR );
-
-        int i_count = 0;
-        while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
-        {
-            if( i_count == event.GetIndex() )
-                break;
-            i_count++;
-        }
-        wxString url = wxU( p_uit->file.psz_url );
-        wxFileDialog *filedialog =
-                    new wxFileDialog( this, wxU(_("Save file ...")),
-                        wxT(""), url.AfterLast( '/' ), wxT("*.*"),
-                        wxSAVE | wxOVERWRITE_PROMPT );
-        if( filedialog->ShowModal() == wxID_OK )
-        {
-            char *psz_dest = ToLocale( filedialog->GetPath().mb_str() );
-
-            update_download( p_uit, psz_dest );
-            LocaleFree( psz_dest );
-        }
-        update_iterator_Delete( p_uit );
-        delete filedialog;
+        update_release_t *p_release = update_GetRelease( p_update );
+        assert( p_release );
+        main_sizer->Add( new wxStaticText( this, -1, wxU( p_release->psz_desc )
+                         + wxU( "\nYou can download the latest version of VLC at the adress :\n" )
+                         + wxU( p_release->psz_url ) ) );
     }
+    else
+        main_sizer->Add( new wxStaticText( this, -1,
+                         wxU( _( "\nYou have the latest version of VLC\n" ) ) ) );
+
+    SetSizerAndFit( main_sizer );
+    Layout();
 }
+#endif