]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/updatevlc.cpp
88eb5e0eaa984f0b7421558c99299f5b4763a8a5
[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 #ifdef UPDATE_CHECK
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include "updatevlc.hpp"
30 #include <wx/imaglist.h>
31
32 #include "bitmaps/update_ascii.xpm"
33 #include "bitmaps/update_binary.xpm"
34 #include "bitmaps/update_document.xpm"
35 #include "bitmaps/update_info.xpm"
36 #include "bitmaps/update_source.xpm"
37
38 /*****************************************************************************
39  * Event Table.
40  *****************************************************************************/
41
42 /* IDs for the controls and the menu commands */
43 enum
44 {
45     Close_Event,
46     CheckForUpdate_Event,
47     ChooseItem_Event
48 };
49
50 BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
51     /* Button events */
52     EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
53     EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)
54
55     /* Hide the window when the user closes the window */
56     EVT_CLOSE(UpdateVLC::OnClose)
57
58 END_EVENT_TABLE()
59
60 /*****************************************************************************
61  * Constructor.
62  *****************************************************************************/
63 UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
64     wxFrame( p_parent, -1, wxU(_("Updates")),
65              wxDefaultPosition, wxDefaultSize,
66              wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT
67              |wxFRAME_TOOL_WINDOW|wxCAPTION )
68 {
69     /* Initializations */
70     p_intf = _p_intf;
71     SetIcon( *p_intf->p_sys->p_icon );
72     SetAutoLayout( TRUE );
73
74     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
75     wxButton *update_button =
76         new wxButton( this, CheckForUpdate_Event,
77                       wxU(_("Check for updates")) );
78     main_sizer->Add( update_button );
79     SetSizerAndFit( main_sizer );
80
81     p_update = update_New( p_intf );
82 }
83
84
85 UpdateVLC::~UpdateVLC()
86 {
87     update_Delete( p_update );
88 }
89
90 void UpdateVLC::OnButtonClose( wxCommandEvent& event )
91 {
92     wxCloseEvent cevent;
93     OnClose(cevent);
94 }
95
96 void UpdateVLC::OnClose( wxCloseEvent& WXUNUSED(event) )
97 {
98     Hide();
99 }
100
101 void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
102 {
103     update_Check( p_update );
104     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
105
106     DestroyChildren();
107
108     /*list->InsertItem( list->GetItemCount(),
109                       wxU(p_uit->file.psz_description)+wxU("\n")
110                       + wxU(p_uit->release.psz_version)+wxU(" ")
111                       + wxU(psz_tmp),
112                       i_image );*/
113
114     if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
115         main_sizer->Add( new wxStaticText( this, -1, wxU( p_update->release.psz_desc )
116                          + wxU( "\nYou can download the latest version of VLC at the adress :\n" )
117                          + wxU( p_update->release.psz_url ) ) );
118     else
119         main_sizer->Add( new wxStaticText( this, -1,
120                          wxU( _( "\nYou have the latest version of VLC\n" ) ) ) );
121
122     SetSizerAndFit( main_sizer );
123     Layout();
124 }
125 #endif