]> Dogcows Code - chaz/openbox/blob - src/openbox.i
new/better/cleaner scripting interface
[chaz/openbox] / src / openbox.i
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 %module ob
4
5 %{
6 #ifdef HAVE_CONFIG_H
7 # include "../config.h"
8 #endif
9
10 #include "frame.hh"
11 #include "openbox.hh"
12 #include "screen.hh"
13 #include "client.hh"
14 #include "bindings.hh"
15 #include "actions.hh"
16 #include "python.hh"
17 #include "otk/otk.hh"
18 %}
19
20 %include "stl.i"
21 //%include std_list.i
22 //%template(ClientList) std::list<Client*>;
23
24 %ignore ob::openbox;
25 %inline %{
26 ob::Openbox *Openbox_instance() { return ob::openbox; }
27 %};
28
29 %{
30 namespace ob {
31 void python_callback(PyObject *func, MouseData *data)
32 {
33 PyObject *arglist;
34 PyObject *result;
35
36 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
37 SWIGTYPE_p_ob__MouseData,
38 0));
39
40 // call the callback
41 result = PyEval_CallObject(func, arglist);
42 if (!result || PyErr_Occurred()) {
43 // an exception occured in the script, display it
44 PyErr_Print();
45 }
46
47 Py_XDECREF(result);
48 Py_DECREF(arglist);
49 }
50
51 void python_callback(PyObject *func, EventData *data)
52 {
53 PyObject *arglist;
54 PyObject *result;
55
56 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
57 SWIGTYPE_p_ob__EventData,
58 0));
59
60 // call the callback
61 result = PyEval_CallObject(func, arglist);
62 if (!result || PyErr_Occurred()) {
63 // an exception occured in the script, display it
64 PyErr_Print();
65 }
66
67 Py_XDECREF(result);
68 Py_DECREF(arglist);
69 }
70
71 void python_callback(PyObject *func, KeyData *data)
72 {
73 PyObject *arglist;
74 PyObject *result;
75
76 arglist = Py_BuildValue("(O)", SWIG_NewPointerObj((void *) data,
77 SWIGTYPE_p_ob__KeyData,
78 0));
79
80 // call the callback
81 result = PyEval_CallObject(func, arglist);
82 if (!result || PyErr_Occurred()) {
83 // an exception occured in the script, display it
84 PyErr_Print();
85 }
86
87 Py_XDECREF(result);
88 Py_DECREF(arglist);
89 }
90
91 }
92 %}
93
94 #ignore ob::openbox;
95
96 %ignore ob::Screen::clients;
97 %{
98 #include <iterator>
99 %}
100 %extend ob::Screen {
101 Client *client(int i) {
102 if (i < 0 || i >= (int)self->clients.size())
103 return NULL;
104 ob::Client::List::iterator it = self->clients.begin();
105 std::advance(it,i);
106 return *it;
107 }
108 int clientCount() const {
109 return (int) self->clients.size();
110 }
111 };
112
113 %include "../otk/ustring.i"
114
115 %ignore otk::display;
116 %inline %{
117 otk::Display *Display_instance() { return otk::display; }
118 %};
119
120 %ignore otk::Property::atoms;
121 %inline %{
122 const otk::Atoms& Property_atoms() { return otk::Property::atoms; }
123 %};
124
125 %include "../otk/display.hh"
126 %include "../otk/point.hh"
127 %include "../otk/property.hh"
128 %include "../otk/rect.hh"
129 %include "../otk/screeninfo.hh"
130 %include "../otk/strut.hh"
131
132 %include "../otk/eventhandler.hh"
133 %include "../otk/eventdispatcher.hh"
134
135 %import "../otk/widget.hh"
136 %import "widgetbase.hh"
137 %import "actions.hh"
138
139 %include "openbox.hh"
140 %include "screen.hh"
141 %include "client.hh"
142 %include "frame.hh"
143 %include "python.hh"
144
145 // for Mod1Mask etc
146 %include "X11/X.h"
This page took 0.039623 seconds and 5 git commands to generate.