]>
Dogcows Code - chaz/openbox/blob - src/config.cc
b1495dc85a7d3b5f067755347c42fcf51f552b01
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
11 #define _(str) gettext(str)
18 static PyObject
*obdict
= NULL
;
20 bool python_get_long(const char *name
, long *value
)
22 PyObject
*val
= PyDict_GetItemString(obdict
, const_cast<char*>(name
));
23 if (!(val
&& PyInt_Check(val
))) return false;
25 *value
= PyInt_AsLong(val
);
29 bool python_get_string(const char *name
, otk::ustring
*value
)
31 PyObject
*val
= PyDict_GetItemString(obdict
, const_cast<char*>(name
));
32 if (!(val
&& PyString_Check(val
))) return false;
34 std::string
temp(PyString_AsString(val
), PyString_Size(val
));
39 bool python_get_stringlist(const char *name
, std::vector
<otk::ustring
> *value
)
41 PyObject
*val
= PyDict_GetItemString(obdict
, const_cast<char*>(name
));
42 if (!(val
&& PyList_Check(val
))) return false;
46 for (int i
= 0, end
= PyList_Size(val
); i
< end
; ++i
) {
47 PyObject
*str
= PyList_GetItem(val
, i
);
48 if (PyString_Check(str
))
49 value
->push_back(PyString_AsString(str
));
56 // set up access to the python global variables
57 PyObject
*obmodule
= PyImport_ImportModule("config");
58 obdict
= PyModule_GetDict(obmodule
);
61 python_get_stringlist("DESKTOP_NAMES", &desktop_names
);
63 python_get_string("THEME", &theme
);
65 if (!python_get_string("TITLEBAR_LAYOUT", &titlebar_layout
)) {
66 fprintf(stderr
, _("Unable to load config.%s\n"), "TITLEBAR_LAYOUT");
70 if (!python_get_long("DOUBLE_CLICK_DELAY", &double_click_delay
)) {
71 fprintf(stderr
, _("Unable to load config.%s\n"), "DOUBLE_CLICK_DELAY");
74 if (!python_get_long("DRAG_THRESHOLD", &drag_threshold
)) {
75 fprintf(stderr
, _("Unable to load config.%s\n"), "DRAG_THRESHOLD");
78 if (!python_get_long("NUMBER_OF_DESKTOPS", (long*)&num_desktops
)) {
79 fprintf(stderr
, _("Unable to load config.%s\n"), "NUMBER_OF_DESKTOPS");
This page took 0.042988 seconds and 4 git commands to generate.