finch/libgnt/pygnt/gnt.override

Sat, 18 Aug 2007 05:54:49 +0000

author
William Ehlhardt <williamehlhardt@gmail.com>
date
Sat, 18 Aug 2007 05:54:49 +0000
branch
soc.2007.certmgr
changeset 19489
772b691e901b
parent 19193
3ad08041d6bd
permissions
-rw-r--r--

- Add purple_certificate_display_x509

15992
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
1 %%
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
2 headers
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
3 #include <Python.h>
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
4 #include "pygobject.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5 #include "gnt.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6 #include "gntbindable.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
7 #include "gntwidget.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
8 #include "gntbox.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
9 #include "gntbutton.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
10 #include "gntcheckbox.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
11 #include "gntcolors.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
12 #include "gntcombobox.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
13 #include "gntentry.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
14 #include "gntfilesel.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
15 #include "gntkeys.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
16 #include "gntlabel.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
17 #include "gntline.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
18 #include "gntmenu.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
19 #include "gntmenuitem.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
20 #include "gntmenuitemcheck.h"
18826
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
21 #include "gntslider.h"
15992
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
22 #include "gntstyle.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
23 #include "gnttextview.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
24 #include "gnttree.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
25 #include "gntutils.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26 #include "gntwindow.h"
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include "gntwm.h"
18826
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
28 #include "gntws.h"
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
29 #include "common.h"
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
30 %%
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
31 include
19185
0af58585b665 This gets rid of more weird crashes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19182
diff changeset
32 gntbox.override
18826
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
33 gntfilesel.override
a276583c694c Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15992
diff changeset
34 gnttree.override
19188
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
35 gntwidget.override
15992
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
36 %%
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
37 modulename gnt
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 %%
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
39 import gobject.GObject as PyGObject_Type
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
40 %%
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
41 ignore-glob
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
42 *_get_gtype
76e7972b3ff9 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43 %%
19181
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
44 define set_flag
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
45 static PyObject *
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
46 _wrap_set_flag(PyGObject *self, PyObject *args, PyObject *kwargs)
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
47 {
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
48 static char *kwlist[] = {"flags", NULL};
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
49 PyGObject *widget;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
50 int flags;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
51
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
52 if (!PyArg_ParseTuple(args, "O!i:gnt.set_flag", &PyGntWidget_Type, &widget,
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
53 &flags)) {
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
54 return NULL;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
55 }
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
56
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
57 GNT_WIDGET_SET_FLAGS(widget->obj, flags);
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
58
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
59 Py_INCREF(Py_None);
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
60 return Py_None;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
61 }
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
62 %%
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
63 define unset_flag
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
64 static PyObject *
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
65 _wrap_unset_flag(PyGObject *self, PyObject *args, PyObject *kwargs)
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
66 {
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
67 static char *kwlist[] = {"flags", NULL};
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
68 PyGObject *widget;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
69 int flags;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
70
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
71 if (!PyArg_ParseTuple(args, "O!i:gnt.unset_flag", &PyGntWidget_Type, &widget,
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
72 &flags)) {
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
73 return NULL;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
74 }
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
75
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
76 GNT_WIDGET_UNSET_FLAGS(widget->obj, flags);
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
77
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
78 Py_INCREF(Py_None);
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
79 return Py_None;
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
80 }
19182
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
81 %%
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
82 define screen_size noargs
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
83 static PyObject *
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
84 _wrap_screen_size(PyObject *self)
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
85 {
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
86 PyObject *list = PyList_New(0);
19181
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
87
19182
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
88 if (list == NULL)
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
89 return NULL;
19181
6dd5ae8a6121 Allow un/setting flags for widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18826
diff changeset
90
19182
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
91 PyList_Append(list, PyInt_FromLong((long)getmaxx(stdscr)));
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
92 PyList_Append(list, PyInt_FromLong((long)getmaxy(stdscr)));
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
93
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
94 return list;
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
95 }
19188
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
96 %%
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
97 override gnt_register_action
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
98 static GHashTable *actions;
19182
f109918d7e3d Add function to get the screen size.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19181
diff changeset
99
19188
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
100
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
101
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
102 static PyObject *
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
103 _wrap_gnt_register_action(PyGObject *self, PyObject *args, PyObject *kwargs)
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
104 {
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
105 static char *kwlist[] = {"name", "callback", NULL};
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
106 PyGObject *callback;
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
107 GClosure *closure;
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
108 char *name;
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
109
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
110 if (!PyArg_ParseTuple(args, "sO:gnt.gnt_register_action", &name, &callback)) {
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
111 return NULL;
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
112 }
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
113
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
114 if (!PyCallable_Check(callback)) {
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
115 PyErr_SetString(PyExc_TypeError, "the callback must be callable ... doh!");
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
116 return NULL;
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
117 }
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
118
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
119 gnt_register_action(name, callback->obj);
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
120
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
121 Py_INCREF(Py_None);
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
122 return Py_None;
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
123 }
19193
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
124 %%
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
125 define register_bindings
19188
5657d0cf1ce0 Export gnt_widget_get_size for pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19185
diff changeset
126
19193
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
127 static gboolean
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
128 pygnt_binding_callback(GntBindable *bindable, GList *list)
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
129 {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
130 PyObject *wrapper = pygobject_new(G_OBJECT(bindable));
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
131 PyObject_CallMethod(wrapper, list->data, "O", Py_None);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
132 Py_DECREF(wrapper);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
133 return TRUE;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
134 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
135
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
136 static PyObject *
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
137 _wrap_register_bindings(PyObject *self, PyObject *args)
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
138 {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
139 PyTypeObject *class;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
140 int pos = 0;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
141 PyObject *key, *value, *gbindings;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
142 GntBindableClass *bindable;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
143
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
144 if (!PyArg_ParseTuple(args, "O!:gnt.register_bindings",
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
145 &PyType_Type, &class)) {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
146 /* Make sure it's a GntBindableClass subclass */
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
147 PyErr_SetString(PyExc_TypeError,
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
148 "argument must be a GntBindable subclass");
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
149 return NULL;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
150 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
151
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
152 gbindings = PyDict_GetItemString(class->tp_dict, "__gntbindings__");
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
153 if (!gbindings)
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
154 goto end;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
155
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
156 if (!PyDict_Check(gbindings)) {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
157 PyErr_SetString(PyExc_TypeError,
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
158 "__gntbindings__ attribute not a dict!");
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
159 return NULL;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
160 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
161
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
162 bindable = g_type_class_ref(pyg_type_from_object((PyObject *)class));
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
163 while (PyDict_Next(gbindings, &pos, &key, &value)) {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
164 const char *trigger, *callback, *name;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
165 GList *list = NULL;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
166
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
167 if (!PyString_Check(key)) {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
168 PyErr_SetString(PyExc_TypeError,
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
169 "__gntbindings__ keys must be strings");
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
170 g_type_class_unref(bindable);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
171 return NULL;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
172 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
173 name = PyString_AsString(key);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
174
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
175 if (!PyTuple_Check(value) ||
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
176 !PyArg_ParseTuple(value, "ss", &callback, &trigger)) {
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
177 PyErr_SetString(PyExc_TypeError,
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
178 "__gntbindings__ values must be (callback, trigger) tupples");
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
179 g_type_class_unref(bindable);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
180 return NULL;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
181 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
182
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
183 gnt_bindable_class_register_action(bindable, name, pygnt_binding_callback,
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
184 trigger, g_strdup(callback), NULL);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
185 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
186 if (gbindings)
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
187 PyDict_DelItemString(class->tp_dict, "__gntbindings__");
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
188 g_type_class_unref(bindable);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
189
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
190 end:
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
191 Py_INCREF(Py_None);
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
192 return Py_None;
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
193 }
3ad08041d6bd Allow adding bindable actions for object types. There's some memory corruption
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19188
diff changeset
194

mercurial