<commit_before>/*****************************************************************************
 * updatevlc.cpp : Check for VLC updates dialog
 *****************************************************************************
 * Copyright (C) 2000-2004 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/intf.h>

#include <wx/progdlg.h>

#include "wxwidgets.h"

#include "vlc_block.h"
#include "vlc_stream.h"
#include "vlc_xml.h"

/* define UPDATE_VLC_OS and UPDATE_VLC_ARCH */
/* todo : move this somewhere else (isn't wx specific) */

#ifdef WIN32
#   define UPDATE_VLC_OS "windows"
#   define UPDATE_VLC_ARCH "i386"
#else
#ifdef SYS_DARWIN
#   define UPDATE_VLC_OS "macosx"
#   define UPDATE_VLC_ARCH "ppc"
#else
#   define UPDATE_VLC_OS "*"
#   define UPDATE_VLC_ARCH "*"
#endif
#endif

/* arch == "*" and os == "*" concern non OS or arch specific stuff */

#define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status"
#define UPDATE_VLC_MIRRORS_URL "http://update.videolan.org/mirrors"

#define UPDATE_VLC_DOWNLOAD_BUFFER_SIZE 2048

class UpdatesTreeItem : public wxTreeItemData
{
    public:
        UpdatesTreeItem( wxString _url ):wxTreeItemData()
        {
            url = _url;
        }
        wxString url;
};

/*****************************************************************************
 * Event Table.
 *****************************************************************************/

/* IDs for the controls and the menu commands */
enum
{
    Close_Event,
    CheckForUpdate_Event,
    MirrorChoice_Event,
    UpdatesTreeActivate_Event
};

BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
    /* Button events */
    EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
    EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)

    /* Choice events */
    EVT_CHOICE(MirrorChoice_Event, UpdateVLC::OnMirrorChoice)

    /* Tree events */
    EVT_TREE_ITEM_ACTIVATED(UpdatesTreeActivate_Event, UpdateVLC::OnUpdatesTreeActivate)

    /* Hide the window when the user closes the window */
    EVT_CLOSE(UpdateVLC::OnClose)

END_EVENT_TABLE()

/*****************************************************************************
 * Constructor.
 *****************************************************************************/
UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
    wxFrame( p_parent, -1, wxU(_("Check for updates ...")), wxDefaultPosition,
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
    /* Initializations */
    p_intf = _p_intf;
    release_type = wxT( "stable" );
    SetIcon( *p_intf->p_sys->p_icon );
    SetAutoLayout( TRUE );

    /* Create a panel to put everything in */
    wxPanel *panel = new wxPanel( this, -1 );
    panel->SetAutoLayout( TRUE );

    updates_tree =
        new wxTreeCtrl( panel, UpdatesTreeActivate_Event, wxDefaultPosition,
                        wxSize( 400, 200 ),
                        wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
    updates_tree->AddRoot( wxU(_("root" )), -1, -1, NULL );

    /* Place everything in sizers */
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *subpanel_sizer = new wxBoxSizer( wxHORIZONTAL );
    panel_sizer->Add( updates_tree, 0, wxGROW | wxALL, 5 );
    wxButton *update_button =
        new wxButton( panel, CheckForUpdate_Event,
                      wxU(_("Check for updates now !")) );
    subpanel_sizer->Add( update_button, 0, wxALL, 5 );
//wxChoice constructor prototype changes with 2.5
#if wxCHECK_VERSION(2,5,0)
    wxArrayString *choices_array = new wxArrayString();
    choices_array->Add( wxT("") );
    mirrors_choice =
        new wxChoice( panel, MirrorChoice_Event, wxDefaultPosition,
                      wxSize( 200, -1 ), *choices_array );
#else
    wxString choices_array = wxT("");
    mirrors_choice =
        new wxChoice( panel, -1, wxDefaultPosition,
                      wxSize( 200, -1 ),1, *choices_array );
#endif
    subpanel_sizer->Add( mirrors_choice, 0, wxALL, 5 );
    subpanel_sizer->Layout();
    panel_sizer->Add( subpanel_sizer, 0, wxALL , 0 );
    panel_sizer->Layout();
    panel->SetSizerAndFit( panel_sizer );
    main_sizer->Add( panel, 0, wxALL | wxGROW, 0 );
    main_sizer->Layout();
    SetSizerAndFit( main_sizer );

    UpdateMirrorsChoice();
    UpdateUpdatesTree();
}


UpdateVLC::~UpdateVLC()
{
}

/* this function gets all the info from the xml files hosted on
http://update.videolan.org/ and stores it in appropriate lists */
void UpdateVLC::GetData()
{<commit_msg> * wxwidgets/updatevlc.cpp: Resize the tree control when resizing the window<commit_after>/*****************************************************************************
 * updatevlc.cpp : Check for VLC updates dialog
 *****************************************************************************
 * Copyright (C) 2000-2004 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/intf.h>

#include <wx/progdlg.h>

#include "wxwidgets.h"

#include "vlc_block.h"
#include "vlc_stream.h"
#include "vlc_xml.h"

/* define UPDATE_VLC_OS and UPDATE_VLC_ARCH */
/* todo : move this somewhere else (isn't wx specific) */

#ifdef WIN32
#   define UPDATE_VLC_OS "windows"
#   define UPDATE_VLC_ARCH "i386"
#else
#ifdef SYS_DARWIN
#   define UPDATE_VLC_OS "macosx"
#   define UPDATE_VLC_ARCH "ppc"
#else
#   define UPDATE_VLC_OS "*"
#   define UPDATE_VLC_ARCH "*"
#endif
#endif

/* arch == "*" and os == "*" concern non OS or arch specific stuff */

#define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status"
#define UPDATE_VLC_MIRRORS_URL "http://update.videolan.org/mirrors"

#define UPDATE_VLC_DOWNLOAD_BUFFER_SIZE 2048

class UpdatesTreeItem : public wxTreeItemData
{
    public:
        UpdatesTreeItem( wxString _url ):wxTreeItemData()
        {
            url = _url;
        }
        wxString url;
};

/*****************************************************************************
 * Event Table.
 *****************************************************************************/

/* IDs for the controls and the menu commands */
enum
{
    Close_Event,
    CheckForUpdate_Event,
    MirrorChoice_Event,
    UpdatesTreeActivate_Event
};

BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
    /* Button events */
    EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
    EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)

    /* Choice events */
    EVT_CHOICE(MirrorChoice_Event, UpdateVLC::OnMirrorChoice)

    /* Tree events */
    EVT_TREE_ITEM_ACTIVATED(UpdatesTreeActivate_Event, UpdateVLC::OnUpdatesTreeActivate)

    /* Hide the window when the user closes the window */
    EVT_CLOSE(UpdateVLC::OnClose)

END_EVENT_TABLE()

/*****************************************************************************
 * Constructor.
 *****************************************************************************/
UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
    wxFrame( p_parent, -1, wxU(_("Check for updates ...")), wxDefaultPosition,
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
    /* Initializations */
    p_intf = _p_intf;
    release_type = wxT( "stable" );
    SetIcon( *p_intf->p_sys->p_icon );
    SetAutoLayout( TRUE );

    /* Create a panel to put everything in */
    wxPanel *panel = new wxPanel( this, -1 );
    panel->SetAutoLayout( TRUE );

    updates_tree =
        new wxTreeCtrl( panel, UpdatesTreeActivate_Event, wxDefaultPosition,
                        wxSize( 400, 200 ),
                        wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
    updates_tree->AddRoot( wxU(_("root" )), -1, -1, NULL );

    /* Place everything in sizers */
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *subpanel_sizer = new wxBoxSizer( wxHORIZONTAL );
    panel_sizer->Add( updates_tree, 1, wxGROW | wxALL, 5 );
    wxButton *update_button =
        new wxButton( panel, CheckForUpdate_Event,
                      wxU(_("Check for updates now !")) );
    subpanel_sizer->Add( update_button, 0, wxALL, 5 );
//wxChoice constructor prototype changes with 2.5
#if wxCHECK_VERSION(2,5,0)
    wxArrayString *choices_array = new wxArrayString();
    choices_array->Add( wxT("") );
    mirrors_choice =
        new wxChoice( panel, MirrorChoice_Event, wxDefaultPosition,
                      wxSize( 200, -1 ), *choices_array );
#else
    wxString choices_array = wxT("");
    mirrors_choice =
        new wxChoice( panel, -1, wxDefaultPosition,
                      wxSize( 200, -1 ),1, *choices_array );
#endif
    subpanel_sizer->Add( mirrors_choice, 0, wxALL, 5 );
    subpanel_sizer->Layout();
    panel_sizer->Add( subpanel_sizer, 0, wxALL , 0 );
    panel_sizer->Layout();
    panel->SetSizerAndFit( panel_sizer );
    main_sizer->Add( panel, 1, wxALL | wxGROW, 0 );
    main_sizer->Layout();
    SetSizerAndFit( main_sizer );

    UpdateMirrorsChoice();
    UpdateUpdatesTree();
}


UpdateVLC::~UpdateVLC()
{
}

/* this function gets all the info from the xml files hosted on
http://update.videolan.org/ and stores it in appropriate lists */
void UpdateVLC::GetData()
{
{'fraction_non_alphanumeric': 0.21815900331630367, 'fraction_numerical': 0.0112933584296854, 'mean_word_length': 3.961316140506892, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5090243', 'n_tokens_mistral': 3513, 'n_tokens_neox': 3253, 'n_words': 887}