]> icculus.org git repositories - dana/openbox.git/blob - src/openbox.i
stop including otk in the openbox module. makes the wm hooger for no good cause....
[dana/openbox.git] / src / openbox.i
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 %module openbox
4
5 %{
6 #ifdef HAVE_CONFIG_H
7 #  include "../config.h"
8 #endif
9
10 #include "openbox.hh"
11 #include "screen.hh"
12 #include "client.hh"
13 #include "bindings.hh"
14 #include "actions.hh"
15 #include "python.hh"
16 #include "otk/otk.hh"
17 %}
18
19 %include "stl.i"
20 //%include std_list.i
21 //%template(ClientList) std::list<OBClient*>;
22
23 %ignore ob::Openbox::instance;
24 %inline %{
25   ob::Openbox *Openbox_instance() { return ob::Openbox::instance; }
26 %};
27
28 %{
29 namespace ob {
30 void python_callback(PyObject *func, MouseData *data)
31 {
32   PyObject *arglist;
33   PyObject *result;
34
35   arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
36                                                     SWIGTYPE_p_ob__MouseData,
37                                                     0));
38   
39   // call the callback
40   result = PyEval_CallObject(func, arglist);
41   if (!result || PyErr_Occurred()) {
42     // an exception occured in the script, display it
43     PyErr_Print();
44   }
45
46   Py_XDECREF(result);
47   Py_DECREF(arglist);
48 }
49
50 void python_callback(PyObject *func, EventData *data)
51 {
52   PyObject *arglist;
53   PyObject *result;
54
55   arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
56                                                     SWIGTYPE_p_ob__EventData,
57                                                     0));
58   
59   // call the callback
60   result = PyEval_CallObject(func, arglist);
61   if (!result || PyErr_Occurred()) {
62     // an exception occured in the script, display it
63     PyErr_Print();
64   }
65
66   Py_XDECREF(result);
67   Py_DECREF(arglist);
68 }
69
70 void python_callback(PyObject *func, KeyData *data)
71 {
72   PyObject *arglist;
73   PyObject *result;
74
75   arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
76                                                     SWIGTYPE_p_ob__KeyData,
77                                                     0));
78   
79   // call the callback
80   result = PyEval_CallObject(func, arglist);
81   if (!result || PyErr_Occurred()) {
82     // an exception occured in the script, display it
83     PyErr_Print();
84   }
85
86   Py_XDECREF(result);
87   Py_DECREF(arglist);
88 }
89
90 }
91 %}
92
93 %ignore ob::OBScreen::clients;
94 %{
95   #include <iterator>
96 %}
97 %extend ob::OBScreen {
98   OBClient *client(int i) {
99     if (i >= (int)self->clients.size())
100       return NULL;
101     ob::OBClient::List::iterator it = self->clients.begin();
102     std::advance(it,i);
103     return *it;
104   }
105   int clientCount() const {
106     return (int) self->clients.size();
107   }
108 };
109
110 %import "../otk/otk.i"
111
112 %import "widgetbase.hh"
113 %import "actions.hh"
114
115 %include "openbox.hh"
116 %include "screen.hh"
117 %include "client.hh"
118 %include "python.hh"
119
120 // for Mod1Mask etc
121 %include "X11/X.h"