31 #include "karambaapp.h" 32 #include "themefile.h" 34 #include "karamba_python.h" 35 #include "meter_python.h" 36 #include "bar_python.h" 37 #include "graph_python.h" 38 #include "textlabel_python.h" 39 #include "richtextlabel_python.h" 40 #include "imagelabel_python.h" 41 #include "widget_python.h" 42 #include "menu_python.h" 43 #include "config_python.h" 44 #include "task_python.h" 45 #include "systray_python.h" 46 #include "svcgrp_python.h" 48 #include "input_python.h" 54 #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) 57 error_out(PyObject *m) {
58 struct module_state *st = GETSTATE(m);
59 PyErr_SetString(st->error,
"something bad happened in karamba_python.cpp");
76 static PyMethodDef karamba_methods[] = {
78 {(
char*)
"createBar", py_createBar, METH_VARARGS, (
char*)
"Create new Bar."},
79 {(
char*)
"deleteBar", py_deleteBar, METH_VARARGS, (
char*)
"Delete Bar."},
80 {(
char*)
"getThemeBar", py_getThemeBar, METH_VARARGS, (
char*)
"Get Bar from .theme using it's name."},
81 {(
char*)
"getBarSize", py_getBarSize, METH_VARARGS, (
char*)
"Get Bar size."},
82 {(
char*)
"resizeBar", py_resizeBar, METH_VARARGS, (
char*)
"Resize Bar."},
83 {(
char*)
"getBarPos", py_getBarPos, METH_VARARGS, (
char*)
"Get Bar position."},
84 {(
char*)
"moveBar", py_moveBar, METH_VARARGS, (
char*)
"Move Bar."},
85 {(
char*)
"hideBar", py_hideBar, METH_VARARGS, (
char*)
"Hide Bar."},
86 {(
char*)
"showBar", py_showBar, METH_VARARGS, (
char*)
"Show Bar."},
87 {(
char*)
"getBarSensor", py_getBarSensor, METH_VARARGS, (
char*)
"Get Bar sensor."},
88 {(
char*)
"setBarSensor", py_setBarSensor, METH_VARARGS, (
char*)
"Set Bar sensor."},
89 {(
char*)
"setBarImage", py_setBarImage, METH_VARARGS, (
char*)
"Set bar image"},
90 {(
char*)
"getBarImage", py_getBarImage, METH_VARARGS, (
char*)
"Get bar image"},
91 {(
char*)
"setBarVertical", py_setBarVertical, METH_VARARGS, (
char*)
"Set bar orientation"},
92 {(
char*)
"getBarVertical", py_getBarVertical, METH_VARARGS, (
char*)
"Get bar orientation"},
93 {(
char*)
"setBarValue", py_setBarValue, METH_VARARGS, (
char*)
"Set bar value"},
94 {(
char*)
"getBarValue", py_getBarValue, METH_VARARGS, (
char*)
"Get bar value"},
95 {(
char*)
"setBarMinMax", py_setBarMinMax, METH_VARARGS, (
char*)
"Set bar min & max"},
96 {(
char*)
"getBarMinMax", py_getBarMinMax, METH_VARARGS, (
char*)
"Get bar min & max"},
97 {(
char*)
"getIncomingData",
py_get_incoming_data, METH_VARARGS, (
char*)
"Get incoming data passed from another theme"},
98 {(
char*)
"setIncomingData",
py_set_incoming_data, METH_VARARGS, (
char*)
"Set incoming data passed in another theme"},
101 {(
char*)
"createGraph", py_createGraph, METH_VARARGS, (
char*)
"Create new Graph."},
102 {(
char*)
"deleteGraph", py_deleteGraph, METH_VARARGS, (
char*)
"Delete Graph."},
103 {(
char*)
"getThemeGraph", py_getThemeGraph, METH_VARARGS, (
char*)
"Get Graph from .theme using it's name."},
104 {(
char*)
"getGraphSize", py_getGraphSize, METH_VARARGS, (
char*)
"Get Graph size."},
105 {(
char*)
"resizeGraph", py_resizeGraph, METH_VARARGS, (
char*)
"Resize Graph."},
106 {(
char*)
"getGraphPos", py_getGraphPos, METH_VARARGS, (
char*)
"Get Graph position."},
107 {(
char*)
"moveGraph", py_moveGraph, METH_VARARGS, (
char*)
"Move Graph."},
108 {(
char*)
"hideGraph", py_hideGraph, METH_VARARGS, (
char*)
"Hide Graph."},
109 {(
char*)
"showGraph", py_showGraph, METH_VARARGS, (
char*)
"Show Graph."},
110 {(
char*)
"getGraphSensor", py_getGraphSensor, METH_VARARGS, (
char*)
"Get Graph sensor."},
111 {(
char*)
"setGraphSensor", py_setGraphSensor, METH_VARARGS, (
char*)
"Set Graph sensor."},
112 {(
char*)
"setGraphValue", py_setGraphValue, METH_VARARGS, (
char*)
"Set graph value"},
113 {(
char*)
"getGraphValue", py_getGraphValue, METH_VARARGS, (
char*)
"Get graph value"},
114 {(
char*)
"setGraphMinMax", py_setGraphMinMax, METH_VARARGS, (
char*)
"Set graph min & max"},
115 {(
char*)
"getGraphMinMax", py_getGraphMinMax, METH_VARARGS, (
char*)
"Get graph min & max"},
116 {(
char*)
"setGraphColor", py_setGraphColor, METH_VARARGS, (
char*)
"Change a Graph Sensor's Color"},
117 {(
char*)
"getGraphColor", py_getGraphColor, METH_VARARGS, (
char*)
"Get a Graph Sensor's Color"},
120 {(
char*)
"createText", py_createText, METH_VARARGS, (
char*)
"Create new Text."},
121 {(
char*)
"deleteText", py_deleteText, METH_VARARGS, (
char*)
"Delete Text."},
122 {(
char*)
"getThemeText", py_getThemeText, METH_VARARGS, (
char*)
"Get Text from .theme using it's name."},
123 {(
char*)
"getTextSize", py_getTextSize, METH_VARARGS, (
char*)
"Get Text size."},
124 {(
char*)
"resizeText", py_resizeText, METH_VARARGS, (
char*)
"Resize Text."},
125 {(
char*)
"getTextPos", py_getTextPos, METH_VARARGS, (
char*)
"Get Text position."},
126 {(
char*)
"moveText", py_moveText, METH_VARARGS, (
char*)
"Move Text."},
127 {(
char*)
"hideText", py_hideText, METH_VARARGS, (
char*)
"Hide Text."},
128 {(
char*)
"showText", py_showText, METH_VARARGS, (
char*)
"Show Text."},
129 {(
char*)
"getTextSensor", py_getTextSensor, METH_VARARGS, (
char*)
"Get Text sensor."},
130 {(
char*)
"setTextSensor", py_setTextSensor, METH_VARARGS, (
char*)
"Set Text sensor."},
131 {(
char*)
"changeText", py_setTextValue, METH_VARARGS, (
char*)
"Change a Text Sensor's Text"},
132 {(
char*)
"getTextValue", py_getTextValue, METH_VARARGS, (
char*)
"Get Text value"},
133 {(
char*)
"changeTextShadow", py_setTextShadow, METH_VARARGS, (
char*)
"Change a Text Shadow size"},
134 {(
char*)
"getTextShadow", py_getTextShadow, METH_VARARGS, (
char*)
"Get a Text Shadow size"},
135 {(
char*)
"changeTextFont", py_setTextFont, METH_VARARGS, (
char*)
"Change a Text Sensor's Font"},
136 {(
char*)
"getTextFont", py_getTextFont, METH_VARARGS, (
char*)
"Get a Text Sensor's Font"},
137 {(
char*)
"changeTextColor", py_setTextColor, METH_VARARGS, (
char*)
"Change a Text Sensor's Color"},
138 {(
char*)
"getTextColor", py_getTextColor, METH_VARARGS, (
char*)
"Get a Text Sensor's Color"},
139 {(
char*)
"changeTextSize", py_setTextFontSize, METH_VARARGS, (
char*)
"Change a Text Sensor's Font Size"},
140 {(
char*)
"getTextFontSize", py_getTextFontSize, METH_VARARGS, (
char*)
"Get a Text Sensor's Font Size"},
141 {(
char*)
"getTextAlign", py_getTextAlign, METH_VARARGS, (
char*)
"Get Text alignment."},
142 {(
char*)
"setTextAlign", py_setTextAlign, METH_VARARGS, (
char*)
"Set Text alignment."},
143 {(
char*)
"setTextScroll", py_setTextScroll, METH_VARARGS, (
char*)
"Set Text scroll."},
146 {(
char*)
"createRichText", py_createRichText, METH_VARARGS, (
char*)
"Create a Rich Text Sensor"},
147 {(
char*)
"deleteRichText", py_deleteRichText, METH_VARARGS, (
char*)
"Deletes a Rich Text Sensor"},
148 {(
char*)
"getThemeRichText", py_getThemeRichText, METH_VARARGS, (
char*)
"Get Rich Text from .theme using it's name."},
149 {(
char*)
"getRichTextSize", py_getRichTextSize, METH_VARARGS, (
char*)
"Get the (width, height) of a Rich Text Sensor"},
150 {(
char*)
"resizeRichText", py_resizeRichText, METH_VARARGS, (
char*)
"Resize Rich Text."},
151 {(
char*)
"setRichTextWidth", py_set_rich_text_width, METH_VARARGS, (
char*)
"Sets the width of a Rich Text Sensor"},
152 {(
char*)
"getRichTextPos", py_getRichTextPos, METH_VARARGS, (
char*)
"Get Rich Text position."},
153 {(
char*)
"moveRichText", py_moveRichText, METH_VARARGS, (
char*)
"Moves a Rich Text Sensor"},
154 {(
char*)
"hideRichText", py_hideRichText, METH_VARARGS, (
char*)
"hides a Rich Text Sensor"},
155 {(
char*)
"showRichText", py_showRichText, METH_VARARGS, (
char*)
"shows a Rich Text Sensor"},
156 {(
char*)
"getRichTextSensor", py_getRichTextSensor, METH_VARARGS, (
char*)
"Get Rich Text sensor."},
157 {(
char*)
"setRichTextSensor", py_setRichTextSensor, METH_VARARGS, (
char*)
"Set Rich Text sensor."},
158 {(
char*)
"changeRichText", py_setRichTextValue, METH_VARARGS, (
char*)
"Change the content of a Rich Text Sensor"},
159 {(
char*)
"getRichTextValue", py_getRichTextValue, METH_VARARGS, (
char*)
"Get Rich Text value"},
160 {(
char*)
"changeRichTextFont", py_setRichTextFont, METH_VARARGS, (
char*)
"Change a Rich Text Sensor's Font"},
161 {(
char*)
"getRichTextFont", py_getRichTextFont, METH_VARARGS, (
char*)
"Get a Rich Text Sensor's Font"},
162 {(
char*)
"changeRichTextSize", py_setRichTextFontSize, METH_VARARGS, (
char*)
"Change a Rich Text Sensor's Font Size"},
163 {(
char*)
"getRichTextFontSize", py_getRichTextFontSize, METH_VARARGS, (
char*)
"Get a Rich Text Sensor's Font Size"},
166 {(
char*)
"createImage", py_createImage, METH_VARARGS, (
char*)
"Create an Image"},
167 {(
char*)
"createTaskIcon", py_createTaskIcon, METH_VARARGS, (
char*)
"Create an Image of the Icon for a Task"},
168 {(
char*)
"createBackgroundImage", py_createBackgroundImage, METH_VARARGS, (
char*)
"Create an Image (only redraw it when background changes)"},
169 {(
char*)
"deleteImage", py_deleteImage, METH_VARARGS, (
char*)
"Delete an Image"},
170 {(
char*)
"getThemeImage", py_getThemeImage, METH_VARARGS, (
char*)
"Get image meter from .theme using it's name"},
171 {(
char*)
"getImageSize", py_getImageSize, METH_VARARGS, (
char*)
"Get Image size."},
172 {(
char*)
"getImageWidth", py_getImageWidth, METH_VARARGS, (
char*)
"Get the width of an Image"},
173 {(
char*)
"getImageHeight", py_getImageHeight, METH_VARARGS, (
char*)
"Get the height of an Image"},
174 {(
char*)
"getImagePos", py_getImagePos, METH_VARARGS, (
char*)
"Get Image position."},
175 {(
char*)
"moveImage", py_moveImage, METH_VARARGS, (
char*)
"Move an Image"},
176 {(
char*)
"hideImage", py_hideImage, METH_VARARGS, (
char*)
"Hide an Image"},
177 {(
char*)
"showImage", py_showImage, METH_VARARGS, (
char*)
"Show an Image"},
178 {(
char*)
"getImagePath", py_getImageValue, METH_VARARGS, (
char*)
"Get Image path."},
179 {(
char*)
"setImagePath", py_setImageValue, METH_VARARGS, (
char*)
"Set Image path."},
180 {(
char*)
"getImageSensor", py_getImageSensor, METH_VARARGS, (
char*)
"Get Image sensor."},
181 {(
char*)
"setImageSensor", py_setImageSensor, METH_VARARGS, (
char*)
"Set Image sensor."},
182 {(
char*)
"addImageTooltip", py_addImageTooltip, METH_VARARGS, (
char*)
"Create a Tooltip for an Image"},
183 {(
char*)
"resizeImage", py_resizeImage, METH_VARARGS, (
char*)
"Scale an Image"},
184 {(
char*)
"resizeImageSmooth", py_resizeImageSmooth, METH_VARARGS, (
char*)
"Scale an Image (slower, better looking)"},
185 {(
char*)
"rotateImage", py_rotateImage, METH_VARARGS, (
char*)
"Rotate an Image"},
186 {(
char*)
"removeImageTransformations", py_removeImageTransformations, METH_VARARGS, (
char*)
"Restore original size and orientation of an Image"},
187 {(
char*)
"removeImageEffects", py_removeImageEffects, METH_VARARGS, (
char*)
"Remove Effects of an Image"},
188 {(
char*)
"changeImageIntensity", py_changeImageIntensity, METH_VARARGS, (
char*)
"Change Intensity of an Image"},
189 {(
char*)
"changeImageChannelIntensity", py_changeImageChannelIntensity, METH_VARARGS, (
char*)
"Change Intensity of an Image Channel"},
190 {(
char*)
"changeImageToGray", py_changeImageToGray, METH_VARARGS, (
char*)
"Converts an Image to Grayscale"},
193 {(
char*)
"createMenu", py_create_menu, METH_VARARGS, (
char*)
"Create a popup menu"},
194 {(
char*)
"deleteMenu", py_delete_menu, METH_VARARGS, (
char*)
"Delete a popup menu"},
195 {(
char*)
"addMenuItem", py_add_menu_item, METH_VARARGS, (
char*)
"Add a popup menu entry"},
196 {(
char*)
"addMenuSeparator", py_add_menu_separator, METH_VARARGS, (
char*)
"Add a popup menu seperator item"},
197 {(
char*)
"removeMenuItem", py_remove_menu_item, METH_VARARGS, (
char*)
"Remove a popup menu entry"},
198 {(
char*)
"popupMenu", py_popup_menu, METH_VARARGS, (
char*)
"Popup a menu at a specified location"},
201 {(
char*)
"addMenuConfigOption", py_add_menu_config_option, METH_VARARGS, (
char*)
"Add a configuration entry to the menu"},
202 {(
char*)
"setMenuConfigOption", py_set_menu_config_option, METH_VARARGS, (
char*)
"Set a configuration entry in the menu"},
203 {(
char*)
"readMenuConfigOption", py_read_menu_config_option, METH_VARARGS, (
char*)
"Read a configuration entry in the menu"},
204 {(
char*)
"readConfigEntry", py_read_config_entry, METH_VARARGS, (
char*)
"Read a configuration entry"},
205 {(
char*)
"writeConfigEntry", py_write_config_entry, METH_VARARGS, (
char*)
"Writes a configuration entry"},
208 {(
char*)
"moveWidget", py_move_widget, METH_VARARGS, (
char*)
"Move Widget to x,y"},
209 {(
char*)
"resizeWidget", py_resize_widget, METH_VARARGS, (
char*)
"Resize Widget to width,height"},
210 {(
char*)
"createWidgetMask", py_create_widget_mask, METH_VARARGS, (
char*)
"Create a clipping mask for this widget"},
211 {(
char*)
"redrawWidget", py_redraw_widget, METH_VARARGS, (
char*)
"Update Widget to reflect your changes"},
212 {(
char*)
"redrawWidgetBackground", py_redraw_widget_background, METH_VARARGS, (
char*)
"Update Widget to reflect background image changes"},
213 {(
char*)
"getWidgetPosition", py_get_widget_position, METH_VARARGS, (
char*)
"Get Widget Position"},
214 {(
char*)
"toggleWidgetRedraw", py_toggle_widget_redraw, METH_VARARGS, (
char*)
"Toggle Widget redrawing"},
217 {(
char*)
"getStartupList", py_get_startup_list, METH_VARARGS, (
char*)
"Get the system startup list"},
218 {(
char*)
"getStartupInfo", py_get_startup_info, METH_VARARGS, (
char*)
"Get all the info for a startup"},
219 {(
char*)
"getTaskList", py_get_task_list, METH_VARARGS, (
char*)
"Get the system task list"},
220 {(
char*)
"getTaskNames", py_get_task_names, METH_VARARGS, (
char*)
"Get the system task list in name form"},
221 {(
char*)
"getTaskInfo", py_get_task_info, METH_VARARGS, (
char*)
"Get all the info for a task"},
222 {(
char*)
"performTaskAction", py_perform_task_action, METH_VARARGS, (
char*)
"Do something with a task, such as minimize it"},
225 {(
char*)
"createSystray", py_create_systray, METH_VARARGS, (
char*)
"Create a Systray"},
226 {(
char*)
"hideSystray", py_hide_systray, METH_VARARGS, (
char*)
"Hide the Systray"},
227 {(
char*)
"showSystray", py_show_systray, METH_VARARGS, (
char*)
"Show the Systray"},
228 {(
char*)
"moveSystray", py_move_systray, METH_VARARGS, (
char*)
"Move the Systray"},
229 {(
char*)
"getCurrentWindowCount", py_get_current_window_count, METH_VARARGS, (
char*)
"Get current Window count"},
230 {(
char*)
"updateSystrayLayout", py_update_systray_layout, METH_VARARGS, (
char*)
"Update Systray layout"},
233 {(
char*)
"getThemePath",
py_get_theme_path, METH_VARARGS, (
char*)
"Get the file path of the theme"},
235 (
char*)
"Read file from theme."},
237 (
char*)
"Return default language of a translation file."},
239 (
char*)
"Return user language."},
241 (
char*)
"Return preferred user languages."},
243 (
char*)
"Open a new theme"},
245 (
char*)
"Reload current theme"},
247 (
char*)
"Allows widget to receive Drop (I.E. Drag and Drop) events"},
249 (
char*)
"Show/Hide the desktop"},
252 {(
char*)
"attachClickArea", (PyCFunction)
py_attach_clickArea, METH_VARARGS|METH_KEYWORDS, (
char*)
"Add a clickArea to the given text or image"},
253 {(
char*)
"createClickArea",
py_create_click_area, METH_VARARGS, (
char*)
"Create a Click Area Sensor"},
254 {(
char*)
"getNumberOfDesktops",
py_get_number_of_desktops, METH_VARARGS, (
char*)
"Get current number of virtual desktops"},
255 {(
char*)
"getIp",
py_get_ip, METH_VARARGS, (
char*)
"Get current host's IP address"},
256 {(
char*)
"translateAll",
py_translate_all, METH_VARARGS, (
char*)
"Translate all widgets in a theme"},
257 {(
char*)
"show",
py_show, METH_VARARGS, (
char*)
"Show theme"},
258 {(
char*)
"hide",
py_hide, METH_VARARGS, (
char*)
"Hide theme"},
261 {(
char*)
"createInputBox", py_createInputBox, METH_VARARGS,
262 (
char*)
"Create new Input Box."},
263 {(
char*)
"deleteInputBox", py_deleteInputBox, METH_VARARGS,
264 (
char*)
"Delete Input Box."},
265 {(
char*)
"getThemeInputBox", py_getThemeInputBox, METH_VARARGS,
266 (
char*)
"Get Input Box from .theme using it's name."},
267 {(
char*)
"getInputBoxValue", py_getInputBoxValue, METH_VARARGS,
268 (
char*)
"Get Input Box value"},
269 {(
char*)
"changeInputBox", py_setInputBoxValue, METH_VARARGS,
270 (
char*)
"Change a Input Box Text"},
271 {(
char*)
"hideInputBox", py_hideInputBox, METH_VARARGS,
272 (
char*)
"Hide Input Box."},
273 {(
char*)
"showInputBox", py_showInputBox, METH_VARARGS,
274 (
char*)
"Show Input Box."},
275 {(
char*)
"getInputBoxPos", py_getInputBoxPos, METH_VARARGS,
276 (
char*)
"Get InputBox position."},
277 {(
char*)
"moveInputBox", py_moveInputBox, METH_VARARGS,
278 (
char*)
"Moves a Input Box"},
279 {(
char*)
"getInputBoxSize", py_getInputBoxSize, METH_VARARGS,
280 (
char*)
"Get the (width, height) of a Input Box"},
281 {(
char*)
"resizeInputBox", py_resizeInputBox, METH_VARARGS,
282 (
char*)
"Resize Input Box."},
283 {(
char*)
"changeInputBoxFont", py_setInputBoxFont, METH_VARARGS,
284 (
char*)
"Change a Input Box Font"},
285 {(
char*)
"getInputBoxFont", py_getInputBoxFont, METH_VARARGS,
286 (
char*)
"Get a Input Box Font"},
287 {(
char*)
"changeInputBoxFontColor", py_setInputBoxFontColor, METH_VARARGS,
288 (
char*)
"Change a Input Box Font Color"},
289 {(
char*)
"getInputBoxFontColor", py_getInputBoxFontColor, METH_VARARGS,
290 (
char*)
"Get a Input Box Font Color"},
291 {(
char*)
"changeInputBoxSelectionColor", py_setInputBoxSelectionColor,
292 METH_VARARGS, (
char*)
"Change a Input Box Selection Color"},
293 {(
char*)
"getInputBoxSelectionColor", py_getInputBoxSelectionColor,
294 METH_VARARGS, (
char*)
"Get a Input Box Selection Color"},
295 {(
char*)
"changeInputBoxBackgroundColor", py_setInputBoxBGColor,
296 METH_VARARGS, (
char*)
"Change a Input Box Background Color"},
297 {(
char*)
"getInputBoxBackgroundColor", py_getInputBoxBGColor, METH_VARARGS,
298 (
char*)
"Get a Input Box Background Color"},
299 {(
char*)
"changeInputBoxFrameColor", py_setInputBoxFrameColor, METH_VARARGS,
300 (
char*)
"Change a Input Box Frame Color"},
301 {(
char*)
"getInputBoxFrameColor", py_getInputBoxFrameColor, METH_VARARGS,
302 (
char*)
"Get a Input Box Frame Color"},
303 {(
char*)
"changeInputBoxSelectedTextColor", py_setInputBoxSelectedTextColor,
304 METH_VARARGS, (
char*)
"Change a Input Box Selected Text Color"},
305 {(
char*)
"getInputBoxSelectedTextColor", py_getInputBoxSelectedTextColor,
306 METH_VARARGS, (
char*)
"Get a Input Box Selected Text Color"},
307 {(
char*)
"changeInputBoxFontSize", py_setInputBoxFontSize, METH_VARARGS,
308 (
char*)
"Change a Input Box Font Size"},
309 {(
char*)
"getInputBoxFontSize", py_getInputBoxFontSize, METH_VARARGS,
310 (
char*)
"Get a Input Box Font Size"},
311 {(
char*)
"setInputFocus", py_setInputFocus, METH_VARARGS,
312 (
char*)
"Set the Input Focus to the Input Box"},
313 {(
char*)
"clearInputFocus", py_clearInputFocus, METH_VARARGS,
314 (
char*)
"Clear the Input Focus of the Input Box"},
315 {(
char*)
"getInputFocus", py_getInputFocus, METH_VARARGS,
316 (
char*)
"Get the Input Box currently focused"},
318 {(
char*)
"setWidgetOnTop", py_set_widget_on_top, METH_VARARGS,
319 (
char*)
"changes 'on top' status"},
320 {(
char*)
"getSystraySize", py_get_systray_size, METH_VARARGS,
321 (
char*)
"Get the size of the Systray"},
323 (
char*)
"Get the pretty name of the theme"},
325 (
char*)
"Open a new theme giving it a new name"},
327 (
char*)
"Pass a string to another theme"},
329 (
char*)
"Change the refresh interval"},
331 (
char*)
"Execute a command with KRun"},
333 (
char*)
"Create a Service-named Click Area Sensor"},
335 (
char*)
"Remove a Click Area Sensor"},
337 (
char*)
"Set last updated time"},
339 (
char*)
"Get last updated time"},
341 (
char*)
"Set to 1 to deactivate management popups"},
343 (
char*)
"Enables wheel events over meters."},
345 (
char*)
"Activates the Management Popup menu"},
348 {(
char*)
"getServiceGroups", py_get_service_groups, METH_VARARGS,
349 (
char*)
"Get KDE Service Groups"},
351 {NULL, NULL, 0 ,NULL}
354 static int karamba_traverse(PyObject *m, visitproc visit,
void *arg) {
355 Py_VISIT(GETSTATE(m)->error);
359 static int karamba_clear(PyObject *m) {
360 Py_CLEAR(GETSTATE(m)->error);
364 static struct PyModuleDef karambadef = {
365 PyModuleDef_HEAD_INIT,
368 sizeof(
struct module_state),
376 #define INITERROR return NULL 378 PyMODINIT_FUNC PyInit_karamba(
void)
380 return PyModule_Create(&karambadef);
383 PyThreadState* KarambaPython::mainThreadState = 0;
385 KarambaPython::KarambaPython(
const ThemeFile& theme,
bool reloading):
386 pythonThemeExtensionLoaded(false), pName(0), pModule(0), pDict(0)
391 PyRun_SimpleString((
char*)
"import sys");
393 snprintf(pypath, 1023,
"sys.path.insert(0, '%s')", theme.path().ascii());
394 PyRun_SimpleString(pypath);
395 PyRun_SimpleString((
char*)
"sys.path.insert(0, '')");
397 pName = PyUnicode_FromString(theme.pythonModule().utf8());
398 pModule = PyImport_Import(pName);
400 fprintf(stderr,
"%s\n", pypath);
404 PyImport_ReloadModule(pModule);
408 pDict = PyModule_GetDict(pModule);
411 pythonThemeExtensionLoaded =
true;
418 "------------------------------------------------------\n");
419 fprintf(stderr,
"What does ImportError mean?\n");
420 fprintf(stderr,
"\n");
422 "It means that I couldn't load a python add-on %s.py\n",
423 theme.pythonModule().ascii());
424 fprintf(stderr,
"If this is a regular theme and doesn't use python\n");
425 fprintf(stderr,
"extensions, then nothing is wrong.\n");
427 "------------------------------------------------------\n");
431 KarambaPython::~KarambaPython()
434 if (pythonThemeExtensionLoaded) {
441 void KarambaPython::initPython()
444 PyImport_AppendInittab((
char*)
"karamba", PyInit_karamba);
447 #if PY_VERSION_HEX < 0x03070000 449 PyEval_InitThreads();
453 mainThreadState = PyThreadState_Get();
456 void KarambaPython::shutdownPython()
459 PyThreadState_Swap(mainThreadState);
463 PyObject* KarambaPython::getFunc(
const char*
function)
465 PyObject* pFunc = PyDict_GetItemString(pDict, (
char*)
function);
466 if (pFunc && PyCallable_Check(pFunc))
471 bool KarambaPython::callObject(
const char* func, PyObject* pArgs)
475 PyObject* pFunc = getFunc(func);
478 PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
487 tqWarning(
"Call to %s failed", func);
495 bool KarambaPython::initWidget(karamba* k)
497 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
498 return callObject(
"initWidget", pArgs);
501 bool KarambaPython::widgetUpdated(karamba* k)
503 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
504 return callObject(
"widgetUpdated", pArgs);
507 bool KarambaPython::widgetClosed(karamba* k)
509 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
510 return callObject(
"widgetClosed", pArgs);
513 bool KarambaPython::menuOptionChanged(karamba* k, TQString key,
bool value)
515 PyObject* pArgs = Py_BuildValue((
char*)
"(lsi)", k, key.ascii(), (int)value);
516 return callObject(
"menuOptionChanged", pArgs);
519 bool KarambaPython::menuItemClicked(karamba* k, TDEPopupMenu* menu,
long id)
521 PyObject* pArgs = Py_BuildValue((
char*)
"(lll)", k, menu,
id);
522 return callObject(
"menuItemClicked", pArgs);
525 bool KarambaPython::meterClicked(karamba* k, Meter* meter,
int button)
527 PyObject* pArgs = Py_BuildValue((
char*)
"(lli)", k, meter, button);
528 return callObject(
"meterClicked", pArgs);
531 bool KarambaPython::meterClicked(karamba* k, TQString anchor,
int button)
533 PyObject* pArgs = Py_BuildValue((
char*)
"(lsi)", k, anchor.ascii(), button);
534 return callObject(
"meterClicked", pArgs);
537 bool KarambaPython::widgetClicked(karamba* k,
int x,
int y,
int button)
539 PyObject* pArgs = Py_BuildValue((
char*)
"(liii)", k, x, y, button);
540 return callObject(
"widgetClicked", pArgs);
543 bool KarambaPython::keyPressed(karamba* k,
const Meter* meter,
const TQString& text)
545 PyObject* pArgs = Py_BuildValue((
char*)
"(lls)", k, meter, text.ucs2());
546 return callObject(
"keyPressed", pArgs);
549 bool KarambaPython::widgetMouseMoved(karamba* k,
int x,
int y,
int button)
551 PyObject* pArgs = Py_BuildValue((
char*)
"(liii)", k, x, y, button);
552 return callObject(
"widgetMouseMoved", pArgs);
555 bool KarambaPython::activeTaskChanged(karamba* k,
Task* t)
557 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
558 return callObject(
"activeTaskChanged", pArgs);
561 bool KarambaPython::taskAdded(karamba* k,
Task* t)
563 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
564 return callObject(
"taskAdded", pArgs);
567 bool KarambaPython::taskRemoved(karamba* k,
Task* t)
569 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
570 return callObject(
"taskRemoved", pArgs);
573 bool KarambaPython::startupAdded(karamba* k,
Startup* t)
575 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
576 return callObject(
"startupAdded", pArgs);
579 bool KarambaPython::startupRemoved(karamba* k,
Startup* t)
581 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
582 return callObject(
"startupRemoved", pArgs);
585 bool KarambaPython::commandOutput(karamba* k,
int pid,
char *buffer)
587 PyObject* pArgs = Py_BuildValue((
char*)
"(lis)", k, pid, buffer);
588 return callObject(
"commandOutput", pArgs);
591 bool KarambaPython::commandFinished(karamba* k,
int pid)
593 PyObject* pArgs = Py_BuildValue((
char*)
"(li)", k, pid);
594 return callObject(
"commandFinished", pArgs);
597 bool KarambaPython::itemDropped(karamba* k, TQString text,
int x,
int y)
599 PyObject* pArgs = Py_BuildValue((
char*)
"(lOii)", k, TQString2PyString(text), x, y);
600 return callObject(
"itemDropped", pArgs);
603 bool KarambaPython::themeNotify(karamba* k,
const char *from,
const char *str)
605 PyObject* pArgs = Py_BuildValue((
char*)
"(lss)", k, from, str);
606 return callObject(
"themeNotify", pArgs);
609 bool KarambaPython::systrayUpdated(karamba* k)
611 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
612 return callObject(
"systrayUpdated", pArgs);
615 bool KarambaPython::desktopChanged(karamba* k,
int desktop)
617 PyObject* pArgs = Py_BuildValue((
char*)
"(li)", k, desktop);
618 return callObject(
"desktopChanged", pArgs);
621 bool KarambaPython::wallpaperChanged(karamba* k,
int desktop)
623 PyObject* pArgs = Py_BuildValue((
char*)
"(li)", k, desktop);
624 return callObject(
"wallpaperChanged", pArgs);
PyObject * py_hide(PyObject *self, PyObject *args)
Misc/hide.
PyObject * py_reload_theme(PyObject *self, PyObject *args)
Misc/reloadTheme.
PyObject * py_get_theme_path(PyObject *self, PyObject *args)
Misc/getThemePath.
Represents a task which is in the process of starting.
PyObject * py_show(PyObject *self, PyObject *args)
Misc/show.
PyObject * py_execute_command_interactive(PyObject *self, PyObject *args)
Misc/executeInteractive.
PyObject * py_attach_clickArea(PyObject *self, PyObject *args, PyObject *dict)
Misc/attachClickArea.
PyObject * py_management_popup(PyObject *self, PyObject *args)
Misc/managementPopup.
PyObject * py_remove_click_area(PyObject *self, PyObject *args)
Misc/removeClickArea.
PyObject * py_toggle_show_desktop(PyObject *self, PyObject *args)
Misc/toggleShowDesktop.
PyObject * py_get_ip(PyObject *self, PyObject *args)
Misc/getIp.
PyObject * py_get_update_time(PyObject *self, PyObject *args)
Misc/getUpdateTime.
PyObject * py_create_click_area(PyObject *self, PyObject *args)
Misc/createClickArea.
PyObject * py_set_incoming_data(PyObject *self, PyObject *args)
Misc/setIncomingData.
PyObject * py_userLanguages(PyObject *self, PyObject *args)
Misc/userLanguages.
PyObject * py_userLanguage(PyObject *self, PyObject *args)
Misc/userLanguage.
PyObject * py_change_interval(PyObject *self, PyObject *args)
Misc/changeInterval.
PyObject * py_set_update_time(PyObject *self, PyObject *args)
Misc/setUpdateTime.
These are global functions that are used to interpret certain Python calls.
PyObject * py_execute_command(PyObject *self, PyObject *args)
Misc/execute.
PyObject * py_run_command(PyObject *self, PyObject *args)
Misc/run.
PyObject * py_open_named_theme(PyObject *self, PyObject *args)
Misc/openNamedTheme.
PyObject * py_get_number_of_desktops(PyObject *self, PyObject *args)
Misc/getNumberOfDesktop.
PyObject * py_accept_drops(PyObject *self, PyObject *args)
Misc/acceptDrops.
PyObject * py_get_pretty_name(PyObject *self, PyObject *args)
Misc/getPrettyThemeName.
PyObject * py_want_right_button(PyObject *self, PyObject *args)
Misc/setWantRightButton.
PyObject * py_want_wheel_event(PyObject *, PyObject *args)
Misc/setWantMeterWheelEvent.
PyObject * py_open_theme(PyObject *self, PyObject *args)
Misc/openTheme.
PyObject * py_read_theme_file(PyObject *self, PyObject *args)
Misc/readThemeFile.
PyObject * py_create_service_click_area(PyObject *self, PyObject *args)
Misc/createServiceClickArea.
PyObject * py_language(PyObject *self, PyObject *args)
Misc/language.
A dynamic interface to a task (main window).
PyObject * py_get_incoming_data(PyObject *self, PyObject *args)
Misc/getIncomingData.
PyObject * py_translate_all(PyObject *self, PyObject *args)
Misc/translateAll.
PyObject * py_call_theme(PyObject *self, PyObject *args)
Misc/callTheme.