]> Dogcows Code - chaz/openbox/blobdiff - src/python.cc
fix \'s
[chaz/openbox] / src / python.cc
index 9ea93b4d5b5c7d61d26fa4533c41ca9bc169edd6..2c71b0182748aa4a44c7410bb97a4cd28eaf6d18 100644 (file)
@@ -11,8 +11,6 @@
 extern "C" {
 // The initializer in openbox_wrap.cc
 extern void init_openbox(void);
-// The initializer in otk_wrap.cc
-extern void init_otk(void);
 }
 
 namespace ob {
@@ -21,26 +19,33 @@ static PyObject *obdict = NULL;
 
 void python_init(char *argv0)
 {
-  Py_SetProgramName(argv0);
-  Py_Initialize();
-  init_otk();
-  init_openbox();
-  PyRun_SimpleString("import sys");
-  PyRun_SimpleString("sys.path.append('" SCRIPTDIR "')");
-  PyRun_SimpleString(const_cast<char*>(((std::string)"sys.path.append('" +
-                                        otk::expandTilde("~/.openbox/python") +
-                                        "')").c_str()));
-//  PyRun_SimpleString("from _otk import *; from _openbox import *;");
-  PyRun_SimpleString("from otk import *; from openbox import *;");
+  std::string path;
+  
+  // start the python engine
+  //Py_SetProgramName(argv0);
+  //Py_Initialize();
+  // initialize the C python module
+  //init_openbox();
+  // include the openbox directories for python scripts in the sys path
+//  PyRun_SimpleString("import sys");
+printf("SCRIPTDIR=%s\n", SCRIPTDIR);
+printf("1 getenv(DISPLAY)=%s\n", getenv("DISPLAY"));
+  path = "sys.path";
+printf("2 getenv(DISPLAY)=%s\n", getenv("DISPLAY"));
+  path = "sys.path.append('";
+printf("3 getenv(DISPLAY)=%s\n", getenv("DISPLAY"));
+  path += SCRIPTDIR;
+  path += "')";
+  PyRun_SimpleString(const_cast<char*>(path.c_str()));
+  path = "sys.path.append('";
+  path += otk::expandTilde("~/.openbox/python");
+  path += "')";
+  PyRun_SimpleString(const_cast<char*>(path.c_str()));
+  // import the otk and openbox modules into the main namespace
+  PyRun_SimpleString("from openbox import *;");
+  // set up convenience global variables
   PyRun_SimpleString("openbox = Openbox_instance()");
-  PyRun_SimpleString("display = OBDisplay_display()");
 
-  /* XXX
-     sys.path.append('stuff')
-     install the .py wrappers, and include their path with this, then import em
-     and ~/.openbox/python/ !!
-  */
-  
   // set up access to the python global variables
   PyObject *obmodule = PyImport_AddModule("__main__");
   obdict = PyModule_GetDict(obmodule);
This page took 0.02123 seconds and 4 git commands to generate.