python with callbacks!
[mikachu/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 "python.hh"
14 %}
15
16
17 %include stl.i
18 //%include std_list.i
19 //%template(ClientList) std::list<OBClient*>;
20
21 %ignore ob::Openbox::instance;
22 %inline %{
23   ob::Openbox *Openbox_instance() { return ob::Openbox::instance; }
24 %};
25
26 // stuff for registering callbacks!
27
28 %inline %{
29   enum ActionType {
30     Action_ButtonPress,
31     Action_ButtonRelease,
32     Action_EnterWindow,
33     Action_LeaveWindow,
34     Action_KeyPress,
35     Action_MouseMotion
36   };
37 %}
38 %ignore ob::python_callback;
39 %rename(register) ob::python_register;
40 %rename(unregister) ob::python_unregister;
41
42 %ignore ob::OBScreen::clients;
43 %{
44   #include <iterator>
45 %}
46 %extend ob::OBScreen {
47   OBClient *client(int i) {
48     if (i >= (int)self->clients.size())
49       return NULL;
50     ob::OBScreen::ClientList::iterator it = self->clients.begin();
51     std::advance(it,i);
52     return *it;
53   }
54   int clientCount() const {
55     return (int) self->clients.size();
56   }
57 };
58
59 %import "../otk/eventdispatcher.hh"
60 %import "../otk/eventhandler.hh"
61 %import "widget.hh"
62
63 %include "openbox.hh"
64 %include "screen.hh"
65 %include "client.hh"
66 %include "python.hh"
67
68 // for Mod1Mask etc
69 %include "X11/X.h"