]> icculus.org git repositories - mikachu/openbox.git/blob - wrap/ob.i
updated wrappers around the new otk widget system and style system
[mikachu/openbox.git] / wrap / ob.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 %include "callback.i"
24
25 %immutable ob::openbox;
26 /*
27 %ignore ob::openbox;
28 %inline %{
29   ob::Openbox *Openbox_instance() { return ob::openbox; }
30 %};
31 */
32
33 %ignore ob::Screen::clients;
34 %{
35   #include <iterator>
36 %}
37 %extend ob::Screen {
38   Client *client(int i) {
39     if (i < 0 || i >= (int)self->clients.size())
40       return NULL;
41     ob::Client::List::iterator it = self->clients.begin();
42     std::advance(it,i);
43     return *it;
44   }
45   int clientCount() const {
46     return (int) self->clients.size();
47   }
48 };
49
50 %import "otk.i"
51
52 %import "actions.hh"
53
54 %include "openbox.hh"
55 %include "screen.hh"
56 %include "client.hh"
57 %include "frame.hh"
58 %include "python.hh"
59
60 // for Window etc
61 %import "X11/X.h"
62
63 %inline %{
64 void set_reset_key(const std::string &key)
65 {
66   ob::openbox->bindings()->setResetKey(key);
67 }
68
69 void send_client_msg(Window target, Atom type, Window about,
70                      long data=0, long data1=0, long data2=0,
71                      long data3=0, long data4=0)
72 {
73   XEvent e;
74   e.xclient.type = ClientMessage;
75   e.xclient.format = 32;
76   e.xclient.message_type = type;
77   e.xclient.window = about;
78   e.xclient.data.l[0] = data;
79   e.xclient.data.l[1] = data1;
80   e.xclient.data.l[2] = data2;
81   e.xclient.data.l[3] = data3;
82   e.xclient.data.l[4] = data4;
83
84   XSendEvent(**otk::display, target, false,
85              SubstructureRedirectMask | SubstructureNotifyMask,
86              &e);
87 }
88
89 void execute(const std::string &bin, int screen=0)
90 {
91   if (screen >= ScreenCount(**otk::display))
92     screen = 0;
93   otk::bexec(bin, otk::display->screenInfo(screen)->displayString());
94 }
95
96 %};
97
98 // globals
99 %pythoncode %{
100 openbox = cvar.openbox;
101 %}