From 4a9a14997dc9d70e8e77a1c37ec3e06a109af300 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Sun, 6 May 2001 16:51:48 +0000 Subject: 2001-05-06 James Henstridge 2001-05-07 James Henstridge * examples/gobject/signal.py: 2001-05-06 James Henstridge * 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+. --- examples/signal.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/signal.py b/examples/signal.py index b98bca7..c52f0ad 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) -- cgit