| 475 | } // ProjectPrivate::runOnProjectCloseCallback |
| 476 | |
| 477 | void |
| 478 | ProjectPrivate::runOnProjectLoadCallback() |
| 479 | { |
| 480 | std::string cb = _publicInterface->getOnProjectLoadCB(); |
| 481 | |
| 482 | if ( !cb.empty() ) { |
| 483 | std::vector<std::string> args; |
| 484 | std::string error; |
| 485 | try { |
| 486 | NATRON_PYTHON_NAMESPACE::getFunctionArguments(cb, &error, &args); |
| 487 | } catch (const std::exception& e) { |
| 488 | _publicInterface->getApp()->appendToScriptEditor( std::string("Failed to get signature of onProjectLoaded callback: ") |
| 489 | + e.what() ); |
| 490 | |
| 491 | return; |
| 492 | } |
| 493 | |
| 494 | if ( !error.empty() ) { |
| 495 | _publicInterface->getApp()->appendToScriptEditor("Failed to get signature of onProjectLoaded callback: " + error); |
| 496 | |
| 497 | return; |
| 498 | } |
| 499 | |
| 500 | std::string signatureError; |
| 501 | signatureError.append("The on project loaded callback supports the following signature(s):\n"); |
| 502 | signatureError.append("- callback(app)"); |
| 503 | if ( (args.size() != 1) || (args[0] != "app") ) { |
| 504 | _publicInterface->getApp()->appendToScriptEditor("Wrong signature of onProjectLoaded callback: " + signatureError); |
| 505 | |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | std::string appID = _publicInterface->getApp()->getAppIDString(); |
| 510 | std::string script; |
| 511 | if (appID != "app") { |
| 512 | script = script + "app = " + appID; |
| 513 | } |
| 514 | script = script + "\n" + cb + "(" + appID + ")\n"; |
| 515 | std::string err; |
| 516 | std::string output; |
| 517 | if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) { |
| 518 | _publicInterface->getApp()->appendToScriptEditor("Failed to run onProjectLoaded callback: " + err); |
| 519 | } else { |
| 520 | if ( !output.empty() ) { |
| 521 | _publicInterface->getApp()->appendToScriptEditor(output); |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | } // ProjectPrivate::runOnProjectLoadCallback |
| 526 | |
| 527 | void |
| 528 | ProjectPrivate::setProjectFilename(const std::string& filename) |
no test coverage detected