]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/updatevlc.cpp
b4e0f6d6f6cdc185e192ed7d46d95ea10f34af64
[vlc] / modules / gui / wxwidgets / dialogs / updatevlc.cpp
1 /*****************************************************************************
2  * updatevlc.cpp : VLC Update checker
3  *****************************************************************************
4  * Copyright (C) 2000-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include "updatevlc.hpp"
28 #include <wx/imaglist.h>
29
30 #include "bitmaps/update_ascii.xpm"
31 #include "bitmaps/update_binary.xpm"
32 #include "bitmaps/update_document.xpm"
33 #include "bitmaps/update_info.xpm"
34 #include "bitmaps/update_source.xpm"
35
36 /*****************************************************************************
37  * Event Table.
38  *****************************************************************************/
39
40 /* IDs for the controls and the menu commands */
41 enum
42 {
43     Close_Event,
44     CheckForUpdate_Event,
45     ChooseItem_Event
46 };
47
48 BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
49     /* Button events */
50     EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
51     EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)
52
53     /* Hide the window when the user closes the window */
54     EVT_CLOSE(UpdateVLC::OnClose)
55
56 END_EVENT_TABLE()
57
58 /*****************************************************************************
59  * Constructor.
60  *****************************************************************************/
61 UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
62     wxFrame( p_parent, -1, wxU(_("Updates")),
63              wxDefaultPosition, wxDefaultSize,
64              wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT
65              |wxFRAME_TOOL_WINDOW|wxCAPTION )
66 {
67     /* Initializations */
68     p_intf = _p_intf;
69     SetIcon( *p_intf->p_sys->p_icon );
70     SetAutoLayout( TRUE );
71
72     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
73     wxButton *update_button =
74         new wxButton( this, CheckForUpdate_Event,
75                       wxU(_("Check for updates")) );
76     main_sizer->Add( update_button );
77     SetSizerAndFit( main_sizer );
78
79     p_update = update_New( p_intf );
80 }
81
82
83 UpdateVLC::~UpdateVLC()
84 {
85     update_Delete( p_update );
86 }
87
88 void UpdateVLC::OnButtonClose( wxCommandEvent& event )
89 {
90     wxCloseEvent cevent;
91     OnClose(cevent);
92 }
93
94 void UpdateVLC::OnClose( wxCloseEvent& WXUNUSED(event) )
95 {
96     Hide();
97 }
98
99 void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
100 {
101     update_Check( p_update );
102     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
103
104     DestroyChildren();
105
106     /*list->InsertItem( list->GetItemCount(),
107                       wxU(p_uit->file.psz_description)+wxU("\n")
108                       + wxU(p_uit->release.psz_version)+wxU(" ")
109                       + wxU(psz_tmp),
110                       i_image );*/
111
112     if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
113         main_sizer->Add( new wxStaticText( this, -1, wxU( p_update->release.psz_desc )
114                          + wxU( "\nYou can download the latest version of VLC at the adress :\n" )
115                          + wxU( p_update->release.psz_url ) ) );
116     else
117         main_sizer->Add( new wxStaticText( this, -1,
118                          wxU( _( "\nYou have the latest version of VLC\n" ) ) ) );
119
120     SetSizerAndFit( main_sizer );
121     Layout();
122 }