Skip to content
Browse files

add a hacky callback implementation for a single use of yes/no dialog…

… (Music->Files->Remove Source). Note it kicks in on the second yes/no dialog (the one that asks whether to clean the library)
  • Loading branch information...
1 parent 4ebb519 commit a9ff501e9384a2dde3e18afd967607f4264f4f40 Jonathan Marshall committed Apr 30, 2012
Showing with 26 additions and 3 deletions.
  1. +13 −3 xbmc/music/windows/GUIWindowMusicSongs.cpp
  2. +13 −0 xbmc/music/windows/GUIWindowMusicSongs.h
View
16 xbmc/music/windows/GUIWindowMusicSongs.cpp
@@ -483,18 +483,28 @@ void CGUIWindowMusicSongs::OnRemoveSource(int iItem)
dialog->SetLine(0, 20340);
dialog->SetLine(1, 20341);
dialog->SetLine(2, 20022);
- dialog->DoModal();
- if (dialog->IsConfirmed())
+ dialog->ShowModal(StaticHackOnRemoveSource, this, m_vecItems->Get(iItem)->GetPath());
+}
+
+void CGUIWindowMusicSongs::OnRemoveSource(bool success, const CVariant &data)
+{
+ if (success)
{
CSongMap songs;
CMusicDatabase database;
database.Open();
- database.RemoveSongsFromPath(m_vecItems->Get(iItem)->GetPath(),songs,false);
+ database.RemoveSongsFromPath(data.asString(),songs,false);
database.CleanupOrphanedItems();
g_infoManager.ResetLibraryBools();
}
}
+void CGUIWindowMusicSongs::StaticHackOnRemoveSource(bool success, void *classptr, const CVariant &data)
+{
+ CGUIWindowMusicSongs *cls = (CGUIWindowMusicSongs *)classptr;
+ cls->OnRemoveSource(success, data);
+}
+
CStdString CGUIWindowMusicSongs::GetStartFolder(const CStdString &dir)
{
SetupShares();
View
13 xbmc/music/windows/GUIWindowMusicSongs.h
@@ -34,6 +34,13 @@ class CGUIWindowMusicSongs : public CGUIWindowMusicBase, public IBackgroundLoade
virtual bool OnAction(const CAction& action);
void DoScan(const CStdString &strPath);
+
+ /* Static callback hack
+ Ideally we'd use something like boost::function() instead so we can call directly
+ into the callback function.
+ */
+ static void StaticHackOnRemoveSource(bool success, void *classptr, const CVariant &data);
+
protected:
virtual void OnItemLoaded(CFileItem* pItem) {};
virtual bool GetDirectory(const CStdString &strDirectory, CFileItemList &items);
@@ -44,6 +51,12 @@ class CGUIWindowMusicSongs : public CGUIWindowMusicBase, public IBackgroundLoade
virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button);
virtual void OnScan(int iItem);
virtual void OnRemoveSource(int iItem);
+ /*! \brief Callback
+ This is the callback code. Can probably remove the OnRemoveSource() function above
+ once things are cleaned up, as all it does is throw up the Yes/No dialog while binding
+ this callback (well, actually the static hack version, but you get the idea...)
+ */
+ void OnRemoveSource(bool success, const CVariant &data);
virtual CStdString GetStartFolder(const CStdString &dir);
// new method

0 comments on commit a9ff501

Please sign in to comment.
Something went wrong with that request. Please try again.