diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 95fad49..b3e17b8 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -134,7 +134,7 @@ BOOST_PYTHON_MODULE(mobase) utils::register_functor_converter(); utils::register_functor_converter(); // converter for the onModMoved-callback and onPluginMoved callbacks utils::register_functor_converter&)>(); // converter for the onModStateChanged-callback (IModList) - utils::register_functor_converter(); // converter for the onPluginStateChanged-callback (IPluginList) + utils::register_functor_converter&)>(); // converter for the onPluginStateChanged-callback (IPluginList) utils::register_functor_converter(); utils::register_functor_converter(); utils::register_functor_converter>(); @@ -146,6 +146,7 @@ BOOST_PYTHON_MODULE(mobase) // This one is kept for backward-compatibility while we deprecate onModStateChanged for singl mod. utils::register_functor_converter(); // converter for the onModStateChanged-callback (IModList). + utils::register_functor_converter(); // converter for the onPluginStateChanged-callback (IPluginList). // // Class declarations: @@ -659,6 +660,18 @@ BOOST_PYTHON_MODULE(mobase) .def("origin", &MOBase::IPluginList::origin, bpy::arg("name")) .def("onRefreshed", &MOBase::IPluginList::onRefreshed, bpy::arg("callback")) .def("onPluginMoved", &MOBase::IPluginList::onPluginMoved, bpy::arg("callback")) + + // Kept but deprecated for backward compatibility: + .def("onPluginStateChanged", +[](IPluginList* modList, const std::function& fn) { + utils::show_deprecation_warning("onPluginStateChanged", + "onPluginStateChanged(Callable[[str, IPluginList.PluginStates], None]) is deprecated, " + "use onPluginStateChanged(Callable[[Dict[str, IPluginList.PluginStates], None]) instead."); + return modList->onPluginStateChanged([fn](auto const& map) { + for (const auto& entry : map) { + fn(entry.first, entry.second); + } + }); + }, bpy::arg("callback")) .def("onPluginStateChanged", &MOBase::IPluginList::onPluginStateChanged, bpy::arg("callback")) .def("pluginNames", &MOBase::IPluginList::pluginNames) .def("setState", &MOBase::IPluginList::setState, (bpy::arg("name"), "state"))