summaryrefslogtreecommitdiffstats
path: root/superkaramba/src/karamba_python.h
blob: b3f7a0a467f6dddec2094b11d43d135af726de1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/****************************************************************************
*  karamba_python.h  -  Functions for calling python scripts
*
*  Copyright (C) 2003 Hans Karlsson <[email protected]>
*  Copyright (C) 2003-2004 Adam Geitgey <[email protected]>
*  Copyright (c) 2004 Petri Damst�n <[email protected]>
*
*  This file is part of SuperKaramba.
*
*  SuperKaramba is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  SuperKaramba is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with SuperKaramba; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
****************************************************************************/

#ifndef KARAMBA_PYTHON_H
#define KARAMBA_PYTHON_H

class TQString;
class TDEPopupMenu;
class Task;
class Startup;
class karamba;
class Meter;
struct _object;
typedef struct _object PyObject;
struct _ts;
typedef struct _ts PyThreadState;
class ThemeFile;

class KarambaPython
{
protected:
  bool pythonThemeExtensionLoaded;
  PyObject *pName, *pModule;
  PyObject *pDict;
  static PyThreadState* mainThreadState;

  void getLock(PyThreadState** myThreadState);
  PyObject* getFunc(const char* function);
  void releaseLock(PyThreadState* myThreadState);
  bool callObject(const char* func, PyObject* pArgs, bool lock=true);

public:
  KarambaPython(const ThemeFile& theme, bool reloading);
  ~KarambaPython();

  static void initPython();
  static void shutdownPython();

  bool isExtensionLoaded() { return pythonThemeExtensionLoaded; };
  bool initWidget(karamba* k);
  bool widgetUpdated(karamba* k);
  bool widgetClosed(karamba* k);
  bool menuOptionChanged(karamba* k, TQString key, bool value);
  bool meterClicked(karamba* k, Meter* meter, int button);
  bool meterClicked(karamba* k, TQString anchor, int button);
  bool widgetClicked(karamba* k, int x, int y, int button);
  bool keyPressed(karamba* k, const Meter* meter, const TQString& text);
  bool widgetMouseMoved(karamba* k, int x, int y, int button);
  bool menuItemClicked(karamba* k, TDEPopupMenu* menu, long id);
  bool activeTaskChanged(karamba* k, Task* t);
  bool taskAdded(karamba* k, Task* t);
  bool taskRemoved(karamba* k, Task* t);
  bool startupAdded(karamba* k, Startup* t);
  bool startupRemoved(karamba* k, Startup* t);
  bool commandOutput(karamba* k, int pid, char *buffer);
  bool commandFinished(karamba* k, int pid);
  bool itemDropped(karamba* k, TQString text, int x, int y);
  bool themeNotify(karamba* k, const char *from, const char *txt);
  bool systrayUpdated(karamba* k);
  bool desktopChanged(karamba* k, int desktop);
  bool wallpaperChanged(karamba* k, int desktop);
};

#endif // KARAMBA_PYTHON_H