Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/olpcgames/_gtkmain.py
diff options
context:
space:
mode:
Diffstat (limited to 'olpcgames/_gtkmain.py')
-rw-r--r--olpcgames/_gtkmain.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/olpcgames/_gtkmain.py b/olpcgames/_gtkmain.py
index 33a6a83..22f2168 100644
--- a/olpcgames/_gtkmain.py
+++ b/olpcgames/_gtkmain.py
@@ -1,7 +1,7 @@
"""Support for GObject mainloop-requiring libraries when not inside GTK
INITIALIZED -- whether we have a running gobject loop yet...
-LOOP_TRACKER -- if present, the manual gtk event loop used to
+LOOP_TRACKER -- if present, the manual gtk event loop used to
support gobject-based code running in a non-Gobject event loop
Holder -- objects which can be held as attributes to keep the mainloop running
@@ -10,13 +10,20 @@ import threading, logging
log = logging.getLogger( 'olpcgames._gtkmain' )
##log.setLevel( logging.DEBUG )
+from gi.repository import Gtk
+from gi.repository import GObject
+
INITIALIZED = False
LOOP_TRACKER = None
-class _TrackLoop( object ):
+class _TrackLoop(GObject.GObject):
"""Tracks the number of open loops and stops when finished"""
count = 0
_mainloop = None
+
+ def __init__(self):
+ GObject.GObject.__init__(self)
+
def increment( self ):
log.info( 'Increment from %s', self.count )
self.count += 1 # XXX race condition here?
@@ -30,11 +37,10 @@ class _TrackLoop( object ):
self.count -= 1
def loop( self ):
"""Little thread loop that replicates the gtk mainloop"""
- import gtk
while self.count >= 1:
log.debug( 'GTK loop restarting' )
- while gtk.events_pending():
- gtk.main_iteration()
+ while Gtk.events_pending():
+ Gtk.main_iteration(False)
log.debug( 'GTK loop exiting' )
try:
del self.t_loop