summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJames Henstridge <james@daa.com.au>2001-05-06 16:51:48 +0000
committerJames Henstridge <jamesh@src.gnome.org>2001-05-06 16:51:48 +0000
commit4a9a14997dc9d70e8e77a1c37ec3e06a109af300 (patch)
tree728a24234a2ebe7e081755b5e83f14e4aa0dd6f3 /examples
parent2fa1a292a8c3056183f7e0ac77ce46551c58b853 (diff)
downloadpygobject-4a9a14997dc9d70e8e77a1c37ec3e06a109af300.tar.gz
2001-05-06 James Henstridge <james@daa.com.au>
2001-05-07 James Henstridge <james@daa.com.au> * examples/gobject/signal.py: 2001-05-06 James Henstridge <james@daa.com.au> * gobjectmodule.c (pygobject__init__): make the __init__ function choose what GType to pass to g_object_new based on the __gtype__ attribute. (pygobject_methods): make __gobject_init__ an alias for GObject.__init__. (pyg_type_register): new function for registering new GTypes. (pyg_type_register): register the type as "module+class" rather than "module.class", as the second form is considered bad (would like to use the second form though. * configure.in: require 1.3.5 versions of glib and gtk+.
Diffstat (limited to 'examples')
-rw-r--r--examples/signal.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/signal.py b/examples/signal.py
index b98bca77..c52f0ad8 100644
--- a/examples/signal.py
+++ b/examples/signal.py
@@ -1,10 +1,12 @@
-import ltihooks, ExtensionClass
import gobject
class C(gobject.GObject):
+ def __init__(self):
+ self.__gobject_init__() # default constructor using our new GType
def do_my_signal(self, arg):
print "C: class closure for `my_signal' called with argument", arg
+gobject.type_register(C)
gobject.signal_new("my_signal", C, gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (gobject.TYPE_INT, ))
@@ -13,6 +15,8 @@ class D(C):
print "D: class closure for `my_signal' called. Chaining up to C"
C.do_my_signal(self, arg)
+gobject.type_register(D)
+
def my_signal_handler(object, arg, *extra):
print "handler for `my_signal' called with argument", arg, \
"and extra args", extra
@@ -20,8 +24,6 @@ def my_signal_handler(object, arg, *extra):
inst = C()
inst2 = D()
-print "instance id 0x%x" % id(inst)
-
inst.connect("my_signal", my_signal_handler, 1, 2, 3)
inst.emit("my_signal", 42)
inst2.emit("my_signal", 42)