Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-08-21 23:57:53 (GMT)
committer flavio <fdanesse@gmail.com>2012-08-21 23:57:53 (GMT)
commit18ab32ab9b93c06058d6301664c4005a052cf429 (patch)
tree5b0914525a43d48b81b65fbb38a39b5c315bdb8e
parent48f5913a4677aac173771735ef4ad7965fc0920f (diff)
GObject corrections
-rw-r--r--olpcgames/_gtkmain.py16
-rw-r--r--olpcgames/activity.py9
-rw-r--r--olpcgames/eventwrap.py8
-rw-r--r--olpcgames/gtkEvent.py8
4 files changed, 24 insertions, 17 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
diff --git a/olpcgames/activity.py b/olpcgames/activity.py
index 570f49a..7d8f40f 100644
--- a/olpcgames/activity.py
+++ b/olpcgames/activity.py
@@ -107,7 +107,7 @@ class PygameActivity(activity.Activity):
log.debug( 'Toolbar size: %s', toolbar.get_size_request())
canvas = self.build_canvas()
self.connect( 'configure-event', canvas._translator.do_resize_event )
-
+
def make_global( self ):
"""Hack to make olpcgames.ACTIVITY point to us
"""
@@ -152,7 +152,8 @@ class PygameActivity(activity.Activity):
# launched from Neighborhood)
joined_cb()
- toolbar.title.unset_flags(gtk.CAN_FOCUS)
+ # FIXME: No exists Gtk.CAN_FOCUS
+ #toolbar.title.unset_flags(Gtk.CAN_FOCUS)
return toolbar
PYGAME_CANVAS_CLASS = PygameCanvas
@@ -171,7 +172,7 @@ class PygameActivity(activity.Activity):
Gdk.threads_init()
return self._pgc
else:
- # FIXME Es necesario quitar hippo de aquĆ­
+ # FIXME: Hippo must be removed from here, (but do not use this code Maze).
#import hippo
#self._drawarea = gtk.DrawingArea()
#canvas = hippo.Canvas()
@@ -242,4 +243,4 @@ class PygameActivity(activity.Activity):
import olpcgames
olpcgames.PyGameActivity = PygameActivity
-PyGameActivity = PygameActivity \ No newline at end of file
+PyGameActivity = PygameActivity
diff --git a/olpcgames/eventwrap.py b/olpcgames/eventwrap.py
index d20091c..f5ac52c 100644
--- a/olpcgames/eventwrap.py
+++ b/olpcgames/eventwrap.py
@@ -29,11 +29,11 @@ log = logging.getLogger( 'olpcgames.eventwrap' )
from pygame.event import Event, event_name, pump as pygame_pump, get as pygame_get
-class Event(GObject.Object):
+class Event(GObject.GObject):
"""Mock pygame events"""
def __init__(self, type, dict=None,**named):
"""Initialise the new event variables from dictionary and named become attributes"""
- GObject.Object.__init__(self)
+ GObject.GObject.__init__(self)
self.type = type
if dict:
self.__dict__.update( dict )
@@ -71,14 +71,14 @@ class Event(GObject.Object):
except AttributeError, err:
pass
-class CallbackResult( GObject.Object ):
+class CallbackResult( GObject.GObject ):
def __init__( self, callable, args, named, callContext=None ):
"""Perform callback in Pygame loop with args and named
callContext is used to provide more information when there is
a failure in the callback (for debugging purposes)
"""
- GObject.Object.__init__(self)
+ GObject.GObject.__init__(self)
self.callable = callable
self.args = args
self.named = named
diff --git a/olpcgames/gtkEvent.py b/olpcgames/gtkEvent.py
index 202b54c..251a78e 100644
--- a/olpcgames/gtkEvent.py
+++ b/olpcgames/gtkEvent.py
@@ -8,13 +8,13 @@ import logging
log = logging.getLogger( 'olpcgames.gtkevent' )
##log.setLevel( logging.DEBUG )
-class _MockEvent(GObject.Object):
+class _MockEvent(GObject.GObject):
"""Used to inject key-repeat events on the gtk side."""
def __init__(self, keyval):
- GObject.Object.__init__(self)
+ GObject.GObject.__init__(self)
self.keyval = keyval
-class Translator(GObject.Object):
+class Translator(GObject.GObject):
"""Utility class to translate GTK events into Pygame events
The Translator object interprets incoming GTK events and generates
@@ -54,7 +54,7 @@ class Translator(GObject.Object):
def __init__(self, mainwindow, mouselistener=None):
"""Initialise the Translator with the windows to which to listen"""
# _inner_evb is Mouselistener
- GObject.Object.__init__(self)
+ GObject.GObject.__init__(self)
self._mainwindow = mainwindow
if mouselistener is None:
mouselistener = mainwindow