gstreamer-python 1.27.90__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. gstreamer_python/Lib/girepository-1.0/GdkPixbuf-2.0.typelib +0 -0
  2. gstreamer_python/Lib/girepository-1.0/HarfBuzz-0.0.typelib +0 -0
  3. gstreamer_python/Lib/girepository-1.0/Json-1.0.typelib +0 -0
  4. gstreamer_python/Lib/girepository-1.0/Pango-1.0.typelib +0 -0
  5. gstreamer_python/Lib/girepository-1.0/PangoCairo-1.0.typelib +0 -0
  6. gstreamer_python/Lib/girepository-1.0/Soup-3.0.typelib +0 -0
  7. gstreamer_python/Lib/gstreamer-1.0/gstpython.dll +0 -0
  8. gstreamer_python/Lib/site-packages/PyGObject-3.50.2.dist-info/METADATA +21 -0
  9. gstreamer_python/Lib/site-packages/cairo/__init__.py +25 -0
  10. gstreamer_python/Lib/site-packages/cairo/__init__.pyi +5889 -0
  11. gstreamer_python/Lib/site-packages/cairo/_cairo.cp313-win_amd64.pyd +0 -0
  12. gstreamer_python/Lib/site-packages/cairo/include/py3cairo.h +266 -0
  13. gstreamer_python/Lib/site-packages/cairo/py.typed +0 -0
  14. gstreamer_python/Lib/site-packages/gi/__init__.py +197 -0
  15. gstreamer_python/Lib/site-packages/gi/_constants.py +47 -0
  16. gstreamer_python/Lib/site-packages/gi/_error.py +55 -0
  17. gstreamer_python/Lib/site-packages/gi/_gi.cp313-win_amd64.pyd +0 -0
  18. gstreamer_python/Lib/site-packages/gi/_gi_cairo.cp313-win_amd64.pyd +0 -0
  19. gstreamer_python/Lib/site-packages/gi/_gtktemplate.py +307 -0
  20. gstreamer_python/Lib/site-packages/gi/_option.py +379 -0
  21. gstreamer_python/Lib/site-packages/gi/_ossighelper.py +275 -0
  22. gstreamer_python/Lib/site-packages/gi/_propertyhelper.py +402 -0
  23. gstreamer_python/Lib/site-packages/gi/_signalhelper.py +249 -0
  24. gstreamer_python/Lib/site-packages/gi/docstring.py +205 -0
  25. gstreamer_python/Lib/site-packages/gi/events.py +674 -0
  26. gstreamer_python/Lib/site-packages/gi/importer.py +153 -0
  27. gstreamer_python/Lib/site-packages/gi/module.py +269 -0
  28. gstreamer_python/Lib/site-packages/gi/overrides/GES.py +94 -0
  29. gstreamer_python/Lib/site-packages/gi/overrides/GIMarshallingTests.py +72 -0
  30. gstreamer_python/Lib/site-packages/gi/overrides/GLib.py +882 -0
  31. gstreamer_python/Lib/site-packages/gi/overrides/GObject.py +692 -0
  32. gstreamer_python/Lib/site-packages/gi/overrides/Gdk.py +444 -0
  33. gstreamer_python/Lib/site-packages/gi/overrides/GdkPixbuf.py +53 -0
  34. gstreamer_python/Lib/site-packages/gi/overrides/Gio.py +655 -0
  35. gstreamer_python/Lib/site-packages/gi/overrides/Gst.py +1273 -0
  36. gstreamer_python/Lib/site-packages/gi/overrides/GstAnalytics.py +106 -0
  37. gstreamer_python/Lib/site-packages/gi/overrides/GstApp.py +50 -0
  38. gstreamer_python/Lib/site-packages/gi/overrides/GstAudio.py +18 -0
  39. gstreamer_python/Lib/site-packages/gi/overrides/GstPbutils.py +99 -0
  40. gstreamer_python/Lib/site-packages/gi/overrides/GstVideo.py +17 -0
  41. gstreamer_python/Lib/site-packages/gi/overrides/Gtk.py +1707 -0
  42. gstreamer_python/Lib/site-packages/gi/overrides/Pango.py +58 -0
  43. gstreamer_python/Lib/site-packages/gi/overrides/__init__.py +357 -0
  44. gstreamer_python/Lib/site-packages/gi/overrides/_gi_gst.cp313-win_amd64.pyd +0 -0
  45. gstreamer_python/Lib/site-packages/gi/overrides/_gi_gst_analytics.cp313-win_amd64.pyd +0 -0
  46. gstreamer_python/Lib/site-packages/gi/overrides/keysyms.py +53 -0
  47. gstreamer_python/Lib/site-packages/gi/pygtkcompat.py +26 -0
  48. gstreamer_python/Lib/site-packages/gi/repository/__init__.py +28 -0
  49. gstreamer_python/Lib/site-packages/gi/types.py +350 -0
  50. gstreamer_python/Lib/site-packages/pycairo-1.27.0.dist-info/METADATA +9 -0
  51. gstreamer_python/__init__.py +32 -0
  52. gstreamer_python-1.27.90.dist-info/METADATA +26 -0
  53. gstreamer_python-1.27.90.dist-info/RECORD +55 -0
  54. gstreamer_python-1.27.90.dist-info/WHEEL +5 -0
  55. gstreamer_python-1.27.90.dist-info/top_level.txt +1 -0
@@ -0,0 +1,692 @@
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 functools
25
+ import warnings
26
+ from collections import namedtuple
27
+
28
+ import gi.module
29
+ from gi.overrides import override, deprecated_attr
30
+ from gi.repository import GLib
31
+ from gi import PyGIDeprecationWarning
32
+ from gi import _propertyhelper as propertyhelper
33
+ from gi import _signalhelper as signalhelper
34
+ from gi import _gi
35
+
36
+
37
+ GObjectModule = gi.module.get_introspection_module('GObject')
38
+
39
+ __all__ = []
40
+
41
+
42
+ from gi import _option as option
43
+ option = option
44
+
45
+
46
+ # API aliases for backwards compatibility
47
+ for name in ['markup_escape_text', 'get_application_name',
48
+ 'set_application_name', 'get_prgname', 'set_prgname',
49
+ 'main_depth', 'filename_display_basename',
50
+ 'filename_display_name', 'filename_from_utf8',
51
+ 'uri_list_extract_uris',
52
+ 'MainLoop', 'MainContext', 'main_context_default',
53
+ 'source_remove', 'Source', 'Idle', 'Timeout', 'PollFD',
54
+ 'idle_add', 'timeout_add', 'timeout_add_seconds',
55
+ 'io_add_watch', 'child_watch_add', 'get_current_time',
56
+ 'spawn_async']:
57
+ globals()[name] = getattr(GLib, name)
58
+ deprecated_attr("GObject", name, "GLib." + name)
59
+ __all__.append(name)
60
+
61
+ # deprecated constants
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
+ with warnings.catch_warnings():
80
+ # TODO: this uses deprecated Glib attributes, silence for now
81
+ warnings.simplefilter('ignore', PyGIDeprecationWarning)
82
+ globals()[name] = getattr(GLib, name)
83
+ deprecated_attr("GObject", name, "GLib." + name)
84
+ __all__.append(name)
85
+
86
+
87
+ for name in ['G_MININT8', 'G_MAXINT8', 'G_MAXUINT8', 'G_MININT16',
88
+ 'G_MAXINT16', 'G_MAXUINT16', 'G_MININT32', 'G_MAXINT32',
89
+ 'G_MAXUINT32', 'G_MININT64', 'G_MAXINT64', 'G_MAXUINT64']:
90
+ new_name = name.split("_", 1)[-1]
91
+ globals()[name] = getattr(GLib, new_name)
92
+ deprecated_attr("GObject", name, "GLib." + new_name)
93
+ __all__.append(name)
94
+
95
+ # these are not currently exported in GLib gir, presumably because they are
96
+ # platform dependent; so get them from our static bindings
97
+ for name in ['G_MINFLOAT', 'G_MAXFLOAT', 'G_MINDOUBLE', 'G_MAXDOUBLE',
98
+ 'G_MINSHORT', 'G_MAXSHORT', 'G_MAXUSHORT', 'G_MININT', 'G_MAXINT',
99
+ 'G_MAXUINT', 'G_MINLONG', 'G_MAXLONG', 'G_MAXULONG', 'G_MAXSIZE',
100
+ 'G_MINSSIZE', 'G_MAXSSIZE', 'G_MINOFFSET', 'G_MAXOFFSET']:
101
+ new_name = name.split("_", 1)[-1]
102
+ globals()[name] = getattr(GLib, new_name)
103
+ deprecated_attr("GObject", name, "GLib." + new_name)
104
+ __all__.append(name)
105
+
106
+
107
+ TYPE_INVALID = GObjectModule.type_from_name('invalid')
108
+ TYPE_NONE = GObjectModule.type_from_name('void')
109
+ TYPE_INTERFACE = GObjectModule.type_from_name('GInterface')
110
+ TYPE_CHAR = GObjectModule.type_from_name('gchar')
111
+ TYPE_UCHAR = GObjectModule.type_from_name('guchar')
112
+ TYPE_BOOLEAN = GObjectModule.type_from_name('gboolean')
113
+ TYPE_INT = GObjectModule.type_from_name('gint')
114
+ TYPE_UINT = GObjectModule.type_from_name('guint')
115
+ TYPE_LONG = GObjectModule.type_from_name('glong')
116
+ TYPE_ULONG = GObjectModule.type_from_name('gulong')
117
+ TYPE_INT64 = GObjectModule.type_from_name('gint64')
118
+ TYPE_UINT64 = GObjectModule.type_from_name('guint64')
119
+ TYPE_ENUM = GObjectModule.type_from_name('GEnum')
120
+ TYPE_FLAGS = GObjectModule.type_from_name('GFlags')
121
+ TYPE_FLOAT = GObjectModule.type_from_name('gfloat')
122
+ TYPE_DOUBLE = GObjectModule.type_from_name('gdouble')
123
+ TYPE_STRING = GObjectModule.type_from_name('gchararray')
124
+ TYPE_POINTER = GObjectModule.type_from_name('gpointer')
125
+ TYPE_BOXED = GObjectModule.type_from_name('GBoxed')
126
+ TYPE_PARAM = GObjectModule.type_from_name('GParam')
127
+ TYPE_OBJECT = GObjectModule.type_from_name('GObject')
128
+ TYPE_PYOBJECT = GObjectModule.type_from_name('PyObject')
129
+ TYPE_GTYPE = GObjectModule.type_from_name('GType')
130
+ TYPE_STRV = GObjectModule.type_from_name('GStrv')
131
+ TYPE_VARIANT = GObjectModule.type_from_name('GVariant')
132
+ TYPE_GSTRING = GObjectModule.type_from_name('GString')
133
+ TYPE_VALUE = GObjectModule.Value.__gtype__
134
+ TYPE_UNICHAR = TYPE_UINT
135
+ __all__ += ['TYPE_INVALID', 'TYPE_NONE', 'TYPE_INTERFACE', 'TYPE_CHAR',
136
+ 'TYPE_UCHAR', 'TYPE_BOOLEAN', 'TYPE_INT', 'TYPE_UINT', 'TYPE_LONG',
137
+ 'TYPE_ULONG', 'TYPE_INT64', 'TYPE_UINT64', 'TYPE_ENUM', 'TYPE_FLAGS',
138
+ 'TYPE_FLOAT', 'TYPE_DOUBLE', 'TYPE_STRING', 'TYPE_POINTER',
139
+ 'TYPE_BOXED', 'TYPE_PARAM', 'TYPE_OBJECT', 'TYPE_PYOBJECT',
140
+ 'TYPE_GTYPE', 'TYPE_STRV', 'TYPE_VARIANT', 'TYPE_GSTRING',
141
+ 'TYPE_UNICHAR', 'TYPE_VALUE']
142
+
143
+
144
+ # Deprecated, use GLib directly
145
+ for name in ['Pid', 'GError', 'OptionGroup', 'OptionContext']:
146
+ globals()[name] = getattr(GLib, name)
147
+ deprecated_attr("GObject", name, "GLib." + name)
148
+ __all__.append(name)
149
+
150
+
151
+ # Deprecated, use: GObject.ParamFlags.* directly
152
+ for name in ['PARAM_CONSTRUCT', 'PARAM_CONSTRUCT_ONLY', 'PARAM_LAX_VALIDATION',
153
+ 'PARAM_READABLE', 'PARAM_WRITABLE']:
154
+ new_name = name.split("_", 1)[-1]
155
+ globals()[name] = getattr(GObjectModule.ParamFlags, new_name)
156
+ deprecated_attr("GObject", name, "GObject.ParamFlags." + new_name)
157
+ __all__.append(name)
158
+
159
+ # PARAM_READWRITE should come from the gi module but cannot due to:
160
+ # https://gitlab.gnome.org/GNOME/gobject-introspection/issues/75
161
+ PARAM_READWRITE = GObjectModule.ParamFlags.READABLE | \
162
+ GObjectModule.ParamFlags.WRITABLE
163
+ deprecated_attr("GObject", "PARAM_READWRITE", "GObject.ParamFlags.READWRITE")
164
+ __all__.append("PARAM_READWRITE")
165
+
166
+
167
+ # Deprecated, use: GObject.SignalFlags.* directly
168
+ for name in ['SIGNAL_ACTION', 'SIGNAL_DETAILED', 'SIGNAL_NO_HOOKS',
169
+ 'SIGNAL_NO_RECURSE', 'SIGNAL_RUN_CLEANUP', 'SIGNAL_RUN_FIRST',
170
+ 'SIGNAL_RUN_LAST']:
171
+ new_name = name.split("_", 1)[-1]
172
+ globals()[name] = getattr(GObjectModule.SignalFlags, new_name)
173
+ deprecated_attr("GObject", name, "GObject.SignalFlags." + new_name)
174
+ __all__.append(name)
175
+
176
+ # Static types
177
+ GBoxed = _gi.GBoxed
178
+ GEnum = _gi.GEnum
179
+ GFlags = _gi.GFlags
180
+ GInterface = _gi.GInterface
181
+ GObject = _gi.GObject
182
+ GObjectWeakRef = _gi.GObjectWeakRef
183
+ GPointer = _gi.GPointer
184
+ GType = _gi.GType
185
+ Warning = _gi.Warning
186
+ __all__ += ['GBoxed', 'GEnum', 'GFlags', 'GInterface', 'GObject',
187
+ 'GObjectWeakRef', 'GPointer', 'GType', 'Warning']
188
+
189
+
190
+ features = {'generic-c-marshaller': True}
191
+ list_properties = _gi.list_properties
192
+ new = _gi.new
193
+ pygobject_version = _gi.pygobject_version
194
+ threads_init = GLib.threads_init
195
+ type_register = _gi.type_register
196
+ __all__ += ['features', 'list_properties', 'new',
197
+ 'pygobject_version', 'threads_init', 'type_register']
198
+
199
+
200
+ class Value(GObjectModule.Value):
201
+ def __init__(self, value_type=None, py_value=None):
202
+ GObjectModule.Value.__init__(self)
203
+ if value_type is not None:
204
+ self.init(value_type)
205
+ if py_value is not None:
206
+ self.set_value(py_value)
207
+
208
+ @property
209
+ def __g_type(self):
210
+ # XXX: This is the same as self.g_type, but the field marshalling
211
+ # code is currently very slow.
212
+ return _gi._gvalue_get_type(self)
213
+
214
+ def set_boxed(self, boxed):
215
+ if not self.__g_type.is_a(TYPE_BOXED):
216
+ warnings.warn('Calling set_boxed() on a non-boxed type deprecated',
217
+ PyGIDeprecationWarning, stacklevel=2)
218
+ # Workaround the introspection marshalers inability to know
219
+ # these methods should be marshaling boxed types. This is because
220
+ # the type information is stored on the GValue.
221
+ _gi._gvalue_set(self, boxed)
222
+
223
+ def get_boxed(self):
224
+ if not self.__g_type.is_a(TYPE_BOXED):
225
+ warnings.warn('Calling get_boxed() on a non-boxed type deprecated',
226
+ PyGIDeprecationWarning, stacklevel=2)
227
+ return _gi._gvalue_get(self)
228
+
229
+ def set_value(self, py_value):
230
+ gtype = self.__g_type
231
+
232
+ if gtype == TYPE_CHAR:
233
+ self.set_char(py_value)
234
+ elif gtype == TYPE_UCHAR:
235
+ self.set_uchar(py_value)
236
+ elif gtype == TYPE_STRING:
237
+ if not isinstance(py_value, str) and py_value is not None:
238
+ raise TypeError("Expected string but got %s%s" %
239
+ (py_value, type(py_value)))
240
+ _gi._gvalue_set(self, py_value)
241
+ elif gtype == TYPE_PARAM:
242
+ self.set_param(py_value)
243
+ elif gtype.is_a(TYPE_FLAGS):
244
+ self.set_flags(py_value)
245
+ elif gtype == TYPE_POINTER:
246
+ self.set_pointer(py_value)
247
+ elif gtype == TYPE_GTYPE:
248
+ self.set_gtype(py_value)
249
+ elif gtype == TYPE_VARIANT:
250
+ self.set_variant(py_value)
251
+ else:
252
+ # Fall back to _gvalue_set which handles some more cases
253
+ # like fundamentals for which a converter is registered
254
+ try:
255
+ _gi._gvalue_set(self, py_value)
256
+ except TypeError:
257
+ if gtype == TYPE_INVALID:
258
+ raise TypeError("GObject.Value needs to be initialized first")
259
+ raise
260
+
261
+ def get_value(self):
262
+ gtype = self.__g_type
263
+
264
+ if gtype == TYPE_CHAR:
265
+ return self.get_char()
266
+ elif gtype == TYPE_UCHAR:
267
+ return self.get_uchar()
268
+ elif gtype == TYPE_PARAM:
269
+ return self.get_param()
270
+ elif gtype.is_a(TYPE_ENUM):
271
+ return self.get_enum()
272
+ elif gtype.is_a(TYPE_FLAGS):
273
+ return self.get_flags()
274
+ elif gtype == TYPE_POINTER:
275
+ return self.get_pointer()
276
+ elif gtype == TYPE_GTYPE:
277
+ return self.get_gtype()
278
+ elif gtype == TYPE_VARIANT:
279
+ # get_variant was missing annotations
280
+ # https://gitlab.gnome.org/GNOME/glib/merge_requests/492
281
+ return self.dup_variant()
282
+ else:
283
+ try:
284
+ return _gi._gvalue_get(self)
285
+ except TypeError:
286
+ if gtype == TYPE_INVALID:
287
+ return None
288
+ raise
289
+
290
+ def __repr__(self):
291
+ return '<Value (%s) %s>' % (self.__g_type.name, self.get_value())
292
+
293
+
294
+ Value = override(Value)
295
+ __all__.append('Value')
296
+
297
+
298
+ def type_from_name(name):
299
+ type_ = GObjectModule.type_from_name(name)
300
+ if type_ == TYPE_INVALID:
301
+ raise RuntimeError('unknown type name: %s' % name)
302
+ return type_
303
+
304
+
305
+ __all__.append('type_from_name')
306
+
307
+
308
+ def type_parent(type_):
309
+ parent = GObjectModule.type_parent(type_)
310
+ if parent == TYPE_INVALID:
311
+ raise RuntimeError('no parent for type')
312
+ return parent
313
+
314
+
315
+ __all__.append('type_parent')
316
+
317
+
318
+ def _validate_type_for_signal_method(type_):
319
+ if hasattr(type_, '__gtype__'):
320
+ type_ = type_.__gtype__
321
+ if not type_.is_instantiatable() and not type_.is_interface():
322
+ raise TypeError('type must be instantiable or an interface, got %s' % type_)
323
+
324
+
325
+ def signal_list_ids(type_):
326
+ _validate_type_for_signal_method(type_)
327
+ return GObjectModule.signal_list_ids(type_)
328
+
329
+
330
+ __all__.append('signal_list_ids')
331
+
332
+
333
+ def signal_list_names(type_):
334
+ ids = signal_list_ids(type_)
335
+ return tuple(GObjectModule.signal_name(i) for i in ids)
336
+
337
+
338
+ __all__.append('signal_list_names')
339
+
340
+
341
+ def signal_lookup(name, type_):
342
+ _validate_type_for_signal_method(type_)
343
+ return GObjectModule.signal_lookup(name, type_)
344
+
345
+
346
+ __all__.append('signal_lookup')
347
+
348
+
349
+ SignalQuery = namedtuple('SignalQuery',
350
+ ['signal_id',
351
+ 'signal_name',
352
+ 'itype',
353
+ 'signal_flags',
354
+ 'return_type',
355
+ # n_params',
356
+ 'param_types'])
357
+
358
+
359
+ def signal_query(id_or_name, type_=None):
360
+ if type_ is not None:
361
+ id_or_name = signal_lookup(id_or_name, type_)
362
+
363
+ res = GObjectModule.signal_query(id_or_name)
364
+ assert res is not None
365
+
366
+ if res.signal_id == 0:
367
+ return None
368
+
369
+ # Return a named tuple to allows indexing which is compatible with the
370
+ # static bindings along with field like access of the gi struct.
371
+ # Note however that the n_params was not returned from the static bindings
372
+ # so we must skip over it.
373
+ return SignalQuery(res.signal_id, res.signal_name, res.itype,
374
+ res.signal_flags, res.return_type,
375
+ tuple(res.param_types))
376
+
377
+
378
+ __all__.append('signal_query')
379
+
380
+
381
+ class _HandlerBlockManager(object):
382
+ def __init__(self, obj, handler_id):
383
+ self.obj = obj
384
+ self.handler_id = handler_id
385
+
386
+ def __enter__(self):
387
+ pass
388
+
389
+ def __exit__(self, exc_type, exc_value, traceback):
390
+ GObjectModule.signal_handler_unblock(self.obj, self.handler_id)
391
+
392
+
393
+ def signal_handler_block(obj, handler_id):
394
+ """Blocks the signal handler from being invoked until
395
+ handler_unblock() is called.
396
+
397
+ :param GObject.Object obj:
398
+ Object instance to block handlers for.
399
+ :param int handler_id:
400
+ Id of signal to block.
401
+ :returns:
402
+ A context manager which optionally can be used to
403
+ automatically unblock the handler:
404
+
405
+ .. code-block:: python
406
+
407
+ with GObject.signal_handler_block(obj, id):
408
+ pass
409
+ """
410
+ GObjectModule.signal_handler_block(obj, handler_id)
411
+ return _HandlerBlockManager(obj, handler_id)
412
+
413
+
414
+ __all__.append('signal_handler_block')
415
+
416
+
417
+ def signal_parse_name(detailed_signal, itype, force_detail_quark):
418
+ """Parse a detailed signal name into (signal_id, detail).
419
+
420
+ :param str detailed_signal:
421
+ Signal name which can include detail.
422
+ For example: "notify:prop_name"
423
+ :returns:
424
+ Tuple of (signal_id, detail)
425
+ :raises ValueError:
426
+ If the given signal is unknown.
427
+ """
428
+ res, signal_id, detail = GObjectModule.signal_parse_name(detailed_signal, itype,
429
+ force_detail_quark)
430
+ if res:
431
+ return signal_id, detail
432
+ else:
433
+ raise ValueError('%s: unknown signal name: %s' % (itype, detailed_signal))
434
+
435
+
436
+ __all__.append('signal_parse_name')
437
+
438
+
439
+ def remove_emission_hook(obj, detailed_signal, hook_id):
440
+ signal_id, detail = signal_parse_name(detailed_signal, obj, True)
441
+ GObjectModule.signal_remove_emission_hook(signal_id, hook_id)
442
+
443
+
444
+ __all__.append('remove_emission_hook')
445
+
446
+
447
+ # GObject accumulators with pure Python implementations
448
+ # These return a tuple of (continue_emission, accumulation_result)
449
+
450
+ def signal_accumulator_first_wins(ihint, return_accu, handler_return, user_data=None):
451
+ # Stop emission but return the result of the last handler
452
+ return (False, handler_return)
453
+
454
+
455
+ __all__.append('signal_accumulator_first_wins')
456
+
457
+
458
+ def signal_accumulator_true_handled(ihint, return_accu, handler_return, user_data=None):
459
+ # Stop emission if the last handler returns True
460
+ return (not handler_return, handler_return)
461
+
462
+
463
+ __all__.append('signal_accumulator_true_handled')
464
+
465
+
466
+ # Statically bound signal functions which need to clobber GI (for now)
467
+
468
+ add_emission_hook = _gi.add_emission_hook
469
+ signal_new = _gi.signal_new
470
+
471
+ __all__ += ['add_emission_hook', 'signal_new']
472
+
473
+
474
+ class _FreezeNotifyManager(object):
475
+ def __init__(self, obj):
476
+ self.obj = obj
477
+
478
+ def __enter__(self):
479
+ pass
480
+
481
+ def __exit__(self, exc_type, exc_value, traceback):
482
+ self.obj.thaw_notify()
483
+
484
+
485
+ def _signalmethod(func):
486
+ # Function wrapper for signal functions used as instance methods.
487
+ # This is needed when the signal functions come directly from GI.
488
+ # (they are not already wrapped)
489
+ @functools.wraps(func)
490
+ def meth(*args, **kwargs):
491
+ return func(*args, **kwargs)
492
+ return meth
493
+
494
+
495
+ class Object(GObjectModule.Object):
496
+ def _unsupported_method(self, *args, **kargs):
497
+ raise RuntimeError('This method is currently unsupported.')
498
+
499
+ def _unsupported_data_method(self, *args, **kargs):
500
+ raise RuntimeError('Data access methods are unsupported. '
501
+ 'Use normal Python attributes instead')
502
+
503
+ # Generic data methods are not needed in python as it can be handled
504
+ # with standard attribute access: https://bugzilla.gnome.org/show_bug.cgi?id=641944
505
+ get_data = _unsupported_data_method
506
+ get_qdata = _unsupported_data_method
507
+ set_data = _unsupported_data_method
508
+ steal_data = _unsupported_data_method
509
+ steal_qdata = _unsupported_data_method
510
+ replace_data = _unsupported_data_method
511
+ replace_qdata = _unsupported_data_method
512
+
513
+ # The following methods as unsupported until we verify
514
+ # they work as gi methods.
515
+ bind_property_full = _unsupported_method
516
+ compat_control = _unsupported_method
517
+ interface_find_property = _unsupported_method
518
+ interface_install_property = _unsupported_method
519
+ interface_list_properties = _unsupported_method
520
+ notify_by_pspec = _unsupported_method
521
+ watch_closure = _unsupported_method
522
+
523
+ # Make all reference management methods private but still accessible.
524
+ _ref = GObjectModule.Object.ref
525
+ _ref_sink = GObjectModule.Object.ref_sink
526
+ _unref = GObjectModule.Object.unref
527
+ _force_floating = GObjectModule.Object.force_floating
528
+
529
+ ref = _unsupported_method
530
+ ref_sink = _unsupported_method
531
+ unref = _unsupported_method
532
+ force_floating = _unsupported_method
533
+
534
+ # The following methods are static APIs which need to leap frog the
535
+ # gi methods until we verify the gi methods can replace them.
536
+ get_property = _gi.GObject.get_property
537
+ get_properties = _gi.GObject.get_properties
538
+ set_property = _gi.GObject.set_property
539
+ set_properties = _gi.GObject.set_properties
540
+ bind_property = _gi.GObject.bind_property
541
+ connect = _gi.GObject.connect
542
+ connect_after = _gi.GObject.connect_after
543
+ connect_object = _gi.GObject.connect_object
544
+ connect_object_after = _gi.GObject.connect_object_after
545
+ disconnect_by_func = _gi.GObject.disconnect_by_func
546
+ handler_block_by_func = _gi.GObject.handler_block_by_func
547
+ handler_unblock_by_func = _gi.GObject.handler_unblock_by_func
548
+ emit = _gi.GObject.emit
549
+ chain = _gi.GObject.chain
550
+ weak_ref = _gi.GObject.weak_ref
551
+ __copy__ = _gi.GObject.__copy__
552
+ __deepcopy__ = _gi.GObject.__deepcopy__
553
+
554
+ def freeze_notify(self):
555
+ """Freezes the object's property-changed notification queue.
556
+
557
+ :returns:
558
+ A context manager which optionally can be used to
559
+ automatically thaw notifications.
560
+
561
+ This will freeze the object so that "notify" signals are blocked until
562
+ the thaw_notify() method is called.
563
+
564
+ .. code-block:: python
565
+
566
+ with obj.freeze_notify():
567
+ pass
568
+ """
569
+ super(Object, self).freeze_notify()
570
+ return _FreezeNotifyManager(self)
571
+
572
+ def connect_data(self, detailed_signal, handler, *data, **kwargs):
573
+ """Connect a callback to the given signal with optional user data.
574
+
575
+ :param str detailed_signal:
576
+ A detailed signal to connect to.
577
+ :param callable handler:
578
+ Callback handler to connect to the signal.
579
+ :param *data:
580
+ Variable data which is passed through to the signal handler.
581
+ :param GObject.ConnectFlags connect_flags:
582
+ Flags used for connection options.
583
+ :returns:
584
+ A signal id which can be used with disconnect.
585
+ """
586
+ flags = kwargs.get('connect_flags', 0)
587
+ if flags & GObjectModule.ConnectFlags.AFTER:
588
+ connect_func = _gi.GObject.connect_after
589
+ else:
590
+ connect_func = _gi.GObject.connect
591
+
592
+ if flags & GObjectModule.ConnectFlags.SWAPPED:
593
+ if len(data) != 1:
594
+ raise ValueError('Using GObject.ConnectFlags.SWAPPED requires exactly '
595
+ 'one argument for user data, got: %s' % [data])
596
+
597
+ def new_handler(obj, *args):
598
+ # Swap obj with the last element in args which will be the user
599
+ # data passed to the connect function.
600
+ args = list(args)
601
+ swap = args.pop()
602
+ args = args + [obj]
603
+ return handler(swap, *args)
604
+ else:
605
+ new_handler = handler
606
+
607
+ return connect_func(self, detailed_signal, new_handler, *data)
608
+
609
+ #
610
+ # Aliases
611
+ #
612
+
613
+ handler_block = signal_handler_block
614
+ handler_unblock = _signalmethod(GObjectModule.signal_handler_unblock)
615
+ disconnect = _signalmethod(GObjectModule.signal_handler_disconnect)
616
+ handler_disconnect = _signalmethod(GObjectModule.signal_handler_disconnect)
617
+ handler_is_connected = _signalmethod(GObjectModule.signal_handler_is_connected)
618
+ stop_emission_by_name = _signalmethod(GObjectModule.signal_stop_emission_by_name)
619
+
620
+ #
621
+ # Deprecated Methods
622
+ #
623
+
624
+ def stop_emission(self, detailed_signal):
625
+ """Deprecated, please use stop_emission_by_name."""
626
+ warnings.warn(self.stop_emission.__doc__, PyGIDeprecationWarning, stacklevel=2)
627
+ return self.stop_emission_by_name(detailed_signal)
628
+
629
+ emit_stop_by_name = stop_emission
630
+
631
+
632
+ Object = override(Object)
633
+ GObject = Object
634
+ __all__ += ['Object', 'GObject']
635
+
636
+
637
+ class Binding(GObjectModule.Binding):
638
+ def __call__(self):
639
+ warnings.warn('Using parentheses (binding()) to retrieve the Binding object is no '
640
+ 'longer needed because the binding is returned directly from "bind_property.',
641
+ PyGIDeprecationWarning, stacklevel=2)
642
+ return self
643
+
644
+ def unbind(self):
645
+ # Fixed in newer glib
646
+ if (GLib.MAJOR_VERSION, GLib.MINOR_VERSION, GLib.MICRO_VERSION) >= (2, 57, 3):
647
+ return super(Binding, self).unbind()
648
+
649
+ if hasattr(self, '_unbound'):
650
+ raise ValueError('binding has already been cleared out')
651
+ else:
652
+ setattr(self, '_unbound', True)
653
+ super(Binding, self).unbind()
654
+
655
+
656
+ Binding = override(Binding)
657
+ __all__.append('Binding')
658
+
659
+
660
+ Property = propertyhelper.Property
661
+ Signal = signalhelper.Signal
662
+ SignalOverride = signalhelper.SignalOverride
663
+ # Deprecated naming "property" available for backwards compatibility.
664
+ # Keep this at the end of the file to avoid clobbering the builtin.
665
+ property = Property
666
+ deprecated_attr("GObject", "property", "GObject.Property")
667
+ __all__ += ['Property', 'Signal', 'SignalOverride', 'property']
668
+
669
+
670
+ @override
671
+ class ParamSpec(GObjectModule.ParamSpec):
672
+
673
+ @property
674
+ def nick(self):
675
+ return self._nick
676
+
677
+ @nick.setter
678
+ def nick(self, nick):
679
+ self._nick = nick
680
+
681
+ @property
682
+ def blurb(self):
683
+ return self._blurb
684
+
685
+ @blurb.setter
686
+ def blurb(self, blurb):
687
+ self._blurb = blurb
688
+
689
+
690
+ GParamSpec = ParamSpec
691
+ deprecated_attr("GObject", "GParamSpec", "GObject.ParamSpec")
692
+ __all__ += ["ParamSpec", "GParamSpec"]