X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpython.cc;h=f1b7f43ca410bbbac1bc19a527cdfadf009ff5af;hb=9823b821f5623ef2ad182f914e07a97a93f3952e;hp=8fec3b15a3aced85d0f2e76cb5267fcc1bc513df;hpb=66a26917a0631463df7f72c34cbeb39df466918a;p=chaz%2Fopenbox diff --git a/src/python.cc b/src/python.cc index 8fec3b15..f1b7f43c 100644 --- a/src/python.cc +++ b/src/python.cc @@ -212,6 +212,7 @@ void python_init(char *argv0) init_otk(); init_openbox(); PyRun_SimpleString("from _otk import *; from _openbox import *;"); + PyRun_SimpleString("openbox = Openbox_instance()"); // set up access to the python global variables PyObject *obmodule = PyImport_AddModule("__main__"); @@ -302,5 +303,17 @@ bool python_get_string(const char *name, std::string *value) return true; } +bool python_get_stringlist(const char *name, std::vector *value) +{ + PyObject *val = PyDict_GetItemString(obdict, const_cast(name)); + if (!(val && PyList_Check(val))) return false; + + for (int i = 0, end = PyList_Size(val); i < end; ++i) { + PyObject *str = PyList_GetItem(val, i); + if (PyString_Check(str)) + value->push_back(PyString_AsString(str)); + } + return true; +} }