Imported Upstream version 3.11.4
[platform/upstream/python-gobject.git] / gi / overrides / GObject.py
1 # -*- Mode: Python; py-indent-offset: 4 -*-
2 # vim: tabstop=4 shiftwidth=4 expandtab
3 #
4 # Copyright (C) 2012 Canonical Ltd.
5 # Author: Martin Pitt <martin.pitt@ubuntu.com>
6 # Copyright (C) 2012-2013 Simon Feltman <sfeltman@src.gnome.org>
7 # Copyright (C) 2012 Bastian Winkler <buz@netbuz.org>
8 #
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
22 # USA
23
24 import sys
25 import warnings
26 from collections import namedtuple
27
28 import gi.overrides
29 import gi.module
30 from gi.overrides import override
31 from gi.repository import GLib
32 from gi import PyGIDeprecationWarning
33
34 from gi._gobject import _gobject
35 from gi._gobject import propertyhelper
36 from gi._gobject import signalhelper
37
38 GObjectModule = gi.module.get_introspection_module('GObject')
39
40 __all__ = []
41
42
43 from gi._glib import option
44 sys.modules['gi._gobject.option'] = option
45
46
47 # API aliases for backwards compatibility
48 for name in ['markup_escape_text', 'get_application_name',
49              'set_application_name', 'get_prgname', 'set_prgname',
50              'main_depth', 'filename_display_basename',
51              'filename_display_name', 'filename_from_utf8',
52              'uri_list_extract_uris',
53              'MainLoop', 'MainContext', 'main_context_default',
54              'source_remove', 'Source', 'Idle', 'Timeout', 'PollFD',
55              'idle_add', 'timeout_add', 'timeout_add_seconds',
56              'io_add_watch', 'child_watch_add', 'get_current_time',
57              'spawn_async']:
58     globals()[name] = gi.overrides.deprecated(getattr(GLib, name), 'GLib.' + name)
59     __all__.append(name)
60
61 # constants are also deprecated, but cannot mark them as such
62 for name in ['PRIORITY_DEFAULT', 'PRIORITY_DEFAULT_IDLE', 'PRIORITY_HIGH',
63              'PRIORITY_HIGH_IDLE', 'PRIORITY_LOW',
64              'IO_IN', 'IO_OUT', 'IO_PRI', 'IO_ERR', 'IO_HUP', 'IO_NVAL',
65              'IO_STATUS_ERROR', 'IO_STATUS_NORMAL', 'IO_STATUS_EOF',
66              'IO_STATUS_AGAIN', 'IO_FLAG_APPEND', 'IO_FLAG_NONBLOCK',
67              'IO_FLAG_IS_READABLE', 'IO_FLAG_IS_WRITEABLE',
68              'IO_FLAG_IS_SEEKABLE', 'IO_FLAG_MASK', 'IO_FLAG_GET_MASK',
69              'IO_FLAG_SET_MASK',
70              'SPAWN_LEAVE_DESCRIPTORS_OPEN', 'SPAWN_DO_NOT_REAP_CHILD',
71              'SPAWN_SEARCH_PATH', 'SPAWN_STDOUT_TO_DEV_NULL',
72              'SPAWN_STDERR_TO_DEV_NULL', 'SPAWN_CHILD_INHERITS_STDIN',
73              'SPAWN_FILE_AND_ARGV_ZERO',
74              'OPTION_FLAG_HIDDEN', 'OPTION_FLAG_IN_MAIN', 'OPTION_FLAG_REVERSE',
75              'OPTION_FLAG_NO_ARG', 'OPTION_FLAG_FILENAME', 'OPTION_FLAG_OPTIONAL_ARG',
76              'OPTION_FLAG_NOALIAS', 'OPTION_ERROR_UNKNOWN_OPTION',
77              'OPTION_ERROR_BAD_VALUE', 'OPTION_ERROR_FAILED', 'OPTION_REMAINING',
78              'glib_version']:
79     globals()[name] = getattr(GLib, name)
80     __all__.append(name)
81
82
83 G_MININT8 = GLib.MININT8
84 G_MAXINT8 = GLib.MAXINT8
85 G_MAXUINT8 = GLib.MAXUINT8
86 G_MININT16 = GLib.MININT16
87 G_MAXINT16 = GLib.MAXINT16
88 G_MAXUINT16 = GLib.MAXUINT16
89 G_MININT32 = GLib.MININT32
90 G_MAXINT32 = GLib.MAXINT32
91 G_MAXUINT32 = GLib.MAXUINT32
92 G_MININT64 = GLib.MININT64
93 G_MAXINT64 = GLib.MAXINT64
94 G_MAXUINT64 = GLib.MAXUINT64
95 __all__ += ['G_MININT8', 'G_MAXINT8', 'G_MAXUINT8', 'G_MININT16',
96             'G_MAXINT16', 'G_MAXUINT16', 'G_MININT32', 'G_MAXINT32',
97             'G_MAXUINT32', 'G_MININT64', 'G_MAXINT64', 'G_MAXUINT64']
98
99 # these are not currently exported in GLib gir, presumably because they are
100 # platform dependent; so get them from our static bindings
101 for name in ['G_MINFLOAT', 'G_MAXFLOAT', 'G_MINDOUBLE', 'G_MAXDOUBLE',
102              'G_MINSHORT', 'G_MAXSHORT', 'G_MAXUSHORT', 'G_MININT', 'G_MAXINT',
103              'G_MAXUINT', 'G_MINLONG', 'G_MAXLONG', 'G_MAXULONG', 'G_MAXSIZE',
104              'G_MINSSIZE', 'G_MAXSSIZE', 'G_MINOFFSET', 'G_MAXOFFSET']:
105     globals()[name] = getattr(_gobject, name)
106     __all__.append(name)
107
108
109 TYPE_INVALID = GObjectModule.type_from_name('invalid')
110 TYPE_NONE = GObjectModule.type_from_name('void')
111 TYPE_INTERFACE = GObjectModule.type_from_name('GInterface')
112 TYPE_CHAR = GObjectModule.type_from_name('gchar')
113 TYPE_UCHAR = GObjectModule.type_from_name('guchar')
114 TYPE_BOOLEAN = GObjectModule.type_from_name('gboolean')
115 TYPE_INT = GObjectModule.type_from_name('gint')
116 TYPE_UINT = GObjectModule.type_from_name('guint')
117 TYPE_LONG = GObjectModule.type_from_name('glong')
118 TYPE_ULONG = GObjectModule.type_from_name('gulong')
119 TYPE_INT64 = GObjectModule.type_from_name('gint64')
120 TYPE_UINT64 = GObjectModule.type_from_name('guint64')
121 TYPE_ENUM = GObjectModule.type_from_name('GEnum')
122 TYPE_FLAGS = GObjectModule.type_from_name('GFlags')
123 TYPE_FLOAT = GObjectModule.type_from_name('gfloat')
124 TYPE_DOUBLE = GObjectModule.type_from_name('gdouble')
125 TYPE_STRING = GObjectModule.type_from_name('gchararray')
126 TYPE_POINTER = GObjectModule.type_from_name('gpointer')
127 TYPE_BOXED = GObjectModule.type_from_name('GBoxed')
128 TYPE_PARAM = GObjectModule.type_from_name('GParam')
129 TYPE_OBJECT = GObjectModule.type_from_name('GObject')
130 TYPE_PYOBJECT = GObjectModule.type_from_name('PyObject')
131 TYPE_GTYPE = GObjectModule.type_from_name('GType')
132 TYPE_STRV = GObjectModule.type_from_name('GStrv')
133 TYPE_VARIANT = GObjectModule.type_from_name('GVariant')
134 TYPE_GSTRING = GObjectModule.type_from_name('GString')
135 TYPE_VALUE = GObjectModule.Value.__gtype__
136 TYPE_UNICHAR = TYPE_UINT
137 __all__ += ['TYPE_INVALID', 'TYPE_NONE', 'TYPE_INTERFACE', 'TYPE_CHAR',
138             'TYPE_UCHAR', 'TYPE_BOOLEAN', 'TYPE_INT', 'TYPE_UINT', 'TYPE_LONG',
139             'TYPE_ULONG', 'TYPE_INT64', 'TYPE_UINT64', 'TYPE_ENUM', 'TYPE_FLAGS',
140             'TYPE_FLOAT', 'TYPE_DOUBLE', 'TYPE_STRING', 'TYPE_POINTER',
141             'TYPE_BOXED', 'TYPE_PARAM', 'TYPE_OBJECT', 'TYPE_PYOBJECT',
142             'TYPE_GTYPE', 'TYPE_STRV', 'TYPE_VARIANT', 'TYPE_GSTRING',
143             'TYPE_UNICHAR', 'TYPE_VALUE']
144
145
146 # Deprecated, use GLib directly
147 Pid = GLib.Pid
148 GError = GLib.GError
149 OptionGroup = GLib.OptionGroup
150 OptionContext = GLib.OptionContext
151 __all__ += ['Pid', 'GError', 'OptionGroup', 'OptionContext']
152
153
154 # Deprecated, use: GObject.ParamFlags.* directly
155 PARAM_CONSTRUCT = GObjectModule.ParamFlags.CONSTRUCT
156 PARAM_CONSTRUCT_ONLY = GObjectModule.ParamFlags.CONSTRUCT_ONLY
157 PARAM_LAX_VALIDATION = GObjectModule.ParamFlags.LAX_VALIDATION
158 PARAM_READABLE = GObjectModule.ParamFlags.READABLE
159 PARAM_WRITABLE = GObjectModule.ParamFlags.WRITABLE
160 # PARAM_READWRITE should come from the gi module but cannot due to:
161 # https://bugzilla.gnome.org/show_bug.cgi?id=687615
162 PARAM_READWRITE = PARAM_READABLE | PARAM_WRITABLE
163 __all__ += ['PARAM_CONSTRUCT', 'PARAM_CONSTRUCT_ONLY', 'PARAM_LAX_VALIDATION',
164             'PARAM_READABLE', 'PARAM_WRITABLE', 'PARAM_READWRITE']
165
166
167 # Deprecated, use: GObject.SignalFlags.* directly
168 SIGNAL_ACTION = GObjectModule.SignalFlags.ACTION
169 SIGNAL_DETAILED = GObjectModule.SignalFlags.DETAILED
170 SIGNAL_NO_HOOKS = GObjectModule.SignalFlags.NO_HOOKS
171 SIGNAL_NO_RECURSE = GObjectModule.SignalFlags.NO_RECURSE
172 SIGNAL_RUN_CLEANUP = GObjectModule.SignalFlags.RUN_CLEANUP
173 SIGNAL_RUN_FIRST = GObjectModule.SignalFlags.RUN_FIRST
174 SIGNAL_RUN_LAST = GObjectModule.SignalFlags.RUN_LAST
175 __all__ += ['SIGNAL_ACTION', 'SIGNAL_DETAILED', 'SIGNAL_NO_HOOKS',
176             'SIGNAL_NO_RECURSE', 'SIGNAL_RUN_CLEANUP', 'SIGNAL_RUN_FIRST',
177             'SIGNAL_RUN_LAST']
178
179
180 # Static types
181 GBoxed = _gobject.GBoxed
182 GEnum = _gobject.GEnum
183 GFlags = _gobject.GFlags
184 GInterface = _gobject.GInterface
185 GObject = _gobject.GObject
186 GObjectWeakRef = _gobject.GObjectWeakRef
187 GParamSpec = _gobject.GParamSpec
188 GPointer = _gobject.GPointer
189 GType = _gobject.GType
190 Warning = _gobject.Warning
191 __all__ += ['GBoxed', 'GEnum', 'GFlags', 'GInterface', 'GObject',
192             'GObjectWeakRef', 'GParamSpec', 'GPointer', 'GType',
193             'Warning']
194
195
196 features = _gobject.features
197 list_properties = _gobject.list_properties
198 new = _gobject.new
199 pygobject_version = _gobject.pygobject_version
200 threads_init = GLib.threads_init
201 type_register = _gobject.type_register
202 __all__ += ['features', 'list_properties', 'new',
203             'pygobject_version', 'threads_init', 'type_register']
204
205
206 class Value(GObjectModule.Value):
207     def __init__(self, value_type=None, py_value=None):
208         GObjectModule.Value.__init__(self)
209         if value_type is not None:
210             self.init(value_type)
211             if py_value is not None:
212                 self.set_value(py_value)
213
214     def __del__(self):
215         if self._free_on_dealloc and self.g_type != TYPE_INVALID:
216             self.unset()
217
218     def set_boxed(self, boxed):
219         # Workaround the introspection marshalers inability to know
220         # these methods should be marshaling boxed types. This is because
221         # the type information is stored on the GValue.
222         _gobject._gvalue_set(self, boxed)
223
224     def get_boxed(self):
225         return _gobject._gvalue_get(self)
226
227     def set_value(self, py_value):
228         gtype = self.g_type
229
230         if gtype == _gobject.TYPE_INVALID:
231             raise TypeError("GObject.Value needs to be initialized first")
232         elif gtype == TYPE_BOOLEAN:
233             self.set_boolean(py_value)
234         elif gtype == TYPE_CHAR:
235             self.set_char(py_value)
236         elif gtype == TYPE_UCHAR:
237             self.set_uchar(py_value)
238         elif gtype == TYPE_INT:
239             self.set_int(py_value)
240         elif gtype == TYPE_UINT:
241             self.set_uint(py_value)
242         elif gtype == TYPE_LONG:
243             self.set_long(py_value)
244         elif gtype == TYPE_ULONG:
245             self.set_ulong(py_value)
246         elif gtype == TYPE_INT64:
247             self.set_int64(py_value)
248         elif gtype == TYPE_UINT64:
249             self.set_uint64(py_value)
250         elif gtype == TYPE_FLOAT:
251             self.set_float(py_value)
252         elif gtype == TYPE_DOUBLE:
253             self.set_double(py_value)
254         elif gtype == TYPE_STRING:
255             if isinstance(py_value, str):
256                 py_value = str(py_value)
257             elif sys.version_info < (3, 0):
258                 if isinstance(py_value, unicode):
259                     py_value = py_value.encode('UTF-8')
260                 else:
261                     raise ValueError("Expected string or unicode but got %s%s" %
262                                      (py_value, type(py_value)))
263             else:
264                 raise ValueError("Expected string but got %s%s" %
265                                  (py_value, type(py_value)))
266             self.set_string(py_value)
267         elif gtype == TYPE_PARAM:
268             self.set_param(py_value)
269         elif gtype.is_a(TYPE_ENUM):
270             self.set_enum(py_value)
271         elif gtype.is_a(TYPE_FLAGS):
272             self.set_flags(py_value)
273         elif gtype.is_a(TYPE_BOXED):
274             self.set_boxed(py_value)
275         elif gtype == TYPE_POINTER:
276             self.set_pointer(py_value)
277         elif gtype.is_a(TYPE_OBJECT):
278             self.set_object(py_value)
279         elif gtype == TYPE_UNICHAR:
280             self.set_uint(int(py_value))
281         # elif gtype == TYPE_OVERRIDE:
282         #     pass
283         elif gtype == TYPE_GTYPE:
284             self.set_gtype(py_value)
285         elif gtype == TYPE_VARIANT:
286             self.set_variant(py_value)
287         elif gtype == TYPE_PYOBJECT:
288             self.set_boxed(py_value)
289         else:
290             raise TypeError("Unknown value type %s" % gtype)
291
292     def get_value(self):
293         gtype = self.g_type
294
295         if gtype == TYPE_BOOLEAN:
296             return self.get_boolean()
297         elif gtype == TYPE_CHAR:
298             return self.get_char()
299         elif gtype == TYPE_UCHAR:
300             return self.get_uchar()
301         elif gtype == TYPE_INT:
302             return self.get_int()
303         elif gtype == TYPE_UINT:
304             return self.get_uint()
305         elif gtype == TYPE_LONG:
306             return self.get_long()
307         elif gtype == TYPE_ULONG:
308             return self.get_ulong()
309         elif gtype == TYPE_INT64:
310             return self.get_int64()
311         elif gtype == TYPE_UINT64:
312             return self.get_uint64()
313         elif gtype == TYPE_FLOAT:
314             return self.get_float()
315         elif gtype == TYPE_DOUBLE:
316             return self.get_double()
317         elif gtype == TYPE_STRING:
318             return self.get_string()
319         elif gtype == TYPE_PARAM:
320             return self.get_param()
321         elif gtype.is_a(TYPE_ENUM):
322             return self.get_enum()
323         elif gtype.is_a(TYPE_FLAGS):
324             return self.get_flags()
325         elif gtype.is_a(TYPE_BOXED):
326             return self.get_boxed()
327         elif gtype == TYPE_POINTER:
328             return self.get_pointer()
329         elif gtype.is_a(TYPE_OBJECT):
330             return self.get_object()
331         elif gtype == TYPE_UNICHAR:
332             return self.get_uint()
333         elif gtype == TYPE_GTYPE:
334             return self.get_gtype()
335         elif gtype == TYPE_VARIANT:
336             return self.get_variant()
337         elif gtype == TYPE_PYOBJECT:
338             pass
339         else:
340             return None
341
342     def __repr__(self):
343         return '<Value (%s) %s>' % (self.g_type.name, self.get_value())
344
345 Value = override(Value)
346 __all__.append('Value')
347
348
349 def type_from_name(name):
350     type_ = GObjectModule.type_from_name(name)
351     if type_ == TYPE_INVALID:
352         raise RuntimeError('unknown type name: %s' % name)
353     return type_
354
355 __all__.append('type_from_name')
356
357
358 def type_parent(type_):
359     parent = GObjectModule.type_parent(type_)
360     if parent == TYPE_INVALID:
361         raise RuntimeError('no parent for type')
362     return parent
363
364 __all__.append('type_parent')
365
366
367 def _validate_type_for_signal_method(type_):
368     if hasattr(type_, '__gtype__'):
369         type_ = type_.__gtype__
370     if not type_.is_instantiatable() and not type_.is_interface():
371         raise TypeError('type must be instantiable or an interface, got %s' % type_)
372
373
374 def signal_list_ids(type_):
375     _validate_type_for_signal_method(type_)
376     return GObjectModule.signal_list_ids(type_)
377
378 __all__.append('signal_list_ids')
379
380
381 def signal_list_names(type_):
382     ids = signal_list_ids(type_)
383     return tuple(GObjectModule.signal_name(i) for i in ids)
384
385 __all__.append('signal_list_names')
386
387
388 def signal_lookup(name, type_):
389     _validate_type_for_signal_method(type_)
390     return GObjectModule.signal_lookup(name, type_)
391
392 __all__.append('signal_lookup')
393
394
395 def signal_query(id_or_name, type_=None):
396     SignalQuery = namedtuple('SignalQuery',
397                              ['signal_id',
398                               'signal_name',
399                               'itype',
400                               'signal_flags',
401                               'return_type',
402                               # n_params',
403                               'param_types'])
404
405     # signal_query needs to use a static method until the following bugs are fixed:
406     # https://bugzilla.gnome.org/show_bug.cgi?id=687550
407     # https://bugzilla.gnome.org/show_bug.cgi?id=687545
408     # https://bugzilla.gnome.org/show_bug.cgi?id=687541
409     if type_ is not None:
410         id_or_name = signal_lookup(id_or_name, type_)
411
412     res = _gobject.signal_query(id_or_name)
413     if res is None:
414         return None
415
416     # Return a named tuple which allows indexing like the static bindings
417     # along with field like access of the gi struct.
418     # Note however that the n_params was not returned from the static bindings.
419     return SignalQuery(*res)
420
421 __all__.append('signal_query')
422
423
424 class _HandlerBlockManager(object):
425     def __init__(self, obj, handler_id):
426         self.obj = obj
427         self.handler_id = handler_id
428
429     def __enter__(self):
430         pass
431
432     def __exit__(self, exc_type, exc_value, traceback):
433         GObjectModule.signal_handler_unblock(self.obj, self.handler_id)
434
435
436 def signal_handler_block(obj, handler_id):
437     """Blocks the signal handler from being invoked until handler_unblock() is called.
438
439     Returns a context manager which optionally can be used to
440     automatically unblock the handler:
441
442       with GObject.signal_handler_block(obj, id):
443          pass
444     """
445     GObjectModule.signal_handler_block(obj, handler_id)
446     return _HandlerBlockManager(obj, handler_id)
447
448 __all__.append('signal_handler_block')
449
450
451 def signal_parse_name(detailed_signal, itype, force_detail_quark):
452     """Parse a detailed signal name into (signal_id, detail).
453
454     :Raises ValueError:
455         If the given signal is unknown.
456
457     :Returns:
458         Tuple of (signal_id, detail)
459     """
460     res, signal_id, detail = GObjectModule.signal_parse_name(detailed_signal, itype,
461                                                              force_detail_quark)
462     if res:
463         return signal_id, detail
464     else:
465         raise ValueError('%s: unknown signal name: %s' % (itype, detailed_signal))
466
467 __all__.append('signal_parse_name')
468
469
470 def remove_emission_hook(obj, detailed_signal, hook_id):
471     signal_id, detail = signal_parse_name(detailed_signal, obj, True)
472     GObjectModule.signal_remove_emission_hook(signal_id, hook_id)
473
474 __all__.append('remove_emission_hook')
475
476
477 # GObject accumulators with pure Python implementations
478 # These return a tuple of (continue_emission, accumulation_result)
479
480 def signal_accumulator_first_wins(ihint, return_accu, handler_return, user_data=None):
481     # Stop emission but return the result of the last handler
482     return (False, handler_return)
483
484 __all__.append('signal_accumulator_first_wins')
485
486
487 def signal_accumulator_true_handled(ihint, return_accu, handler_return, user_data=None):
488     # Stop emission if the last handler returns True
489     return (not handler_return, handler_return)
490
491 __all__.append('signal_accumulator_true_handled')
492
493
494 # Statically bound signal functions which need to clobber GI (for now)
495
496 add_emission_hook = _gobject.add_emission_hook
497 signal_new = _gobject.signal_new
498
499 __all__ += ['add_emission_hook', 'signal_new']
500
501
502 class _FreezeNotifyManager(object):
503     def __init__(self, obj):
504         self.obj = obj
505
506     def __enter__(self):
507         pass
508
509     def __exit__(self, exc_type, exc_value, traceback):
510         self.obj.thaw_notify()
511
512
513 def _signalmethod(func):
514     # Function wrapper for signal functions used as instance methods.
515     # This is needed when the signal functions come directly from GI.
516     # (they are not already wrapped)
517     @gi.overrides.wraps(func)
518     def meth(*args, **kwargs):
519         return func(*args, **kwargs)
520     return meth
521
522
523 class Object(GObjectModule.Object):
524     def _unsupported_method(self, *args, **kargs):
525         raise RuntimeError('This method is currently unsupported.')
526
527     def _unsupported_data_method(self, *args, **kargs):
528         raise RuntimeError('Data access methods are unsupported. '
529                            'Use normal Python attributes instead')
530
531     # Generic data methods are not needed in python as it can be handled
532     # with standard attribute access: https://bugzilla.gnome.org/show_bug.cgi?id=641944
533     get_data = _unsupported_data_method
534     get_qdata = _unsupported_data_method
535     set_data = _unsupported_data_method
536     steal_data = _unsupported_data_method
537     steal_qdata = _unsupported_data_method
538     replace_data = _unsupported_data_method
539     replace_qdata = _unsupported_data_method
540
541     # The following methods as unsupported until we verify
542     # they work as gi methods.
543     bind_property_full = _unsupported_method
544     compat_control = _unsupported_method
545     interface_find_property = _unsupported_method
546     interface_install_property = _unsupported_method
547     interface_list_properties = _unsupported_method
548     notify_by_pspec = _unsupported_method
549     run_dispose = _unsupported_method
550     watch_closure = _unsupported_method
551
552     # Make all reference management methods private but still accessible.
553     _ref = GObjectModule.Object.ref
554     _ref_sink = GObjectModule.Object.ref_sink
555     _unref = GObjectModule.Object.unref
556     _force_floating = GObjectModule.Object.force_floating
557
558     ref = _unsupported_method
559     ref_sink = _unsupported_method
560     unref = _unsupported_method
561     force_floating = _unsupported_method
562
563     # The following methods are static APIs which need to leap frog the
564     # gi methods until we verify the gi methods can replace them.
565     get_property = _gobject.GObject.get_property
566     get_properties = _gobject.GObject.get_properties
567     set_property = _gobject.GObject.set_property
568     set_properties = _gobject.GObject.set_properties
569     bind_property = _gobject.GObject.bind_property
570     connect = _gobject.GObject.connect
571     connect_after = _gobject.GObject.connect_after
572     connect_object = _gobject.GObject.connect_object
573     connect_object_after = _gobject.GObject.connect_object_after
574     disconnect_by_func = _gobject.GObject.disconnect_by_func
575     handler_block_by_func = _gobject.GObject.handler_block_by_func
576     handler_unblock_by_func = _gobject.GObject.handler_unblock_by_func
577     emit = _gobject.GObject.emit
578     chain = _gobject.GObject.chain
579     weak_ref = _gobject.GObject.weak_ref
580     __copy__ = _gobject.GObject.__copy__
581     __deepcopy__ = _gobject.GObject.__deepcopy__
582
583     def freeze_notify(self):
584         """Freezes the object's property-changed notification queue.
585
586         This will freeze the object so that "notify" signals are blocked until
587         the thaw_notify() method is called.
588
589         Returns a context manager which optionally can be used to
590         automatically thaw notifications:
591
592           with obj.freeze_notify():
593               pass
594         """
595         super(Object, self).freeze_notify()
596         return _FreezeNotifyManager(self)
597
598     #
599     # Aliases
600     #
601
602     handler_block = signal_handler_block
603     handler_unblock = _signalmethod(GObjectModule.signal_handler_unblock)
604     disconnect = _signalmethod(GObjectModule.signal_handler_disconnect)
605     handler_disconnect = _signalmethod(GObjectModule.signal_handler_disconnect)
606     handler_is_connected = _signalmethod(GObjectModule.signal_handler_is_connected)
607     stop_emission_by_name = _signalmethod(GObjectModule.signal_stop_emission_by_name)
608
609     #
610     # Deprecated Methods
611     #
612
613     def stop_emission(self, detailed_signal):
614         """Deprecated, please use stop_emission_by_name."""
615         warnings.warn(self.stop_emission.__doc__, PyGIDeprecationWarning, stacklevel=2)
616         return self.stop_emission_by_name(detailed_signal)
617
618     emit_stop_by_name = stop_emission
619
620
621 Object = override(Object)
622 GObject = Object
623 __all__ += ['Object', 'GObject']
624
625
626 class Binding(GObjectModule.Binding):
627     def __call__(self):
628         warnings.warn('Using parentheses (binding()) to retrieve the Binding object is no '
629                       'longer needed because the binding is returned directly from "bind_property.',
630                       PyGIDeprecationWarning, stacklevel=2)
631         return self
632
633     def unbind(self):
634         if hasattr(self, '_unbound'):
635             raise ValueError('binding has already been cleared out')
636         else:
637             setattr(self, '_unbound', True)
638             super(Binding, self).unbind()
639
640
641 Binding = override(Binding)
642 __all__.append('Binding')
643
644
645 Property = propertyhelper.Property
646 Signal = signalhelper.Signal
647 SignalOverride = signalhelper.SignalOverride
648 # Deprecated naming "property" available for backwards compatibility.
649 # Keep this at the end of the file to avoid clobbering the builtin.
650 property = Property
651 __all__ += ['Property', 'Signal', 'SignalOverride', 'property']