Exemple #1
0
    def build_toolbar( self ):

	self.max_participants = 1
        """Build our Activity toolbar for the Sugar system

        This is a customisation point for those games which want to
        provide custom toolbars when running under Sugar.

"""
        toolbarbox = ToolbarBox()

        toolbar = activity.ActivityToolbar(self)
        toolbar.show()
        self.set_toolbox(toolbar)

        toolbar_box = ToolbarBox()

#	recargar_button = ToolButton('help-icon')
#	recargar_button.set_tooltip(('Ayuda'))
#	self.toolbar_box.insert(recargar_button, +1)
#	recargar_button.connect('clicked', self.__recargar_cb)
#	recargar_button.show()

#	volver_button = ToolButton('previous')
#	volver_button.set_tooltip(('Volver al Menu'))
#	self.toolbar_box.insert(volver_button, +1)
#	volver_button.connect('clicked', self.__menu_cb)
#	volver_button.show()

        toolbar.title.unset_flags(gtk.CAN_FOCUS)
        return toolbar
Exemple #2
0
    def build_toolbar(self):
        """Build our Activity toolbar for the Sugar system

        This is a customisation point for those games which want to
        provide custom toolbars when running under Sugar.
        """

        try:
            from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
            from sugar.activity.widgets import ActivityToolbarButton, StopButton, \
                                                ShareButton, KeepButton
            from mybutton import MyActivityToolbarButton

            toolbar_box = ToolbarBox()
            activity_button = MyActivityToolbarButton(self)
            toolbar_box.toolbar.insert(activity_button, 0)
            activity_button.show()

            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            toolbar_box.toolbar.insert(separator, -1)
            separator.show()

            share_button = ShareButton(self)
            toolbar_box.toolbar.insert(share_button, -1)
            share_button.show()

            keep_button = KeepButton(self)
            toolbar_box.toolbar.insert(keep_button, -1)
            keep_button.show()

            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl><Shift>Q'
            toolbar_box.toolbar.insert(stop_button, -1)
            stop_button.show()

            self.set_toolbar_box(toolbar_box)
            toolbar_box.show()
            toolbar = toolbar_box.toolbar
        except ImportError:
            toolbar = activity.ActivityToolbar(self)
            toolbar.show()
            self.set_toolbox(toolbar)
            toolbar.title.unset_flags(gtk.CAN_FOCUS)

        def shared_cb(*args, **kwargs):
            log.info('shared: %s, %s', args, kwargs)
            try:
                mesh.activity_shared(self)
            except Exception, err:
                log.error(
                    """Failure signaling activity sharing to mesh module: %s""",
                    util.get_traceback(err))
            else:
Exemple #3
0
    def __init__(self, handle):
        super(PyGameActivity, self).__init__(handle)

        self.set_title(self.game_title)

        toolbar = activity.ActivityToolbar(self)
        toolbar.show()
        self.set_toolbox(toolbar)

        def shared_cb(*args, **kwargs):
            mesh.activity_shared(self)

        def joined_cb(*args, **kwargs):
            mesh.activity_joined(self)

        self.connect("shared", shared_cb)
        self.connect("joined", joined_cb)

        if self.get_shared():
            # if set at this point, it means we've already joined (i.e.,
            # launched from Neighborhood)
            joined_cb()

        toolbar.title.unset_flags(gtk.CAN_FOCUS)

        assert self.game_handler or self.game_name, 'You must specify a handler module (%r)' % (
            self.game_handler or self.game_name)

        if self.pygame_mode != 'Cairo':

            self._pgc = PyGameCanvas(*self.game_size)
            self.set_canvas(self._pgc)
            self._pgc.grab_focus()
            self._pgc.connect_game(self.game_handler or self.game_name)
            gtk.gdk.threads_init()

        else:
            self._drawarea = gtk.DrawingArea()
            canvas = hippo.Canvas()
            canvas.grab_focus()
            self.set_canvas(canvas)
            self.show_all()

            import pygamecairo
            pygamecairo.install()

            pygamecairo.display.init(canvas)
            app = self.game_handler or self.game_name
            if ':' not in app:
                app += ':main'
            mod_name, fn_name = app.split(':')
            mod = __import__(mod_name, globals(), locals(), [])
            fn = getattr(mod, fn_name)
            fn()
    def build_toolbar( self ):
        """Build our Activity toolbar for the Sugar system

        This is a customisation point for those games which want to
        provide custom toolbars when running under Sugar.
        """
        toolbar = activity.ActivityToolbar(self)
        toolbar.show()
        self.set_toolbox(toolbar)
        def shared_cb(*args, **kwargs):
            log.info( 'shared: %s, %s', args, kwargs )
            try:
                mesh.activity_shared(self)
            except Exception, err:
                log.error( """Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err) )
            else:
    def build_toolbar( self ):
        """Build our Activity toolbar for the Sugar system

        This is a customisation point for those games which want to
        provide custom toolbars when running under Sugar.
        """
        toolbar = activity.ActivityToolbar(self)
        toolbar.show()
        self.set_toolbox(toolbar)
        def shared_cb(*args, **kwargs):
            log.info( 'shared: %s, %s', args, kwargs )
            try:
                mesh.activity_shared(self)
            except Exception as err:
                log.error( """Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err) )
            else:
                log.info( 'mesh activity shared message sent, trying to grab focus' )
            try:
                self._pgc.grab_focus()
            except Exception as err:
                log.warn( 'Focus failed: %s', err )
            else:
                log.info( 'asserting focus' )
                assert self._pgc.is_focus(), """Did not successfully set pygame canvas focus"""
            log.info( 'callback finished' )
            
        def joined_cb(*args, **kwargs):
            log.info( 'joined: %s, %s', args, kwargs )
            mesh.activity_joined(self)
            self._pgc.grab_focus()
        self.connect("shared", shared_cb)
        self.connect("joined", joined_cb)

        if self.get_shared():
            # if set at this point, it means we've already joined (i.e.,
            # launched from Neighborhood)
            joined_cb()

        toolbar.title.unset_flags(gtk.CAN_FOCUS)
        return toolbar