Sat, 28 Jul 2007 11:16:05 +0000
Add some more functions for GntTree. One point to note is that the key
for each row in a tree needs to be a GObject, which, really is quite simple
to do in python (examples coming up shortly).
There is a wrapper for gpointer, which I am going to remove shortly.
I also need to fix the install location. The way to go, I think, is to
change the configure script in libgnt/configure.ac. This involves checking
for python and doing things of that sort.
|
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 | #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
|
2 | |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
3 | /* {{{ Wrapper for gpointer */ |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
4 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
5 | typedef struct { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
6 | PyObject_HEAD |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
7 | PyGPointer *data; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
8 | } mygpointer; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
9 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
10 | static PyObject * |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
11 | mygpointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
12 | { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
13 | mygpointer *self = (mygpointer*)type->tp_alloc(type, 0); |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
14 | self->data = NULL; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
15 | return (PyObject*)self; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
16 | } |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
17 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
18 | static const PyMethodDef mygpointer_methods[] = { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
19 | /*{"value", (PyCFunction)get_value, METH_NOARGS, NULL},*/ |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
20 | {NULL, NULL, 0, NULL} |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
21 | }; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
22 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
23 | static int |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
24 | mygpointer_init(mygpointer *self, PyObject *args, PyObject *kwds) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
25 | { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
26 | static char *kwlist[] = {"data", NULL}; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
27 | PyObject *data = NULL; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
28 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
29 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
30 | &data)) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
31 | return -1; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
32 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
33 | Py_INCREF(data); |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
34 | Py_DECREF(self->data); |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
35 | self->data = data; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
36 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
37 | return 0; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
38 | } |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
39 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
40 | static PyTypeObject mygpointer_type = { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
41 | PyObject_HEAD_INIT(&PyType_Type) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
42 | .tp_name = "gpointer", |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
43 | .tp_basicsize = sizeof(mygpointer), |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
44 | .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
45 | .tp_doc = "gpointer stuff", |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
46 | .tp_members = NULL, |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
47 | .tp_init = mygpointer_init, |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
48 | .tp_new = mygpointer_new, |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
49 | .tp_methods = mygpointer_methods |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
50 | }; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
51 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
52 | PyObject *create_mygpointer(gpointer data) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
53 | { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
54 | mygpointer *p = mygpointer_new(&mygpointer_type, NULL, NULL); |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
55 | p->data = data; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
56 | return (PyObject *)p; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
57 | } |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
58 | /* }}} Wrapper for gpointer */ |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
59 | |
|
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
|
60 | void gnt_register_classes (PyObject *d); |
|
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
|
61 | extern PyMethodDef gnt_functions[]; |
|
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
|
62 | |
|
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
|
63 | DL_EXPORT(void) |
|
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
|
64 | initgnt(void) |
|
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
|
65 | { |
|
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
|
66 | PyObject *m, *d; |
|
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
|
67 | |
|
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
|
68 | init_pygobject (); |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
69 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
70 | if (PyType_Ready(&mygpointer_type) < 0) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
71 | return; |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
72 | |
|
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
|
73 | m = Py_InitModule ("gnt", gnt_functions); |
|
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
|
74 | d = PyModule_GetDict (m); |
|
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
|
75 | |
|
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
|
76 | gnt_register_classes (d); |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
77 | gnt_add_constants(m, "GNT_"); |
|
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
|
78 | |
|
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
|
79 | if (PyErr_Occurred ()) { |
|
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
|
80 | Py_FatalError ("can't initialise module sad"); |
|
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
|
81 | } |
|
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
|
82 | } |
|
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
|
83 |