diff options
author | Antoine Cellerier <dionoea@videolan.org> | 2007-06-10 20:52:20 +0000 |
---|---|---|
committer | Antoine Cellerier <dionoea@videolan.org> | 2007-06-10 20:52:20 +0000 |
commit | 71eedc7a5be6b01fc910967e93ef7f3acf92eeaf (patch) | |
tree | 9587a4003cd192c65966f225324bc73464e46f48 /rbutil | |
parent | d86e1a4998fdad8b6dafc92ebb0ab85c026c9a08 (diff) |
When clicking on one of the rbutil actions, ask the user if he wants to try autodetecting his device if none was selected.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13611 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilCtrls.cpp | 5 | ||||
-rw-r--r-- | rbutil/rbutilCtrls.h | 2 | ||||
-rw-r--r-- | rbutil/rbutilFrm.cpp | 83 | ||||
-rw-r--r-- | rbutil/rbutilFrm.h | 4 |
4 files changed, 53 insertions, 41 deletions
diff --git a/rbutil/rbutilCtrls.cpp b/rbutil/rbutilCtrls.cpp index e8a3f9e320..f30442c66d 100644 --- a/rbutil/rbutilCtrls.cpp +++ b/rbutil/rbutilCtrls.cpp @@ -430,6 +430,11 @@ void DeviceSelectorCtrl::OnComboBox(wxCommandEvent& event) void DeviceSelectorCtrl::OnAutoDetect(wxCommandEvent& event) { + AutoDetect(); +} + +void DeviceSelectorCtrl::AutoDetect() +{ struct ipod_t ipod; int n = ipod_scan(&ipod); if(n == 1) diff --git a/rbutil/rbutilCtrls.h b/rbutil/rbutilCtrls.h index 53690a251e..f31429fa16 100644 --- a/rbutil/rbutilCtrls.h +++ b/rbutil/rbutilCtrls.h @@ -177,6 +177,8 @@ public: wxString getDevice(); void setDefault(); + void AutoDetect(); + protected: wxString m_currentDevice; wxComboBox* m_deviceCbx; diff --git a/rbutil/rbutilFrm.cpp b/rbutil/rbutilFrm.cpp index fd9558905b..ce695b03a0 100644 --- a/rbutil/rbutilFrm.cpp +++ b/rbutil/rbutilFrm.cpp @@ -441,13 +441,9 @@ void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event) { wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)")); - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } wxString bootloadermethod = gv->plat_bootloadermethod[index]; @@ -530,13 +526,10 @@ void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event) { wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderBtn(event)")); - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } + wxString bootloadermethod = gv->plat_bootloadermethod[index]; if(!gv->plat_needsbootloader[index]) @@ -646,13 +639,9 @@ void rbutilFrm::OnInstallBtn(wxCommandEvent& event) wxFileConfig* buildinfo; wxDateSpan oneday; - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } // rockbox install dialog rockboxInstallDlg dialog(NULL, wxID_ANY, @@ -770,13 +759,9 @@ void rbutilFrm::OnFontBtn(wxCommandEvent& event) wxFileConfig* buildinfo; wxDateSpan oneday; - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } // font install dialog fontInstallDlg dialog(NULL, wxID_ANY, @@ -867,13 +852,9 @@ void rbutilFrm::OnDoomBtn(wxCommandEvent& event) wxString src, dest, buf; wxLogVerbose(wxT("=== begin rbutilFrm::OnDoomBtn(event)")); - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } // font install dialog, reused fontInstallDlg dialog(NULL, wxID_ANY, @@ -934,13 +915,9 @@ void rbutilFrm::OnThemesBtn(wxCommandEvent& event) wxString src, dest, buf; wxLogVerbose(wxT("=== begin rbutilFrm::OnThemesBtn(event)")); - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } // Theme install dialog themesInstallDlg dialog(NULL, wxID_ANY, @@ -977,13 +954,9 @@ void rbutilFrm::OnRemoveBtn(wxCommandEvent& event) { wxLogVerbose(wxT("=== begin rbutilFrm::OnRemoveBtn(event)")); - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } // Rockbox deinstall dialog rockboxDeInstallDlg dialog(NULL, wxID_ANY, @@ -1020,13 +993,9 @@ void rbutilFrm::OnPortableInstall(wxCommandEvent& event) wxFileSystem fs; wxDateSpan oneday; - int index = gv->plat_id.Index(gv->curplat); + int index = GetDeviceId(); if(index < 0) - { - WARN_DIALOG(wxT("No Device selected"), - wxT("Select a Device")); return; - } //portable install dialog ( reused font dialog) fontInstallDlg dialog(NULL, wxID_ANY, @@ -1051,6 +1020,40 @@ void rbutilFrm::OnPortableInstall(wxCommandEvent& event) wxLogVerbose(wxT("=== end rbutilFrm::OnUnstallPortable")); } +int rbutilFrm::GetDeviceId() +{ + int index = gv->plat_id.Index(gv->curplat); + if(index < 0) + { + if( wxMessageBox(wxT("No device selected. Do you want to autodetect " + "the device?"), + wxT("Warning"), wxYES_NO ) == wxYES ) + { + myDeviceSelector->AutoDetect(); + index = gv->plat_id.Index(gv->curplat); + if(index < 0) + { + WARN_DIALOG( wxT("Aborting"), wxT("Auto detection failed") ); + return index; + } + else + { + if( wxMessageBox(wxT("Found ") + gv->plat_name[index] + + wxT(". Do you want to continue?"), + wxT("Device found"), wxYES_NO ) == wxYES ) + return index; + else + return -1; + } + } + else + { + return -1; + } + } + return index; +} + AboutDlg::AboutDlg(rbutilFrm* parent) : wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) diff --git a/rbutil/rbutilFrm.h b/rbutil/rbutilFrm.h index f33adc13f1..0d3b2526e4 100644 --- a/rbutil/rbutilFrm.h +++ b/rbutil/rbutilFrm.h @@ -61,7 +61,7 @@ public: wxHtmlWindow* manual; wxString curManualDevice; - wxMenuBar *WxMenuBar1; + wxMenuBar *WxMenuBar1; wxStaticText *WxStaticText3; wxBitmapButton *WxBitmapButton2; wxStaticText *WxStaticText2; @@ -120,6 +120,8 @@ public: void OnFileProxy(wxCommandEvent& event); void OnDoomBtn(wxCommandEvent& event); + int GetDeviceId(); + }; #endif |