make compiled in python extension initialization more flexable
[mussa.git] / qui / mussagl.cpp
index 55afefd02bf37ca5a4fc74470def09ca02306027..3001cbb29ddaeb127b0e89f5541aa8651abdd399 100644 (file)
@@ -3,6 +3,8 @@ using namespace boost::filesystem;
 
 #ifdef USE_PYTHON
 #include "py/python.hpp"
+extern "C" void initmussa();
+extern "C" void initmussaqui();
 #endif
 
 #include "qui/MussaWindow.hpp"
@@ -65,10 +67,22 @@ int main(int argc, char **argv)
       // allow the user to keep the interpreter open even after
       // closing all the windows
       app.setQuitOnLastWindowClosed(false);
-      const InterpreterThread *interp = thread.create_interpreter();
+      InterpreterThread *interp = thread.create_interpreter();
+      if (!interp) {
+        std::cerr << "Unable to initialize interpeter thread" << std::endl;
+        return 1;
+      }
+      MussaPython *py = interp->get_py();
+      if (!py) {
+        std::cerr << "Unable to initialize python interpreter" << std::endl;
+        return 1;
+      }
+      py->add_module("mussa", &initmussa);
+      py->add_module("mussaqui", &initmussaqui);
       // quit when the interpreter exits
       QObject::connect(interp, SIGNAL(finished()),
                        &app, SLOT(quit()));
+      interp->start();
       app.exec();
     } else 
 #endif /* USE_PYTHON */