all repos — openbox @ 14cf42ff0780bf58a6b54c9443c87c7402b61faa

openbox fork - make it a bit more like ryudo

run scripts before initializing screens. kill the globals.py. add the python_get_stringlist.
Dana Jansens danakj@orodu.net
commit

14cf42ff0780bf58a6b54c9443c87c7402b61faa

parent

6d58d84f22887f03ac5471b9775452b90103b6f0

5 files changed, 24 insertions(+), 22 deletions(-)

jump to
D scripts/globals.py

@@ -1,14 +0,0 @@

-############################################################################# -### Variables defined for other scripts to use. ### -############################################################################# - -# openbox - pointer to the current Openbox instance -openbox = Openbox_instance() - -# screens - list of all screens in the current openbox instance -screens = [] -for i in range(Openbox_screenCount(openbox)): - screens.append(Openbox_screen(openbox, i)) - - -print "Loaded globals.py"
M src/openbox.ccsrc/openbox.cc

@@ -133,6 +133,11 @@ python_init(argv[0]);

// load config values python_exec(SCRIPTDIR"/config.py"); // load openbox config values + // run all of the python scripts + python_exec(SCRIPTDIR"/clientmotion.py"); // moving and resizing clients + python_exec(SCRIPTDIR"/clicks.py"); // titlebar/root clicks and dblclicks + // run the user's script + python_exec(_scriptfilepath.c_str()); // initialize all the screens OBScreen *screen;

@@ -147,12 +152,6 @@ if (_screens.empty()) {

printf(_("No screens were found without a window manager. Exiting.\n")); ::exit(1); } - - // run all of the python scripts, including the user's - python_exec(SCRIPTDIR"/globals.py"); // create/set global vars - python_exec(SCRIPTDIR"/clientmotion.py"); // moving and resizing clients - python_exec(SCRIPTDIR"/clicks.py"); // titlebar/root clicks and dblclicks - python_exec(_scriptfilepath.c_str()); ScreenList::iterator it, end = _screens.end(); for (it = _screens.begin(); it != end; ++it) {
M src/openbox_wrap.ccsrc/openbox_wrap.cc

@@ -786,7 +786,9 @@ Action_DoubleClick,

Action_EnterWindow, Action_LeaveWindow, Action_KeyPress, - Action_MouseMotion + Action_MouseMotion, + Action_NewWindow, + Action_CloseWindow }; enum WidgetType { Type_Frame,

@@ -2918,6 +2920,8 @@ { SWIG_PY_INT, (char *)"Action_EnterWindow", (long) Action_EnterWindow, 0, 0, 0},

{ SWIG_PY_INT, (char *)"Action_LeaveWindow", (long) Action_LeaveWindow, 0, 0, 0}, { SWIG_PY_INT, (char *)"Action_KeyPress", (long) Action_KeyPress, 0, 0, 0}, { SWIG_PY_INT, (char *)"Action_MouseMotion", (long) Action_MouseMotion, 0, 0, 0}, +{ SWIG_PY_INT, (char *)"Action_NewWindow", (long) Action_NewWindow, 0, 0, 0}, +{ SWIG_PY_INT, (char *)"Action_CloseWindow", (long) Action_CloseWindow, 0, 0, 0}, { SWIG_PY_INT, (char *)"Type_Frame", (long) Type_Frame, 0, 0, 0}, { SWIG_PY_INT, (char *)"Type_Titlebar", (long) Type_Titlebar, 0, 0, 0}, { SWIG_PY_INT, (char *)"Type_Handle", (long) Type_Handle, 0, 0, 0},
M src/python.ccsrc/python.cc

@@ -212,6 +212,7 @@ Py_Initialize();

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 @@ *value = PyString_AsString(val);

return true; } +bool python_get_stringlist(const char *name, std::vector<std::string> *value) +{ + PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(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; +} }
M src/python.hhsrc/python.hh

@@ -32,7 +32,7 @@ unsigned int key, Time time);

bool python_get_string(const char *name, std::string *value); -bool python_getstringlist(const char *name, std::vector<std::string> *value); +bool python_get_stringlist(const char *name, std::vector<std::string> *value); }