|
|
|
@ -322,35 +322,35 @@ static PyMethodDef karamba_methods[] = {
|
|
|
|
|
|
|
|
|
|
{(char*)"setWidgetOnTop", py_set_widget_on_top, METH_VARARGS,
|
|
|
|
|
(char*)"changes 'on top' status"},
|
|
|
|
|
{(char*)"getSystraySize", py_get_systray_size, METH_VARARGS,
|
|
|
|
|
{(char*)"getSystraySize", py_get_systray_size, METH_VARARGS,
|
|
|
|
|
(char*)"Get the size of the Systray"},
|
|
|
|
|
{(char*)"getPrettyThemeName", py_get_pretty_name, METH_VARARGS,
|
|
|
|
|
{(char*)"getPrettyThemeName", py_get_pretty_name, METH_VARARGS,
|
|
|
|
|
(char*)"Get the pretty name of the theme"},
|
|
|
|
|
{(char*)"openNamedTheme", py_open_named_theme, METH_VARARGS,
|
|
|
|
|
{(char*)"openNamedTheme", py_open_named_theme, METH_VARARGS,
|
|
|
|
|
(char*)"Open a new theme giving it a new name"},
|
|
|
|
|
{(char*)"callTheme", py_call_theme, METH_VARARGS,
|
|
|
|
|
{(char*)"callTheme", py_call_theme, METH_VARARGS,
|
|
|
|
|
(char*)"Pass a string to another theme"},
|
|
|
|
|
{(char*)"changeInterval", py_change_interval, METH_VARARGS,
|
|
|
|
|
{(char*)"changeInterval", py_change_interval, METH_VARARGS,
|
|
|
|
|
(char*)"Change the refresh interval"},
|
|
|
|
|
{(char*)"run", py_run_command, METH_VARARGS,
|
|
|
|
|
{(char*)"run", py_run_command, METH_VARARGS,
|
|
|
|
|
(char*)"Execute a command with KRun"},
|
|
|
|
|
{(char*)"createServiceClickArea", py_create_service_click_area, METH_VARARGS,
|
|
|
|
|
{(char*)"createServiceClickArea", py_create_service_click_area, METH_VARARGS,
|
|
|
|
|
(char*)"Create a Service-named Click Area Sensor"},
|
|
|
|
|
{(char*)"removeClickArea", py_remove_click_area, METH_VARARGS,
|
|
|
|
|
{(char*)"removeClickArea", py_remove_click_area, METH_VARARGS,
|
|
|
|
|
(char*)"Remove a Click Area Sensor"},
|
|
|
|
|
{(char*)"setUpdateTime", py_set_update_time, METH_VARARGS,
|
|
|
|
|
{(char*)"setUpdateTime", py_set_update_time, METH_VARARGS,
|
|
|
|
|
(char*)"Set last updated time"},
|
|
|
|
|
{(char*)"getUpdateTime", py_get_update_time, METH_VARARGS,
|
|
|
|
|
{(char*)"getUpdateTime", py_get_update_time, METH_VARARGS,
|
|
|
|
|
(char*)"Get last updated time"},
|
|
|
|
|
{(char*)"setWantRightButton", py_want_right_button, METH_VARARGS,
|
|
|
|
|
{(char*)"setWantRightButton", py_want_right_button, METH_VARARGS,
|
|
|
|
|
(char*)"Set to 1 to deactivate management popups"},
|
|
|
|
|
{(char*)"setWantMeterWheelEvent", py_want_wheel_event, METH_VARARGS,
|
|
|
|
|
{(char*)"setWantMeterWheelEvent", py_want_wheel_event, METH_VARARGS,
|
|
|
|
|
(char*)"Enables wheel events over meters."},
|
|
|
|
|
{(char*)"managementPopup", py_management_popup, METH_VARARGS,
|
|
|
|
|
{(char*)"managementPopup", py_management_popup, METH_VARARGS,
|
|
|
|
|
(char*)"Activates the Management Popup menu"},
|
|
|
|
|
|
|
|
|
|
// service groups
|
|
|
|
|
{(char*)"getServiceGroups", py_get_service_groups, METH_VARARGS,
|
|
|
|
|
{(char*)"getServiceGroups", py_get_service_groups, METH_VARARGS,
|
|
|
|
|
(char*)"Get KDE Service Groups"},
|
|
|
|
|
|
|
|
|
|
{NULL, NULL, 0 ,NULL}
|
|
|
|
@ -413,9 +413,9 @@ KarambaPython::KarambaPython(const ThemeFile& theme, bool reloading):
|
|
|
|
|
#endif
|
|
|
|
|
pName = PyBytes_FromString(theme.pythonModule().ascii());
|
|
|
|
|
pModule = PyImport_Import(pName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "%s\n", pypath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Make sure the module is up to date.
|
|
|
|
|
if (reloading)
|
|
|
|
|
PyImport_ReloadModule(pModule);
|
|
|
|
@ -464,49 +464,44 @@ KarambaPython::~KarambaPython()
|
|
|
|
|
void KarambaPython::initPython()
|
|
|
|
|
{
|
|
|
|
|
// initialize Python
|
|
|
|
|
Py_Initialize();
|
|
|
|
|
Py_InitializeEx(1);
|
|
|
|
|
|
|
|
|
|
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION <= 6
|
|
|
|
|
// initialize thread support
|
|
|
|
|
PyEval_InitThreads();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// save a pointer to the main PyThreadState object
|
|
|
|
|
mainThreadState = PyThreadState_Get();
|
|
|
|
|
mainThreadState = PyGILState_GetThisThreadState();
|
|
|
|
|
|
|
|
|
|
// release the lock
|
|
|
|
|
PyEval_ReleaseLock();
|
|
|
|
|
PyEval_ReleaseThread(mainThreadState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KarambaPython::shutdownPython()
|
|
|
|
|
{
|
|
|
|
|
// shut down the interpreter
|
|
|
|
|
PyInterpreterState * mainInterpreterState = mainThreadState->interp;
|
|
|
|
|
// create a thread state object for this thread
|
|
|
|
|
PyThreadState * myThreadState = PyThreadState_New(mainInterpreterState);
|
|
|
|
|
PyThreadState_Swap(myThreadState);
|
|
|
|
|
PyEval_AcquireLock();
|
|
|
|
|
Py_Finalize();
|
|
|
|
|
PyEval_AcquireThread(mainThreadState);
|
|
|
|
|
Py_FinalizeEx();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KarambaPython::getLock(PyThreadState** myThreadState)
|
|
|
|
|
{
|
|
|
|
|
// get the global lock
|
|
|
|
|
PyEval_AcquireLock();
|
|
|
|
|
PyEval_AcquireThread(mainThreadState);
|
|
|
|
|
|
|
|
|
|
// create a thread state object for this thread
|
|
|
|
|
*myThreadState = PyThreadState_New(mainThreadState->interp);
|
|
|
|
|
PyThreadState_Swap(*myThreadState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KarambaPython::releaseLock(PyThreadState* myThreadState)
|
|
|
|
|
{
|
|
|
|
|
// swap my thread state out of the interpreter
|
|
|
|
|
PyThreadState_Swap(NULL);
|
|
|
|
|
// clear out any cruft from thread state object
|
|
|
|
|
PyThreadState_Clear(myThreadState);
|
|
|
|
|
// delete my thread state object
|
|
|
|
|
PyThreadState_Delete(myThreadState);
|
|
|
|
|
// release the lock
|
|
|
|
|
PyEval_ReleaseLock();
|
|
|
|
|
PyEval_ReleaseThread(mainThreadState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyObject* KarambaPython::getFunc(const char* function)
|
|
|
|
|