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"
63 static PyMethodDef karamba_methods[] = {
65 {(
char*)
"createBar", py_createBar, METH_VARARGS, (
char*)
"Create new Bar."},
66 {(
char*)
"deleteBar", py_deleteBar, METH_VARARGS, (
char*)
"Delete Bar."},
67 {(
char*)
"getThemeBar", py_getThemeBar, METH_VARARGS, (
char*)
"Get Bar from .theme using it's name."},
68 {(
char*)
"getBarSize", py_getBarSize, METH_VARARGS, (
char*)
"Get Bar size."},
69 {(
char*)
"resizeBar", py_resizeBar, METH_VARARGS, (
char*)
"Resize Bar."},
70 {(
char*)
"getBarPos", py_getBarPos, METH_VARARGS, (
char*)
"Get Bar position."},
71 {(
char*)
"moveBar", py_moveBar, METH_VARARGS, (
char*)
"Move Bar."},
72 {(
char*)
"hideBar", py_hideBar, METH_VARARGS, (
char*)
"Hide Bar."},
73 {(
char*)
"showBar", py_showBar, METH_VARARGS, (
char*)
"Show Bar."},
74 {(
char*)
"getBarSensor", py_getBarSensor, METH_VARARGS, (
char*)
"Get Bar sensor."},
75 {(
char*)
"setBarSensor", py_setBarSensor, METH_VARARGS, (
char*)
"Set Bar sensor."},
76 {(
char*)
"setBarImage", py_setBarImage, METH_VARARGS, (
char*)
"Set bar image"},
77 {(
char*)
"getBarImage", py_getBarImage, METH_VARARGS, (
char*)
"Get bar image"},
78 {(
char*)
"setBarVertical", py_setBarVertical, METH_VARARGS, (
char*)
"Set bar orientation"},
79 {(
char*)
"getBarVertical", py_getBarVertical, METH_VARARGS, (
char*)
"Get bar orientation"},
80 {(
char*)
"setBarValue", py_setBarValue, METH_VARARGS, (
char*)
"Set bar value"},
81 {(
char*)
"getBarValue", py_getBarValue, METH_VARARGS, (
char*)
"Get bar value"},
82 {(
char*)
"setBarMinMax", py_setBarMinMax, METH_VARARGS, (
char*)
"Set bar min & max"},
83 {(
char*)
"getBarMinMax", py_getBarMinMax, METH_VARARGS, (
char*)
"Get bar min & max"},
84 {(
char*)
"getIncomingData", py_get_incoming_data, METH_VARARGS, (
char*)
"Get incoming data passed from another theme"},
85 {(
char*)
"setIncomingData", py_set_incoming_data, METH_VARARGS, (
char*)
"Set incoming data passed in another theme"},
88 {(
char*)
"createGraph", py_createGraph, METH_VARARGS, (
char*)
"Create new Graph."},
89 {(
char*)
"deleteGraph", py_deleteGraph, METH_VARARGS, (
char*)
"Delete Graph."},
90 {(
char*)
"getThemeGraph", py_getThemeGraph, METH_VARARGS, (
char*)
"Get Graph from .theme using it's name."},
91 {(
char*)
"getGraphSize", py_getGraphSize, METH_VARARGS, (
char*)
"Get Graph size."},
92 {(
char*)
"resizeGraph", py_resizeGraph, METH_VARARGS, (
char*)
"Resize Graph."},
93 {(
char*)
"getGraphPos", py_getGraphPos, METH_VARARGS, (
char*)
"Get Graph position."},
94 {(
char*)
"moveGraph", py_moveGraph, METH_VARARGS, (
char*)
"Move Graph."},
95 {(
char*)
"hideGraph", py_hideGraph, METH_VARARGS, (
char*)
"Hide Graph."},
96 {(
char*)
"showGraph", py_showGraph, METH_VARARGS, (
char*)
"Show Graph."},
97 {(
char*)
"getGraphSensor", py_getGraphSensor, METH_VARARGS, (
char*)
"Get Graph sensor."},
98 {(
char*)
"setGraphSensor", py_setGraphSensor, METH_VARARGS, (
char*)
"Set Graph sensor."},
99 {(
char*)
"setGraphValue", py_setGraphValue, METH_VARARGS, (
char*)
"Set graph value"},
100 {(
char*)
"getGraphValue", py_getGraphValue, METH_VARARGS, (
char*)
"Get graph value"},
101 {(
char*)
"setGraphMinMax", py_setGraphMinMax, METH_VARARGS, (
char*)
"Set graph min & max"},
102 {(
char*)
"getGraphMinMax", py_getGraphMinMax, METH_VARARGS, (
char*)
"Get graph min & max"},
103 {(
char*)
"setGraphColor", py_setGraphColor, METH_VARARGS, (
char*)
"Change a Graph Sensor's Color"},
104 {(
char*)
"getGraphColor", py_getGraphColor, METH_VARARGS, (
char*)
"Get a Graph Sensor's Color"},
107 {(
char*)
"createText", py_createText, METH_VARARGS, (
char*)
"Create new Text."},
108 {(
char*)
"deleteText", py_deleteText, METH_VARARGS, (
char*)
"Delete Text."},
109 {(
char*)
"getThemeText", py_getThemeText, METH_VARARGS, (
char*)
"Get Text from .theme using it's name."},
110 {(
char*)
"getTextSize", py_getTextSize, METH_VARARGS, (
char*)
"Get Text size."},
111 {(
char*)
"resizeText", py_resizeText, METH_VARARGS, (
char*)
"Resize Text."},
112 {(
char*)
"getTextPos", py_getTextPos, METH_VARARGS, (
char*)
"Get Text position."},
113 {(
char*)
"moveText", py_moveText, METH_VARARGS, (
char*)
"Move Text."},
114 {(
char*)
"hideText", py_hideText, METH_VARARGS, (
char*)
"Hide Text."},
115 {(
char*)
"showText", py_showText, METH_VARARGS, (
char*)
"Show Text."},
116 {(
char*)
"getTextSensor", py_getTextSensor, METH_VARARGS, (
char*)
"Get Text sensor."},
117 {(
char*)
"setTextSensor", py_setTextSensor, METH_VARARGS, (
char*)
"Set Text sensor."},
118 {(
char*)
"changeText", py_setTextValue, METH_VARARGS, (
char*)
"Change a Text Sensor's Text"},
119 {(
char*)
"getTextValue", py_getTextValue, METH_VARARGS, (
char*)
"Get Text value"},
120 {(
char*)
"changeTextShadow", py_setTextShadow, METH_VARARGS, (
char*)
"Change a Text Shadow size"},
121 {(
char*)
"getTextShadow", py_getTextShadow, METH_VARARGS, (
char*)
"Get a Text Shadow size"},
122 {(
char*)
"changeTextFont", py_setTextFont, METH_VARARGS, (
char*)
"Change a Text Sensor's Font"},
123 {(
char*)
"getTextFont", py_getTextFont, METH_VARARGS, (
char*)
"Get a Text Sensor's Font"},
124 {(
char*)
"changeTextColor", py_setTextColor, METH_VARARGS, (
char*)
"Change a Text Sensor's Color"},
125 {(
char*)
"getTextColor", py_getTextColor, METH_VARARGS, (
char*)
"Get a Text Sensor's Color"},
126 {(
char*)
"changeTextSize", py_setTextFontSize, METH_VARARGS, (
char*)
"Change a Text Sensor's Font Size"},
127 {(
char*)
"getTextFontSize", py_getTextFontSize, METH_VARARGS, (
char*)
"Get a Text Sensor's Font Size"},
128 {(
char*)
"getTextAlign", py_getTextAlign, METH_VARARGS, (
char*)
"Get Text alignment."},
129 {(
char*)
"setTextAlign", py_setTextAlign, METH_VARARGS, (
char*)
"Set Text alignment."},
130 {(
char*)
"setTextScroll", py_setTextScroll, METH_VARARGS, (
char*)
"Set Text scroll."},
133 {(
char*)
"createRichText", py_createRichText, METH_VARARGS, (
char*)
"Create a Rich Text Sensor"},
134 {(
char*)
"deleteRichText", py_deleteRichText, METH_VARARGS, (
char*)
"Deletes a Rich Text Sensor"},
135 {(
char*)
"getThemeRichText", py_getThemeRichText, METH_VARARGS, (
char*)
"Get Rich Text from .theme using it's name."},
136 {(
char*)
"getRichTextSize", py_getRichTextSize, METH_VARARGS, (
char*)
"Get the (width, height) of a Rich Text Sensor"},
137 {(
char*)
"resizeRichText", py_resizeRichText, METH_VARARGS, (
char*)
"Resize Rich Text."},
138 {(
char*)
"setRichTextWidth", py_set_rich_text_width, METH_VARARGS, (
char*)
"Sets the width of a Rich Text Sensor"},
139 {(
char*)
"getRichTextPos", py_getRichTextPos, METH_VARARGS, (
char*)
"Get Rich Text position."},
140 {(
char*)
"moveRichText", py_moveRichText, METH_VARARGS, (
char*)
"Moves a Rich Text Sensor"},
141 {(
char*)
"hideRichText", py_hideRichText, METH_VARARGS, (
char*)
"hides a Rich Text Sensor"},
142 {(
char*)
"showRichText", py_showRichText, METH_VARARGS, (
char*)
"shows a Rich Text Sensor"},
143 {(
char*)
"getRichTextSensor", py_getRichTextSensor, METH_VARARGS, (
char*)
"Get Rich Text sensor."},
144 {(
char*)
"setRichTextSensor", py_setRichTextSensor, METH_VARARGS, (
char*)
"Set Rich Text sensor."},
145 {(
char*)
"changeRichText", py_setRichTextValue, METH_VARARGS, (
char*)
"Change the content of a Rich Text Sensor"},
146 {(
char*)
"getRichTextValue", py_getRichTextValue, METH_VARARGS, (
char*)
"Get Rich Text value"},
147 {(
char*)
"changeRichTextFont", py_setRichTextFont, METH_VARARGS, (
char*)
"Change a Rich Text Sensor's Font"},
148 {(
char*)
"getRichTextFont", py_getRichTextFont, METH_VARARGS, (
char*)
"Get a Rich Text Sensor's Font"},
149 {(
char*)
"changeRichTextSize", py_setRichTextFontSize, METH_VARARGS, (
char*)
"Change a Rich Text Sensor's Font Size"},
150 {(
char*)
"getRichTextFontSize", py_getRichTextFontSize, METH_VARARGS, (
char*)
"Get a Rich Text Sensor's Font Size"},
153 {(
char*)
"createImage", py_createImage, METH_VARARGS, (
char*)
"Create an Image"},
154 {(
char*)
"createTaskIcon", py_createTaskIcon, METH_VARARGS, (
char*)
"Create an Image of the Icon for a Task"},
155 {(
char*)
"createBackgroundImage", py_createBackgroundImage, METH_VARARGS, (
char*)
"Create an Image (only redraw it when background changes)"},
156 {(
char*)
"deleteImage", py_deleteImage, METH_VARARGS, (
char*)
"Delete an Image"},
157 {(
char*)
"getThemeImage", py_getThemeImage, METH_VARARGS, (
char*)
"Get image meter from .theme using it's name"},
158 {(
char*)
"getImageSize", py_getImageSize, METH_VARARGS, (
char*)
"Get Image size."},
159 {(
char*)
"getImageWidth", py_getImageWidth, METH_VARARGS, (
char*)
"Get the width of an Image"},
160 {(
char*)
"getImageHeight", py_getImageHeight, METH_VARARGS, (
char*)
"Get the height of an Image"},
161 {(
char*)
"getImagePos", py_getImagePos, METH_VARARGS, (
char*)
"Get Image position."},
162 {(
char*)
"moveImage", py_moveImage, METH_VARARGS, (
char*)
"Move an Image"},
163 {(
char*)
"hideImage", py_hideImage, METH_VARARGS, (
char*)
"Hide an Image"},
164 {(
char*)
"showImage", py_showImage, METH_VARARGS, (
char*)
"Show an Image"},
165 {(
char*)
"getImagePath", py_getImageValue, METH_VARARGS, (
char*)
"Get Image path."},
166 {(
char*)
"setImagePath", py_setImageValue, METH_VARARGS, (
char*)
"Set Image path."},
167 {(
char*)
"getImageSensor", py_getImageSensor, METH_VARARGS, (
char*)
"Get Image sensor."},
168 {(
char*)
"setImageSensor", py_setImageSensor, METH_VARARGS, (
char*)
"Set Image sensor."},
169 {(
char*)
"addImageTooltip", py_addImageTooltip, METH_VARARGS, (
char*)
"Create a Tooltip for an Image"},
170 {(
char*)
"resizeImage", py_resizeImage, METH_VARARGS, (
char*)
"Scale an Image"},
171 {(
char*)
"resizeImageSmooth", py_resizeImageSmooth, METH_VARARGS, (
char*)
"Scale an Image (slower, better looking)"},
172 {(
char*)
"rotateImage", py_rotateImage, METH_VARARGS, (
char*)
"Rotate an Image"},
173 {(
char*)
"removeImageTransformations", py_removeImageTransformations, METH_VARARGS, (
char*)
"Restore original size and orientation of an Image"},
174 {(
char*)
"removeImageEffects", py_removeImageEffects, METH_VARARGS, (
char*)
"Remove Effects of an Image"},
175 {(
char*)
"changeImageIntensity", py_changeImageIntensity, METH_VARARGS, (
char*)
"Change Intensity of an Image"},
176 {(
char*)
"changeImageChannelIntensity", py_changeImageChannelIntensity, METH_VARARGS, (
char*)
"Change Intensity of an Image Channel"},
177 {(
char*)
"changeImageToGray", py_changeImageToGray, METH_VARARGS, (
char*)
"Converts an Image to Grayscale"},
180 {(
char*)
"createMenu", py_create_menu, METH_VARARGS, (
char*)
"Create a popup menu"},
181 {(
char*)
"deleteMenu", py_delete_menu, METH_VARARGS, (
char*)
"Delete a popup menu"},
182 {(
char*)
"addMenuItem", py_add_menu_item, METH_VARARGS, (
char*)
"Add a popup menu entry"},
183 {(
char*)
"addMenuSeparator", py_add_menu_separator, METH_VARARGS, (
char*)
"Add a popup menu seperator item"},
184 {(
char*)
"removeMenuItem", py_remove_menu_item, METH_VARARGS, (
char*)
"Remove a popup menu entry"},
185 {(
char*)
"popupMenu", py_popup_menu, METH_VARARGS, (
char*)
"Popup a menu at a specified location"},
188 {(
char*)
"addMenuConfigOption", py_add_menu_config_option, METH_VARARGS, (
char*)
"Add a configuration entry to the menu"},
189 {(
char*)
"setMenuConfigOption", py_set_menu_config_option, METH_VARARGS, (
char*)
"Set a configuration entry in the menu"},
190 {(
char*)
"readMenuConfigOption", py_read_menu_config_option, METH_VARARGS, (
char*)
"Read a configuration entry in the menu"},
191 {(
char*)
"readConfigEntry", py_read_config_entry, METH_VARARGS, (
char*)
"Read a configuration entry"},
192 {(
char*)
"writeConfigEntry", py_write_config_entry, METH_VARARGS, (
char*)
"Writes a configuration entry"},
195 {(
char*)
"moveWidget", py_move_widget, METH_VARARGS, (
char*)
"Move Widget to x,y"},
196 {(
char*)
"resizeWidget", py_resize_widget, METH_VARARGS, (
char*)
"Resize Widget to width,height"},
197 {(
char*)
"createWidgetMask", py_create_widget_mask, METH_VARARGS, (
char*)
"Create a clipping mask for this widget"},
198 {(
char*)
"redrawWidget", py_redraw_widget, METH_VARARGS, (
char*)
"Update Widget to reflect your changes"},
199 {(
char*)
"redrawWidgetBackground", py_redraw_widget_background, METH_VARARGS, (
char*)
"Update Widget to reflect background image changes"},
200 {(
char*)
"getWidgetPosition", py_get_widget_position, METH_VARARGS, (
char*)
"Get Widget Position"},
201 {(
char*)
"toggleWidgetRedraw", py_toggle_widget_redraw, METH_VARARGS, (
char*)
"Toggle Widget redrawing"},
204 {(
char*)
"getStartupList", py_get_startup_list, METH_VARARGS, (
char*)
"Get the system startup list"},
205 {(
char*)
"getStartupInfo", py_get_startup_info, METH_VARARGS, (
char*)
"Get all the info for a startup"},
206 {(
char*)
"getTaskList", py_get_task_list, METH_VARARGS, (
char*)
"Get the system task list"},
207 {(
char*)
"getTaskNames", py_get_task_names, METH_VARARGS, (
char*)
"Get the system task list in name form"},
208 {(
char*)
"getTaskInfo", py_get_task_info, METH_VARARGS, (
char*)
"Get all the info for a task"},
209 {(
char*)
"performTaskAction", py_perform_task_action, METH_VARARGS, (
char*)
"Do something with a task, such as minimize it"},
212 {(
char*)
"createSystray", py_create_systray, METH_VARARGS, (
char*)
"Create a Systray"},
213 {(
char*)
"hideSystray", py_hide_systray, METH_VARARGS, (
char*)
"Hide the Systray"},
214 {(
char*)
"showSystray", py_show_systray, METH_VARARGS, (
char*)
"Show the Systray"},
215 {(
char*)
"moveSystray", py_move_systray, METH_VARARGS, (
char*)
"Move the Systray"},
216 {(
char*)
"getCurrentWindowCount", py_get_current_window_count, METH_VARARGS, (
char*)
"Get current Window count"},
217 {(
char*)
"updateSystrayLayout", py_update_systray_layout, METH_VARARGS, (
char*)
"Update Systray layout"},
220 {(
char*)
"getThemePath", py_get_theme_path, METH_VARARGS, (
char*)
"Get the file path of the theme"},
221 {(
char*)
"readThemeFile", py_read_theme_file, METH_VARARGS,
222 (
char*)
"Read file from theme."},
223 {(
char*)
"language", py_language, METH_VARARGS,
224 (
char*)
"Return default language of a translation file."},
225 {(
char*)
"userLanguage", py_userLanguage, METH_VARARGS,
226 (
char*)
"Return user language."},
227 {(
char*)
"userLanguages", py_userLanguages, METH_VARARGS,
228 (
char*)
"Return preferred user languages."},
229 {(
char*)
"openTheme", py_open_theme, METH_VARARGS,
230 (
char*)
"Open a new theme"},
231 {(
char*)
"reloadTheme", py_reload_theme, METH_VARARGS,
232 (
char*)
"Reload current theme"},
233 {(
char*)
"acceptDrops", py_accept_drops, METH_VARARGS,
234 (
char*)
"Allows widget to receive Drop (I.E. Drag and Drop) events"},
235 {(
char*)
"toggleShowDesktop", py_toggle_show_desktop, METH_VARARGS,
236 (
char*)
"Show/Hide the desktop"},
237 {(
char*)
"execute", py_execute_command, METH_VARARGS, (
char*)
"Execute a command"},
238 {(
char*)
"executeInteractive", py_execute_command_interactive, METH_VARARGS, (
char*)
"Execute a command and get it's output (stdout)"},
239 {(
char*)
"attachClickArea", (PyCFunction)py_attach_clickArea, METH_VARARGS|METH_KEYWORDS, (
char*)
"Add a clickArea to the given text or image"},
240 {(
char*)
"createClickArea", py_create_click_area, METH_VARARGS, (
char*)
"Create a Click Area Sensor"},
241 {(
char*)
"getNumberOfDesktops", py_get_number_of_desktops, METH_VARARGS, (
char*)
"Get current number of virtual desktops"},
242 {(
char*)
"getIp", py_get_ip, METH_VARARGS, (
char*)
"Get current host's IP address"},
243 {(
char*)
"translateAll", py_translate_all, METH_VARARGS, (
char*)
"Translate all widgets in a theme"},
244 {(
char*)
"show", py_show, METH_VARARGS, (
char*)
"Show theme"},
245 {(
char*)
"hide", py_hide, METH_VARARGS, (
char*)
"Hide theme"},
248 {(
char*)
"createInputBox", py_createInputBox, METH_VARARGS,
249 (
char*)
"Create new Input Box."},
250 {(
char*)
"deleteInputBox", py_deleteInputBox, METH_VARARGS,
251 (
char*)
"Delete Input Box."},
252 {(
char*)
"getThemeInputBox", py_getThemeInputBox, METH_VARARGS,
253 (
char*)
"Get Input Box from .theme using it's name."},
254 {(
char*)
"getInputBoxValue", py_getInputBoxValue, METH_VARARGS,
255 (
char*)
"Get Input Box value"},
256 {(
char*)
"changeInputBox", py_setInputBoxValue, METH_VARARGS,
257 (
char*)
"Change a Input Box Text"},
258 {(
char*)
"hideInputBox", py_hideInputBox, METH_VARARGS,
259 (
char*)
"Hide Input Box."},
260 {(
char*)
"showInputBox", py_showInputBox, METH_VARARGS,
261 (
char*)
"Show Input Box."},
262 {(
char*)
"getInputBoxPos", py_getInputBoxPos, METH_VARARGS,
263 (
char*)
"Get InputBox position."},
264 {(
char*)
"moveInputBox", py_moveInputBox, METH_VARARGS,
265 (
char*)
"Moves a Input Box"},
266 {(
char*)
"getInputBoxSize", py_getInputBoxSize, METH_VARARGS,
267 (
char*)
"Get the (width, height) of a Input Box"},
268 {(
char*)
"resizeInputBox", py_resizeInputBox, METH_VARARGS,
269 (
char*)
"Resize Input Box."},
270 {(
char*)
"changeInputBoxFont", py_setInputBoxFont, METH_VARARGS,
271 (
char*)
"Change a Input Box Font"},
272 {(
char*)
"getInputBoxFont", py_getInputBoxFont, METH_VARARGS,
273 (
char*)
"Get a Input Box Font"},
274 {(
char*)
"changeInputBoxFontColor", py_setInputBoxFontColor, METH_VARARGS,
275 (
char*)
"Change a Input Box Font Color"},
276 {(
char*)
"getInputBoxFontColor", py_getInputBoxFontColor, METH_VARARGS,
277 (
char*)
"Get a Input Box Font Color"},
278 {(
char*)
"changeInputBoxSelectionColor", py_setInputBoxSelectionColor,
279 METH_VARARGS, (
char*)
"Change a Input Box Selection Color"},
280 {(
char*)
"getInputBoxSelectionColor", py_getInputBoxSelectionColor,
281 METH_VARARGS, (
char*)
"Get a Input Box Selection Color"},
282 {(
char*)
"changeInputBoxBackgroundColor", py_setInputBoxBGColor,
283 METH_VARARGS, (
char*)
"Change a Input Box Background Color"},
284 {(
char*)
"getInputBoxBackgroundColor", py_getInputBoxBGColor, METH_VARARGS,
285 (
char*)
"Get a Input Box Background Color"},
286 {(
char*)
"changeInputBoxFrameColor", py_setInputBoxFrameColor, METH_VARARGS,
287 (
char*)
"Change a Input Box Frame Color"},
288 {(
char*)
"getInputBoxFrameColor", py_getInputBoxFrameColor, METH_VARARGS,
289 (
char*)
"Get a Input Box Frame Color"},
290 {(
char*)
"changeInputBoxSelectedTextColor", py_setInputBoxSelectedTextColor,
291 METH_VARARGS, (
char*)
"Change a Input Box Selected Text Color"},
292 {(
char*)
"getInputBoxSelectedTextColor", py_getInputBoxSelectedTextColor,
293 METH_VARARGS, (
char*)
"Get a Input Box Selected Text Color"},
294 {(
char*)
"changeInputBoxFontSize", py_setInputBoxFontSize, METH_VARARGS,
295 (
char*)
"Change a Input Box Font Size"},
296 {(
char*)
"getInputBoxFontSize", py_getInputBoxFontSize, METH_VARARGS,
297 (
char*)
"Get a Input Box Font Size"},
298 {(
char*)
"setInputFocus", py_setInputFocus, METH_VARARGS,
299 (
char*)
"Set the Input Focus to the Input Box"},
300 {(
char*)
"clearInputFocus", py_clearInputFocus, METH_VARARGS,
301 (
char*)
"Clear the Input Focus of the Input Box"},
302 {(
char*)
"getInputFocus", py_getInputFocus, METH_VARARGS,
303 (
char*)
"Get the Input Box currently focused"},
305 {(
char*)
"setWidgetOnTop", py_set_widget_on_top, METH_VARARGS,
306 (
char*)
"changes 'on top' status"},
307 {(
char*)
"getSystraySize", py_get_systray_size, METH_VARARGS,
308 (
char*)
"Get the size of the Systray"},
309 {(
char*)
"getPrettyThemeName", py_get_pretty_name, METH_VARARGS,
310 (
char*)
"Get the pretty name of the theme"},
311 {(
char*)
"openNamedTheme", py_open_named_theme, METH_VARARGS,
312 (
char*)
"Open a new theme giving it a new name"},
313 {(
char*)
"callTheme", py_call_theme, METH_VARARGS,
314 (
char*)
"Pass a string to another theme"},
315 {(
char*)
"changeInterval", py_change_interval, METH_VARARGS,
316 (
char*)
"Change the refresh interval"},
317 {(
char*)
"run", py_run_command, METH_VARARGS,
318 (
char*)
"Execute a command with KRun"},
319 {(
char*)
"createServiceClickArea", py_create_service_click_area, METH_VARARGS,
320 (
char*)
"Create a Service-named Click Area Sensor"},
321 {(
char*)
"removeClickArea", py_remove_click_area, METH_VARARGS,
322 (
char*)
"Remove a Click Area Sensor"},
323 {(
char*)
"setUpdateTime", py_set_update_time, METH_VARARGS,
324 (
char*)
"Set last updated time"},
325 {(
char*)
"getUpdateTime", py_get_update_time, METH_VARARGS,
326 (
char*)
"Get last updated time"},
327 {(
char*)
"setWantRightButton", py_want_right_button, METH_VARARGS,
328 (
char*)
"Set to 1 to deactivate management popups"},
329 {(
char*)
"setWantMeterWheelEvent", py_want_wheel_event, METH_VARARGS,
330 (
char*)
"Enables wheel events over meters."},
331 {(
char*)
"managementPopup", py_management_popup, METH_VARARGS,
332 (
char*)
"Activates the Management Popup menu"},
335 {(
char*)
"getServiceGroups", py_get_service_groups, METH_VARARGS,
336 (
char*)
"Get KDE Service Groups"},
338 {NULL, NULL, 0 ,NULL}
341 PyThreadState* KarambaPython::mainThreadState = 0;
343 KarambaPython::KarambaPython(
const ThemeFile& theme,
bool reloading):
344 pythonThemeExtensionLoaded(false), pName(0), pModule(0), pDict(0)
346 PyThreadState* myThreadState;
349 getLock(&myThreadState);
352 PyRun_SimpleString((
char*)
"import sys");
354 snprintf(pypath, 1023,
"sys.path.insert(0, '%s')", theme.path().ascii());
355 PyRun_SimpleString(pypath);
356 PyRun_SimpleString((
char*)
"sys.path.insert(0, '')");
358 PyImport_AddModule((
char*)
"karamba");
359 Py_InitModule((
char*)
"karamba", karamba_methods);
361 pName = PyString_FromString(theme.pythonModule().ascii());
362 pModule = PyImport_Import(pName);
364 fprintf(stderr,
"%s\n", pypath);
368 PyImport_ReloadModule(pModule);
372 pDict = PyModule_GetDict(pModule);
375 pythonThemeExtensionLoaded =
true;
382 "------------------------------------------------------\n");
383 fprintf(stderr,
"What does ImportError mean?\n");
384 fprintf(stderr,
"\n");
386 "It means that I couldn't load a python add-on %s.py\n",
387 theme.pythonModule().ascii());
388 fprintf(stderr,
"If this is a regular theme and doesn't use python\n");
389 fprintf(stderr,
"extensions, then nothing is wrong.\n");
391 "------------------------------------------------------\n");
393 releaseLock(myThreadState);
396 KarambaPython::~KarambaPython()
399 if (pythonThemeExtensionLoaded) {
400 PyThreadState* myThreadState;
401 getLock(&myThreadState);
407 releaseLock(myThreadState);
411 void KarambaPython::initPython()
417 PyEval_InitThreads();
420 mainThreadState = PyThreadState_Get();
423 PyEval_ReleaseLock();
426 void KarambaPython::shutdownPython()
429 PyInterpreterState * mainInterpreterState = mainThreadState->interp;
431 PyThreadState * myThreadState = PyThreadState_New(mainInterpreterState);
432 PyThreadState_Swap(myThreadState);
433 PyEval_AcquireLock();
437 void KarambaPython::getLock(PyThreadState** myThreadState)
440 PyEval_AcquireLock();
443 *myThreadState = PyThreadState_New(mainThreadState->interp);
444 PyThreadState_Swap(*myThreadState);
447 void KarambaPython::releaseLock(PyThreadState* myThreadState)
450 PyThreadState_Swap(NULL);
452 PyThreadState_Clear(myThreadState);
454 PyThreadState_Delete(myThreadState);
456 PyEval_ReleaseLock();
459 PyObject* KarambaPython::getFunc(
const char*
function)
461 PyObject* pFunc = PyDict_GetItemString(pDict, (
char*)
function);
462 if (pFunc && PyCallable_Check(pFunc))
467 bool KarambaPython::callObject(
const char* func, PyObject* pArgs,
bool lock)
470 PyThreadState* myThreadState;
475 getLock(&myThreadState);
476 PyObject* pFunc = getFunc(func);
480 PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
489 qWarning(
"Call to %s failed", func);
495 releaseLock(myThreadState);
499 bool KarambaPython::initWidget(karamba* k)
501 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
502 return callObject(
"initWidget", pArgs);
505 bool KarambaPython::widgetUpdated(karamba* k)
507 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
508 return callObject(
"widgetUpdated", pArgs);
511 bool KarambaPython::widgetClosed(karamba* k)
513 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
514 return callObject(
"widgetClosed", pArgs);
517 bool KarambaPython::menuOptionChanged(karamba* k, TQString key,
bool value)
519 PyObject* pArgs = Py_BuildValue((
char*)
"(lsi)", k, key.ascii(), (int)value);
520 return callObject(
"menuOptionChanged", pArgs);
523 bool KarambaPython::menuItemClicked(karamba* k, KPopupMenu* menu,
long id)
525 PyObject* pArgs = Py_BuildValue((
char*)
"(lll)", k, menu,
id);
526 return callObject(
"menuItemClicked", pArgs);
529 bool KarambaPython::meterClicked(karamba* k, Meter* meter,
int button)
531 PyObject* pArgs = Py_BuildValue((
char*)
"(lli)", k, meter, button);
532 return callObject(
"meterClicked", pArgs);
535 bool KarambaPython::meterClicked(karamba* k, TQString anchor,
int button)
537 PyObject* pArgs = Py_BuildValue((
char*)
"(lsi)", k, anchor.ascii(), button);
538 return callObject(
"meterClicked", pArgs);
541 bool KarambaPython::widgetClicked(karamba* k,
int x,
int y,
int button)
543 PyObject* pArgs = Py_BuildValue((
char*)
"(liii)", k, x, y, button);
544 return callObject(
"widgetClicked", pArgs);
547 bool KarambaPython::keyPressed(karamba* k,
const Meter* meter,
548 const TQString& text)
550 PyObject* pArgs = Py_BuildValue((
char*)
"(lls)", k, meter, text.ucs2());
551 return callObject(
"keyPressed", pArgs);
554 bool KarambaPython::widgetMouseMoved(karamba* k,
int x,
int y,
int button)
556 PyObject* pArgs = Py_BuildValue((
char*)
"(liii)", k, x, y, button);
557 return callObject(
"widgetMouseMoved", pArgs);
560 bool KarambaPython::activeTaskChanged(karamba* k,
Task* t)
562 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
563 return callObject(
"activeTaskChanged", pArgs);
566 bool KarambaPython::taskAdded(karamba* k,
Task* t)
568 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
569 return callObject(
"taskAdded", pArgs);
572 bool KarambaPython::taskRemoved(karamba* k,
Task* t)
574 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
575 return callObject(
"taskRemoved", pArgs);
578 bool KarambaPython::startupAdded(karamba* k,
Startup* t)
580 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
581 return callObject(
"startupAdded", pArgs);
584 bool KarambaPython::startupRemoved(karamba* k,
Startup* t)
586 PyObject* pArgs = Py_BuildValue((
char*)
"(ll)", k, t);
587 return callObject(
"startupRemoved", pArgs);
590 bool KarambaPython::commandOutput(karamba* k,
int pid,
char *buffer)
592 PyObject* pArgs = Py_BuildValue((
char*)
"(lis)", k, pid, buffer);
593 return callObject(
"commandOutput", pArgs);
596 bool KarambaPython::commandFinished(karamba* k,
int pid)
598 PyObject* pArgs = Py_BuildValue((
char*)
"(li)", k, pid);
599 return callObject(
"commandFinished", pArgs);
602 bool KarambaPython::itemDropped(karamba* k, TQString text,
int x,
int y)
604 PyObject* pArgs = Py_BuildValue((
char*)
"(lOii)", k, TQString2PyString(text), x, y);
605 return callObject(
"itemDropped", pArgs);
608 bool KarambaPython::themeNotify(karamba* k,
const char *from,
const char *str)
615 PyObject* pArgs = Py_BuildValue((
char*)
"(lss)", k, from, str);
616 return callObject(
"themeNotify", pArgs,
false);
619 bool KarambaPython::systrayUpdated(karamba* k)
621 PyObject* pArgs = Py_BuildValue((
char*)
"(l)", k);
622 return callObject(
"systrayUpdated", pArgs);
625 bool KarambaPython::desktopChanged(karamba* k,
int desktop)
627 PyObject* pArgs = Py_BuildValue((
char*)
"(li)", k, desktop);
628 return callObject(
"desktopChanged", pArgs);
631 bool KarambaPython::wallpaperChanged(karamba* k,
int desktop)
633 PyObject* pArgs = Py_BuildValue((
char*)
"(li)", k, desktop);
634 return callObject(
"wallpaperChanged", pArgs);