| 450 | } // ProjectPrivate::runOnProjectCloseCallback |
| 451 | |
| 452 | void |
| 453 | ProjectPrivate::runOnProjectLoadCallback() |
| 454 | { |
| 455 | std::string cb = _publicInterface->getOnProjectLoadCB(); |
| 456 | |
| 457 | if ( !cb.empty() ) { |
| 458 | std::vector<std::string> args; |
| 459 | std::string error; |
| 460 | try { |
| 461 | NATRON_PYTHON_NAMESPACE::getFunctionArguments(cb, &error, &args); |
| 462 | } catch (const std::exception& e) { |
| 463 | _publicInterface->getApp()->appendToScriptEditor( std::string("Failed to run onProjectLoaded callback: ") |
| 464 | + e.what() ); |
| 465 | |
| 466 | return; |
| 467 | } |
| 468 | |
| 469 | if ( !error.empty() ) { |
| 470 | _publicInterface->getApp()->appendToScriptEditor("Failed to run onProjectLoaded callback: " + error); |
| 471 | |
| 472 | return; |
| 473 | } |
| 474 | |
| 475 | std::string signatureError; |
| 476 | signatureError.append("The on project loaded callback supports the following signature(s):\n"); |
| 477 | signatureError.append("- callback(app)"); |
| 478 | if (args.size() != 1) { |
| 479 | _publicInterface->getApp()->appendToScriptEditor("Failed to run onProjectLoaded callback: " + signatureError); |
| 480 | |
| 481 | return; |
| 482 | } |
| 483 | if (args[0] != "app") { |
| 484 | _publicInterface->getApp()->appendToScriptEditor("Failed to run onProjectLoaded callback: " + signatureError); |
| 485 | |
| 486 | return; |
| 487 | } |
| 488 | |
| 489 | std::string appID = _publicInterface->getApp()->getAppIDString(); |
| 490 | std::string script; |
| 491 | if (appID != "app") { |
| 492 | script = script + "app = " + appID; |
| 493 | } |
| 494 | script = script + "\n" + cb + "(" + appID + ")\n"; |
| 495 | std::string err; |
| 496 | std::string output; |
| 497 | if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) { |
| 498 | _publicInterface->getApp()->appendToScriptEditor("Failed to run onProjectLoaded callback: " + err); |
| 499 | } else { |
| 500 | if ( !output.empty() ) { |
| 501 | _publicInterface->getApp()->appendToScriptEditor(output); |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | } // ProjectPrivate::runOnProjectLoadCallback |
| 506 | |
| 507 | void |
| 508 | ProjectPrivate::setProjectFilename(const std::string& filename) |
no test coverage detected