annotate finch/libgnt/pygnt/gnt.override @ 18729:fae29ba432c8

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