Exemplo n.º 1
0
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = MAX_HANDS

        if have_toolbox:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button = ActivityToolbarButton(self)

            toolbox.toolbar.insert(activity_button, 0)
            activity_button.show()

            self.set_toolbar_box(toolbox)
            toolbox.show()
            self.toolbar = toolbox.toolbar

        else:
            # Use pre-0.86 toolbar design
            games_toolbar = gtk.Toolbar()
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.add_toolbar(_('Game'), games_toolbar)
            toolbox.show()
            toolbox.set_current_toolbar(1)
            self.toolbar = games_toolbar

        self._new_game_button = _button_factory(
            'new-game', _('Start a new game.'), self._new_game_cb,
            self.toolbar)

        self.robot_button = _button_factory(
            'robot-off', _('Play with the robot.'), self._robot_cb,
            self.toolbar)

        self.player = _image_factory(
            svg_str_to_pixbuf(generate_xo(scale=0.8,
                                          colors=['#303030', '#303030'])),
            self.toolbar, tooltip=self.nick)

        self.dialog_button = _button_factory('go-next',
                                             _('Turn complete'),
                                             self._dialog_cb, self.toolbar)

        self.status = _label_factory('', self.toolbar)

        self.hint_button = _button_factory('help-toolbar',
                                             _('Help'),
                                             self._hint_cb, self.toolbar)

        self.score = _label_factory(_('Score: ') + '0', self.toolbar)

        if _have_toolbox:
            _separator_factory(toolbox.toolbar, False, True)

            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl>q'
            toolbox.toolbar.insert(stop_button, -1)
            stop_button.show()
Exemplo n.º 2
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        logging.debug('Starting the Analyze activity')
        self.set_title(_('Analyze Activity'))

        self._network = NetworkView()
        self._xserver = XorgView()
        self._ps = PresenceServiceNameWatcher(dbus.SessionBus())

        self._box = gtk.HBox()
        self._box.pack_start(self._network)
        self._box.show()

        self.set_canvas(self._box)

        # TOOLBAR
        toolbox = activity.ActivityToolbox(self)
        toolbox.show()

        toolbar = AnalizeToolbar(self)
        toolbox.add_toolbar(_('Interfaces'), toolbar)
        toolbar.show()

        self.set_toolbox(toolbox)
        self.show()

        # Dirty hide()
        toolbar = toolbox.get_activity_toolbar()
        toolbar.share.hide()
        toolbar.keep.hide()
Exemplo n.º 3
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        logging.debug('Starting the IRC Activity')
        self.set_title(_('IRC Activity'))

        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.connect('visibility-notify-event',
                     self.__visibility_notify_event_cb)

        self.is_visible = False

        self.client = purk.Client()
        if handle.object_id is None:
            self.default_config()
        self.client.show()
        widget = self.client.get_widget()

        # CANVAS
        self.set_canvas(widget)

        # TOOLBAR
        toolbox = activity.ActivityToolbox(self)

        # Remove the Share button, since this activity isn't shareable
        toolbar = toolbox.get_activity_toolbar()
        toolbar.remove(toolbar.share)

        self.set_toolbox(toolbox)
        self.show_all()
Exemplo n.º 4
0
    def __init__(self, handle):
        "The entry point to the Activity"
        global page
        activity.Activity.__init__(self, handle)

        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False
        self.set_toolbox(toolbox)

        toolbox.show()
        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scrolled_window.props.shadow_type = gtk.SHADOW_NONE

        self.textview = gtk.TextView()
        self.textview.set_editable(False)
        self.textview.set_cursor_visible(False)
        self.textview.set_left_margin(50)
        self.textview.connect("key_press_event", self.keypress_cb)

        self.scrolled_window.add(self.textview)
        self.set_canvas(self.scrolled_window)
        self.textview.show()
        self.scrolled_window.show()
        page = 0
        self.textview.grab_focus()
        self.font_desc = pango.FontDescription("sans %d" % style.zoom(10))
        self.textview.modify_font(self.font_desc)
Exemplo n.º 5
0
    def createToolbox(self):
        toolbox = activity.ActivityToolbox(self)
        self.toolbar = gtk.Toolbar()

        toolbox.add_toolbar(_('Ecomundo'), self.toolbar)
        self.toolbar.show()
        self.set_toolbox(toolbox)
        toolbox.show()

        self.btnNew = ToolButton('reload')
        self.btnNew.connect('clicked', self.onBtNewClicked)
        self.toolbar.insert(self.btnNew, -1)
        self.btnNew.show()

        self.btPlay = ToolButton('next')
        self.btPlay.connect('clicked', self.onBtPlayClicked)
        self.toolbar.insert(self.btPlay, -1)
        self.btPlay.show()

        self.btStop = ToolButton('process-stop')
        self.btStop.connect('clicked', self.onBtStopClicked)
        self.toolbar.insert(self.btStop, -1)
        self.btStop.show()

        self.btStop.props.sensitive = False;
        self.btPlay.props.sensitive = True;

        toolbox.set_current_toolbar(1)
 def __init__(self, handle):
     activity.Activity.__init__(self, handle)
     os.environ["FILEMANAGER_PATH"] = os.path.join(
         os.environ["SUGAR_BUNDLE_PATH"], "share", "sugar-file-manager")
     self.set_title("Sugar File Manager")
     toolbox = activity.ActivityToolbox(self)
     self.set_toolbox(toolbox)
     toolbox.show()
     toolbox.get_activity_toolbar().share.hide()
     toolbox.get_activity_toolbar().keep.hide()
     #vbox = gtk.VBox() 	 # NO ENCONTRE SOLUCIÓN
     #toolbar = gtk.Toolbar()
     #button1 = gtk.ToolButton("gtk-go-up")
     #button1.show()
     #toolbar.insert(button1, -1)
     #refresh = gtk.ToolButton("gtk-refresh")
     #refresh.show()
     #toolbar.insert(refresh, -1)
     toolbar.show()
     vbox.pack_start(toolbar, False, True)
     widget = filemanager.Widget()
     #go_up.connect("clicked", go_up_callback, widget)
     #refresh.connect("clicked", refresh_callback, widget)
     widget.show()
     current_directory = gio.File(path=os.environ["HOME"])
     widget.set_current_directory(current_directory.get_uri())
     widget.connect("file-menu", self.file_menu)
     widget.connect('current-directory-menu', self.current_directory_menu)
     vbox.pack_start(widget, True, True, 0)
     vbox.show()
     self.set_canvas(widget)
     self.show()
Exemplo n.º 7
0
 def __init__(self, handle):
     activity.Activity.__init__(self, handle)
     self.toolbox = activity.ActivityToolbox(self)
     activity_toolbar = self.toolbox.get_activity_toolbar()
     activity_toolbar.share.props.visible = False
     activity_toolbar.keep.props.visible = False
     connect = ToolButton("gtk-refresh")
     connect.props.tooltip = "Conectar"
     connect.connect("clicked", self.connect_vnc)
     connect.show()
     activity_toolbar.insert(connect, 2)
     fullscreen = ToolButton("view-fullscreen")
     fullscreen.props.tooltip = "Pantalla Completa"
     fullscreen.connect("clicked", self.fullscreen_cb)
     fullscreen.show()
     activity_toolbar.insert(fullscreen, 2)
     self.set_toolbox(self.toolbox)
     self.toolbox.show()
     area = gtk.ScrolledWindow()
     area.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     area.show()
     self.vnc = GRFBWidget()
     area.add_with_viewport(self.vnc)
     self.vnc.show()
     self.set_canvas(area)
     self.present()
     self.maximize()
     self.show()
Exemplo n.º 8
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        logging.debug('Starting the XoIRC Activity')
        self.set_title(_('Xo IRC Activity'))

        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.connect('visibility-notify-event',
                     self.__visibility_notify_event_cb)

        self.is_visible = False

        client = purk.Client()
        client.add_channel('#sugar')
        client.add_channel('#olpc-paraguay')
        client.join_server('irc.freenode.net')
        client.show()
        widget = client.get_widget()

        # CANVAS
        self.set_canvas(widget)

        # TOOLBAR
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        self.show_all()
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        try:
            view = gnash.View()
            view.props.uri = os.path.join(activity.get_bundle_path(), SWFNAME)
            self.set_canvas(view)
            view.show()

        except NameError:
            socket = gtk.Socket()
            self.set_canvas(socket)
            self.show_all()

            args = [
                'gnash', '-x',
                str(socket.get_id()),
                os.path.join(activity.get_bundle_path(), SWFNAME)
            ]
            logging.debug(args)
            self._process = subprocess.Popen(args)
Exemplo n.º 10
0
    def __init__(self, handle):
        super(PeterActivity, self).__init__(handle)

        # Build the activity toolbar.
        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False

        toolbox.show()
        self.set_toolbox(toolbox)

        # Create the game instance.
        self.game = PMJ.PMJ()

        # Build the Pygame canvas.
        self._pygamecanvas = \
            sugargame.canvas.PygameCanvas(self)
        # Note that set_canvas implicitly calls
        # read_file when resuming from the Journal.
        self.set_canvas(self._pygamecanvas)
        self.game.canvas = self._pygamecanvas

        # Start the game running.
        self._pygamecanvas.run_pygame(self.game.run)
Exemplo n.º 11
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_canvas(canvas.widget)
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        alert = Alert()
        # Populate the title and text body of the alert.
        alert.props.title = 'Current Recording'
        alert.props.msg = 'recording information goes here'
        stop_icon = Icon(icon_name='dialog-cancel')
        stop_icon.set_pixel_size(50)
        alert.add_button(gtk.RESPONSE_CANCEL, 'End', stop_icon)
        stop_icon.show()
        alert.connect('response', singletab.stop)
        alert.connect('response', incramentaltab.stop)
        alert.connect('response', lapsetab.stop)
        # Call the add_alert() method (inherited via the sugar.graphics.Window superclass of Activity)
        # to add this alert to the activity window.
        self.add_alert(alert)
        alert.hide()

        for tab in tabs:
            toolbox.add_toolbar(tab.tab_name, tab.widget)
            tab.set_alert(alert)
Exemplo n.º 12
0
    def __init__(self, handle):
        """Creates a plotter application window."""
        activity.Activity.__init__(self, handle)

        # create toolbox: this provides default sugar controls
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        # setup container for glade widgets
        main_view = gtk.VBox()

        # load Glade XML and get main window
        # get the VBox that's a child of the glade window
        self._app = app = Plotter()
        app.plot_scrolledwindow.reparent(main_view)
        app.plot_scrolledwindow.show()

        # create edit toolbar
        edit_toolbar = activity.EditToolbar()
        toolbox.add_toolbar(_("Edit"), edit_toolbar)
        edit_toolbar.show()

        # connect undo/redo to app events
        edit_toolbar.undo.connect("clicked", app.on_undo)
        edit_toolbar.redo.connect("clicked", app.on_redo)
        edit_toolbar.copy.connect("clicked", app.on_copy)
        edit_toolbar.paste.connect("clicked", app.on_paste)

        # make main_view act as our canvas
        main_view.show()
        self.set_canvas(main_view)
        self.show_all()
Exemplo n.º 13
0
    def __init__(sfelf, handle):
        import gtk, pango, vte
        super(VteActivity, self).__init__(handle)
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        # creates vte widget
        self._vte = vte.Terminal()
        self._vte.set_size(30, 5)
        self._vte.set_size_request(200, 300)
        font = 'Monospace 10'
        self._vte.set_font(pango.FontDescription(font))
        self._vte.set_colors(gtk.gdk.color_parse('#000000'),
                             gtk.gdk.color_parse('#E7E7E7'), [])
        # ...and its scrollbar
        vtebox = gtk.HBox()
        vtebox.pack_start(self._vte)
        vtesb = gtk.VScrollbar(self._vte.get_adjustment())
        vtesb.show()
        vtebox.pack_start(vtesb, False, False, 0)
        self.set_canvas(vtebox)
        self.show_all()

        # now start subprocess.
        self._vte.grab_focus()
        bundle_path = activity.get_bundle_path()
        # the 'sleep 1' works around a bug with the command dying before
        # the vte widget manages to snarf the last bits of its output
        self._pid = self._vte.fork_command \
                    (command='/bin/sh',
                     argv=['/bin/sh','-c',
                           'python %s/pippy_app.py; sleep 1' % bundle_path],
                     envv=["PYTHONPATH=%s/library" % bundle_path],
                     directory=bundle_path)
Exemplo n.º 14
0
    def __init__(self, handle):
        """Set up the GoGo activity."""

        activity.Activity.__init__(self, handle)
        self.set_title(_('GoGo'))
        logging.info(_('GoGo'))

        # Show the toolbox elements
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        self.monitor = BoardMonitor(self)

        # Display everything
        vb = gtk.VBox()
        self.monitor.notebookMain.reparent(vb)
        self.monitor.statusbar.reparent(vb)
        self.set_canvas(vb)
        self.show_all()

        if runningOnXO():
            try:
                self.APM = power.get_automatic_pm()
                power.set_automatic_pm(False)
            except:
                pass
Exemplo n.º 15
0
    def __init__(self, handle):
        print "running activity init", handle
        activity.Activity.__init__(self, handle)
        print "activity running"

        self.set_title('Hello World')

        # Creates the Toolbox. It contains the Activity Toolbar, which is the
        # bar that appears on every Sugar window and contains essential
        # functionalities, such as the 'Collaborate' and 'Close' buttons.
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        # Creates a new button with the label "Hello World".
        self.button = gtk.Button("Hello World")
    
        # When the button receives the "clicked" signal, it will call the
        # function hello() passing it None as its argument.  The hello()
        # function is defined above.
        self.button.connect("clicked", self.hello, None)
    
        # Set the button to be our canvas. The canvas is the main section of
        # every Sugar Window. It fills all the area below the toolbox.
        self.set_canvas(self.button)
    
        # The final step is to display this newly created widget.
        self.button.show()
    
        print "AT END OF THE CLASS"
Exemplo n.º 16
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        if self._NEW_TOOLBAR_SUPPORT:  #toolbar nuevo
            #self.toolbar_box = sugar.graphics.toolbarbox.ToolbarBox()
            self.toolbar_box = sugar.activity.widgets.ActivityToolbar(self)
            self.toolbar_box.keep.hide()

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

            self.set_toolbar_box(self.toolbar_box)
            self.toolbar_box.show()

        else:  #old toolbar
            toolbox = activity.ActivityToolbox(self)

            activity_toolbar = toolbox.get_activity_toolbar()
            activity_toolbar.share.props.visible = False  #Todavia no hay share
            activity_toolbar.show()

            self.set_toolbox(toolbox)
            toolbox.show()

        self.activity = Control()

        self.set_canvas(self.activity.todo)
        self.nomArch = ""

        self.connect('key_press_event', self.activity.onKeyPress)
Exemplo n.º 17
0
 def __init__(self, handle):
     # fork pygame before we initialize the activity.
     import os
     import pygame
     import sys
     pygame.init()
     windowid = pygame.display.get_wm_info()['wmwindow']
     self.child_pid = os.fork()
     if self.child_pid == 0:
         bp = activity.get_bundle_path()
         library_path = os.path.join(bp, 'library')
         pippy_app_path = os.path.join(bp, 'pippy_app.py')
         sys.path[0:0] = [library_path]
         g = globals()
         g['__name__'] = '__main__'
         execfile(pippy_app_path, g, g)  # start pygame
         sys.exit(0)
     super(PyGameActivity, self).__init__(handle)
     import gobject
     import gtk
     toolbox = activity.ActivityToolbox(self)
     toolbar = toolbox.get_activity_toolbar()
     self.set_toolbox(toolbox)
     toolbox.show()
     socket = gtk.Socket()
     socket.set_flags(socket.flags() | gtk.CAN_FOCUS)
     socket.show()
     self.set_canvas(socket)
     socket.add_id(windowid)
     self.show_all()
     socket.grab_focus()
     gobject.child_watch_add(self.child_pid, lambda pid, cond: self.close())
     # hide the buttons we don't use.
     toolbar.share.hide()  # this should share bundle.
     toolbar.keep.hide()
	def __init__(self, handle):
		activity.Activity.__init__(self, handle)
		self.toolbox = activity.ActivityToolbox(self)
		activity_toolbar = self.toolbox.get_activity_toolbar()
		activity_toolbar.share.props.visible = False
		activity_toolbar.keep.props.visible = False
		go_up = ToolButton("gtk-go-up")
		go_up.props.tooltip = _("Go Up")
		go_up.show()
		activity_toolbar.insert(go_up, 2)
		refresh = ToolButton("gtk-refresh")
		refresh.props.tooltip = _("Refresh")
		refresh.show()
		activity_toolbar.insert(refresh, 2)
		self.set_toolbox(self.toolbox)
		self.toolbox.show()
		widget = filemanager.Widget()
		go_up.connect("clicked", self.go_up_callback, widget)
		refresh.connect("clicked", self.refresh_callback, widget)
		widget.show()
		current_directory = gio.File(path=os.environ["HOME"])
		widget.set_current_directory(current_directory.get_uri())
		widget.connect("file-menu", self.file_menu)
		widget.connect('current-directory-menu', self.current_directory_menu)
		self.set_canvas(widget)
		self.show()
Exemplo n.º 19
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self._name = handle

        # Set title for our Activity
        self.set_title(_('Clic Player'))

        # Attach sugar toolbox (Share, ...)
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        # Create the main container
        self._main_view = gtk.VBox()
        
        # Import our class Manager():

        # Step 1: Load class, which creates Manager.widget
        self.Manager = Manager()

        # Step 2: Remove the widget's parent
        if self.Manager.widget.parent:
            self.Manager.widget.parent.remove(self.Manager.widget)
 
        # Step 3: We attach that widget to our window
        self._main_view.pack_start(self.Manager.widget)

        # Display everything
        self.Manager.widget.show()
        self._main_view.show()
        self.set_canvas(self._main_view)
        self.show()
        
        #called every 250 miliseconds (for pygame)
        gobject.timeout_add(250, self.Manager.updating)
Exemplo n.º 20
0
    def __init__(self, handle):
        # !!!!!! initialize threading in gtk !!!!!
        # ! this is important for the networking !
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        gtk.gdk.threads_init()

        activity.Activity.__init__(self, handle)

        for snd in ['mic1', 'mic2', 'mic3', 'mic4']:
            if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
                shutil.copyfile(Config.SOUNDS_DIR + '/' + snd,
                                Config.DATA_DIR + '/' + snd)
                os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')

        color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(gtk.STATE_NORMAL, color)

        self.set_title('TamTam Jam')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        if Config.HAVE_TOOLBOX:
            self.toolbox = ToolbarBox()
            self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self),
                                        -1)
            self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1)
        else:
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

        self.toolbox.show()

        self.trackpad.setContext('jam')
        self.jam = JamMain(self)
        self.connect('key-press-event', self.jam.onKeyPress)
        self.connect('key-release-event', self.jam.onKeyRelease)
        #self.modeList[mode].regenerate()

        self.set_canvas(self.jam)

        self.jam.onActivate(arg=None)

        if Config.HAVE_TOOLBOX:
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            self.toolbox.toolbar.insert(separator, -1)
            self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
            self.toolbox.toolbar.show_all()

        self.show()
Exemplo n.º 21
0
    def __init__(self, handle):

        activity.Activity.__init__(self, handle, False)

        barraprincipal = activity.ActivityToolbox(self)
        self.set_toolbox(barraprincipal)

        self.show_all()
        os.system("./emesene")
Exemplo n.º 22
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        #        for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
        #            if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
        #                shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd)
        #                os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')

        color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(gtk.STATE_NORMAL, color)

        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        if Config.HAVE_TOOLBOX:
            # no sharing
            self.max_participants = 1

            self.toolbox = ToolbarBox()
            self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self),
                                        -1)
        else:
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

            self.activity_toolbar = self.toolbox.get_activity_toolbar()

        self.toolbox.show()

        self.trackpad.setContext('edit')
        self.edit = MainWindow(self)
        self.connect('key-press-event', self.edit.onKeyPress)
        self.connect('key-release-event', self.edit.onKeyRelease)
        #self.modeList[mode].regenerate()

        self.set_canvas(self.edit)

        self.edit.onActivate(arg=None)

        if Config.HAVE_TOOLBOX:
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            self.toolbox.toolbar.insert(separator, -1)
            self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
            self.toolbox.toolbar.show_all()
        else:
            self.activity_toolbar.share.hide()

        self.show()
Exemplo n.º 23
0
    def __init__(self, handle):
        self.mini = None

        activity.Activity.__init__(self, handle)

        color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(gtk.STATE_NORMAL, color)

        self.set_title('TamTam Mini')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)
        self.trackpad.setContext('mini')

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        if Config.HAVE_TOOLBOX:
            self.toolbox = ToolbarBox()
            self.toolbox.toolbar.insert(widgets.ActivityButton(self), -1)
            self.toolbox.toolbar.insert(widgets.TitleEntry(self), -1)

            try:
                from sugar.activity.widgets import DescriptionItem
            except ImportError:
               logging.debug('DescriptionItem button is not available,' +
                    'toolkit version < 0.96')
            else:
                description_item = DescriptionItem(self)
                self.toolbox.toolbar.insert(description_item, -1)
                description_item.show()

            self.toolbox.toolbar.insert(widgets.ShareButton(self), -1)
        else:
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

        self.toolbox.show()

        self.mini = miniTamTamMain(self)
        self.mini.onActivate(arg=None)
        self.mini.updateInstrumentPanel()
        #self.modeList[mode].regenerate()

        self.set_canvas(self.mini)
        self.mini.instrumentPanel.grab_focus()

        if Config.HAVE_TOOLBOX:
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            self.toolbox.toolbar.insert(separator, -1)
            self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
            self.toolbox.toolbar.show_all()

        self.show()
Exemplo n.º 24
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        logging.debug('Starting the Frotz activity')

        self.set_title(_('Frotz'))
        self.connect('key-press-event', self.__key_press_cb)

        toolbox = activity.ActivityToolbox(self)

        self._edit_toolbar = activity.EditToolbar()
        toolbox.add_toolbar(_('Edit'), self._edit_toolbar)
        self._edit_toolbar.show()
        self._edit_toolbar.undo.props.visible = False
        self._edit_toolbar.redo.props.visible = False
        self._edit_toolbar.separator.props.visible = False
        self._edit_toolbar.copy.connect('clicked', self._copy_cb)
        self._edit_toolbar.paste.connect('clicked', self._paste_cb)

        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.share.props.visible = False
        activity_toolbar.keep.props.visible = False

        # Add a button that will send you to the ifarchive to get more games
        activity_toolbar.get_games = ToolButton('activity-get-games')
        activity_toolbar.get_games.set_tooltip(_('Get More Games'))
        activity_toolbar.get_games.connect('clicked', self._get_games_cb)
        activity_toolbar.insert(activity_toolbar.get_games, 2)
        activity_toolbar.get_games.show()

        self.set_toolbox(toolbox)
        toolbox.show()

        box = gtk.HBox(False, 4)

        self._vte = VTE()
        self._vte.show()
        self._vte.connect("child-exited", self._quit_cb)

        scrollbar = gtk.VScrollbar(self._vte.get_adjustment())
        scrollbar.show()

        box.pack_start(self._vte)
        box.pack_start(scrollbar, False, False, 0)

        self.set_canvas(box)
        box.show()

        self._vte.grab_focus()

        self.game_started = False
        default_game_file = os.path.join(activity.get_bundle_path(),
                                         "Advent.z5")
        # when we return to the idle state, launch the default game
        # if read_file is called, that will override this
        gobject.idle_add(self.start_game, default_game_file)
Exemplo n.º 25
0
    def __init__(self, handle):
        import gtk, pango, platform, sys
        from ctypes import cdll

        if platform.machine().startswith('arm'):
            pass  # FIXME
        else:
            if platform.architecture()[0] == '64bit':
                vte_path = "x86-64"
            else:
                vte_path = "x86"
            vte = cdll.LoadLibrary("lib/%s/libvte.so.9" % vte_path)
        sys.path.append("lib/%s" % vte_path)

        import vte

        super(VteActivity, self).__init__(handle, create_jobject=False)
        self.__source_object_id = None

        # creates vte widget
        self._vte = vte.Terminal()

        if DEBUG_TERMINAL:
            toolbox = activity.ActivityToolbox(self)
            toolbar = toolbox.get_activity_toolbar()
            self.set_toolbox(toolbox)

            self._vte.set_size(30, 5)
            self._vte.set_size_request(200, 300)
            font = 'Monospace 10'
            self._vte.set_font(pango.FontDescription(font))
            self._vte.set_colors(gtk.gdk.color_parse('#E7E7E7'),
                                 gtk.gdk.color_parse('#000000'), [])

            vtebox = gtk.HBox()
            vtebox.pack_start(self._vte)
            vtesb = gtk.VScrollbar(self._vte.get_adjustment())
            vtesb.show()
            vtebox.pack_start(vtesb, False, False, 0)
            self.set_canvas(vtebox)

            toolbox.show()
            self.show_all()
            toolbar.share.hide()
            toolbar.keep.hide()

        # now start subprocess.
        self._vte.connect('child-exited', self.on_child_exit)
        self._vte.grab_focus()
        bundle_path = activity.get_bundle_path()
        self._pid = self._vte.fork_command \
            (command='/bin/sh',
             argv=['/bin/sh','-c',
             'python %s/blocku.py' % bundle_path],
             envv=["PYTHONPATH=%s/library" % bundle_path],
             directory=bundle_path)
Exemplo n.º 26
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.
        """
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()
        return toolbox
Exemplo n.º 27
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        app = sonata.Base(self, True)
        logging.info('done setting up sonata')
        self.set_title('Sonata')
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(gtk.STATE_NORMAL, color)

        self.set_title('TamTam SynthLab')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        if Config.HAVE_TOOLBOX:
            # no sharing
            self.max_participants = 1

            self.toolbox = ToolbarBox()
            self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0)
            self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1)
        else:
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)
            # no sharing
            self.activity_toolbar = self.toolbox.get_activity_toolbar()
            self.activity_toolbar.share.hide()
            self.activity_toolbar.keep.hide()

        self.toolbox.show()

        self.trackpad.setContext('synthLab')
        self.synthLab = SynthLabMain(self)
        self.connect('key-press-event', self.synthLab.onKeyPress)
        self.connect('key-release-event', self.synthLab.onKeyRelease)

        self.connect("key-press-event", self.synthLab.onKeyPress)
        self.connect("key-release-event", self.synthLab.onKeyRelease)

        self.set_canvas(self.synthLab)

        self.synthLab.onActivate(arg=None)

        if Config.HAVE_TOOLBOX:
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            self.toolbox.toolbar.insert(separator, -1)
            self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
            self.toolbox.toolbar.show_all()

        self.show()
Exemplo n.º 29
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self._name = handle
        self.metadata['mime_type'] = 'application/x-kandid-activity'
        self._print_greetings(handle)
        self._status = ka_status.Status.instance()
        self._joined_buddies = set([])
        self._new_tubes = []
        # Set title for our Activity
        self.set_title('Kandid')

        # Attach sugar toolbox (Share, ...)
        try:
            # try sugar 0.86
            ka_debug.info('searching sugar 0.86, sugar.graphics.toolbarbox')
            import sugar.graphics.toolbarbox
            toolbar_box = sugar.graphics.toolbarbox.ToolbarBox()
            self._add_toolbar_buttons(toolbar_box)
            self.set_toolbar_box(toolbar_box)
        except:
            ka_debug.err('failed sugar 0.86 toolbarbox [%s] [%s]' % \
                   (sys.exc_info()[0], sys.exc_info()[1]))
            traceback.print_exc(file=sys.__stderr__)
            # try sugar 0.82
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)

        # Create the main container
        main_view = gtk.HBox()
        self._widget = ka_widget.KandidWidget()
        main_view.pack_start(self._widget.get_widget_tree())
        # Create a controller to connect view and model
        self._controller = ka_controller.KandidController( \
                                                      self._widget,
                                                      self.get_activity_root(),
                                                      handle.object_id is None)
        self._controller.create_pages()
        self.set_canvas(main_view)

        self.kandidtube = None  # Shared session
        self.initiating = False
        self.telepathy_conn = None
        self.tubes_chan = None
        self.text_chan = None

        # get the Presence Service
        self.pservice = presenceservice.get_instance()
        self._start_collaboration()

        self.show_all()
        if handle.object_id is None:
            self._controller.switch_page('GettingstartedController')
Exemplo n.º 30
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_title('MapStats')

        # The XOCom object helps us communicate with the browser
        # This uses web/index.html as the default page to load
        self.xocom = XOCom()

        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        self.set_canvas(self.xocom.create_webview())