All pastes #21977 Raw Edit

Diff

public text v1 · immutable
#21977 ·published 2005-09-02 21:15 UTC
rendered paste body
Index: twisted/internet/gtk2reactor.py===================================================================--- twisted/internet/gtk2reactor.py	(revision 14339)+++ twisted/internet/gtk2reactor.py	(working copy)@@ -30,8 +30,9 @@ try:     if not hasattr(sys, 'frozen'):         # Don't want to check this for py2exe-        import pygtk-        pygtk.require('2.0')+       	import pygtk+       	if not sys.modules.has_key('gtk'):+       		pygtk.require('2.0') except (ImportError, AttributeError):     pass # maybe we're using pygtk before this hack existed. import gobject@@ -79,7 +80,7 @@      implements(IReactorFDSet) -    def __init__(self, useGtk=True):+    def __init__(self, useGtk=True, useExistingGtk=False):         self.context = gobject.main_context_default()         self.loop = gobject.MainLoop()         posixbase.PosixReactorBase.__init__(self)@@ -96,7 +97,10 @@             self.__pending = gtk.events_pending             self.__iteration = gtk.main_iteration             self.__crash = _our_mainquit-            self.__run = gtk.main+            if useExistingGtk:+            	self.__run = lambda: None+            else:+            	self.__run = gtk.main      # The input_add function in pygtk1 checks for objects with a     # 'fileno' method and, if present, uses the result of that method@@ -253,13 +257,15 @@         _simtag = gobject.timeout_add(int(timeout * 1010), self.simulate)  -def install(useGtk=True):+def install(useGtk=True, useExistingGtk=False):     """Configure the twisted mainloop to be run inside the gtk mainloop.      @param useGtk: should glib rather than GTK+ event loop be     used (this will be slightly faster but does not support GUI).+    @param useExistingGtk: When used in combination with useGtk,+    do not launch gtk.main, but use the existing gtk mainloop.     """-    reactor = Gtk2Reactor(useGtk)+    reactor = Gtk2Reactor(useGtk, useExistingGtk)     from twisted.internet.main import installReactor     installReactor(reactor)     return reactor