]> Dogcows Code - chaz/openbox/commitdiff
run scripts before initializing screens. kill the globals.py. add the python_get_stri...
authorDana Jansens <danakj@orodu.net>
Thu, 2 Jan 2003 21:05:29 +0000 (21:05 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 2 Jan 2003 21:05:29 +0000 (21:05 +0000)
scripts/globals.py [deleted file]
src/openbox.cc
src/openbox_wrap.cc
src/python.cc
src/python.hh

diff --git a/scripts/globals.py b/scripts/globals.py
deleted file mode 100644 (file)
index 450ee8b..0000000
+++ /dev/null
@@ -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"
index f7f2098b1bc1d608952f3a522e0470fbb6186538..436c09fadb6ec9c6eb5bfd3976b812bc790adebe 100644 (file)
@@ -133,6 +133,11 @@ Openbox::Openbox(int argc, char **argv)
   
   // 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;
@@ -148,12 +153,6 @@ Openbox::Openbox(int argc, char **argv)
     ::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) {
     (*it)->manageExisting();
index ada473b6b6ccca6350549da16907984acf517fbe..146bb2a759f3ecc881e63d63991f3599cb431b1a 100644 (file)
@@ -786,7 +786,9 @@ static std::string SwigString_AsString(PyObject* o) {
     Action_EnterWindow,
     Action_LeaveWindow,
     Action_KeyPress,
-    Action_MouseMotion
+    Action_MouseMotion,
+    Action_NewWindow,
+    Action_CloseWindow
   };
   enum WidgetType {
     Type_Frame,
@@ -2918,6 +2920,8 @@ static swig_const_info swig_const_table[] = {
 { 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},
index 8fec3b15a3aced85d0f2e76cb5267fcc1bc513df..f1b7f43ca410bbbac1bc19a527cdfadf009ff5af 100644 (file)
@@ -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<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;
+}
 
 }
index 0870c9ad312d391889b07e8802899a0ccd11fadc..2fa3e867955312376924ce54c7ce89bbd1364a17 100644 (file)
@@ -32,7 +32,7 @@ void python_callback(PyObject *func, Window window, unsigned int state,
 
 
 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);
 
 }
 
This page took 0.030925 seconds and 4 git commands to generate.