]> Dogcows Code - chaz/openbox/blob - wrap/ob.i
return a Python list of Client*'s when a std::list<Client*> is returned
[chaz/openbox] / wrap / ob.i
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 %module ob
4
5 %{
6 #include "config.h"
7
8 #include "frame.hh"
9 #include "openbox.hh"
10 #include "screen.hh"
11 #include "client.hh"
12 #include "bindings.hh"
13 #include "actions.hh"
14 #include "python.hh"
15 #include "otk/otk.hh"
16 %}
17
18 %include "stl.i"
19 %include "callback.i"
20
21 %immutable ob::openbox;
22 /*
23 %ignore ob::openbox;
24 %inline %{
25 ob::Openbox *Openbox_instance() { return ob::openbox; }
26 %};
27 */
28
29 %typemap(python,out) std::list<ob::Client*> {
30 unsigned int s = $1.size();
31 PyObject *l = PyList_New(s);
32
33 std::list<ob::Client*>::const_iterator it = $1.begin(), end = $1.end();
34 for (unsigned int i = 0; i < s; ++i, ++it) {
35 PyObject *pdata = SWIG_NewPointerObj((void *) *it,
36 SWIGTYPE_p_ob__Client, 0);
37 PyList_SET_ITEM(l, i, pdata);
38 }
39 $result = l;
40 }
41
42 // do this through events
43 %ignore ob::Screen::showDesktop(bool);
44
45 %ignore ob::Screen::managed;
46 %ignore ob::Screen::config;
47
48 %import "otk.i"
49
50 %import "actions.hh"
51
52 %include "openbox.hh"
53 %include "screen.hh"
54 %include "client.hh"
55 %include "frame.hh"
56 %include "python.hh"
57
58 // for Window etc
59 %import "X11/X.h"
60
61 %inline %{
62 void set_reset_key(const std::string &key)
63 {
64 ob::openbox->bindings()->setResetKey(key);
65 }
66
67 void send_client_msg(Window target, Atom type, Window about,
68 long data=0, long data1=0, long data2=0,
69 long data3=0, long data4=0)
70 {
71 XEvent e;
72 e.xclient.type = ClientMessage;
73 e.xclient.format = 32;
74 e.xclient.message_type = type;
75 e.xclient.window = about;
76 e.xclient.data.l[0] = data;
77 e.xclient.data.l[1] = data1;
78 e.xclient.data.l[2] = data2;
79 e.xclient.data.l[3] = data3;
80 e.xclient.data.l[4] = data4;
81
82 XSendEvent(**otk::display, target, false,
83 SubstructureRedirectMask | SubstructureNotifyMask,
84 &e);
85 }
86
87 void execute(const std::string &bin, int screen=0)
88 {
89 if (screen >= ScreenCount(**otk::display))
90 screen = 0;
91 otk::bexec(bin, otk::display->screenInfo(screen)->displayString());
92 }
93
94 %};
95
96 // globals
97 %pythoncode %{
98 openbox = cvar.openbox;
99 %}
This page took 0.043136 seconds and 5 git commands to generate.