]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs/updatevlc.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / wxwidgets / dialogs / updatevlc.cpp
index 790b6fa7dc81fe4344ab7ed7afb48bad72f0fec1..fa2ad5307fa27926be66de7dd342e40f26fb3819 100644 (file)
@@ -25,9 +25,7 @@
  * Preamble
  *****************************************************************************/
 #include "updatevlc.hpp"
-#include <wx/listctrl.h>
 #include <wx/imaglist.h>
-#include <wx/thread.h>
 
 #include "bitmaps/update_ascii.xpm"
 #include "bitmaps/update_binary.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.
  *****************************************************************************/
@@ -69,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;
@@ -81,7 +75,7 @@ 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 );
 
@@ -122,7 +116,7 @@ void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
         wxListCtrl *list =
             new wxListCtrl( this, ChooseItem_Event,
                             wxDefaultPosition, wxSize( 400, 300 ),
-                            wxLC_AUTOARRANGE|wxLC_SINGLE_SEL );
+                            wxLC_SINGLE_SEL|wxLC_LIST );
         wxImageList *images = new wxImageList( 32, 32, TRUE );
         images->Add( wxIcon( update_ascii_xpm ) );
         images->Add( wxIcon( update_info_xpm ) );
@@ -132,10 +126,6 @@ void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
         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 )
             {
@@ -154,41 +144,39 @@ void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
                 default:
                     i_image = 0;
             }
+            char *psz_tmp = NULL;
+            if( p_uit->file.l_size )
+            {
+                if( p_uit->file.l_size > 1024 * 1024 * 1024 )
+                     asprintf( &psz_tmp, "(%ld GB)",
+                                p_uit->file.l_size / (1024*1024*1024) );
+                if( p_uit->file.l_size > 1024 * 1024 )
+                    asprintf( &psz_tmp, "(%ld MB)",
+                                p_uit->file.l_size / (1024*1024) );
+                else if( p_uit->file.l_size > 1024 )
+                    asprintf( &psz_tmp, "(%ld kB)",
+                                p_uit->file.l_size / 1024 );
+                else
+                    asprintf( &psz_tmp, "(%ld B)", p_uit->file.l_size );
+            }
             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(")"),
+                              + wxU(p_uit->release.psz_version)+wxU(" ")
+                              + wxU(psz_tmp),
                               i_image );
+            if( psz_tmp ) free( psz_tmp );
         }
 
-        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 */);
+        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 );
         SetSizerAndFit( main_sizer );
         Layout();
         update_iterator_Delete( p_uit );
     }
 }
 
-class DownloadThread : public wxThread
-{
-    public:
-    DownloadThread( update_iterator_t *p_uit, char *psz_dest )
-        :p_uit( p_uit ),psz_dest( psz_dest )
-    {
-            Create();
-            Run();
-    }
-    ExitCode Entry()
-    {
-        update_download( p_uit, psz_dest );
-        update_iterator_Delete( p_uit );
-        LocaleFree( psz_dest );
-        return 0;
-    };
-    update_iterator_t *p_uit;
-    char *psz_dest;
-};
-
 void UpdateVLC::OnChooseItem( wxListEvent& event )
 {
     update_iterator_t *p_uit = update_iterator_New( p_u );
@@ -207,21 +195,14 @@ void UpdateVLC::OnChooseItem( wxListEvent& event )
         }
         wxString url = wxU( p_uit->file.psz_url );
         wxFileDialog *filedialog =
-                    new wxFileDialog( this, wxU(_("Save file ...")),
+                    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() );
-
-            /* Launch the download process in a new thread so it doesn't
-             * block the interface */
-            new DownloadThread( p_uit, psz_dest );
-        }
-        else
-        {
-            update_iterator_Delete( p_uit );
+            update_download( p_uit, filedialog->GetPath().mb_str(wxConvUTF8) );
         }
+        update_iterator_Delete( p_uit );
         delete filedialog;
     }
 }