gstreamer-python 1.27.90__cp313-cp313-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.
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-win32.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-win32.pyd +0 -0
  18. gstreamer_python/Lib/site-packages/gi/_gi_cairo.cp313-win32.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-win32.pyd +0 -0
  45. gstreamer_python/Lib/site-packages/gi/overrides/_gi_gst_analytics.cp313-win32.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,1707 @@
1
+ # -*- Mode: Python; py-indent-offset: 4 -*-
2
+ # vim: tabstop=4 shiftwidth=4 expandtab
3
+ #
4
+ # Copyright (C) 2009 Johan Dahlin <johan@gnome.org>
5
+ # 2010 Simon van der Linden <svdlinden@src.gnome.org>
6
+ #
7
+ # This library is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation; either
10
+ # version 2.1 of the License, or (at your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ # Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public
18
+ # License along with this library; if not, write to the Free Software
19
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20
+ # USA
21
+
22
+ import sys
23
+ import warnings
24
+
25
+ from gi.repository import GObject, GLib
26
+ from .._ossighelper import register_sigint_fallback, get_event_loop
27
+ from .._gtktemplate import Template, _extract_handler_and_args
28
+ from ..overrides import (override, strip_boolean_result, deprecated_init,
29
+ wrap_list_store_sort_func)
30
+ from ..module import get_introspection_module
31
+ from gi import PyGIDeprecationWarning
32
+
33
+
34
+ Gtk = get_introspection_module('Gtk')
35
+ GTK3 = Gtk._version == '3.0'
36
+ GTK4 = Gtk._version == '4.0'
37
+
38
+ __all__ = []
39
+
40
+
41
+ Template = Template
42
+ __all__.append('Template')
43
+
44
+ # Exposed for unit-testing.
45
+ _extract_handler_and_args = _extract_handler_and_args
46
+ __all__.append('_extract_handler_and_args')
47
+
48
+
49
+ class PyGTKDeprecationWarning(PyGIDeprecationWarning):
50
+ pass
51
+
52
+
53
+ __all__.append('PyGTKDeprecationWarning')
54
+
55
+
56
+ if GTK3:
57
+ def _construct_target_list(targets):
58
+ """Create a list of TargetEntry items from a list of tuples in the form (target, flags, info)
59
+
60
+ The list can also contain existing TargetEntry items in which case the existing entry
61
+ is re-used in the return list.
62
+ """
63
+ target_entries = []
64
+ for entry in targets:
65
+ if not isinstance(entry, Gtk.TargetEntry):
66
+ entry = Gtk.TargetEntry.new(*entry)
67
+ target_entries.append(entry)
68
+ return target_entries
69
+
70
+ __all__.append('_construct_target_list')
71
+
72
+
73
+ def _builder_connect_callback(builder, gobj, signal_name, handler_name, connect_obj, flags, obj_or_map):
74
+ handler, args = _extract_handler_and_args(obj_or_map, handler_name)
75
+
76
+ after = flags & GObject.ConnectFlags.AFTER
77
+ if connect_obj is not None:
78
+ if after:
79
+ gobj.connect_object_after(signal_name, handler, connect_obj, *args)
80
+ else:
81
+ gobj.connect_object(signal_name, handler, connect_obj, *args)
82
+ else:
83
+ if after:
84
+ gobj.connect_after(signal_name, handler, *args)
85
+ else:
86
+ gobj.connect(signal_name, handler, *args)
87
+
88
+
89
+ class _FreezeNotifyManager(object):
90
+ def __init__(self, obj):
91
+ self.obj = obj
92
+
93
+ def __enter__(self):
94
+ pass
95
+
96
+ def __exit__(self, exc_type, exc_value, traceback):
97
+ self.obj.thaw_child_notify()
98
+
99
+
100
+ class Widget(Gtk.Widget):
101
+
102
+ translate_coordinates = strip_boolean_result(Gtk.Widget.translate_coordinates)
103
+
104
+ if GTK4:
105
+ def __contains__(self, child):
106
+ return child in list(self)
107
+
108
+ def __iter__(self):
109
+ child = self.get_first_child()
110
+ while child:
111
+ yield child
112
+ child = child.get_next_sibling()
113
+
114
+ if GTK3:
115
+ def freeze_child_notify(self):
116
+ super(Widget, self).freeze_child_notify()
117
+ return _FreezeNotifyManager(self)
118
+
119
+ if GTK3:
120
+ def drag_dest_set_target_list(self, target_list):
121
+ if (target_list is not None) and (not isinstance(target_list, Gtk.TargetList)):
122
+ target_list = Gtk.TargetList.new(_construct_target_list(target_list))
123
+ super(Widget, self).drag_dest_set_target_list(target_list)
124
+
125
+ if GTK3:
126
+ def drag_source_set_target_list(self, target_list):
127
+ if (target_list is not None) and (not isinstance(target_list, Gtk.TargetList)):
128
+ target_list = Gtk.TargetList.new(_construct_target_list(target_list))
129
+ super(Widget, self).drag_source_set_target_list(target_list)
130
+
131
+ if GTK3:
132
+ def style_get_property(self, property_name, value=None):
133
+ if value is None:
134
+ prop = self.find_style_property(property_name)
135
+ if prop is None:
136
+ raise ValueError('Class "%s" does not contain style property "%s"' %
137
+ (self, property_name))
138
+ value = GObject.Value(prop.value_type)
139
+
140
+ Gtk.Widget.style_get_property(self, property_name, value)
141
+ return value.get_value()
142
+
143
+
144
+ Widget = override(Widget)
145
+ __all__.append('Widget')
146
+
147
+
148
+ if GTK3:
149
+ class Container(Gtk.Container, Widget):
150
+
151
+ def __len__(self):
152
+ return len(self.get_children())
153
+
154
+ def __contains__(self, child):
155
+ return child in self.get_children()
156
+
157
+ def __iter__(self):
158
+ return iter(self.get_children())
159
+
160
+ def __bool__(self):
161
+ return True
162
+
163
+ def child_get_property(self, child, property_name, value=None):
164
+ if value is None:
165
+ prop = self.find_child_property(property_name)
166
+ if prop is None:
167
+ raise ValueError('Class "%s" does not contain child property "%s"' %
168
+ (self, property_name))
169
+ value = GObject.Value(prop.value_type)
170
+
171
+ Gtk.Container.child_get_property(self, child, property_name, value)
172
+ return value.get_value()
173
+
174
+ def child_get(self, child, *prop_names):
175
+ """Returns a list of child property values for the given names."""
176
+ return [self.child_get_property(child, name) for name in prop_names]
177
+
178
+ def child_set(self, child, **kwargs):
179
+ """Set a child properties on the given child to key/value pairs."""
180
+ for name, value in kwargs.items():
181
+ name = name.replace('_', '-')
182
+ self.child_set_property(child, name, value)
183
+
184
+ get_focus_chain = strip_boolean_result(Gtk.Container.get_focus_chain)
185
+
186
+ Container = override(Container)
187
+ __all__.append('Container')
188
+ else:
189
+ Container = object
190
+
191
+
192
+ class Editable(Gtk.Editable):
193
+
194
+ def insert_text(self, text, position):
195
+ return super(Editable, self).insert_text(text, -1, position)
196
+
197
+ get_selection_bounds = strip_boolean_result(Gtk.Editable.get_selection_bounds, fail_ret=())
198
+
199
+
200
+ Editable = override(Editable)
201
+ __all__.append("Editable")
202
+
203
+
204
+ if GTK3:
205
+ class Action(Gtk.Action):
206
+ __init__ = deprecated_init(Gtk.Action.__init__,
207
+ arg_names=('name', 'label', 'tooltip', 'stock_id'),
208
+ category=PyGTKDeprecationWarning)
209
+
210
+ Action = override(Action)
211
+ __all__.append("Action")
212
+
213
+ class RadioAction(Gtk.RadioAction):
214
+ __init__ = deprecated_init(Gtk.RadioAction.__init__,
215
+ arg_names=('name', 'label', 'tooltip', 'stock_id', 'value'),
216
+ category=PyGTKDeprecationWarning)
217
+
218
+ RadioAction = override(RadioAction)
219
+ __all__.append("RadioAction")
220
+
221
+ class ActionGroup(Gtk.ActionGroup):
222
+ __init__ = deprecated_init(Gtk.ActionGroup.__init__,
223
+ arg_names=('name',),
224
+ category=PyGTKDeprecationWarning)
225
+
226
+ def add_actions(self, entries, user_data=None):
227
+ """
228
+ The add_actions() method is a convenience method that creates a number
229
+ of gtk.Action objects based on the information in the list of action
230
+ entry tuples contained in entries and adds them to the action group.
231
+ The entry tuples can vary in size from one to six items with the
232
+ following information:
233
+
234
+ * The name of the action. Must be specified.
235
+ * The stock id for the action. Optional with a default value of None
236
+ if a label is specified.
237
+ * The label for the action. This field should typically be marked
238
+ for translation, see the set_translation_domain() method. Optional
239
+ with a default value of None if a stock id is specified.
240
+ * The accelerator for the action, in the format understood by the
241
+ gtk.accelerator_parse() function. Optional with a default value of
242
+ None.
243
+ * The tooltip for the action. This field should typically be marked
244
+ for translation, see the set_translation_domain() method. Optional
245
+ with a default value of None.
246
+ * The callback function invoked when the action is activated.
247
+ Optional with a default value of None.
248
+
249
+ The "activate" signals of the actions are connected to the callbacks and
250
+ their accel paths are set to <Actions>/group-name/action-name.
251
+ """
252
+ try:
253
+ iter(entries)
254
+ except (TypeError):
255
+ raise TypeError('entries must be iterable')
256
+
257
+ def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None):
258
+ action = Action(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
259
+ if callback is not None:
260
+ if user_data is None:
261
+ action.connect('activate', callback)
262
+ else:
263
+ action.connect('activate', callback, user_data)
264
+
265
+ self.add_action_with_accel(action, accelerator)
266
+
267
+ for e in entries:
268
+ # using inner function above since entries can leave out optional arguments
269
+ _process_action(*e)
270
+
271
+ def add_toggle_actions(self, entries, user_data=None):
272
+ """
273
+ The add_toggle_actions() method is a convenience method that creates a
274
+ number of gtk.ToggleAction objects based on the information in the list
275
+ of action entry tuples contained in entries and adds them to the action
276
+ group. The toggle action entry tuples can vary in size from one to seven
277
+ items with the following information:
278
+
279
+ * The name of the action. Must be specified.
280
+ * The stock id for the action. Optional with a default value of None
281
+ if a label is specified.
282
+ * The label for the action. This field should typically be marked
283
+ for translation, see the set_translation_domain() method. Optional
284
+ with a default value of None if a stock id is specified.
285
+ * The accelerator for the action, in the format understood by the
286
+ gtk.accelerator_parse() function. Optional with a default value of
287
+ None.
288
+ * The tooltip for the action. This field should typically be marked
289
+ for translation, see the set_translation_domain() method. Optional
290
+ with a default value of None.
291
+ * The callback function invoked when the action is activated.
292
+ Optional with a default value of None.
293
+ * A flag indicating whether the toggle action is active. Optional
294
+ with a default value of False.
295
+
296
+ The "activate" signals of the actions are connected to the callbacks and
297
+ their accel paths are set to <Actions>/group-name/action-name.
298
+ """
299
+
300
+ try:
301
+ iter(entries)
302
+ except (TypeError):
303
+ raise TypeError('entries must be iterable')
304
+
305
+ def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None, is_active=False):
306
+ action = Gtk.ToggleAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
307
+ action.set_active(is_active)
308
+ if callback is not None:
309
+ if user_data is None:
310
+ action.connect('activate', callback)
311
+ else:
312
+ action.connect('activate', callback, user_data)
313
+
314
+ self.add_action_with_accel(action, accelerator)
315
+
316
+ for e in entries:
317
+ # using inner function above since entries can leave out optional arguments
318
+ _process_action(*e)
319
+
320
+ def add_radio_actions(self, entries, value=None, on_change=None, user_data=None):
321
+ """
322
+ The add_radio_actions() method is a convenience method that creates a
323
+ number of gtk.RadioAction objects based on the information in the list
324
+ of action entry tuples contained in entries and adds them to the action
325
+ group. The entry tuples can vary in size from one to six items with the
326
+ following information:
327
+
328
+ * The name of the action. Must be specified.
329
+ * The stock id for the action. Optional with a default value of None
330
+ if a label is specified.
331
+ * The label for the action. This field should typically be marked
332
+ for translation, see the set_translation_domain() method. Optional
333
+ with a default value of None if a stock id is specified.
334
+ * The accelerator for the action, in the format understood by the
335
+ gtk.accelerator_parse() function. Optional with a default value of
336
+ None.
337
+ * The tooltip for the action. This field should typically be marked
338
+ for translation, see the set_translation_domain() method. Optional
339
+ with a default value of None.
340
+ * The value to set on the radio action. Optional with a default
341
+ value of 0. Should be specified in applications.
342
+
343
+ The value parameter specifies the radio action that should be set
344
+ active. The "changed" signal of the first radio action is connected to
345
+ the on_change callback (if specified and not None) and the accel paths
346
+ of the actions are set to <Actions>/group-name/action-name.
347
+ """
348
+ try:
349
+ iter(entries)
350
+ except (TypeError):
351
+ raise TypeError('entries must be iterable')
352
+
353
+ first_action = None
354
+
355
+ def _process_action(group_source, name, stock_id=None, label=None, accelerator=None, tooltip=None, entry_value=0):
356
+ action = RadioAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id, value=entry_value)
357
+
358
+ if GTK3:
359
+ action.join_group(group_source)
360
+
361
+ if value == entry_value:
362
+ action.set_active(True)
363
+
364
+ self.add_action_with_accel(action, accelerator)
365
+ return action
366
+
367
+ for e in entries:
368
+ # using inner function above since entries can leave out optional arguments
369
+ action = _process_action(first_action, *e)
370
+ if first_action is None:
371
+ first_action = action
372
+
373
+ if first_action is not None and on_change is not None:
374
+ if user_data is None:
375
+ first_action.connect('changed', on_change)
376
+ else:
377
+ first_action.connect('changed', on_change, user_data)
378
+
379
+ ActionGroup = override(ActionGroup)
380
+ __all__.append('ActionGroup')
381
+
382
+ class UIManager(Gtk.UIManager):
383
+ def add_ui_from_string(self, buffer):
384
+ if not isinstance(buffer, str):
385
+ raise TypeError('buffer must be a string')
386
+
387
+ length = _get_utf8_length(buffer)
388
+
389
+ return Gtk.UIManager.add_ui_from_string(self, buffer, length)
390
+
391
+ def insert_action_group(self, buffer, length=-1):
392
+ return Gtk.UIManager.insert_action_group(self, buffer, length)
393
+
394
+ UIManager = override(UIManager)
395
+ __all__.append('UIManager')
396
+
397
+
398
+ class ComboBox(Gtk.ComboBox, Container):
399
+ get_active_iter = strip_boolean_result(Gtk.ComboBox.get_active_iter)
400
+
401
+
402
+ ComboBox = override(ComboBox)
403
+ __all__.append('ComboBox')
404
+
405
+
406
+ if GTK3:
407
+ class Box(Gtk.Box):
408
+ __init__ = deprecated_init(Gtk.Box.__init__,
409
+ arg_names=('homogeneous', 'spacing'),
410
+ category=PyGTKDeprecationWarning)
411
+
412
+ Box = override(Box)
413
+ __all__.append('Box')
414
+
415
+
416
+ if GTK3:
417
+ class SizeGroup(Gtk.SizeGroup):
418
+ __init__ = deprecated_init(Gtk.SizeGroup.__init__,
419
+ arg_names=('mode',),
420
+ deprecated_defaults={'mode': Gtk.SizeGroupMode.VERTICAL},
421
+ category=PyGTKDeprecationWarning)
422
+
423
+ SizeGroup = override(SizeGroup)
424
+ __all__.append('SizeGroup')
425
+
426
+
427
+ if GTK3:
428
+ class MenuItem(Gtk.MenuItem):
429
+ __init__ = deprecated_init(Gtk.MenuItem.__init__,
430
+ arg_names=('label',),
431
+ category=PyGTKDeprecationWarning)
432
+
433
+ MenuItem = override(MenuItem)
434
+ __all__.append('MenuItem')
435
+
436
+
437
+ def _get_utf8_length(string):
438
+ assert isinstance(string, str)
439
+ if not isinstance(string, bytes):
440
+ string = string.encode("utf-8")
441
+ return len(string)
442
+
443
+
444
+ class Builder(Gtk.Builder):
445
+ if GTK4:
446
+ from .._gtktemplate import define_builder_scope
447
+ BuilderScope = define_builder_scope()
448
+
449
+ def __init__(self, scope_object_or_map=None):
450
+ super(Builder, self).__init__()
451
+ if scope_object_or_map:
452
+ self.set_scope(Builder.BuilderScope(scope_object_or_map))
453
+
454
+ else:
455
+ def connect_signals(self, obj_or_map):
456
+ """Connect signals specified by this builder to a name, handler mapping.
457
+
458
+ Connect signal, name, and handler sets specified in the builder with
459
+ the given mapping "obj_or_map". The handler/value aspect of the mapping
460
+ can also contain a tuple in the form of (handler [,arg1 [,argN]])
461
+ allowing for extra arguments to be passed to the handler. For example:
462
+
463
+ .. code-block:: python
464
+
465
+ builder.connect_signals({'on_clicked': (on_clicked, arg1, arg2)})
466
+ """
467
+ self.connect_signals_full(_builder_connect_callback, obj_or_map)
468
+
469
+ def add_from_string(self, buffer):
470
+ if not isinstance(buffer, str):
471
+ raise TypeError('buffer must be a string')
472
+
473
+ length = _get_utf8_length(buffer)
474
+
475
+ return Gtk.Builder.add_from_string(self, buffer, length)
476
+
477
+ def add_objects_from_string(self, buffer, object_ids):
478
+ if not isinstance(buffer, str):
479
+ raise TypeError('buffer must be a string')
480
+
481
+ length = _get_utf8_length(buffer)
482
+
483
+ return Gtk.Builder.add_objects_from_string(self, buffer, length, object_ids)
484
+
485
+
486
+ Builder = override(Builder)
487
+ __all__.append('Builder')
488
+
489
+
490
+ # NOTE: This must come before any other Window/Dialog subclassing, to ensure
491
+ # that we have a correct inheritance hierarchy.
492
+
493
+ if GTK4:
494
+ _window_init = Gtk.Window.__init__
495
+ else:
496
+ _window_init = deprecated_init(Gtk.Window.__init__,
497
+ arg_names=('type',),
498
+ category=PyGTKDeprecationWarning,
499
+ stacklevel=3)
500
+
501
+
502
+ class Window(Gtk.Window):
503
+ def __init__(self, *args, **kwargs):
504
+ if not initialized:
505
+ raise RuntimeError(
506
+ "Gtk couldn't be initialized. "
507
+ "Use Gtk.init_check() if you want to handle this case.")
508
+ _window_init(self, *args, **kwargs)
509
+
510
+
511
+ Window = override(Window)
512
+ __all__.append('Window')
513
+
514
+
515
+ class Dialog(Gtk.Dialog, Container):
516
+ if GTK3:
517
+ _old_arg_names = ('title', 'parent', 'flags', 'buttons', '_buttons_property')
518
+ _init = deprecated_init(Gtk.Dialog.__init__,
519
+ arg_names=('title', 'transient_for', 'flags',
520
+ 'add_buttons', 'buttons'),
521
+ ignore=('flags', 'add_buttons'),
522
+ deprecated_aliases={'transient_for': 'parent',
523
+ 'buttons': '_buttons_property'},
524
+ category=PyGTKDeprecationWarning)
525
+
526
+ def __init__(self, *args, **kwargs):
527
+
528
+ new_kwargs = kwargs.copy()
529
+ old_kwargs = dict(zip(self._old_arg_names, args))
530
+ old_kwargs.update(kwargs)
531
+
532
+ # Increment the warning stacklevel for sub-classes which implement their own __init__.
533
+ stacklevel = 2
534
+ if self.__class__ != Dialog and self.__class__.__init__ != Dialog.__init__:
535
+ stacklevel += 1
536
+
537
+ # buttons was overloaded by PyGtk but is needed for Gtk.MessageDialog
538
+ # as a pass through, so type check the argument and give a deprecation
539
+ # when it is not of type Gtk.ButtonsType
540
+ add_buttons = old_kwargs.get('buttons', None)
541
+ if add_buttons is not None and not isinstance(add_buttons, Gtk.ButtonsType):
542
+ warnings.warn('The "buttons" argument must be a Gtk.ButtonsType enum value. '
543
+ 'Please use the "add_buttons" method for adding buttons. '
544
+ 'See: https://wiki.gnome.org/PyGObject/InitializerDeprecations',
545
+ PyGTKDeprecationWarning, stacklevel=stacklevel)
546
+ new_kwargs.pop('buttons', None)
547
+ else:
548
+ add_buttons = None
549
+
550
+ flags = old_kwargs.get('flags', 0)
551
+ if flags:
552
+ warnings.warn('The "flags" argument for dialog construction is deprecated. '
553
+ 'Please use initializer keywords: modal=True and/or destroy_with_parent=True. '
554
+ 'See: https://wiki.gnome.org/PyGObject/InitializerDeprecations',
555
+ PyGTKDeprecationWarning, stacklevel=stacklevel)
556
+
557
+ if flags & Gtk.DialogFlags.MODAL:
558
+ new_kwargs['modal'] = True
559
+
560
+ if flags & Gtk.DialogFlags.DESTROY_WITH_PARENT:
561
+ new_kwargs['destroy_with_parent'] = True
562
+
563
+ self._init(*args, **new_kwargs)
564
+
565
+ if add_buttons:
566
+ self.add_buttons(*add_buttons)
567
+
568
+ def run(self, *args, **kwargs):
569
+ with register_sigint_fallback(self.destroy):
570
+ with get_event_loop(GLib.MainContext.default()).running(self.destroy):
571
+ return Gtk.Dialog.run(self, *args, **kwargs)
572
+
573
+ action_area = property(lambda dialog: dialog.get_action_area())
574
+ vbox = property(lambda dialog: dialog.get_content_area())
575
+
576
+ def add_buttons(self, *args):
577
+ """
578
+ The add_buttons() method adds several buttons to the Gtk.Dialog using
579
+ the button data passed as arguments to the method. This method is the
580
+ same as calling the Gtk.Dialog.add_button() repeatedly. The button data
581
+ pairs - button text (or stock ID) and a response ID integer are passed
582
+ individually. For example:
583
+
584
+ .. code-block:: python
585
+
586
+ dialog.add_buttons(Gtk.STOCK_OPEN, 42, "Close", Gtk.ResponseType.CLOSE)
587
+
588
+ will add "Open" and "Close" buttons to dialog.
589
+ """
590
+ def _button(b):
591
+ while b:
592
+ try:
593
+ t, r = b[0:2]
594
+ except ValueError:
595
+ raise ValueError('Must pass an even number of arguments')
596
+ b = b[2:]
597
+ yield t, r
598
+
599
+ for text, response in _button(args):
600
+ self.add_button(text, response)
601
+
602
+
603
+ Dialog = override(Dialog)
604
+ __all__.append('Dialog')
605
+
606
+
607
+ if GTK3:
608
+ class MessageDialog(Gtk.MessageDialog, Dialog):
609
+ __init__ = deprecated_init(Gtk.MessageDialog.__init__,
610
+ arg_names=('parent', 'flags', 'message_type',
611
+ 'buttons', 'message_format'),
612
+ deprecated_aliases={'text': 'message_format',
613
+ 'message_type': 'type'},
614
+ category=PyGTKDeprecationWarning)
615
+
616
+ def format_secondary_text(self, message_format):
617
+ self.set_property('secondary-use-markup', False)
618
+ self.set_property('secondary-text', message_format)
619
+
620
+ def format_secondary_markup(self, message_format):
621
+ self.set_property('secondary-use-markup', True)
622
+ self.set_property('secondary-text', message_format)
623
+
624
+ MessageDialog = override(MessageDialog)
625
+ __all__.append('MessageDialog')
626
+
627
+
628
+ if GTK3:
629
+ class ColorSelectionDialog(Gtk.ColorSelectionDialog):
630
+ __init__ = deprecated_init(Gtk.ColorSelectionDialog.__init__,
631
+ arg_names=('title',),
632
+ category=PyGTKDeprecationWarning)
633
+
634
+ ColorSelectionDialog = override(ColorSelectionDialog)
635
+ __all__.append('ColorSelectionDialog')
636
+
637
+ class FileChooserDialog(Gtk.FileChooserDialog):
638
+ __init__ = deprecated_init(Gtk.FileChooserDialog.__init__,
639
+ arg_names=('title', 'parent', 'action', 'buttons'),
640
+ category=PyGTKDeprecationWarning)
641
+
642
+ FileChooserDialog = override(FileChooserDialog)
643
+ __all__.append('FileChooserDialog')
644
+
645
+
646
+ if GTK3:
647
+ class FontSelectionDialog(Gtk.FontSelectionDialog):
648
+ __init__ = deprecated_init(Gtk.FontSelectionDialog.__init__,
649
+ arg_names=('title',),
650
+ category=PyGTKDeprecationWarning)
651
+
652
+ FontSelectionDialog = override(FontSelectionDialog)
653
+ __all__.append('FontSelectionDialog')
654
+
655
+
656
+ if GTK3:
657
+ class RecentChooserDialog(Gtk.RecentChooserDialog):
658
+ # Note, the "manager" keyword must work across the entire 3.x series because
659
+ # "recent_manager" is not backwards compatible with PyGObject versions prior to 3.10.
660
+ __init__ = deprecated_init(Gtk.RecentChooserDialog.__init__,
661
+ arg_names=('title', 'parent', 'recent_manager', 'buttons'),
662
+ deprecated_aliases={'recent_manager': 'manager'},
663
+ category=PyGTKDeprecationWarning)
664
+
665
+ RecentChooserDialog = override(RecentChooserDialog)
666
+ __all__.append('RecentChooserDialog')
667
+
668
+
669
+ class IconView(Gtk.IconView):
670
+ if GTK3:
671
+ __init__ = deprecated_init(Gtk.IconView.__init__,
672
+ arg_names=('model',),
673
+ category=PyGTKDeprecationWarning)
674
+
675
+ get_item_at_pos = strip_boolean_result(Gtk.IconView.get_item_at_pos)
676
+ get_visible_range = strip_boolean_result(Gtk.IconView.get_visible_range)
677
+ get_dest_item_at_pos = strip_boolean_result(Gtk.IconView.get_dest_item_at_pos)
678
+
679
+
680
+ IconView = override(IconView)
681
+ __all__.append('IconView')
682
+
683
+
684
+ if GTK3:
685
+ class ToolButton(Gtk.ToolButton):
686
+ __init__ = deprecated_init(Gtk.ToolButton.__init__,
687
+ arg_names=('stock_id',),
688
+ category=PyGTKDeprecationWarning)
689
+
690
+ ToolButton = override(ToolButton)
691
+ __all__.append('ToolButton')
692
+
693
+
694
+ class IMContext(Gtk.IMContext):
695
+ get_surrounding = strip_boolean_result(Gtk.IMContext.get_surrounding)
696
+
697
+
698
+ IMContext = override(IMContext)
699
+ __all__.append('IMContext')
700
+
701
+
702
+ class RecentInfo(Gtk.RecentInfo):
703
+ get_application_info = strip_boolean_result(Gtk.RecentInfo.get_application_info)
704
+
705
+
706
+ RecentInfo = override(RecentInfo)
707
+ __all__.append('RecentInfo')
708
+
709
+
710
+ class TextBuffer(Gtk.TextBuffer):
711
+
712
+ def create_tag(self, tag_name=None, **properties):
713
+ """Creates a tag and adds it to the tag table of the TextBuffer.
714
+
715
+ :param str tag_name:
716
+ Name of the new tag, or None
717
+ :param **properties:
718
+ Keyword list of properties and their values
719
+
720
+ This is equivalent to creating a Gtk.TextTag and then adding the
721
+ tag to the buffer's tag table. The returned tag is owned by
722
+ the buffer's tag table.
723
+
724
+ If ``tag_name`` is None, the tag is anonymous.
725
+
726
+ If ``tag_name`` is not None, a tag called ``tag_name`` must not already
727
+ exist in the tag table for this buffer.
728
+
729
+ Properties are passed as a keyword list of names and values (e.g.
730
+ foreground='DodgerBlue', weight=Pango.Weight.BOLD)
731
+
732
+ :returns:
733
+ A new tag.
734
+ """
735
+
736
+ tag = Gtk.TextTag(name=tag_name, **properties)
737
+ self.get_tag_table().add(tag)
738
+ return tag
739
+
740
+ def create_mark(self, mark_name, where, left_gravity=False):
741
+ return Gtk.TextBuffer.create_mark(self, mark_name, where, left_gravity)
742
+
743
+ def set_text(self, text, length=-1):
744
+ Gtk.TextBuffer.set_text(self, text, length)
745
+
746
+ def insert(self, iter, text, length=-1):
747
+ if not isinstance(text, str):
748
+ raise TypeError('text must be a string, not %s' % type(text))
749
+
750
+ Gtk.TextBuffer.insert(self, iter, text, length)
751
+
752
+ def insert_with_tags(self, iter, text, *tags):
753
+ start_offset = iter.get_offset()
754
+ self.insert(iter, text)
755
+
756
+ if not tags:
757
+ return
758
+
759
+ start = self.get_iter_at_offset(start_offset)
760
+
761
+ for tag in tags:
762
+ self.apply_tag(tag, start, iter)
763
+
764
+ def insert_with_tags_by_name(self, iter, text, *tags):
765
+ tag_objs = []
766
+
767
+ for tag in tags:
768
+ tag_obj = self.get_tag_table().lookup(tag)
769
+ if not tag_obj:
770
+ raise ValueError('unknown text tag: %s' % tag)
771
+ tag_objs.append(tag_obj)
772
+
773
+ self.insert_with_tags(iter, text, *tag_objs)
774
+
775
+ def insert_at_cursor(self, text, length=-1):
776
+ if not isinstance(text, str):
777
+ raise TypeError('text must be a string, not %s' % type(text))
778
+
779
+ Gtk.TextBuffer.insert_at_cursor(self, text, length)
780
+
781
+ get_selection_bounds = strip_boolean_result(Gtk.TextBuffer.get_selection_bounds, fail_ret=())
782
+
783
+
784
+ TextBuffer = override(TextBuffer)
785
+ __all__.append('TextBuffer')
786
+
787
+
788
+ class TextIter(Gtk.TextIter):
789
+ forward_search = strip_boolean_result(Gtk.TextIter.forward_search)
790
+ backward_search = strip_boolean_result(Gtk.TextIter.backward_search)
791
+
792
+
793
+ TextIter = override(TextIter)
794
+ __all__.append('TextIter')
795
+
796
+
797
+ class TreeModel(Gtk.TreeModel):
798
+ def __len__(self):
799
+ return self.iter_n_children(None)
800
+
801
+ def __bool__(self):
802
+ return True
803
+
804
+ def _getiter(self, key):
805
+ if isinstance(key, Gtk.TreeIter):
806
+ return key
807
+ elif isinstance(key, int) and key < 0:
808
+ index = len(self) + key
809
+ if index < 0:
810
+ raise IndexError("row index is out of bounds: %d" % key)
811
+ return self.get_iter(index)
812
+ else:
813
+ try:
814
+ aiter = self.get_iter(key)
815
+ except ValueError:
816
+ raise IndexError("could not find tree path '%s'" % key)
817
+ return aiter
818
+
819
+ def sort_new_with_model(self):
820
+ super_object = super(TreeModel, self)
821
+ if hasattr(super_object, "sort_new_with_model"):
822
+ return super_object.sort_new_with_model()
823
+ else:
824
+ return TreeModelSort.new_with_model(self)
825
+
826
+ def _coerce_path(self, path):
827
+ if isinstance(path, Gtk.TreePath):
828
+ return path
829
+ else:
830
+ return TreePath(path)
831
+
832
+ def __getitem__(self, key):
833
+ aiter = self._getiter(key)
834
+ return TreeModelRow(self, aiter)
835
+
836
+ def __setitem__(self, key, value):
837
+ row = self[key]
838
+ self.set_row(row.iter, value)
839
+
840
+ def __delitem__(self, key):
841
+ aiter = self._getiter(key)
842
+ self.remove(aiter)
843
+
844
+ def __iter__(self):
845
+ return TreeModelRowIter(self, self.get_iter_first())
846
+
847
+ get_iter_first = strip_boolean_result(Gtk.TreeModel.get_iter_first)
848
+ iter_children = strip_boolean_result(Gtk.TreeModel.iter_children)
849
+ iter_nth_child = strip_boolean_result(Gtk.TreeModel.iter_nth_child)
850
+ iter_parent = strip_boolean_result(Gtk.TreeModel.iter_parent)
851
+ get_iter_from_string = strip_boolean_result(Gtk.TreeModel.get_iter_from_string,
852
+ ValueError, 'invalid tree path')
853
+
854
+ def get_iter(self, path):
855
+ path = self._coerce_path(path)
856
+ success, aiter = super(TreeModel, self).get_iter(path)
857
+ if not success:
858
+ raise ValueError("invalid tree path '%s'" % path)
859
+ return aiter
860
+
861
+ def iter_next(self, aiter):
862
+ next_iter = aiter.copy()
863
+ success = super(TreeModel, self).iter_next(next_iter)
864
+ if success:
865
+ return next_iter
866
+
867
+ def iter_previous(self, aiter):
868
+ prev_iter = aiter.copy()
869
+ success = super(TreeModel, self).iter_previous(prev_iter)
870
+ if success:
871
+ return prev_iter
872
+
873
+ def _convert_row(self, row):
874
+ # TODO: Accept a dictionary for row
875
+ # model.append(None,{COLUMN_ICON: icon, COLUMN_NAME: name})
876
+ if isinstance(row, str):
877
+ raise TypeError('Expected a list or tuple, but got str')
878
+
879
+ n_columns = self.get_n_columns()
880
+ if len(row) != n_columns:
881
+ raise ValueError('row sequence has the incorrect number of elements')
882
+
883
+ result = []
884
+ columns = []
885
+ for cur_col, value in enumerate(row):
886
+ # do not try to set None values, they are causing warnings
887
+ if value is None:
888
+ continue
889
+ result.append(self._convert_value(cur_col, value))
890
+ columns.append(cur_col)
891
+ return (result, columns)
892
+
893
+ def set_row(self, treeiter, row):
894
+ converted_row, columns = self._convert_row(row)
895
+ for column in columns:
896
+ self.set_value(treeiter, column, row[column])
897
+
898
+ def _convert_value(self, column, value):
899
+ '''Convert value to a GObject.Value of the expected type'''
900
+
901
+ if isinstance(value, GObject.Value):
902
+ return value
903
+ return GObject.Value(self.get_column_type(column), value)
904
+
905
+ def get(self, treeiter, *columns):
906
+ n_columns = self.get_n_columns()
907
+
908
+ values = []
909
+ for col in columns:
910
+ if not isinstance(col, int):
911
+ raise TypeError("column numbers must be ints")
912
+
913
+ if col < 0 or col >= n_columns:
914
+ raise ValueError("column number is out of range")
915
+
916
+ values.append(self.get_value(treeiter, col))
917
+
918
+ return tuple(values)
919
+
920
+ #
921
+ # Signals supporting python iterables as tree paths
922
+ #
923
+ def row_changed(self, path, iter):
924
+ return super(TreeModel, self).row_changed(self._coerce_path(path), iter)
925
+
926
+ def row_inserted(self, path, iter):
927
+ return super(TreeModel, self).row_inserted(self._coerce_path(path), iter)
928
+
929
+ def row_has_child_toggled(self, path, iter):
930
+ return super(TreeModel, self).row_has_child_toggled(self._coerce_path(path),
931
+ iter)
932
+
933
+ def row_deleted(self, path):
934
+ return super(TreeModel, self).row_deleted(self._coerce_path(path))
935
+
936
+ def rows_reordered(self, path, iter, new_order):
937
+ return super(TreeModel, self).rows_reordered(self._coerce_path(path),
938
+ iter, new_order)
939
+
940
+
941
+ TreeModel = override(TreeModel)
942
+ __all__.append('TreeModel')
943
+
944
+
945
+ class TreeSortable(Gtk.TreeSortable, ):
946
+
947
+ get_sort_column_id = strip_boolean_result(Gtk.TreeSortable.get_sort_column_id, fail_ret=(None, None))
948
+
949
+ def set_sort_func(self, sort_column_id, sort_func, user_data=None):
950
+ super(TreeSortable, self).set_sort_func(sort_column_id, sort_func, user_data)
951
+
952
+ def set_default_sort_func(self, sort_func, user_data=None):
953
+ super(TreeSortable, self).set_default_sort_func(sort_func, user_data)
954
+
955
+
956
+ TreeSortable = override(TreeSortable)
957
+ __all__.append('TreeSortable')
958
+
959
+
960
+ if GTK3:
961
+ class TreeModelSort(Gtk.TreeModelSort):
962
+ __init__ = deprecated_init(Gtk.TreeModelSort.__init__,
963
+ arg_names=('model',),
964
+ category=PyGTKDeprecationWarning)
965
+
966
+ if not hasattr(Gtk.TreeModelSort, "new_with_model"):
967
+ @classmethod
968
+ def new_with_model(self, child_model):
969
+ return TreeModel.sort_new_with_model(child_model)
970
+
971
+ TreeModelSort = override(TreeModelSort)
972
+ __all__.append('TreeModelSort')
973
+
974
+
975
+ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
976
+ def __init__(self, *column_types):
977
+ Gtk.ListStore.__init__(self)
978
+ self.set_column_types(column_types)
979
+
980
+ # insert_with_valuesv got renamed to insert_with_values with 4.1.0
981
+ # https://gitlab.gnome.org/GNOME/gtk/-/commit/a1216599ff6b39bca3e9
982
+ if not hasattr(Gtk.ListStore, "insert_with_valuesv"):
983
+ insert_with_valuesv = Gtk.ListStore.insert_with_values
984
+ elif not hasattr(Gtk.ListStore, "insert_with_values"):
985
+ insert_with_values = Gtk.ListStore.insert_with_valuesv
986
+
987
+ def _do_insert(self, position, row):
988
+ if row is not None:
989
+ row, columns = self._convert_row(row)
990
+ treeiter = self.insert_with_values(position, columns, row)
991
+ else:
992
+ treeiter = Gtk.ListStore.insert(self, position)
993
+
994
+ return treeiter
995
+
996
+ def append(self, row=None):
997
+ if row:
998
+ return self._do_insert(-1, row)
999
+ # gtk_list_store_insert() does not know about the "position == -1"
1000
+ # case, so use append() here
1001
+ else:
1002
+ return Gtk.ListStore.append(self)
1003
+
1004
+ def prepend(self, row=None):
1005
+ return self._do_insert(0, row)
1006
+
1007
+ def insert(self, position, row=None):
1008
+ return self._do_insert(position, row)
1009
+
1010
+ def insert_before(self, sibling, row=None):
1011
+ if row is not None:
1012
+ if sibling is None:
1013
+ position = -1
1014
+ else:
1015
+ position = self.get_path(sibling).get_indices()[-1]
1016
+ return self._do_insert(position, row)
1017
+
1018
+ return Gtk.ListStore.insert_before(self, sibling)
1019
+
1020
+ def insert_after(self, sibling, row=None):
1021
+ if row is not None:
1022
+ if sibling is None:
1023
+ position = 0
1024
+ else:
1025
+ position = self.get_path(sibling).get_indices()[-1] + 1
1026
+ return self._do_insert(position, row)
1027
+
1028
+ return Gtk.ListStore.insert_after(self, sibling)
1029
+
1030
+ def set_value(self, treeiter, column, value):
1031
+ value = self._convert_value(column, value)
1032
+ Gtk.ListStore.set_value(self, treeiter, column, value)
1033
+
1034
+ def set(self, treeiter, *args):
1035
+ def _set_lists(cols, vals):
1036
+ if len(cols) != len(vals):
1037
+ raise TypeError('The number of columns do not match the number of values')
1038
+
1039
+ columns = []
1040
+ values = []
1041
+ for col_num, value in zip(cols, vals):
1042
+ if not isinstance(col_num, int):
1043
+ raise TypeError('TypeError: Expected integer argument for column.')
1044
+
1045
+ columns.append(col_num)
1046
+ values.append(self._convert_value(col_num, value))
1047
+
1048
+ Gtk.ListStore.set(self, treeiter, columns, values)
1049
+
1050
+ if args:
1051
+ if isinstance(args[0], int):
1052
+ _set_lists(args[::2], args[1::2])
1053
+ elif isinstance(args[0], (tuple, list)):
1054
+ if len(args) != 2:
1055
+ raise TypeError('Too many arguments')
1056
+ _set_lists(args[0], args[1])
1057
+ elif isinstance(args[0], dict):
1058
+ _set_lists(list(args[0]), args[0].values())
1059
+ else:
1060
+ raise TypeError('Argument list must be in the form of (column, value, ...), ((columns,...), (values, ...)) or {column: value}. No -1 termination is needed.')
1061
+
1062
+
1063
+ ListStore = override(ListStore)
1064
+ __all__.append('ListStore')
1065
+
1066
+
1067
+ class TreeModelRow(object):
1068
+
1069
+ def __init__(self, model, iter_or_path):
1070
+ if not isinstance(model, Gtk.TreeModel):
1071
+ raise TypeError("expected Gtk.TreeModel, %s found" % type(model).__name__)
1072
+ self.model = model
1073
+ if isinstance(iter_or_path, Gtk.TreePath):
1074
+ self.iter = model.get_iter(iter_or_path)
1075
+ elif isinstance(iter_or_path, Gtk.TreeIter):
1076
+ self.iter = iter_or_path
1077
+ else:
1078
+ raise TypeError("expected Gtk.TreeIter or Gtk.TreePath, "
1079
+ "%s found" % type(iter_or_path).__name__)
1080
+
1081
+ @property
1082
+ def path(self):
1083
+ return self.model.get_path(self.iter)
1084
+
1085
+ @property
1086
+ def next(self):
1087
+ return self.get_next()
1088
+
1089
+ @property
1090
+ def previous(self):
1091
+ return self.get_previous()
1092
+
1093
+ @property
1094
+ def parent(self):
1095
+ return self.get_parent()
1096
+
1097
+ def get_next(self):
1098
+ next_iter = self.model.iter_next(self.iter)
1099
+ if next_iter:
1100
+ return TreeModelRow(self.model, next_iter)
1101
+
1102
+ def get_previous(self):
1103
+ prev_iter = self.model.iter_previous(self.iter)
1104
+ if prev_iter:
1105
+ return TreeModelRow(self.model, prev_iter)
1106
+
1107
+ def get_parent(self):
1108
+ parent_iter = self.model.iter_parent(self.iter)
1109
+ if parent_iter:
1110
+ return TreeModelRow(self.model, parent_iter)
1111
+
1112
+ def __getitem__(self, key):
1113
+ if isinstance(key, int):
1114
+ if key >= self.model.get_n_columns():
1115
+ raise IndexError("column index is out of bounds: %d" % key)
1116
+ elif key < 0:
1117
+ key = self._convert_negative_index(key)
1118
+ return self.model.get_value(self.iter, key)
1119
+ elif isinstance(key, slice):
1120
+ start, stop, step = key.indices(self.model.get_n_columns())
1121
+ alist = []
1122
+ for i in range(start, stop, step):
1123
+ alist.append(self.model.get_value(self.iter, i))
1124
+ return alist
1125
+ elif isinstance(key, tuple):
1126
+ return [self[k] for k in key]
1127
+ else:
1128
+ raise TypeError("indices must be integers, slice or tuple, not %s"
1129
+ % type(key).__name__)
1130
+
1131
+ def __setitem__(self, key, value):
1132
+ if isinstance(key, int):
1133
+ if key >= self.model.get_n_columns():
1134
+ raise IndexError("column index is out of bounds: %d" % key)
1135
+ elif key < 0:
1136
+ key = self._convert_negative_index(key)
1137
+ self.model.set_value(self.iter, key, value)
1138
+ elif isinstance(key, slice):
1139
+ start, stop, step = key.indices(self.model.get_n_columns())
1140
+ indexList = range(start, stop, step)
1141
+ if len(indexList) != len(value):
1142
+ raise ValueError(
1143
+ "attempt to assign sequence of size %d to slice of size %d"
1144
+ % (len(value), len(indexList)))
1145
+
1146
+ for i, v in enumerate(indexList):
1147
+ self.model.set_value(self.iter, v, value[i])
1148
+ elif isinstance(key, tuple):
1149
+ if len(key) != len(value):
1150
+ raise ValueError(
1151
+ "attempt to assign sequence of size %d to sequence of size %d"
1152
+ % (len(value), len(key)))
1153
+ for k, v in zip(key, value):
1154
+ self[k] = v
1155
+ else:
1156
+ raise TypeError("indices must be an integer, slice or tuple, not %s"
1157
+ % type(key).__name__)
1158
+
1159
+ def _convert_negative_index(self, index):
1160
+ new_index = self.model.get_n_columns() + index
1161
+ if new_index < 0:
1162
+ raise IndexError("column index is out of bounds: %d" % index)
1163
+ return new_index
1164
+
1165
+ def iterchildren(self):
1166
+ child_iter = self.model.iter_children(self.iter)
1167
+ return TreeModelRowIter(self.model, child_iter)
1168
+
1169
+
1170
+ __all__.append('TreeModelRow')
1171
+
1172
+
1173
+ class TreeModelRowIter(object):
1174
+
1175
+ def __init__(self, model, aiter):
1176
+ self.model = model
1177
+ self.iter = aiter
1178
+
1179
+ def __next__(self):
1180
+ if not self.iter:
1181
+ raise StopIteration
1182
+ row = TreeModelRow(self.model, self.iter)
1183
+ self.iter = self.model.iter_next(self.iter)
1184
+ return row
1185
+
1186
+ def __iter__(self):
1187
+ return self
1188
+
1189
+
1190
+ __all__.append('TreeModelRowIter')
1191
+
1192
+
1193
+ class TreePath(Gtk.TreePath):
1194
+
1195
+ def __new__(cls, path=0):
1196
+ if isinstance(path, int):
1197
+ path = str(path)
1198
+ elif not isinstance(path, str):
1199
+ path = ":".join(str(val) for val in path)
1200
+
1201
+ if len(path) == 0:
1202
+ raise TypeError("could not parse subscript '%s' as a tree path" % path)
1203
+ try:
1204
+ return TreePath.new_from_string(path)
1205
+ except TypeError:
1206
+ raise TypeError("could not parse subscript '%s' as a tree path" % path)
1207
+
1208
+ def __init__(self, *args, **kwargs):
1209
+ super(TreePath, self).__init__()
1210
+
1211
+ def __str__(self):
1212
+ return self.to_string() or ""
1213
+
1214
+ def __lt__(self, other):
1215
+ return other is not None and self.compare(other) < 0
1216
+
1217
+ def __le__(self, other):
1218
+ return other is not None and self.compare(other) <= 0
1219
+
1220
+ def __eq__(self, other):
1221
+ return other is not None and self.compare(other) == 0
1222
+
1223
+ def __ne__(self, other):
1224
+ return other is None or self.compare(other) != 0
1225
+
1226
+ def __gt__(self, other):
1227
+ return other is None or self.compare(other) > 0
1228
+
1229
+ def __ge__(self, other):
1230
+ return other is None or self.compare(other) >= 0
1231
+
1232
+ def __iter__(self):
1233
+ return iter(self.get_indices())
1234
+
1235
+ def __len__(self):
1236
+ return self.get_depth()
1237
+
1238
+ def __getitem__(self, index):
1239
+ return self.get_indices()[index]
1240
+
1241
+
1242
+ TreePath = override(TreePath)
1243
+ __all__.append('TreePath')
1244
+
1245
+
1246
+ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
1247
+ def __init__(self, *column_types):
1248
+ Gtk.TreeStore.__init__(self)
1249
+ self.set_column_types(column_types)
1250
+
1251
+ def _do_insert(self, parent, position, row):
1252
+ if row is not None:
1253
+ row, columns = self._convert_row(row)
1254
+ treeiter = self.insert_with_values(parent, position, columns, row)
1255
+ else:
1256
+ treeiter = Gtk.TreeStore.insert(self, parent, position)
1257
+
1258
+ return treeiter
1259
+
1260
+ def append(self, parent, row=None):
1261
+ return self._do_insert(parent, -1, row)
1262
+
1263
+ def prepend(self, parent, row=None):
1264
+ return self._do_insert(parent, 0, row)
1265
+
1266
+ def insert(self, parent, position, row=None):
1267
+ return self._do_insert(parent, position, row)
1268
+
1269
+ def insert_before(self, parent, sibling, row=None):
1270
+ if row is not None:
1271
+ if sibling is None:
1272
+ position = -1
1273
+ else:
1274
+ if parent is None:
1275
+ parent = self.iter_parent(sibling)
1276
+ position = self.get_path(sibling).get_indices()[-1]
1277
+ return self._do_insert(parent, position, row)
1278
+
1279
+ return Gtk.TreeStore.insert_before(self, parent, sibling)
1280
+
1281
+ def insert_after(self, parent, sibling, row=None):
1282
+ if row is not None:
1283
+ if sibling is None:
1284
+ position = 0
1285
+ else:
1286
+ if parent is None:
1287
+ parent = self.iter_parent(sibling)
1288
+ position = self.get_path(sibling).get_indices()[-1] + 1
1289
+ return self._do_insert(parent, position, row)
1290
+
1291
+ return Gtk.TreeStore.insert_after(self, parent, sibling)
1292
+
1293
+ def set_value(self, treeiter, column, value):
1294
+ value = self._convert_value(column, value)
1295
+ Gtk.TreeStore.set_value(self, treeiter, column, value)
1296
+
1297
+ def set(self, treeiter, *args):
1298
+ def _set_lists(cols, vals):
1299
+ if len(cols) != len(vals):
1300
+ raise TypeError('The number of columns do not match the number of values')
1301
+
1302
+ columns = []
1303
+ values = []
1304
+ for col_num, value in zip(cols, vals):
1305
+ if not isinstance(col_num, int):
1306
+ raise TypeError('TypeError: Expected integer argument for column.')
1307
+
1308
+ columns.append(col_num)
1309
+ values.append(self._convert_value(col_num, value))
1310
+
1311
+ Gtk.TreeStore.set(self, treeiter, columns, values)
1312
+
1313
+ if args:
1314
+ if isinstance(args[0], int):
1315
+ _set_lists(args[::2], args[1::2])
1316
+ elif isinstance(args[0], (tuple, list)):
1317
+ if len(args) != 2:
1318
+ raise TypeError('Too many arguments')
1319
+ _set_lists(args[0], args[1])
1320
+ elif isinstance(args[0], dict):
1321
+ _set_lists(args[0].keys(), args[0].values())
1322
+ else:
1323
+ raise TypeError('Argument list must be in the form of (column, value, ...), ((columns,...), (values, ...)) or {column: value}. No -1 termination is needed.')
1324
+
1325
+
1326
+ TreeStore = override(TreeStore)
1327
+ __all__.append('TreeStore')
1328
+
1329
+
1330
+ class TreeView(Gtk.TreeView, Container):
1331
+ if GTK3:
1332
+ __init__ = deprecated_init(Gtk.TreeView.__init__,
1333
+ arg_names=('model',),
1334
+ category=PyGTKDeprecationWarning)
1335
+
1336
+ get_path_at_pos = strip_boolean_result(Gtk.TreeView.get_path_at_pos)
1337
+ get_visible_range = strip_boolean_result(Gtk.TreeView.get_visible_range)
1338
+ get_dest_row_at_pos = strip_boolean_result(Gtk.TreeView.get_dest_row_at_pos)
1339
+
1340
+ if GTK3:
1341
+ def enable_model_drag_source(self, start_button_mask, targets, actions):
1342
+ target_entries = _construct_target_list(targets)
1343
+ super(TreeView, self).enable_model_drag_source(start_button_mask,
1344
+ target_entries,
1345
+ actions)
1346
+
1347
+ if GTK3:
1348
+ def enable_model_drag_dest(self, targets, actions):
1349
+ target_entries = _construct_target_list(targets)
1350
+ super(TreeView, self).enable_model_drag_dest(target_entries,
1351
+ actions)
1352
+
1353
+ def scroll_to_cell(self, path, column=None, use_align=False, row_align=0.0, col_align=0.0):
1354
+ if not isinstance(path, Gtk.TreePath):
1355
+ path = TreePath(path)
1356
+ super(TreeView, self).scroll_to_cell(path, column, use_align, row_align, col_align)
1357
+
1358
+ def set_cursor(self, path, column=None, start_editing=False):
1359
+ if not isinstance(path, Gtk.TreePath):
1360
+ path = TreePath(path)
1361
+ super(TreeView, self).set_cursor(path, column, start_editing)
1362
+
1363
+ def get_cell_area(self, path, column=None):
1364
+ if not isinstance(path, Gtk.TreePath):
1365
+ path = TreePath(path)
1366
+ return super(TreeView, self).get_cell_area(path, column)
1367
+
1368
+ def insert_column_with_attributes(self, position, title, cell, **kwargs):
1369
+ column = TreeViewColumn()
1370
+ column.set_title(title)
1371
+ column.pack_start(cell, False)
1372
+ self.insert_column(column, position)
1373
+ column.set_attributes(cell, **kwargs)
1374
+
1375
+
1376
+ TreeView = override(TreeView)
1377
+ __all__.append('TreeView')
1378
+
1379
+
1380
+ class TreeViewColumn(Gtk.TreeViewColumn):
1381
+ def __init__(self, title='',
1382
+ cell_renderer=None,
1383
+ **attributes):
1384
+ Gtk.TreeViewColumn.__init__(self, title=title)
1385
+ if cell_renderer:
1386
+ self.pack_start(cell_renderer, True)
1387
+
1388
+ for (name, value) in attributes.items():
1389
+ self.add_attribute(cell_renderer, name, value)
1390
+
1391
+ cell_get_position = strip_boolean_result(Gtk.TreeViewColumn.cell_get_position)
1392
+
1393
+ def set_cell_data_func(self, cell_renderer, func, func_data=None):
1394
+ super(TreeViewColumn, self).set_cell_data_func(cell_renderer, func, func_data)
1395
+
1396
+ def set_attributes(self, cell_renderer, **attributes):
1397
+ Gtk.CellLayout.clear_attributes(self, cell_renderer)
1398
+
1399
+ for (name, value) in attributes.items():
1400
+ Gtk.CellLayout.add_attribute(self, cell_renderer, name, value)
1401
+
1402
+
1403
+ TreeViewColumn = override(TreeViewColumn)
1404
+ __all__.append('TreeViewColumn')
1405
+
1406
+
1407
+ class TreeSelection(Gtk.TreeSelection):
1408
+
1409
+ def select_path(self, path):
1410
+ if not isinstance(path, Gtk.TreePath):
1411
+ path = TreePath(path)
1412
+ super(TreeSelection, self).select_path(path)
1413
+
1414
+ def get_selected(self):
1415
+ success, model, aiter = super(TreeSelection, self).get_selected()
1416
+ if success:
1417
+ return (model, aiter)
1418
+ else:
1419
+ return (model, None)
1420
+
1421
+ # for compatibility with PyGtk
1422
+
1423
+ def get_selected_rows(self):
1424
+ rows, model = super(TreeSelection, self).get_selected_rows()
1425
+ return (model, rows)
1426
+
1427
+
1428
+ TreeSelection = override(TreeSelection)
1429
+ __all__.append('TreeSelection')
1430
+
1431
+
1432
+ if GTK3:
1433
+ class Button(Gtk.Button, Container):
1434
+ _init = deprecated_init(Gtk.Button.__init__,
1435
+ arg_names=('label', 'stock', 'use_stock', 'use_underline'),
1436
+ ignore=('stock',),
1437
+ category=PyGTKDeprecationWarning,
1438
+ stacklevel=3)
1439
+
1440
+ def __init__(self, *args, **kwargs):
1441
+ # Doubly deprecated initializer, the stock keyword is non-standard.
1442
+ # Simply give a warning that stock items are deprecated even though
1443
+ # we want to deprecate the non-standard keyword as well here from
1444
+ # the overrides.
1445
+ if 'stock' in kwargs and kwargs['stock']:
1446
+ warnings.warn('Stock items are deprecated. '
1447
+ 'Please use: Gtk.Button.new_with_mnemonic(label)',
1448
+ PyGTKDeprecationWarning, stacklevel=2)
1449
+ new_kwargs = kwargs.copy()
1450
+ new_kwargs['label'] = new_kwargs['stock']
1451
+ new_kwargs['use_stock'] = True
1452
+ new_kwargs['use_underline'] = True
1453
+ del new_kwargs['stock']
1454
+ Gtk.Button.__init__(self, **new_kwargs)
1455
+ else:
1456
+ self._init(*args, **kwargs)
1457
+
1458
+ if hasattr(Gtk.Widget, "set_focus_on_click"):
1459
+ def set_focus_on_click(self, *args, **kwargs):
1460
+ # Gtk.Widget.set_focus_on_click should be used instead but it's
1461
+ # no obvious how because of the shadowed method, so override here
1462
+ return Gtk.Widget.set_focus_on_click(self, *args, **kwargs)
1463
+
1464
+ if hasattr(Gtk.Widget, "get_focus_on_click"):
1465
+ def get_focus_on_click(self, *args, **kwargs):
1466
+ # Gtk.Widget.get_focus_on_click should be used instead but it's
1467
+ # no obvious how because of the shadowed method, so override here
1468
+ return Gtk.Widget.get_focus_on_click(self, *args, **kwargs)
1469
+
1470
+ Button = override(Button)
1471
+ __all__.append('Button')
1472
+
1473
+ class LinkButton(Gtk.LinkButton):
1474
+ __init__ = deprecated_init(Gtk.LinkButton.__init__,
1475
+ arg_names=('uri', 'label'),
1476
+ category=PyGTKDeprecationWarning)
1477
+
1478
+ LinkButton = override(LinkButton)
1479
+ __all__.append('LinkButton')
1480
+
1481
+ class Label(Gtk.Label):
1482
+ __init__ = deprecated_init(Gtk.Label.__init__,
1483
+ arg_names=('label',),
1484
+ category=PyGTKDeprecationWarning)
1485
+
1486
+ Label = override(Label)
1487
+ __all__.append('Label')
1488
+
1489
+
1490
+ class Adjustment(Gtk.Adjustment):
1491
+ if GTK3:
1492
+ _init = deprecated_init(Gtk.Adjustment.__init__,
1493
+ arg_names=('value', 'lower', 'upper',
1494
+ 'step_increment', 'page_increment', 'page_size'),
1495
+ deprecated_aliases={'page_increment': 'page_incr',
1496
+ 'step_increment': 'step_incr'},
1497
+ category=PyGTKDeprecationWarning,
1498
+ stacklevel=3)
1499
+
1500
+ def __init__(self, *args, **kwargs):
1501
+ if GTK3:
1502
+ self._init(*args, **kwargs)
1503
+ # The value property is set between lower and (upper - page_size).
1504
+ # Just in case lower, upper or page_size was still 0 when value
1505
+ # was set, we set it again here.
1506
+ if 'value' in kwargs:
1507
+ self.set_value(kwargs['value'])
1508
+ elif len(args) >= 1:
1509
+ self.set_value(args[0])
1510
+ else:
1511
+ Gtk.Adjustment.__init__(self, *args, **kwargs)
1512
+
1513
+ # The value property is set between lower and (upper - page_size).
1514
+ # Just in case lower, upper or page_size was still 0 when value
1515
+ # was set, we set it again here.
1516
+ if 'value' in kwargs:
1517
+ self.set_value(kwargs['value'])
1518
+
1519
+
1520
+ Adjustment = override(Adjustment)
1521
+ __all__.append('Adjustment')
1522
+
1523
+
1524
+ if GTK3:
1525
+ class Table(Gtk.Table, Container):
1526
+ __init__ = deprecated_init(Gtk.Table.__init__,
1527
+ arg_names=('n_rows', 'n_columns', 'homogeneous'),
1528
+ deprecated_aliases={'n_rows': 'rows', 'n_columns': 'columns'},
1529
+ category=PyGTKDeprecationWarning)
1530
+
1531
+ def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
1532
+ Gtk.Table.attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
1533
+
1534
+ Table = override(Table)
1535
+ __all__.append('Table')
1536
+
1537
+ class ScrolledWindow(Gtk.ScrolledWindow):
1538
+ __init__ = deprecated_init(Gtk.ScrolledWindow.__init__,
1539
+ arg_names=('hadjustment', 'vadjustment'),
1540
+ category=PyGTKDeprecationWarning)
1541
+
1542
+ ScrolledWindow = override(ScrolledWindow)
1543
+ __all__.append('ScrolledWindow')
1544
+
1545
+
1546
+ if GTK3:
1547
+ class HScrollbar(Gtk.HScrollbar):
1548
+ __init__ = deprecated_init(Gtk.HScrollbar.__init__,
1549
+ arg_names=('adjustment',),
1550
+ category=PyGTKDeprecationWarning)
1551
+
1552
+ HScrollbar = override(HScrollbar)
1553
+ __all__.append('HScrollbar')
1554
+
1555
+ class VScrollbar(Gtk.VScrollbar):
1556
+ __init__ = deprecated_init(Gtk.VScrollbar.__init__,
1557
+ arg_names=('adjustment',),
1558
+ category=PyGTKDeprecationWarning)
1559
+
1560
+ VScrollbar = override(VScrollbar)
1561
+ __all__.append('VScrollbar')
1562
+
1563
+
1564
+ if GTK3:
1565
+ class Paned(Gtk.Paned):
1566
+ def pack1(self, child, resize=False, shrink=True):
1567
+ super(Paned, self).pack1(child, resize, shrink)
1568
+
1569
+ def pack2(self, child, resize=True, shrink=True):
1570
+ super(Paned, self).pack2(child, resize, shrink)
1571
+
1572
+ Paned = override(Paned)
1573
+ __all__.append('Paned')
1574
+
1575
+
1576
+ if GTK3:
1577
+ class Arrow(Gtk.Arrow):
1578
+ __init__ = deprecated_init(Gtk.Arrow.__init__,
1579
+ arg_names=('arrow_type', 'shadow_type'),
1580
+ category=PyGTKDeprecationWarning)
1581
+
1582
+ Arrow = override(Arrow)
1583
+ __all__.append('Arrow')
1584
+
1585
+ class IconSet(Gtk.IconSet):
1586
+ def __new__(cls, pixbuf=None):
1587
+ if pixbuf is not None:
1588
+ warnings.warn('Gtk.IconSet(pixbuf) has been deprecated. Please use: '
1589
+ 'Gtk.IconSet.new_from_pixbuf(pixbuf)',
1590
+ PyGTKDeprecationWarning, stacklevel=2)
1591
+ iconset = Gtk.IconSet.new_from_pixbuf(pixbuf)
1592
+ else:
1593
+ iconset = Gtk.IconSet.__new__(cls)
1594
+ return iconset
1595
+
1596
+ def __init__(self, *args, **kwargs):
1597
+ return super(IconSet, self).__init__()
1598
+
1599
+ IconSet = override(IconSet)
1600
+ __all__.append('IconSet')
1601
+
1602
+ class Viewport(Gtk.Viewport):
1603
+ __init__ = deprecated_init(Gtk.Viewport.__init__,
1604
+ arg_names=('hadjustment', 'vadjustment'),
1605
+ category=PyGTKDeprecationWarning)
1606
+
1607
+ Viewport = override(Viewport)
1608
+ __all__.append('Viewport')
1609
+
1610
+
1611
+ class TreeModelFilter(Gtk.TreeModelFilter):
1612
+ def set_visible_func(self, func, data=None):
1613
+ super(TreeModelFilter, self).set_visible_func(func, data)
1614
+
1615
+ def set_value(self, iter, column, value):
1616
+ # Delegate to child model
1617
+ iter = self.convert_iter_to_child_iter(iter)
1618
+ self.get_model().set_value(iter, column, value)
1619
+
1620
+
1621
+ TreeModelFilter = override(TreeModelFilter)
1622
+ __all__.append('TreeModelFilter')
1623
+
1624
+
1625
+ if GTK3 or GTK4:
1626
+ class CssProvider(Gtk.CssProvider):
1627
+ def load_from_data(self, text, length=-1):
1628
+ if (Gtk.get_major_version(), Gtk.get_minor_version()) >= (4, 9):
1629
+ if isinstance(text, bytes):
1630
+ text = text.decode("utf-8")
1631
+ super(CssProvider, self).load_from_data(text, length)
1632
+ else:
1633
+ if isinstance(text, str):
1634
+ text = text.encode("utf-8")
1635
+ super(CssProvider, self).load_from_data(text)
1636
+
1637
+ CssProvider = override(CssProvider)
1638
+ __all__.append("CssProvider")
1639
+
1640
+ if GTK4:
1641
+ class CustomSorter(Gtk.CustomSorter):
1642
+
1643
+ @classmethod
1644
+ def new(cls, sort_func, user_data=None):
1645
+ if sort_func is not None:
1646
+ compare_func = wrap_list_store_sort_func(sort_func)
1647
+ else:
1648
+ compare_func = None
1649
+
1650
+ return Gtk.CustomSorter.new(compare_func, user_data)
1651
+
1652
+ def set_sort_func(self, sort_func, user_data=None):
1653
+ if sort_func is not None:
1654
+ compare_func = wrap_list_store_sort_func(sort_func)
1655
+ else:
1656
+ compare_func = None
1657
+
1658
+ return super(CustomSorter, self).set_sort_func(compare_func, user_data)
1659
+
1660
+ CustomSorter = override(CustomSorter)
1661
+ __all__.append("CustomSorter")
1662
+
1663
+ if GTK3:
1664
+ class Menu(Gtk.Menu):
1665
+ def popup(self, parent_menu_shell, parent_menu_item, func, data, button, activate_time):
1666
+ self.popup_for_device(None, parent_menu_shell, parent_menu_item, func, data, button, activate_time)
1667
+ Menu = override(Menu)
1668
+ __all__.append('Menu')
1669
+
1670
+ if GTK3:
1671
+ _Gtk_main_quit = Gtk.main_quit
1672
+
1673
+ @override(Gtk.main_quit)
1674
+ def main_quit(*args):
1675
+ _Gtk_main_quit()
1676
+
1677
+ _Gtk_main = Gtk.main
1678
+
1679
+ @override(Gtk.main)
1680
+ def main(*args, **kwargs):
1681
+ with register_sigint_fallback(Gtk.main_quit):
1682
+ with get_event_loop(GLib.MainContext.default()).running(Gtk.main_quit):
1683
+ return _Gtk_main(*args, **kwargs)
1684
+
1685
+ _Gtk_main_iteration = Gtk.main_iteration
1686
+ _Gtk_main_iteration_do = Gtk.main_iteration_do
1687
+
1688
+ @override(Gtk.main_iteration)
1689
+ def main_iteration():
1690
+ with get_event_loop(GLib.MainContext.default()).paused():
1691
+ return _Gtk_main_iteration()
1692
+
1693
+ @override(Gtk.main_iteration)
1694
+ def main_iteration_do(blocking):
1695
+ with get_event_loop(GLib.MainContext.default()).paused():
1696
+ return _Gtk_main_iteration_do(blocking)
1697
+
1698
+
1699
+ if GTK3:
1700
+ stock_lookup = strip_boolean_result(Gtk.stock_lookup)
1701
+ __all__.append('stock_lookup')
1702
+
1703
+ if GTK4:
1704
+ initialized = Gtk.init_check()
1705
+ else:
1706
+ initialized, argv = Gtk.init_check(sys.argv)
1707
+ sys.argv = list(argv)