]>
Dogcows Code - chaz/openbox/blob - src/config.cc
6feb94b20520cbf2e53af745bf5a144aeb274d3e
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
13 static PyObject
*obdict
= NULL
;
15 bool python_get_long(const char *name
, long *value
)
17 PyObject
*val
= PyDict_GetItemString(obdict
, const_cast<char*>(name
));
18 if (!(val
&& PyInt_Check(val
))) return false;
20 *value
= PyInt_AsLong(val
);
24 bool python_get_string(const char *name
, otk::ustring
*value
)
26 PyObject
*val
= PyDict_GetItemString(obdict
, const_cast<char*>(name
));
27 if (!(val
&& PyString_Check(val
))) return false;
29 *value
= PyString_AsString(val
);
33 bool python_get_stringlist(const char *name
, std::vector
<otk::ustring
> *value
)
35 PyObject
*val
= PyDict_GetItemString(obdict
, const_cast<char*>(name
));
36 if (!(val
&& PyList_Check(val
))) return false;
40 for (int i
= 0, end
= PyList_Size(val
); i
< end
; ++i
) {
41 PyObject
*str
= PyList_GetItem(val
, i
);
42 if (PyString_Check(str
))
43 value
->push_back(PyString_AsString(str
));
50 PyRun_SimpleString("import config;");
51 // set up access to the python global variables
52 PyObject
*obmodule
= PyImport_AddModule("config");
53 obdict
= PyModule_GetDict(obmodule
);
55 std::vector
<otk::ustring
> names
;
56 python_get_stringlist("DESKTOP_NAMES", &names
);
58 python_get_string("THEME", &theme
);
60 if (!python_get_string("TITLEBAR_LAYOUT", &titlebar_layout
))
61 titlebar_layout
= "NTIMC";
62 printf("LAYOUT %s\n", titlebar_layout
.c_str());
64 if (!python_get_long("DOUBLE_CLICK_DELAY", &double_click_delay
))
65 double_click_delay
= 300;
66 if (!python_get_long("DRAG_THRESHOLD", &drag_threshold
))
68 if (!python_get_long("NUMBER_OF_DESKTOPS", (long*)&num_desktops
))
This page took 0.037831 seconds and 4 git commands to generate.