diff options
| author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2006-04-11 21:51:06 +0000 |
|---|---|---|
| committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2006-04-11 21:51:06 +0000 |
| commit | 921eb7103fce05bb55aaadc0bcd3527781a1b229 (patch) | |
| tree | 34e9d19e16167878c437ef27632c27d7d35508eb /gobject/__init__.py | |
| parent | 2b30a70e7b7d2111910ebbf76750bdefe51381ff (diff) | |
| download | pygobject-921eb7103fce05bb55aaadc0bcd3527781a1b229.tar.gz pygobject-921eb7103fce05bb55aaadc0bcd3527781a1b229.tar.xz pygobject-921eb7103fce05bb55aaadc0bcd3527781a1b229.zip | |
Move GObjectMeta from C to python-land
Diffstat (limited to 'gobject/__init__.py')
| -rw-r--r-- | gobject/__init__.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gobject/__init__.py b/gobject/__init__.py index c31c777..22cc434 100644 --- a/gobject/__init__.py +++ b/gobject/__init__.py @@ -28,3 +28,21 @@ except ImportError: pass from _gobject import * + +class GObjectMeta(type): + "Metaclass for automatically gobject.type_register()ing GObject classes" + def __init__(cls, name, bases, dict_): + type.__init__(cls, name, bases, dict_) + ## don't register the class if already registered + if '__gtype__' in cls.__dict__: + return + + if not ('__gproperties__' in cls.__dict__ or + '__gsignals__' in cls.__dict__ or + '__gtype_name__' in cls.__dict__): + return + + type_register(cls, cls.__dict__.get('__gtype_name__')) + +_gobject._install_metaclass(GObjectMeta) + |
