//since the 'toolbar marker' is not unique, find index of first occurrence of the
//'toolbar marker' in the array and check that next string is name of the toolbar
+namespace
+{
+ const char* salomeAppDir = "SALOME_APPLICATION_DIR";
+}
+
void LightAppCleanUpAppResources()
{
if ( LightApp_Application::_prefs_ ) {
connect( moduleAction, SIGNAL(showExtInfo()),
this, SLOT(onShowExtInfo()));
+ addExtensionsActions(moduleAction);
+
// New window
int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
createTool( ModulesListId, modTBar );
}
+/*!Create actions for installed extensions:*/
+void LightApp_Application::addExtensionsActions(LightApp_ModuleAction* moduleAction)
+{
+ ASSERT(moduleAction)
+ if (!moduleAction)
+ {
+ return;
+ }
+
+ // It should be set on the app start
+ auto extRootDir = getenv(salomeAppDir);
+ ASSERT(extRootDir)
+ if (!extRootDir)
+ {
+ return;
+ }
+ SCRUTE(extRootDir);
+
+ // Import Python module that manages SALOME extensions.
+ PyLockWrapper lck; // acquire GIL
+ PyObjWrapper extensionQuery = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_query");
+ PyObjWrapper installedExtensions = PyObject_CallMethod(
+ extensionQuery, (char*)"ext_by_name", (char*)"s", extRootDir);
+ if (!installedExtensions)
+ {
+ return;
+ }
+
+ // Iterate installed extensions
+ for (Py_ssize_t pos = 0; pos < PyList_Size(installedExtensions); ++pos)
+ {
+ // Get the current ext name
+ auto extNameItem = PyList_GetItem(installedExtensions, pos);
+ QString extName(PyUnicode_AsUTF8(extNameItem));
+ SCRUTE(extName.toStdString());
+
+ moduleAction->insertExtension(extName);
+ }
+}
+
/*!
Customize actions.
*/
return;
// It should be set on the app start
- auto extRootDir = getenv("SALOME_APPLICATION_DIR");
+ auto extRootDir = getenv(salomeAppDir);
ASSERT(extRootDir)
if (!extRootDir)
{
PyObjWrapper unpackedModules = PyObject_CallMethod(
extensionUnpacker, (char*)"install_salomex", (char*)"s", extPath.c_str());
- if (!unpackedModules)
+ if (!unpackedModules || unpackedModules == Py_None)
{
SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_UNPACK_EXTENSION").arg(path) );
continue;
SCRUTE(extName);
// It should be set on the app start
- auto extRootDir = getenv("SALOME_APPLICATION_DIR");
+ auto extRootDir = getenv(salomeAppDir);
ASSERT(extRootDir)
if (!extRootDir)
{
PyObjWrapper extensionRemover = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_remover");
PyObjWrapper removedModules = PyObject_CallMethod(
extensionRemover, (char*)"remove_salomex", (char*)"ss", extRootDir, extName.c_str());
- if (!removedModules)
+ if (!removedModules || removedModules == Py_None)
{
SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_REMOVE_EXTENSION").arg(title) );
return;