summaryrefslogtreecommitdiff
path: root/rbutil/wizard_pages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/wizard_pages.cpp')
-rw-r--r--rbutil/wizard_pages.cpp362
1 files changed, 352 insertions, 10 deletions
diff --git a/rbutil/wizard_pages.cpp b/rbutil/wizard_pages.cpp
index 7cd38cf004..2c4c609271 100644
--- a/rbutil/wizard_pages.cpp
+++ b/rbutil/wizard_pages.cpp
@@ -19,6 +19,85 @@
19 ****************************************************************************/ 19 ****************************************************************************/
20 20
21#include "wizard_pages.h" 21#include "wizard_pages.h"
22#include "bootloaders.h"
23
24wxBootPlatformPage::wxBootPlatformPage(wxWizard *parent) : wxWizardPageSimple(parent)
25{
26 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
27
28 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
29 _("Please select the model of audio device that you would like to"
30 "\ninstall the Rockbox Bootloader on from the list below:"));
31 WxBoxSizer1->Add(WxStaticText1,0,wxGROW | wxALL,5);
32
33 wxArrayString arrayStringFor_WxListBox1;
34 for (unsigned int i=0; i< gv->plat_name.GetCount(); i++) {
35 if (gv->plat_needsbootloader[i])
36 {
37 if(gv->plat_autodetect[i])
38 {
39 if(arrayStringFor_WxListBox1.Index(gv->plat_combinedname[i]) == wxNOT_FOUND)
40 arrayStringFor_WxListBox1.Add(gv->plat_combinedname[i]);
41 }
42 else
43 {
44 arrayStringFor_WxListBox1.Add(gv->plat_name[i]);
45 }
46 }
47 }
48
49 BootPlatformListBox = new wxListBox(this, wxID_ANY, wxDefaultPosition,
50 wxDefaultSize, arrayStringFor_WxListBox1, wxLB_SINGLE);
51 WxBoxSizer1->Add(BootPlatformListBox,0,wxGROW | wxALL,5);
52
53 SetSizer(WxBoxSizer1);
54 WxBoxSizer1->Fit(this);
55
56 for (unsigned int i=0; i< gv->plat_id.GetCount(); i++) {
57 if (gv->plat_id[i] == gv->curplat) BootPlatformListBox->SetSelection(i);
58 }
59
60}
61
62wxWizardPage * wxBootPlatformPage::GetNext() const
63{
64 if(gv->curbootloadermethod != "fwpatcher"&& gv->curbootloadermethod != "ipodpatcher")
65 {
66 if(wxWizardPageSimple::GetNext()->GetNext() != NULL) // not iriver hx0 and ipod, skip one page
67 return wxWizardPageSimple::GetNext()->GetNext();
68 }
69 else if(gv->curbootloadermethod == "ipodpatcher")
70 {
71 if(wxWizardPageSimple::GetNext()->GetNext() != NULL)
72 if(wxWizardPageSimple::GetNext()->GetNext()->GetNext() != NULL)
73 return wxWizardPageSimple::GetNext()->GetNext()->GetNext(); //ipod, skip 2 pages
74 else
75 return wxWizardPageSimple::GetNext()->GetNext(); //ipod, skip 1 page (for uninstallation)
76 }
77
78 // all others , no skip
79 return wxWizardPageSimple::GetNext();
80}
81
82bool wxBootPlatformPage::TransferDataFromWindow()
83{
84 if (BootPlatformListBox->GetSelection() == wxNOT_FOUND )
85 {
86 WARN_DIALOG(_("You must select an audio device type before proceeding"),
87 _("Select Platform"));
88 return false;
89 } else
90 {
91 int idx = gv->plat_name.Index(BootPlatformListBox->GetStringSelection());
92 if(idx == wxNOT_FOUND) idx =gv->plat_combinedname.Index(BootPlatformListBox->GetStringSelection());
93 gv->curplatnum = idx;
94 gv->curplat = gv->plat_id[gv->curplatnum];
95 gv->curbootloadermethod = gv->plat_bootloadermethod[gv->curplatnum];
96 gv->curbootloader = gv->plat_bootloadername[gv->curplatnum];
97
98 return true;
99 }
100}
22 101
23wxPlatformPage::wxPlatformPage(wxWizard *parent) : wxWizardPageSimple(parent) 102wxPlatformPage::wxPlatformPage(wxWizard *parent) : wxWizardPageSimple(parent)
24{ 103{
@@ -56,8 +135,265 @@ bool wxPlatformPage::TransferDataFromWindow()
56 } 135 }
57} 136}
58 137
138BEGIN_EVENT_TABLE(wxIpodLocationPage,wxWizardPageSimple)
139 EVT_BUTTON (ID_IPODLOCATION_BTN, wxIpodLocationPage::OnIpodLocationBtn)
140 EVT_WIZARD_PAGE_CHANGING(wxID_ANY, wxIpodLocationPage::OnWizardPageChanging)
141END_EVENT_TABLE();
142
143wxIpodLocationPage::wxIpodLocationPage(wxWizard* parent) : wxWizardPageSimple(parent)
144{
145
146 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
147
148 // Header text
149 IpodLocationLabel = new wxStaticText(this, wxID_ANY,
150 wxT("Rockbox utility needs to know the device where your ipod\n"
151 "device is located on your computer. Rockbox utility\n"
152 "has detected the following location:"));
153 WxBoxSizer1->Add(IpodLocationLabel,0,wxGROW | wxALL, 5);
154
155 // device location
156 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
157 WxBoxSizer1->Add(WxBoxSizer3,0,
158 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
159
160 IpodLocationText = new wxStaticText(this, wxID_ANY, "",
161 wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
162 WxBoxSizer3->Add(IpodLocationText,1,
163 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
164
165 IpodLocationBtn = new wxButton(this, ID_IPODLOCATION_BTN, wxT("Scan"),
166 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator,
167 wxT("IpodLocationBtn"));
168 IpodLocationBtn->SetToolTip(wxT("Scan for your Ipod"));
169 WxBoxSizer3->Add(IpodLocationBtn,0,wxALIGN_CENTER_VERTICAL | wxALL, 5);
170
171 // Extra text
172 IpodLocationExtraText = new wxStaticText(this,wxID_ANY, wxT(""));
173 WxBoxSizer1->Add(IpodLocationExtraText,0,wxGROW | wxALL, 5);
174
175 SetSizer(WxBoxSizer1);
176 WxBoxSizer1->Fit(this);
177}
178
179wxWizardPage* wxIpodLocationPage::GetPrev() const
180{
181 if(gv->curbootloadermethod == "ipodpatcher") //if ipod, skip previous
182 {
183 if(wxWizardPageSimple::GetPrev()->GetPrev() != NULL)
184 return wxWizardPageSimple::GetPrev()->GetPrev();
185
186 }
187}
188
189void wxIpodLocationPage::OnWizardPageChanging(wxWizardEvent& event)
190{
191 if(event.GetDirection()) // going forwards in the Wizard
192 {
193 if(gv->curbootloadermethod=="ipodpatcher")
194 {
195 if(IpodLocationText->GetLabel() == "no Ipod found" ||
196 IpodLocationText->GetLabel() =="More than 1 Ipod found" ||
197 IpodLocationText->GetLabel() =="")
198 {
199 WARN_DIALOG(_("No valid ipod found!"), _("Select Location"));
200 event.Veto(); //stop pagechanging
201 }
202 }
203 }
204}
205
206void wxIpodLocationPage::OnIpodLocationBtn(wxCommandEvent& event)
207{
208 wxLogVerbose("=== begin wxIpodLocationPage::OnIpodLocationBtn");
209 struct ipod_t ipod;
210 int n = ipod_scan(&ipod);
211
212 gv->curbootloader="bootloader-";
213 gv->curbootloader.Append(ipod.targetname);
214 if(n == 0)
215 IpodLocationText->SetLabel("no Ipod found");
216 else if( n==1)
217 IpodLocationText->SetLabel(ipod.modelstr);
218 else
219 IpodLocationText->SetLabel("More than 1 Ipod found");
220
221 if(ipod.macpod)
222 IpodLocationExtraText->SetLabel("This Ipod is a Mac formated Ipod\n"
223 "Rockbox will not work on this.\n"
224 "You have to convert it first to Fat32");
225 wxLogVerbose("=== end wxIpodLocationPage::OnIpodLocationBtn");
226
227}
228
229BEGIN_EVENT_TABLE(wxBootLocationPage,wxWizardPageSimple)
230 EVT_BUTTON (ID_BOOTLOCATION_BTN, wxBootLocationPage::OnBootLocationBtn)
231 EVT_WIZARD_PAGE_CHANGING(wxID_ANY, wxBootLocationPage::OnWizardPageChanging)
232END_EVENT_TABLE();
233
234wxBootLocationPage::wxBootLocationPage(wxWizard* parent) : wxWizardPageSimple(parent)
235 {
236
237 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
238
239 // Header text
240 BootLocationLabel = new wxStaticText(this, wxID_ANY,
241 wxT("Rockbox utility needs to know the folder where your audio\n"
242 "device is located on your computer. Currently Rockbox utility\n"
243 "is configured to use the following location:"));
244 WxBoxSizer1->Add(BootLocationLabel,0,wxGROW | wxALL, 5);
245
246 // device location
247 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
248 WxBoxSizer1->Add(WxBoxSizer3,0,
249 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
250
251 if (gv->curdestdir == wxT("")) gv->curdestdir = _("<none>");
252 BootLocationText = new wxStaticText(this, wxID_ANY, gv->curdestdir,
253 wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
254 WxBoxSizer3->Add(BootLocationText,1,
255 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
256
257 BootLocationBtn = new wxButton(this, ID_BOOTLOCATION_BTN, wxT("Change"),
258 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator,
259 wxT("BootLocationBtn"));
260 BootLocationBtn->SetToolTip(wxT("Select the location of your audio device"));
261 WxBoxSizer3->Add(BootLocationBtn,0,wxALIGN_CENTER_VERTICAL | wxALL, 5);
262
263 SetSizer(WxBoxSizer1);
264 WxBoxSizer1->Fit(this);
265}
266
267wxWizardPage* wxBootLocationPage::GetPrev() const
268{
269 if(gv->curbootloadermethod != "fwpatcher")
270 {
271 if(wxWizardPageSimple::GetPrev()->GetPrev() != NULL)
272 return wxWizardPageSimple::GetPrev()->GetPrev();
273
274 }
275
276 return wxWizardPageSimple::GetPrev();
277}
278
279wxWizardPage* wxBootLocationPage::GetNext() const
280{
281 if(gv->curbootloadermethod == "ipodpatcher")
282 {
283 return wxWizardPageSimple::GetNext(); // if ipod then this is not the last page
284 }
285 else return NULL; // else this is the last page
286}
287
288void wxBootLocationPage::OnWizardPageChanging(wxWizardEvent& event)
289{
290 if(event.GetDirection()) // going forwards in the Wizard
291 {
292 if(!wxDirExists(BootLocationText->GetLabel()))
293 {
294 WARN_DIALOG(_("You have not selected a valid location for your audio "
295 "device"), _("Select Location"));
296 event.Veto();
297 }
298
299 }
300}
301
302bool wxBootLocationPage::TransferDataFromWindow()
303{
304 gv->curdestdir = BootLocationText->GetLabel();
305 return true;
306
307}
308
309
310void wxBootLocationPage::OnBootLocationBtn(wxCommandEvent& event)
311{
312 const wxString& temp = wxDirSelector(
313 _("Please select the location of your audio device"), gv->curdestdir);
314 wxLogVerbose("=== begin wxBootLocationPage::OnBootLocationBtn(event)");
315 if (!temp.empty())
316 {
317 BootLocationText->SetLabel(temp);
318 }
319 wxLogVerbose("=== end wxBootLocationPage::OnBootLocationBtn");
320
321}
322
323
324BEGIN_EVENT_TABLE(wxFirmwareLocationPage,wxWizardPageSimple)
325 EVT_BUTTON (ID_FIRMWARELOCATION_BTN, wxFirmwareLocationPage::OnFirmwareFilenameBtn)
326 EVT_WIZARD_PAGE_CHANGING(wxID_ANY, wxFirmwareLocationPage::OnWizardPageChanging)
327END_EVENT_TABLE();
328
329wxFirmwareLocationPage::wxFirmwareLocationPage(wxWizard* parent) : wxWizardPageSimple(parent)
330{
331
332 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
333
334 // Header text
335 FirmwareLocationText = new wxStaticText(this, wxID_ANY,
336 wxT("For this step Rockbox Utility needs an original Firmware.\n"
337 "You can download this from the Manufacturers Website."));
338 WxBoxSizer1->Add(FirmwareLocationText,0,wxGROW | wxALL, 5);
339
340 // Filename text
341 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
342 WxBoxSizer1->Add(WxBoxSizer4,0,
343 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
344
345 FirmwareLocationFilename = new wxStaticText(this, wxID_ANY, gv->curfirmware,
346 wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
347 WxBoxSizer4->Add(FirmwareLocationFilename,1,
348 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
349
350 // Button
351 FirmwareLocationBtn = new wxButton(this, ID_FIRMWARELOCATION_BTN, wxT("Explore"),
352 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator,
353 wxT("FirmwareLocationBtn"));
354 FirmwareLocationBtn->SetToolTip(wxT("Select the location of the downloaded Firmware"));
355 WxBoxSizer4->Add(FirmwareLocationBtn,0,wxALIGN_CENTER_VERTICAL | wxALL, 5);
356
357
358 SetSizer(WxBoxSizer1);
359 WxBoxSizer1->Fit(this);
360}
361
362void wxFirmwareLocationPage::OnWizardPageChanging(wxWizardEvent& event)
363{
364 if(event.GetDirection()) // going forwards in the Wizard
365 {
366 if( !wxFileExists(gv->curfirmware))
367 {
368 WARN_DIALOG(_("You have not selected a valid location for the firmware "
369 "file"), _("Select File"));
370 event.Veto();
371 }
372 }
373
374}
375
376void wxFirmwareLocationPage::OnFirmwareFilenameBtn(wxCommandEvent& event)
377{
378 wxString temp = wxFileSelector(
379 _("Please select the location of the original Firmware"), gv->curdestdir,"","","*.hex");
380 wxLogVerbose("=== begin wxFirmwareLocationPage::OnFirmwareFilenameBtn(event)");
381 if (!temp.empty())
382 {
383 gv->curfirmware=temp;
384 if(temp.Length() > 30)
385 {
386 temp.Remove(0, temp.Length()-30);
387 temp.Prepend("...");
388 }
389 FirmwareLocationFilename->SetLabel(temp);
390 }
391 wxLogVerbose("=== end wxFirmwareLocationPage::OnFirmwareFilenameBtn");
392}
393
59BEGIN_EVENT_TABLE(wxLocationPage,wxWizardPageSimple) 394BEGIN_EVENT_TABLE(wxLocationPage,wxWizardPageSimple)
60 EVT_BUTTON (ID_LOCATION_BTN, wxLocationPage::OnLocationBtn) 395 EVT_BUTTON (ID_LOCATION_BTN, wxLocationPage::OnLocationBtn)
396 EVT_WIZARD_PAGE_CHANGING(wxID_ANY, wxLocationPage::OnWizardPageChanging)
61END_EVENT_TABLE(); 397END_EVENT_TABLE();
62 398
63wxLocationPage::wxLocationPage(wxWizard* parent) : wxWizardPageSimple(parent) 399wxLocationPage::wxLocationPage(wxWizard* parent) : wxWizardPageSimple(parent)
@@ -90,18 +426,24 @@ wxLocationPage::wxLocationPage(wxWizard* parent) : wxWizardPageSimple(parent)
90 WxBoxSizer1->Fit(this); 426 WxBoxSizer1->Fit(this);
91} 427}
92 428
93bool wxLocationPage::TransferDataFromWindow() 429
430void wxLocationPage::OnWizardPageChanging(wxWizardEvent& event)
94{ 431{
95 if ( wxDirExists(LocationText->GetLabel() ) ) 432 if(event.GetDirection()) // going forwards in the Wizard
96 { 433 {
97 gv->curdestdir = LocationText->GetLabel(); 434 if(!wxDirExists(LocationText->GetLabel()))
98 return true; 435 {
99 } else 436 WARN_DIALOG(_("You have not selected a valid location for your audio "
100 {
101 WARN_DIALOG(_("You have not selected a valid location for your audio "
102 "device"), _("Select Location")); 437 "device"), _("Select Location"));
103 return false; 438 event.Veto();
104 } 439 }
440 }
441}
442
443bool wxLocationPage::TransferDataFromWindow()
444{
445 gv->curdestdir = LocationText->GetLabel();
446 return true;
105} 447}
106 448
107void wxLocationPage::OnLocationBtn(wxCommandEvent& event) 449void wxLocationPage::OnLocationBtn(wxCommandEvent& event)