karamba_python.h
00001 /**************************************************************************** 00002 * karamba_python.h - Functions for calling python scripts 00003 * 00004 * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se> 00005 * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org> 00006 * Copyright (c) 2004 Petri Damstén <damu@iki.fi> 00007 * 00008 * This file is part of SuperKaramba. 00009 * 00010 * SuperKaramba is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * SuperKaramba is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with SuperKaramba; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 ****************************************************************************/ 00024 00025 #ifndef KARAMBA_PYTHON_H 00026 #define KARAMBA_PYTHON_H 00027 00028 class TQString; 00029 class TDEPopupMenu; 00030 class Task; 00031 class Startup; 00032 class karamba; 00033 class Meter; 00034 struct _object; 00035 typedef struct _object PyObject; 00036 struct _ts; 00037 typedef struct _ts PyThreadState; 00038 class ThemeFile; 00039 00040 class KarambaPython 00041 { 00042 protected: 00043 bool pythonThemeExtensionLoaded; 00044 PyObject *pName, *pModule; 00045 PyObject *pDict; 00046 static PyThreadState* mainThreadState; 00047 00048 void getLock(PyThreadState** myThreadState); 00049 PyObject* getFunc(const char* function); 00050 void releaseLock(PyThreadState* myThreadState); 00051 bool callObject(const char* func, PyObject* pArgs, bool lock=true); 00052 00053 public: 00054 KarambaPython(const ThemeFile& theme, bool reloading); 00055 ~KarambaPython(); 00056 00057 static void initPython(); 00058 static void shutdownPython(); 00059 00060 bool isExtensionLoaded() { return pythonThemeExtensionLoaded; }; 00061 bool initWidget(karamba* k); 00062 bool widgetUpdated(karamba* k); 00063 bool widgetClosed(karamba* k); 00064 bool menuOptionChanged(karamba* k, TQString key, bool value); 00065 bool meterClicked(karamba* k, Meter* meter, int button); 00066 bool meterClicked(karamba* k, TQString anchor, int button); 00067 bool widgetClicked(karamba* k, int x, int y, int button); 00068 bool keyPressed(karamba* k, const Meter* meter, const TQString& text); 00069 bool widgetMouseMoved(karamba* k, int x, int y, int button); 00070 bool menuItemClicked(karamba* k, TDEPopupMenu* menu, long id); 00071 bool activeTaskChanged(karamba* k, Task* t); 00072 bool taskAdded(karamba* k, Task* t); 00073 bool taskRemoved(karamba* k, Task* t); 00074 bool startupAdded(karamba* k, Startup* t); 00075 bool startupRemoved(karamba* k, Startup* t); 00076 bool commandOutput(karamba* k, int pid, char *buffer); 00077 bool commandFinished(karamba* k, int pid); 00078 bool itemDropped(karamba* k, TQString text, int x, int y); 00079 bool themeNotify(karamba* k, const char *from, const char *txt); 00080 bool systrayUpdated(karamba* k); 00081 bool desktopChanged(karamba* k, int desktop); 00082 bool wallpaperChanged(karamba* k, int desktop); 00083 }; 00084 00085 #endif // KARAMBA_PYTHON_H