]> Dogcows Code - chaz/openbox/blob - src/openbox.i
new python callbacks data, infrastructure. going to rework bindings code. cvs wont...
[chaz/openbox] / 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/display.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, MotionData *data)
31 {
32 PyObject *arglist;
33 PyObject *result;
34
35 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
36 SWIGTYPE_p_ob__MotionData,
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, ButtonData *data)
51 {
52 PyObject *arglist;
53 PyObject *result;
54
55 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
56 SWIGTYPE_p_ob__ButtonData,
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, EventData *data)
71 {
72 PyObject *arglist;
73 PyObject *result;
74
75 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
76 SWIGTYPE_p_ob__EventData,
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 void python_callback(PyObject *func, KeyData *data)
91 {
92 PyObject *arglist;
93 PyObject *result;
94
95 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
96 SWIGTYPE_p_ob__KeyData,
97 0));
98
99 // call the callback
100 result = PyEval_CallObject(func, arglist);
101 if (!result || PyErr_Occurred()) {
102 // an exception occured in the script, display it
103 PyErr_Print();
104 }
105
106 Py_XDECREF(result);
107 Py_DECREF(arglist);
108 }
109
110 }
111 %}
112
113 %ignore ob::OBScreen::clients;
114 %{
115 #include <iterator>
116 %}
117 %extend ob::OBScreen {
118 OBClient *client(int i) {
119 if (i >= (int)self->clients.size())
120 return NULL;
121 ob::OBClient::List::iterator it = self->clients.begin();
122 std::advance(it,i);
123 return *it;
124 }
125 int clientCount() const {
126 return (int) self->clients.size();
127 }
128 };
129
130 %import "../otk/eventdispatcher.hh"
131 %import "../otk/eventhandler.hh"
132 %import "widget.hh"
133 %import "actions.hh"
134
135 %include "openbox.hh"
136 %include "screen.hh"
137 %include "client.hh"
138 %include "python.hh"
139
140 // for Mod1Mask etc
141 %include "X11/X.h"
This page took 0.049755 seconds and 5 git commands to generate.