Ticket #4558: gtk3-4558-2-fixes.patch
| File gtk3-4558-2-fixes.patch, 10.1 KB (added by dobey, 16 months ago) |
|---|
-
twisted/internet/_glibbase.py
94 94 # callbacks queued from a thread: 95 95 _wakerFactory = GlibWaker 96 96 97 def __init__(self ):97 def __init__(self, glib_module, gtk_module, useGtk=False): 98 98 self._simtag = None 99 99 self._reads = set() 100 100 self._writes = set() 101 101 self._sources = {} 102 self._glib = glib_module 103 self._gtk = gtk_module 102 104 posixbase.PosixReactorBase.__init__(self) 103 105 106 self._source_remove = self._glib.source_remove 107 self._timeout_add = self._glib.timeout_add 104 108 109 def _mainquit(): 110 if self._gtk.main_level(): 111 self._gtk.main_quit() 112 113 if useGtk: 114 self._pending = self._gtk.events_pending 115 self._iteration = self._gtk.main_iteration_do 116 self._crash = _mainquit 117 self._run = self._gtk.main 118 else: 119 self.context = self._glib.main_context_default() 120 self._pending = self.context.pending 121 self._iteration = self.context.iteration 122 self.loop = self._glib.MainLoop() 123 self._crash = lambda: self._glib.idle_add(self.loop.quit) 124 self._run = self.loop.run 125 126 # The input_add function in pygtk1 checks for objects with a 127 # 'fileno' method and, if present, uses the result of that method 128 # as the input source. The pygtk2 input_add does not do this. The 129 # function below replicates the pygtk1 functionality. 130 131 # In addition, pygtk maps gtk.input_add to _gobject.io_add_watch, and 132 # g_io_add_watch() takes different condition bitfields than 133 # gtk_input_add(). We use g_io_add_watch() here in case pygtk fixes this 134 # bug. 105 135 def input_add(self, source, condition, callback): 106 """ 107 This is a stub to be implemented by inheriting classes. 108 """ 109 raise NotImplementedError() 136 if hasattr(source, 'fileno'): 137 # handle python objects 138 def wrapper(source, condition, real_s=source, real_cb=callback): 139 return real_cb(real_s, condition) 140 return self._glib.io_add_watch(source.fileno(), condition, wrapper) 141 else: 142 return self._glib.io_add_watch(source, condition, callback) 110 143 111 144 112 145 def _ioEventCallback(self, source, condition): … … 287 320 288 321 Sockets aren't supported by GObject's input_add on Win32. 289 322 """ 290 def __init__(self ):323 def __init__(self, glib_module, gtk_module, useGtk=False): 291 324 self._simtag = None 325 self._glib = glib_module 326 self._gtk = gtk_module 292 327 selectreactor.SelectReactor.__init__(self) 293 328 329 self._source_remove = self._glib.source_remove 330 self._timeout_add = self._glib.timeout_add 331 332 def _mainquit(): 333 if self._gtk.main_level(): 334 self._gtk.main_quit() 335 336 if useGtk: 337 self._crash = _mainquit 338 self._run = self._gtk.main 339 else: 340 self.loop = self._glib.MainLoop() 341 self._crash = lambda: self._glib.idle_add(self.loop.quit) 342 self._run = self.loop.run 343 294 344 295 345 def crash(self): 296 346 selectreactor.SelectReactor.crash(self) … … 313 363 timeout = min(self.timeout(), 0.01) 314 364 if timeout is None: 315 365 timeout = 0.01 316 self._simtag = self._timeout_add(int(timeout * 10 00), self.simulate)366 self._simtag = self._timeout_add(int(timeout * 1010), self.simulate) -
twisted/internet/gireactor.py
52 52 OUTFLAGS = _POLL_OUT | _POLL_DISCONNECTED 53 53 54 54 def __init__(self, useGtk=False): 55 _glibbase.GlibReactorBase.__init__(self) 55 _gtk = None 56 if useGtk is True: 57 from gi.repository import Gtk as _gtk 56 58 57 self._source_remove = GLib.source_remove 58 self._timeout_add = GLib.timeout_add 59 60 if useGtk: 61 from gi.repository import Gtk 62 63 self._pending = Gtk.events_pending 64 self._iteration = Gtk.main_iteration_do 65 self._crash = Gtk.main_quit 66 self._run = Gtk.main 67 else: 68 self.context = GLib.main_context_default() 69 self._pending = self.context.pending 70 self._iteration = self.context.iteration 71 self.loop = GLib.MainLoop() 72 self._crash = lambda: GLib.idle_add(self.loop.quit) 73 self._run = self.loop.run 74 75 # The input_add function in pygtk1 checks for objects with a 76 # 'fileno' method and, if present, uses the result of that method 77 # as the input source. The pygtk2 input_add does not do this. The 78 # function below replicates the pygtk1 functionality. 79 80 # In addition, pygtk maps gtk.input_add to _gobject.io_add_watch, and 81 # g_io_add_watch() takes different condition bitfields than 82 # gtk_input_add(). We use g_io_add_watch() here in case pygtk fixes this 83 # bug. 84 def input_add(self, source, condition, callback): 85 if hasattr(source, 'fileno'): 86 # handle python objects 87 def wrapper(source, condition, real_s=source, real_cb=callback): 88 return real_cb(real_s, condition) 89 return GLib.io_add_watch(source.fileno(), condition, wrapper) 90 else: 91 return GLib.io_add_watch(source, condition, callback) 59 _glibbase.GlibReactorBase.__init__(self, GLib, _gtk, useGtk=useGtk) 92 60 93 61 94 62 … … 97 65 Portable GObject Introspection event loop reactor. 98 66 """ 99 67 def __init__(self, useGtk=False): 100 _glibbase.PortableGlibReactorBase.__init__(self) 101 102 self._source_remove = GLib.source_remove 103 self._timeout_add = GLib.timeout_add 104 105 if useGtk: 106 from gi.repository import Gtk 107 108 self._crash = Gtk.main_quit 109 self._run = Gtk.main 110 else: 111 self.loop = GLib.MainLoop() 112 self._crash = lambda: GLib.idle_add(self.loop.quit) 113 self._run = self.loop.run 68 _gtk = None 69 if useGtk is True: 70 from gi.repository import Gtk as _gtk 114 71 72 _glibbase.PortableGlibReactorBase.__init__(self, GLib, _gtk, 73 useGtk=useGtk) 115 74 116 75 117 76 def install(useGtk=False): -
twisted/internet/gtk2reactor.py
62 62 OUTFLAGS = _POLL_OUT | _POLL_DISCONNECTED 63 63 64 64 def __init__(self, useGtk=True): 65 _glibbase.GlibReactorBase.__init__(self) 65 _gtk = None 66 if useGtk is True: 67 import gtk as _gtk 66 68 67 self._source_remove = gobject.source_remove 68 self._timeout_add = gobject.timeout_add 69 70 # pre 2.3.91 the glib iteration and mainloop functions didn't release 71 # global interpreter lock, thus breaking thread and signal support. 72 if getattr(gobject, "pygtk_version", ()) >= (2, 3, 91) and not useGtk: 73 self.context = gobject.main_context_default() 74 self._pending = self.context.pending 75 self._iteration = self.context.iteration 76 self.loop = gobject.MainLoop() 77 self._crash = self.loop.quit 78 self._run = self.loop.run 79 else: 80 import gtk 81 82 def mainquit(): 83 if gtk.main_level(): 84 gtk.main_quit() 85 86 self._pending = gtk.events_pending 87 self._iteration = gtk.main_iteration 88 self._crash = mainquit 89 self._run = gtk.main 90 91 92 # The input_add function in pygtk1 checks for objects with a 93 # 'fileno' method and, if present, uses the result of that method 94 # as the input source. The pygtk2 input_add does not do this. The 95 # function below replicates the pygtk1 functionality. 96 97 # In addition, pygtk maps gtk.input_add to _gobject.io_add_watch, and 98 # g_io_add_watch() takes different condition bitfields than 99 # gtk_input_add(). We use g_io_add_watch() here in case pygtk fixes this 100 # bug. 101 def input_add(self, source, condition, callback): 102 if hasattr(source, 'fileno'): 103 # handle python objects 104 def wrapper(source, condition, real_s=source, real_cb=callback): 105 return real_cb(real_s, condition) 106 return gobject.io_add_watch(source.fileno(), condition, wrapper) 107 else: 108 return gobject.io_add_watch(source, condition, callback) 69 _glibbase.GlibReactorBase.__init__(self, gobject, _gtk, useGtk=useGtk) 109 70 110 71 111 72 … … 115 76 116 77 Sockets aren't supported by GTK+'s input_add on Win32. 117 78 """ 118 def __init__(self, useGtk=False): 119 _glibbase.PortableGlibReactorBase.__init__(self) 120 121 self._source_remove = gobject.source_remove 122 self._timeout_add = gobject.timeout_add 123 124 if useGtk: 125 import gtk 79 def __init__(self, useGtk=True): 80 _gtk = None 81 if useGtk is True: 82 import gtk as _gtk 126 83 127 def mainquit(): 128 if gtk.main_level(): 129 gtk.main_quit() 130 131 self._crash = mainquit 132 self._run = gtk.main 133 else: 134 self.loop = gobject.MainLoop() 135 self._crash = lambda: gobject.idle_add(self.loop.quit) 136 self._run = self.loop.run 84 _glibbase.PortableGlibReactorBase.__init__(self, gobject, _gtk, 85 useGtk=useGtk) 137 86 138 87 139 88 def install(useGtk=True):
