]> 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 16b39c8d17d7d5623f81bee2709be8c271dd6fb7..fa2ad5307fa27926be66de7dd342e40f26fb3819 100644 (file)
@@ -62,30 +62,22 @@ 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;
     SetIcon( *p_intf->p_sys->p_icon );
     SetAutoLayout( TRUE );
 
-    panel = new wxPanel( this, -1 );
-    panel->SetAutoLayout( TRUE );
-
-    main_sizer = new wxBoxSizer( wxVERTICAL );
-    panel_sizer = new wxBoxSizer( wxVERTICAL );
-
-    update_button =  new wxButton( panel, CheckForUpdate_Event,
+    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
+    wxButton *update_button =
+        new wxButton( this, CheckForUpdate_Event,
                       wxU(_("Check for updates")) );
-    panel_sizer->Add( update_button, 0, wxALL, 5 );
-    panel_sizer->Layout();
-    panel->SetSizerAndFit( panel_sizer );
-    main_sizer->Add( panel_sizer );
-    main_sizer->Layout();
-    SetSizer( main_sizer );
-    Fit( );
+    main_sizer->Add( update_button );
+    SetSizerAndFit( main_sizer );
 
     p_u = update_New( p_intf );
 }
@@ -113,18 +105,18 @@ void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
     update_iterator_t *p_uit = update_iterator_New( p_u );
     if( p_uit )
     {
-        panel_sizer->Remove( update_button );
-        panel->DestroyChildren();
+        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( panel, ChooseItem_Event,
+            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 ) );
@@ -152,20 +144,35 @@ 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 );
         }
 
-        panel_sizer->Add( new wxStaticText( panel, -1, wxU( _("\nAvailable updates and related downloads:\n(Double click on a file to download it)\n" ) ) ) );
-        panel_sizer->Add( list, 0, wxALL, 5 );
-        panel_sizer->Layout();
-        panel->SetSizerAndFit( panel_sizer );
-        main_sizer->Layout();
+        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 );
     }
 }
@@ -193,7 +200,7 @@ void UpdateVLC::OnChooseItem( wxListEvent& event )
                         wxSAVE | wxOVERWRITE_PROMPT );
         if( filedialog->ShowModal() == wxID_OK )
         {
-            update_download( p_uit, filedialog->GetPath().mb_str() );
+            update_download( p_uit, filedialog->GetPath().mb_str(wxConvUTF8) );
         }
         update_iterator_Delete( p_uit );
         delete filedialog;