X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpython.cc;h=891d11203104b03f1140e6286a03b29a9a2de9f7;hb=8f8acc24933830d4f5784616b9b0c5896bde0b93;hp=b1e19ed26c81fba4d0f4223fd0b76a8c80aa1a35;hpb=c8e246f8de5af9963b22cc104d22ca10772028dd;p=chaz%2Fopenbox diff --git a/src/python.cc b/src/python.cc index b1e19ed2..891d1120 100644 --- a/src/python.cc +++ b/src/python.cc @@ -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,22 @@ static PyObject *obdict = NULL; void python_init(char *argv0) { + // start the python engine Py_SetProgramName(argv0); Py_Initialize(); - init_otk(); + // initialize the C python module init_openbox(); + // include the openbox directories for python scripts in the sys path PyRun_SimpleString("import sys"); PyRun_SimpleString("sys.path.append('" SCRIPTDIR "')"); - PyRun_SimpleString(const_cast(((std::string)"sys.path.append('" + + PyRun_SimpleString(const_cast(("sys.path.append('" + otk::expandTilde("~/.openbox/python") + "')").c_str())); -// PyRun_SimpleString("from _otk import *; from _openbox import *;"); + // 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);