gstreamer-python 1.27.90__cp39-cp39-win32.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.
- gstreamer_python/Lib/girepository-1.0/GdkPixbuf-2.0.typelib +0 -0
- gstreamer_python/Lib/girepository-1.0/HarfBuzz-0.0.typelib +0 -0
- gstreamer_python/Lib/girepository-1.0/Json-1.0.typelib +0 -0
- gstreamer_python/Lib/girepository-1.0/Pango-1.0.typelib +0 -0
- gstreamer_python/Lib/girepository-1.0/PangoCairo-1.0.typelib +0 -0
- gstreamer_python/Lib/girepository-1.0/Soup-3.0.typelib +0 -0
- gstreamer_python/Lib/gstreamer-1.0/gstpython.dll +0 -0
- gstreamer_python/Lib/site-packages/PyGObject-3.50.2.dist-info/METADATA +21 -0
- gstreamer_python/Lib/site-packages/cairo/__init__.py +25 -0
- gstreamer_python/Lib/site-packages/cairo/__init__.pyi +5889 -0
- gstreamer_python/Lib/site-packages/cairo/_cairo.cp39-win32.pyd +0 -0
- gstreamer_python/Lib/site-packages/cairo/include/py3cairo.h +266 -0
- gstreamer_python/Lib/site-packages/cairo/py.typed +0 -0
- gstreamer_python/Lib/site-packages/gi/__init__.py +197 -0
- gstreamer_python/Lib/site-packages/gi/_constants.py +47 -0
- gstreamer_python/Lib/site-packages/gi/_error.py +55 -0
- gstreamer_python/Lib/site-packages/gi/_gi.cp39-win32.pyd +0 -0
- gstreamer_python/Lib/site-packages/gi/_gi_cairo.cp39-win32.pyd +0 -0
- gstreamer_python/Lib/site-packages/gi/_gtktemplate.py +307 -0
- gstreamer_python/Lib/site-packages/gi/_option.py +379 -0
- gstreamer_python/Lib/site-packages/gi/_ossighelper.py +275 -0
- gstreamer_python/Lib/site-packages/gi/_propertyhelper.py +402 -0
- gstreamer_python/Lib/site-packages/gi/_signalhelper.py +249 -0
- gstreamer_python/Lib/site-packages/gi/docstring.py +205 -0
- gstreamer_python/Lib/site-packages/gi/events.py +674 -0
- gstreamer_python/Lib/site-packages/gi/importer.py +153 -0
- gstreamer_python/Lib/site-packages/gi/module.py +269 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GES.py +94 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GIMarshallingTests.py +72 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GLib.py +882 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GObject.py +692 -0
- gstreamer_python/Lib/site-packages/gi/overrides/Gdk.py +444 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GdkPixbuf.py +53 -0
- gstreamer_python/Lib/site-packages/gi/overrides/Gio.py +655 -0
- gstreamer_python/Lib/site-packages/gi/overrides/Gst.py +1273 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GstAnalytics.py +106 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GstApp.py +50 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GstAudio.py +18 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GstPbutils.py +99 -0
- gstreamer_python/Lib/site-packages/gi/overrides/GstVideo.py +17 -0
- gstreamer_python/Lib/site-packages/gi/overrides/Gtk.py +1707 -0
- gstreamer_python/Lib/site-packages/gi/overrides/Pango.py +58 -0
- gstreamer_python/Lib/site-packages/gi/overrides/__init__.py +357 -0
- gstreamer_python/Lib/site-packages/gi/overrides/_gi_gst.cp39-win32.pyd +0 -0
- gstreamer_python/Lib/site-packages/gi/overrides/_gi_gst_analytics.cp39-win32.pyd +0 -0
- gstreamer_python/Lib/site-packages/gi/overrides/keysyms.py +53 -0
- gstreamer_python/Lib/site-packages/gi/pygtkcompat.py +26 -0
- gstreamer_python/Lib/site-packages/gi/repository/__init__.py +28 -0
- gstreamer_python/Lib/site-packages/gi/types.py +350 -0
- gstreamer_python/Lib/site-packages/pycairo-1.27.0.dist-info/METADATA +9 -0
- gstreamer_python/__init__.py +32 -0
- gstreamer_python-1.27.90.dist-info/METADATA +26 -0
- gstreamer_python-1.27.90.dist-info/RECORD +55 -0
- gstreamer_python-1.27.90.dist-info/WHEEL +5 -0
- gstreamer_python-1.27.90.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
# -*- Mode: Python; py-indent-offset: 4 -*-
|
|
2
|
+
# vim: tabstop=4 shiftwidth=4 expandtab
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2010 Ignacio Casal Quinteiro <icq@gnome.org>
|
|
5
|
+
#
|
|
6
|
+
# This library is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
# License as published by the Free Software Foundation; either
|
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with this library; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
|
|
19
|
+
# USA
|
|
20
|
+
|
|
21
|
+
import warnings
|
|
22
|
+
from contextlib import suppress
|
|
23
|
+
|
|
24
|
+
from .._ossighelper import register_sigint_fallback, get_event_loop
|
|
25
|
+
from ..overrides import (
|
|
26
|
+
override,
|
|
27
|
+
deprecated_attr,
|
|
28
|
+
deprecated_init,
|
|
29
|
+
wrap_list_store_equal_func,
|
|
30
|
+
wrap_list_store_sort_func,
|
|
31
|
+
)
|
|
32
|
+
from .._gi import CallableInfo
|
|
33
|
+
from ..module import get_introspection_module
|
|
34
|
+
from gi import PyGIWarning
|
|
35
|
+
|
|
36
|
+
from gi.repository import GLib
|
|
37
|
+
|
|
38
|
+
import sys
|
|
39
|
+
|
|
40
|
+
Gio = get_introspection_module('Gio')
|
|
41
|
+
|
|
42
|
+
__all__ = []
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Application(Gio.Application):
|
|
46
|
+
|
|
47
|
+
def run(self, *args, **kwargs):
|
|
48
|
+
with register_sigint_fallback(self.quit):
|
|
49
|
+
with get_event_loop(GLib.MainContext.default()).running(self.quit):
|
|
50
|
+
return Gio.Application.run(self, *args, **kwargs)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Application = override(Application)
|
|
54
|
+
__all__.append('Application')
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _warn_init(cls, instead=None):
|
|
58
|
+
|
|
59
|
+
def new_init(self, *args, **kwargs):
|
|
60
|
+
super(cls, self).__init__(*args, **kwargs)
|
|
61
|
+
name = cls.__module__.rsplit(".", 1)[-1] + "." + cls.__name__
|
|
62
|
+
if instead:
|
|
63
|
+
warnings.warn(
|
|
64
|
+
("%s shouldn't be instantiated directly, "
|
|
65
|
+
"use %s instead." % (name, instead)),
|
|
66
|
+
PyGIWarning, stacklevel=2)
|
|
67
|
+
else:
|
|
68
|
+
warnings.warn(
|
|
69
|
+
"%s shouldn't be instantiated directly." % (name,),
|
|
70
|
+
PyGIWarning, stacklevel=2)
|
|
71
|
+
|
|
72
|
+
return new_init
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@override
|
|
76
|
+
class VolumeMonitor(Gio.VolumeMonitor):
|
|
77
|
+
# https://bugzilla.gnome.org/show_bug.cgi?id=744690
|
|
78
|
+
__init__ = _warn_init(Gio.VolumeMonitor, "Gio.VolumeMonitor.get()")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
__all__.append('VolumeMonitor')
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@override
|
|
85
|
+
class DBusAnnotationInfo(Gio.DBusAnnotationInfo):
|
|
86
|
+
__init__ = _warn_init(Gio.DBusAnnotationInfo)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
__all__.append('DBusAnnotationInfo')
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@override
|
|
93
|
+
class DBusArgInfo(Gio.DBusArgInfo):
|
|
94
|
+
__init__ = _warn_init(Gio.DBusArgInfo)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
__all__.append('DBusArgInfo')
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@override
|
|
101
|
+
class DBusMethodInfo(Gio.DBusMethodInfo):
|
|
102
|
+
__init__ = _warn_init(Gio.DBusMethodInfo)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
__all__.append('DBusMethodInfo')
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@override
|
|
109
|
+
class DBusSignalInfo(Gio.DBusSignalInfo):
|
|
110
|
+
__init__ = _warn_init(Gio.DBusSignalInfo)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
__all__.append('DBusSignalInfo')
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@override
|
|
117
|
+
class DBusInterfaceInfo(Gio.DBusInterfaceInfo):
|
|
118
|
+
__init__ = _warn_init(Gio.DBusInterfaceInfo)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
__all__.append('DBusInterfaceInfo')
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@override
|
|
125
|
+
class DBusNodeInfo(Gio.DBusNodeInfo):
|
|
126
|
+
__init__ = _warn_init(Gio.DBusNodeInfo)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
__all__.append('DBusNodeInfo')
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class ActionMap(Gio.ActionMap):
|
|
133
|
+
def add_action_entries(self, entries, user_data=None):
|
|
134
|
+
"""
|
|
135
|
+
The add_action_entries() method is a convenience function for creating
|
|
136
|
+
multiple Gio.SimpleAction instances and adding them to a Gio.ActionMap.
|
|
137
|
+
Each action is constructed as per one entry.
|
|
138
|
+
|
|
139
|
+
:param list entries:
|
|
140
|
+
List of entry tuples for add_action() method. The entry tuple can
|
|
141
|
+
vary in size with the following information:
|
|
142
|
+
|
|
143
|
+
* The name of the action. Must be specified.
|
|
144
|
+
* The callback to connect to the "activate" signal of the
|
|
145
|
+
action. Since GLib 2.40, this can be None for stateful
|
|
146
|
+
actions, in which case the default handler is used. For
|
|
147
|
+
boolean-stated actions with no parameter, this is a toggle.
|
|
148
|
+
For other state types (and parameter type equal to the state
|
|
149
|
+
type) this will be a function that just calls change_state
|
|
150
|
+
(which you should provide).
|
|
151
|
+
* The type of the parameter that must be passed to the activate
|
|
152
|
+
function for this action, given as a single GLib.Variant type
|
|
153
|
+
string (or None for no parameter)
|
|
154
|
+
* The initial state for this action, given in GLib.Variant text
|
|
155
|
+
format. The state is parsed with no extra type information, so
|
|
156
|
+
type tags must be added to the string if they are necessary.
|
|
157
|
+
Stateless actions should give None here.
|
|
158
|
+
* The callback to connect to the "change-state" signal of the
|
|
159
|
+
action. All stateful actions should provide a handler here;
|
|
160
|
+
stateless actions should not.
|
|
161
|
+
|
|
162
|
+
:param user_data:
|
|
163
|
+
The user data for signal connections, or None
|
|
164
|
+
"""
|
|
165
|
+
try:
|
|
166
|
+
iter(entries)
|
|
167
|
+
except (TypeError):
|
|
168
|
+
raise TypeError('entries must be iterable')
|
|
169
|
+
|
|
170
|
+
def _process_action(name, activate=None, parameter_type=None,
|
|
171
|
+
state=None, change_state=None):
|
|
172
|
+
if parameter_type:
|
|
173
|
+
if not GLib.VariantType.string_is_valid(parameter_type):
|
|
174
|
+
raise TypeError("The type string '%s' given as the "
|
|
175
|
+
"parameter type for action '%s' is "
|
|
176
|
+
"not a valid GVariant type string. " %
|
|
177
|
+
(parameter_type, name))
|
|
178
|
+
variant_parameter = GLib.VariantType.new(parameter_type)
|
|
179
|
+
else:
|
|
180
|
+
variant_parameter = None
|
|
181
|
+
|
|
182
|
+
if state is not None:
|
|
183
|
+
# stateful action
|
|
184
|
+
variant_state = GLib.Variant.parse(None, state, None, None)
|
|
185
|
+
action = Gio.SimpleAction.new_stateful(name, variant_parameter,
|
|
186
|
+
variant_state)
|
|
187
|
+
if change_state is not None:
|
|
188
|
+
action.connect('change-state', change_state, user_data)
|
|
189
|
+
else:
|
|
190
|
+
# stateless action
|
|
191
|
+
if change_state is not None:
|
|
192
|
+
raise ValueError("Stateless action '%s' should give "
|
|
193
|
+
"None for 'change_state', not '%s'." %
|
|
194
|
+
(name, change_state))
|
|
195
|
+
action = Gio.SimpleAction(name=name, parameter_type=variant_parameter)
|
|
196
|
+
|
|
197
|
+
if activate is not None:
|
|
198
|
+
action.connect('activate', activate, user_data)
|
|
199
|
+
self.add_action(action)
|
|
200
|
+
|
|
201
|
+
for entry in entries:
|
|
202
|
+
# using inner function above since entries can leave out optional arguments
|
|
203
|
+
_process_action(*entry)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
ActionMap = override(ActionMap)
|
|
207
|
+
__all__.append('ActionMap')
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class FileEnumerator(Gio.FileEnumerator):
|
|
211
|
+
def __iter__(self):
|
|
212
|
+
return self
|
|
213
|
+
|
|
214
|
+
def __next__(self):
|
|
215
|
+
file_info = self.next_file(None)
|
|
216
|
+
|
|
217
|
+
if file_info is not None:
|
|
218
|
+
return file_info
|
|
219
|
+
else:
|
|
220
|
+
raise StopIteration
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
FileEnumerator = override(FileEnumerator)
|
|
224
|
+
__all__.append('FileEnumerator')
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class MenuItem(Gio.MenuItem):
|
|
228
|
+
def set_attribute(self, attributes):
|
|
229
|
+
for (name, format_string, value) in attributes:
|
|
230
|
+
self.set_attribute_value(name, GLib.Variant(format_string, value))
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
MenuItem = override(MenuItem)
|
|
234
|
+
__all__.append('MenuItem')
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class Settings(Gio.Settings):
|
|
238
|
+
'''Provide dictionary-like access to GLib.Settings.'''
|
|
239
|
+
|
|
240
|
+
__init__ = deprecated_init(Gio.Settings.__init__,
|
|
241
|
+
arg_names=('schema', 'path', 'backend'))
|
|
242
|
+
|
|
243
|
+
def __contains__(self, key):
|
|
244
|
+
return key in self.list_keys()
|
|
245
|
+
|
|
246
|
+
def __len__(self):
|
|
247
|
+
return len(self.list_keys())
|
|
248
|
+
|
|
249
|
+
def __iter__(self):
|
|
250
|
+
for key in self.list_keys():
|
|
251
|
+
yield key
|
|
252
|
+
|
|
253
|
+
def __bool__(self):
|
|
254
|
+
# for "if mysettings" we don't want a dictionary-like test here, just
|
|
255
|
+
# if the object isn't None
|
|
256
|
+
return True
|
|
257
|
+
|
|
258
|
+
def __getitem__(self, key):
|
|
259
|
+
# get_value() aborts the program on an unknown key
|
|
260
|
+
if key not in self:
|
|
261
|
+
raise KeyError('unknown key: %r' % (key,))
|
|
262
|
+
|
|
263
|
+
return self.get_value(key).unpack()
|
|
264
|
+
|
|
265
|
+
def __setitem__(self, key, value):
|
|
266
|
+
# set_value() aborts the program on an unknown key
|
|
267
|
+
if key not in self:
|
|
268
|
+
raise KeyError('unknown key: %r' % (key,))
|
|
269
|
+
|
|
270
|
+
# determine type string of this key
|
|
271
|
+
range = self.get_range(key)
|
|
272
|
+
type_ = range.get_child_value(0).get_string()
|
|
273
|
+
v = range.get_child_value(1)
|
|
274
|
+
if type_ == 'type':
|
|
275
|
+
# v is boxed empty array, type of its elements is the allowed value type
|
|
276
|
+
type_str = v.get_child_value(0).get_type_string()
|
|
277
|
+
assert type_str.startswith('a')
|
|
278
|
+
type_str = type_str[1:]
|
|
279
|
+
elif type_ == 'enum':
|
|
280
|
+
# v is an array with the allowed values
|
|
281
|
+
assert v.get_child_value(0).get_type_string().startswith('a')
|
|
282
|
+
type_str = v.get_child_value(0).get_child_value(0).get_type_string()
|
|
283
|
+
allowed = v.unpack()
|
|
284
|
+
if value not in allowed:
|
|
285
|
+
raise ValueError('value %s is not an allowed enum (%s)' % (value, allowed))
|
|
286
|
+
elif type_ == 'range':
|
|
287
|
+
tuple_ = v.get_child_value(0)
|
|
288
|
+
type_str = tuple_.get_child_value(0).get_type_string()
|
|
289
|
+
min_, max_ = tuple_.unpack()
|
|
290
|
+
if value < min_ or value > max_:
|
|
291
|
+
raise ValueError(
|
|
292
|
+
'value %s not in range (%s - %s)' % (value, min_, max_))
|
|
293
|
+
else:
|
|
294
|
+
raise NotImplementedError('Cannot handle allowed type range class ' + str(type_))
|
|
295
|
+
|
|
296
|
+
self.set_value(key, GLib.Variant(type_str, value))
|
|
297
|
+
|
|
298
|
+
def keys(self):
|
|
299
|
+
return self.list_keys()
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
Settings = override(Settings)
|
|
303
|
+
__all__.append('Settings')
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class _DBusProxyMethodCall:
|
|
307
|
+
'''Helper class to implement DBusProxy method calls.'''
|
|
308
|
+
|
|
309
|
+
def __init__(self, dbus_proxy, method_name):
|
|
310
|
+
self.dbus_proxy = dbus_proxy
|
|
311
|
+
self.method_name = method_name
|
|
312
|
+
|
|
313
|
+
def __async_result_handler(self, obj, result, user_data):
|
|
314
|
+
(result_callback, error_callback, real_user_data) = user_data
|
|
315
|
+
try:
|
|
316
|
+
ret = obj.call_finish(result)
|
|
317
|
+
except Exception:
|
|
318
|
+
etype, e = sys.exc_info()[:2]
|
|
319
|
+
# return exception as value
|
|
320
|
+
if error_callback:
|
|
321
|
+
error_callback(obj, e, real_user_data)
|
|
322
|
+
else:
|
|
323
|
+
result_callback(obj, e, real_user_data)
|
|
324
|
+
return
|
|
325
|
+
|
|
326
|
+
result_callback(obj, self._unpack_result(ret), real_user_data)
|
|
327
|
+
|
|
328
|
+
def __call__(self, *args, **kwargs):
|
|
329
|
+
# the first positional argument is the signature, unless we are calling
|
|
330
|
+
# a method without arguments; then signature is implied to be '()'.
|
|
331
|
+
if args:
|
|
332
|
+
signature = args[0]
|
|
333
|
+
args = args[1:]
|
|
334
|
+
if not isinstance(signature, str):
|
|
335
|
+
raise TypeError('first argument must be the method signature string: %r' % signature)
|
|
336
|
+
else:
|
|
337
|
+
signature = '()'
|
|
338
|
+
|
|
339
|
+
arg_variant = GLib.Variant(signature, tuple(args))
|
|
340
|
+
|
|
341
|
+
if 'result_handler' in kwargs:
|
|
342
|
+
# asynchronous call
|
|
343
|
+
user_data = (kwargs['result_handler'],
|
|
344
|
+
kwargs.get('error_handler'),
|
|
345
|
+
kwargs.get('user_data'))
|
|
346
|
+
self.dbus_proxy.call(self.method_name, arg_variant,
|
|
347
|
+
kwargs.get('flags', 0), kwargs.get('timeout', -1), None,
|
|
348
|
+
self.__async_result_handler, user_data)
|
|
349
|
+
else:
|
|
350
|
+
# synchronous call
|
|
351
|
+
result = self.dbus_proxy.call_sync(self.method_name, arg_variant,
|
|
352
|
+
kwargs.get('flags', 0),
|
|
353
|
+
kwargs.get('timeout', -1),
|
|
354
|
+
None)
|
|
355
|
+
return self._unpack_result(result)
|
|
356
|
+
|
|
357
|
+
@classmethod
|
|
358
|
+
def _unpack_result(klass, result):
|
|
359
|
+
'''Convert a D-BUS return variant into an appropriate return value'''
|
|
360
|
+
|
|
361
|
+
result = result.unpack()
|
|
362
|
+
|
|
363
|
+
# to be compatible with standard Python behaviour, unbox
|
|
364
|
+
# single-element tuples and return None for empty result tuples
|
|
365
|
+
if len(result) == 1:
|
|
366
|
+
result = result[0]
|
|
367
|
+
elif len(result) == 0:
|
|
368
|
+
result = None
|
|
369
|
+
|
|
370
|
+
return result
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
class DBusProxy(Gio.DBusProxy):
|
|
374
|
+
'''Provide comfortable and pythonic method calls.
|
|
375
|
+
|
|
376
|
+
This marshalls the method arguments into a GVariant, invokes the
|
|
377
|
+
call_sync() method on the DBusProxy object, and unmarshalls the result
|
|
378
|
+
GVariant back into a Python tuple.
|
|
379
|
+
|
|
380
|
+
The first argument always needs to be the D-Bus signature tuple of the
|
|
381
|
+
method call. Example:
|
|
382
|
+
|
|
383
|
+
proxy = Gio.DBusProxy.new_sync(...)
|
|
384
|
+
result = proxy.MyMethod('(is)', 42, 'hello')
|
|
385
|
+
|
|
386
|
+
The exception are methods which take no arguments, like
|
|
387
|
+
proxy.MyMethod('()'). For these you can omit the signature and just write
|
|
388
|
+
proxy.MyMethod().
|
|
389
|
+
|
|
390
|
+
Optional keyword arguments:
|
|
391
|
+
|
|
392
|
+
- timeout: timeout for the call in milliseconds (default to D-Bus timeout)
|
|
393
|
+
|
|
394
|
+
- flags: Combination of Gio.DBusCallFlags.*
|
|
395
|
+
|
|
396
|
+
- result_handler: Do an asynchronous method call and invoke
|
|
397
|
+
result_handler(proxy_object, result, user_data) when it finishes.
|
|
398
|
+
|
|
399
|
+
- error_handler: If the asynchronous call raises an exception,
|
|
400
|
+
error_handler(proxy_object, exception, user_data) is called when it
|
|
401
|
+
finishes. If error_handler is not given, result_handler is called with
|
|
402
|
+
the exception object as result instead.
|
|
403
|
+
|
|
404
|
+
- user_data: Optional user data to pass to result_handler for
|
|
405
|
+
asynchronous calls.
|
|
406
|
+
|
|
407
|
+
Example for asynchronous calls:
|
|
408
|
+
|
|
409
|
+
def mymethod_done(proxy, result, user_data):
|
|
410
|
+
if isinstance(result, Exception):
|
|
411
|
+
# handle error
|
|
412
|
+
else:
|
|
413
|
+
# do something with result
|
|
414
|
+
|
|
415
|
+
proxy.MyMethod('(is)', 42, 'hello',
|
|
416
|
+
result_handler=mymethod_done, user_data='data')
|
|
417
|
+
'''
|
|
418
|
+
def __getattr__(self, name):
|
|
419
|
+
return _DBusProxyMethodCall(self, name)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
DBusProxy = override(DBusProxy)
|
|
423
|
+
__all__.append('DBusProxy')
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
class ListModel(Gio.ListModel):
|
|
427
|
+
|
|
428
|
+
def __getitem__(self, key):
|
|
429
|
+
if isinstance(key, slice):
|
|
430
|
+
return [self.get_item(i) for i in range(*key.indices(len(self)))]
|
|
431
|
+
elif isinstance(key, int):
|
|
432
|
+
if key < 0:
|
|
433
|
+
key += len(self)
|
|
434
|
+
if key < 0:
|
|
435
|
+
raise IndexError
|
|
436
|
+
ret = self.get_item(key)
|
|
437
|
+
if ret is None:
|
|
438
|
+
raise IndexError
|
|
439
|
+
return ret
|
|
440
|
+
else:
|
|
441
|
+
raise TypeError
|
|
442
|
+
|
|
443
|
+
def __contains__(self, item):
|
|
444
|
+
pytype = self.get_item_type().pytype
|
|
445
|
+
if not isinstance(item, pytype):
|
|
446
|
+
raise TypeError(
|
|
447
|
+
"Expected type %s.%s" % (pytype.__module__, pytype.__name__))
|
|
448
|
+
for i in self:
|
|
449
|
+
if i == item:
|
|
450
|
+
return True
|
|
451
|
+
return False
|
|
452
|
+
|
|
453
|
+
def __len__(self):
|
|
454
|
+
return self.get_n_items()
|
|
455
|
+
|
|
456
|
+
def __iter__(self):
|
|
457
|
+
for i in range(len(self)):
|
|
458
|
+
yield self.get_item(i)
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
ListModel = override(ListModel)
|
|
462
|
+
__all__.append('ListModel')
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
if (GLib.MAJOR_VERSION, GLib.MINOR_VERSION, GLib.MICRO_VERSION) < (2, 57, 1):
|
|
466
|
+
# The "additions" functionality in splice() was broken in older glib
|
|
467
|
+
# https://bugzilla.gnome.org/show_bug.cgi?id=795307
|
|
468
|
+
# This is a slower fallback which emits a signal per added item
|
|
469
|
+
def _list_store_splice(self, position, n_removals, additions):
|
|
470
|
+
self.splice(position, n_removals, [])
|
|
471
|
+
for v in reversed(additions):
|
|
472
|
+
self.insert(position, v)
|
|
473
|
+
else:
|
|
474
|
+
def _list_store_splice(self, position, n_removals, additions):
|
|
475
|
+
self.splice(position, n_removals, additions)
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
class ListStore(Gio.ListStore):
|
|
479
|
+
|
|
480
|
+
def sort(self, compare_func, *user_data):
|
|
481
|
+
compare_func = wrap_list_store_sort_func(compare_func)
|
|
482
|
+
return super(ListStore, self).sort(compare_func, *user_data)
|
|
483
|
+
|
|
484
|
+
def insert_sorted(self, item, compare_func, *user_data):
|
|
485
|
+
compare_func = wrap_list_store_sort_func(compare_func)
|
|
486
|
+
return super(ListStore, self).insert_sorted(
|
|
487
|
+
item, compare_func, *user_data)
|
|
488
|
+
|
|
489
|
+
def __delitem__(self, key):
|
|
490
|
+
if isinstance(key, slice):
|
|
491
|
+
start, stop, step = key.indices(len(self))
|
|
492
|
+
if step == 1:
|
|
493
|
+
_list_store_splice(self, start, max(stop - start, 0), [])
|
|
494
|
+
elif step == -1:
|
|
495
|
+
_list_store_splice(self, stop + 1, max(start - stop, 0), [])
|
|
496
|
+
else:
|
|
497
|
+
for i in sorted(range(start, stop, step), reverse=True):
|
|
498
|
+
self.remove(i)
|
|
499
|
+
elif isinstance(key, int):
|
|
500
|
+
if key < 0:
|
|
501
|
+
key += len(self)
|
|
502
|
+
if key < 0 or key >= len(self):
|
|
503
|
+
raise IndexError
|
|
504
|
+
self.remove(key)
|
|
505
|
+
else:
|
|
506
|
+
raise TypeError
|
|
507
|
+
|
|
508
|
+
def __setitem__(self, key, value):
|
|
509
|
+
if isinstance(key, slice):
|
|
510
|
+
pytype = self.get_item_type().pytype
|
|
511
|
+
valuelist = []
|
|
512
|
+
for v in value:
|
|
513
|
+
if not isinstance(v, pytype):
|
|
514
|
+
raise TypeError(
|
|
515
|
+
"Expected type %s.%s" % (
|
|
516
|
+
pytype.__module__, pytype.__name__))
|
|
517
|
+
valuelist.append(v)
|
|
518
|
+
|
|
519
|
+
start, stop, step = key.indices(len(self))
|
|
520
|
+
if step == 1:
|
|
521
|
+
_list_store_splice(
|
|
522
|
+
self, start, max(stop - start, 0), valuelist)
|
|
523
|
+
else:
|
|
524
|
+
indices = list(range(start, stop, step))
|
|
525
|
+
if len(indices) != len(valuelist):
|
|
526
|
+
raise ValueError
|
|
527
|
+
|
|
528
|
+
if step == -1:
|
|
529
|
+
_list_store_splice(
|
|
530
|
+
self, stop + 1, max(start - stop, 0), valuelist[::-1])
|
|
531
|
+
else:
|
|
532
|
+
for i, v in zip(indices, valuelist):
|
|
533
|
+
_list_store_splice(self, i, 1, [v])
|
|
534
|
+
elif isinstance(key, int):
|
|
535
|
+
if key < 0:
|
|
536
|
+
key += len(self)
|
|
537
|
+
if key < 0 or key >= len(self):
|
|
538
|
+
raise IndexError
|
|
539
|
+
|
|
540
|
+
pytype = self.get_item_type().pytype
|
|
541
|
+
if not isinstance(value, pytype):
|
|
542
|
+
raise TypeError(
|
|
543
|
+
"Expected type %s.%s" % (
|
|
544
|
+
pytype.__module__, pytype.__name__))
|
|
545
|
+
|
|
546
|
+
_list_store_splice(self, key, 1, [value])
|
|
547
|
+
else:
|
|
548
|
+
raise TypeError
|
|
549
|
+
|
|
550
|
+
def find_with_equal_func(self, item, equal_func, *user_data):
|
|
551
|
+
# find_with_equal_func() is not suited for language bindings,
|
|
552
|
+
# see: https://gitlab.gnome.org/GNOME/glib/-/issues/2447.
|
|
553
|
+
# Use find_with_equal_func_full() instead.
|
|
554
|
+
equal_func = wrap_list_store_equal_func(equal_func)
|
|
555
|
+
return self.find_with_equal_func_full(item, equal_func, *user_data)
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
ListStore = override(ListStore)
|
|
559
|
+
__all__.append('ListStore')
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
class DataInputStream(Gio.DataInputStream):
|
|
563
|
+
|
|
564
|
+
def __iter__(self):
|
|
565
|
+
return self
|
|
566
|
+
|
|
567
|
+
def __next__(self):
|
|
568
|
+
line = self.read_line_utf8(None)[0]
|
|
569
|
+
|
|
570
|
+
if line is not None:
|
|
571
|
+
return line
|
|
572
|
+
else:
|
|
573
|
+
raise StopIteration
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
DataInputStream = override(DataInputStream)
|
|
577
|
+
__all__.append('DataInputStream')
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
class File(Gio.File):
|
|
581
|
+
|
|
582
|
+
def __fspath__(self):
|
|
583
|
+
path = self.peek_path()
|
|
584
|
+
# A file isn't guaranteed to have a path associated and returning
|
|
585
|
+
# `None` here will result in a `TypeError` trying to subscribe to it.
|
|
586
|
+
if path is None or path == '':
|
|
587
|
+
raise TypeError('File has no associated path.')
|
|
588
|
+
return path
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
File = override(File)
|
|
592
|
+
__all__.append("File")
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
GioPlatform = None
|
|
596
|
+
|
|
597
|
+
with suppress(ImportError):
|
|
598
|
+
from gi.repository import GioUnix as GioPlatform
|
|
599
|
+
|
|
600
|
+
if not GioPlatform:
|
|
601
|
+
with suppress(ImportError):
|
|
602
|
+
from gi.repository import GioWin32 as GioPlatform
|
|
603
|
+
|
|
604
|
+
if GioPlatform:
|
|
605
|
+
# Add support for using platform-specific Gio symbols.
|
|
606
|
+
gio_globals = globals()
|
|
607
|
+
|
|
608
|
+
platform_name = f"{GioPlatform._namespace[len(Gio._namespace):]}"
|
|
609
|
+
platform_name_lower = platform_name.lower()
|
|
610
|
+
|
|
611
|
+
for attr in dir(GioPlatform):
|
|
612
|
+
if attr.startswith("_"):
|
|
613
|
+
continue
|
|
614
|
+
|
|
615
|
+
original_attr = getattr(GioPlatform, attr)
|
|
616
|
+
wrapper_attr = attr
|
|
617
|
+
|
|
618
|
+
if isinstance(
|
|
619
|
+
original_attr, CallableInfo
|
|
620
|
+
) and original_attr.get_symbol().startswith(f"g_{platform_name_lower}_"):
|
|
621
|
+
wrapper_attr = f"{platform_name_lower}_{attr}"
|
|
622
|
+
else:
|
|
623
|
+
try:
|
|
624
|
+
gtype = getattr(original_attr, "__gtype__")
|
|
625
|
+
if gtype.name.startswith(f"G{platform_name}"):
|
|
626
|
+
wrapper_attr = f"{platform_name}{attr}"
|
|
627
|
+
except AttributeError:
|
|
628
|
+
pass
|
|
629
|
+
|
|
630
|
+
if wrapper_attr == attr and hasattr(Gio, wrapper_attr):
|
|
631
|
+
try:
|
|
632
|
+
name = original_attr.__name__[0]
|
|
633
|
+
except (AttributeError, IndexError):
|
|
634
|
+
name = original_attr
|
|
635
|
+
|
|
636
|
+
# Fallback if we don't have the original name.
|
|
637
|
+
if name.islower():
|
|
638
|
+
wrapper_attr = f"{platform_name_lower}_{attr}"
|
|
639
|
+
elif "_" in name:
|
|
640
|
+
wrapper_attr = f"{platform_name.upper()}_{attr}"
|
|
641
|
+
elif name:
|
|
642
|
+
wrapper_attr = f"{platform_name}{attr}"
|
|
643
|
+
|
|
644
|
+
if (
|
|
645
|
+
wrapper_attr in __all__ or
|
|
646
|
+
wrapper_attr in gio_globals or
|
|
647
|
+
hasattr(Gio, wrapper_attr)
|
|
648
|
+
):
|
|
649
|
+
continue
|
|
650
|
+
|
|
651
|
+
gio_globals[wrapper_attr] = original_attr
|
|
652
|
+
deprecated_attr(
|
|
653
|
+
Gio._namespace, wrapper_attr, f"{GioPlatform._namespace}.{attr}"
|
|
654
|
+
)
|
|
655
|
+
__all__.append(wrapper_attr)
|