diff options
author | James Henstridge <james@daa.com.au> | 2001-03-27 14:04:32 +0000 |
---|---|---|
committer | James Henstridge <jamesh@src.gnome.org> | 2001-03-27 14:04:32 +0000 |
commit | 5d67cea99789d0c8307ad3640387f741760c7c5e (patch) | |
tree | 9abdc1e09d36c22bd2db3d9b8ff45f6b1852ea51 /examples | |
parent | 52ef209f971c317bf6e55763d1f3737d7a267886 (diff) | |
download | pygobject-5d67cea99789d0c8307ad3640387f741760c7c5e.tar.gz |
simple example program that adds a signal to a class, connects a handler
2001-03-27 James Henstridge <james@daa.com.au>
* examples/gobject/signal.py: simple example program that adds a
signal to a class, connects a handler to an instance of that
class, and finally emits that signal. Messages are printed by
both the signal handler and class method closure.
* gobjectmodule.c (pyg_signal_class_closure_marshal): convert
dashes in signal name to underscores. Why does g_siganl_name use
dashes?
(pyg_signal_class_closure_marshal): fix off by one error when
setting up the python argument tuple. The first element was
getting left uninitialised. Signals introduced in python now
work.
* gtk/gtk.defs (GtkFileSelection.get_filename): return value is
const.
* gtk/gtk.override (_wrap_gtk_list_store_set_value): change name.
(_wrap_gtk_tree_store_insert): change name.
* gtk/gtk.defs (GtkListStore.set_value): change from set_cell to
set_value.
(GtkListStore.set_value): same here.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/signal.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/signal.py b/examples/signal.py new file mode 100644 index 00000000..6fd622d2 --- /dev/null +++ b/examples/signal.py @@ -0,0 +1,20 @@ +import ltihooks, ExtensionClass +import gobject + +class C(gobject.GObject): + def do_my_signal(self, arg): + print "class closure for `my_signal' called with argument", arg + +gobject.signal_new("my_signal", C, gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, (gobject.TYPE_INT, )) + +def my_signal_handler(object, arg, *extra): + print "handler for `my_signal' called with argument", arg, \ + "and extra args", extra + +inst = C() + +print "instance id 0x%x" % id(inst) + +inst.connect("my_signal", my_signal_handler, 1, 2, 3) +inst.emit("my_signal", 42) |