Exemple #1
0
    def build_toolbar(self):

        toolbox = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbox.toolbar.insert(activity_button, -1)
        activity_button.show()

        self.build_calibrate_toolbar(toolbox)
        self.build_options_toolbar(toolbox)
        self.build_resolution_toolbar(toolbox)
        self.build_colors_toolbar(toolbox)

        separador13 = gtk.SeparatorToolItem()
        separador13.props.draw = False
        separador13.set_expand(True)
        toolbox.toolbar.insert(separador13, -1)

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

        self.set_toolbox(toolbox)
        toolbox.show()

        self.show_all()
    def _setup_toolbar(self):
        if pre_086_toolbars:
            self.toolbox = Toolbox()
            self.set_toolbox(self.toolbox)

            toolbar = gtk.Toolbar()
            self.toolbox.add_toolbar('Toolbar', toolbar)
            toolbar_box = self.toolbox

        else:
            toolbar_box = ToolbarBox()
            toolbar = toolbar_box.toolbar
            self.set_toolbar_box(toolbar_box)

        self._restore_button = RestoreButton()
        self._restore_button.connect('clicked', self._restore_cb)
        self._restore_button.set_sensitive(False)
        toolbar.insert(self._restore_button, -1)

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

        stop_button = StopButton(self)
        toolbar.insert(stop_button, -1)

        toolbar_box.show_all()
Exemple #3
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        # Pause/Play button:

        stop_play = ToolButton('media-playback-stop')
        stop_play.set_tooltip(_("Stop"))
        stop_play.set_accelerator(_('<ctrl>space'))
        stop_play.connect('clicked', self._stop_play_cb)
        stop_play.show()

        toolbar_box.toolbar.insert(stop_play, -1)

        # Blank space (separator) and Stop button at the end:

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
    def setup_toolbar(self):
        '''Setup the top toolbar. Groupthink needs some work here.'''
        toolbar_box = ToolbarBox()

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

        self.edit_toolbar = EditToolbar()
        edit_toolbar_button = ToolbarButton(page=self.edit_toolbar,
                                            icon_name='toolbar-edit')
        self.edit_toolbar.show()
        toolbar_box.toolbar.insert(edit_toolbar_button, -1)
        edit_toolbar_button.show()

        self.edit_toolbar.undo.connect('clicked', self.undobutton_cb)
        self.edit_toolbar.redo.connect('clicked', self.redobutton_cb)
        self.edit_toolbar.copy.connect('clicked', self.copybutton_cb)
        self.edit_toolbar.paste.connect('clicked', self.pastebutton_cb)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.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()
Exemple #5
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        self.blocklist = [] 
        self.radioList = {}
        for c in tools.allTools:                             
            button = ToolButton(c.icon)
            button.set_tooltip(_(c.toolTip))
            button.connect('clicked',self.radioClicked)
            toolbar_box.toolbar.insert(button, -1)    
            button.show()
            self.radioList[button] = c.name
       
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.show_all()
Exemple #6
0
    def build_toolbar(self):

        toolbox = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbox.toolbar.insert(activity_button, -1)
        activity_button.show()

        self.build_calibrate_toolbar(toolbox)
        self.build_options_toolbar(toolbox)
        self.build_resolution_toolbar(toolbox)
        self.build_colors_toolbar(toolbox)

        separador13 = gtk.SeparatorToolItem()
        separador13.props.draw = False
        separador13.set_expand(True)
        toolbox.toolbar.insert(separador13, -1)

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

        self.set_toolbox(toolbox)
        toolbox.show()

        self.show_all()
Exemple #7
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 #8
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self._name = handle

        self.num = mynum.Numbers()

        if NEW_TOOLBARS:
            toolbar_box = ToolbarBox()

            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            toolbar_box.toolbar.insert(separator, -1)
            separator.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()

        else:
            toolbox = ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.show()

        if self.num.widget.parent:
            self.num.widget.parent.remove(self.num.widget)

        self.num.widget.show()
        self.set_canvas(self.num.widget)
        self.show_all()
        self.num.setActivity(self)
Exemple #9
0
    def build_toolbar(self):

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

        separator = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()

        return toolbar_box
    def build_toolbar(self):
        """Build our Activity toolbar for the Sugar system."""

        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()

        self.connect("destroy", self.__stop_pygame)

        return toolbar_box
Exemple #11
0
    def _configure_toolbars(self):
        if _USE_OLD_TOOLBARS:
            toolbox = ActivityToolbox(self)
            toolbar = gtk.Toolbar()
        else:
            toolbar_box = ToolbarBox()
            toolbar = toolbar_box.toolbar

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

            self._add_expander(toolbar_box.toolbar)

            toolbar.add(gtk.SeparatorToolItem())

        if _USE_OLD_TOOLBARS:
            self.set_toolbox(toolbox)
            toolbox.show()
        else:
            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()
    def build_toolbar(self):

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

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

        button = ToolButton('speaker-muted-100')
        button.set_tooltip(_('Sound'))
        button.connect('clicked', self.sound_control)
        toolbar_box.toolbar.insert(button, -1)

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.show_all()
    def build_toolbar(self):

        self.max_participants = 1

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

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

        self.create_help(toolbar_box.toolbar)

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.show_all()
Exemple #14
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()
Exemple #15
0
    def __init__(self, handle):
        """Set up the HelloWorld activity."""
        activity.Activity.__init__(self, handle)

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        self.load_data()
        self.cargar_ui()
    def build_toolbar(self):

        toolbox = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        toolbox.toolbar.insert(activity_button, -1)
        activity_button.show()

        barra = toolbox.toolbar

        """
        separator1 = gtk.SeparatorToolItem()
        separator1.props.draw = True
        separator1.set_expand(False)
        barra.insert(separator1,-1)

        save_button = ToolButton('filesave')
        save_button.set_tooltip(_('Save Image'))
        save_button.connect('clicked', self._savebutton_cb)
        barra.insert(save_button, -1)
        save_button.show()"""

        separator2 = gtk.SeparatorToolItem()
        separator2.props.draw = False
        separator2.set_expand(True)
        barra.insert(separator2, -1)

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        barra.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbox)

        toolbox.show_all()
Exemple #17
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

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

        item1 = gtk.ToolItem()
        label1 = gtk.Label()
        label1.set_text(_('Levels') + ' ')
        item1.add(label1)
        toolbar_box.toolbar.insert(item1, -1)

        item2 = gtk.ToolItem()

        levels = (_('Cross'),
            _('Cross 2'),
            #TRANS:'chimney' - the place where you make fire
            _('Hearth'),
            _('Arrow'),
            _('Pyramid'),
            _('Diamond'),
            _('Solitaire'))
        combo = Combo(levels)
        item2.add(combo)
        combo.connect('changed', self.change_combo)
        toolbar_box.toolbar.insert(item2, -1)

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

        sound_button = ToolButton('speaker-muted-100')
        sound_button.set_tooltip(_('Sound'))
        sound_button.connect('clicked', self.sound_control)
        toolbar_box.toolbar.insert(sound_button, -1)

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()


        self.show_all()
Exemple #18
0
    def __init__(self, pca):
        self.ca = pca
        # listen for ctrl+c & escape key
        self.ca.connect('key-press-event', self._key_press_event_cb)
        self.ACTIVE = False
        self.LAUNCHING = True
        self.ca.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.ca.connect("visibility-notify-event", self._visible_notify_cb)

        self.control_bar_ht = 60

        # True when we're showing live video feed in the primary screen
        self.CAPTUREMODE = True

        #self.inset = self.__class__.dim_INSET

        #init
        self.mapped = False
        self.setup = False

        self.tbars = {Constants.MODE_VIDEO: 1, Constants.MODE_HELP: 2}

        # Use 0.86 toolbar design
        self.toolbox = ToolbarBox()

        # Buttons added to the Activity toolbar
        activity_button = ActivityToolbarButton(self.ca)
        self.toolbox.toolbar.insert(activity_button, 0)
        activity_button.show()
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        separator.show()
        self.toolbox.toolbar.insert(separator, -1)

        # The ever-present Stop Button
        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>Q'
        self.toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.ca.set_toolbar_box(self.toolbox)
        self.toolbox.show()
        self.toolbox_ht = self.toolbox.size_request()[1]
        self.vh = gtk.gdk.screen_height() - \
                  (self.toolbox_ht + self.control_bar_ht)
        self.vw = int(self.vh / .75)

        main_box = gtk.VBox()
        self.ca.set_canvas(main_box)
        main_box.get_parent().modify_bg(gtk.STATE_NORMAL,
                                        Constants.color_black.gColor)
        main_box.show()

        self._play_button = PlayButton()
        self._play_button.connect('clicked', self._button_play_click)
        main_box.pack_start(self._play_button, expand=True)
        self._play_button.show()
        self.setup_windows()
Exemple #19
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

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

        item1 = gtk.ToolItem()
        label1 = gtk.Label()
        label1.set_text(_('Levels') + ' ')
        item1.add(label1)
        toolbar_box.toolbar.insert(item1, -1)

        item2 = gtk.ToolItem()

        levels = (
            _('Cross'),
            _('Cross 2'),
            #TRANS:'chimney' - the place where you make fire
            _('Hearth'),
            _('Arrow'),
            _('Pyramid'),
            _('Diamond'),
            _('Solitaire'))
        combo = Combo(levels)
        item2.add(combo)
        combo.connect('changed', self.change_combo)
        toolbar_box.toolbar.insert(item2, -1)

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

        sound_button = ToolButton('speaker-muted-100')
        sound_button.set_tooltip(_('Sound'))
        sound_button.connect('clicked', self.sound_control)
        toolbar_box.toolbar.insert(sound_button, -1)

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.show_all()
Exemple #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()
    def create_toolbar(self):
        """ 
	    This function creates the game toolbar
        """
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.toolbar.insert(ActivityToolbarButton(self), -1)

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

	scoreButton = ScoreButton(self)
	toolbar_box.toolbar.insert(scoreButton, -1)

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

	self._modes = ToolComboBox()
        self._modelist = ['Select Mode', '+ Addition', '- Subtraction']
       	for i, f in enumerate(self._modelist):
         self._modes.combo.append_item(i, f) 
       	self.modes_handle_id = self._modes.combo.connect("changed", self._change_modes_toolbar)
        toolbar_box.toolbar.insert(self._modes, -1)
        self._modes.combo.set_active(0)

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

	scorestats = VisualScore(self)
	toolbar_box.toolbar.insert(scorestats, -1)

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

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

	timestats = VisualTime(self)
	toolbar_box.toolbar.insert(timestats, -1)

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

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

	stopButton = StopButton(self)
	toolbar_box.toolbar.insert(stopButton, -1)
        toolbar_box.show_all()
Exemple #22
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()
Exemple #23
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()
    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()
Exemple #25
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', self.toolbar, self._new_game_cb,
            tooltip=_('Start a new game.'))

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

        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', self.toolbar, self._dialog_cb,
            tooltip=_('Turn complete'))

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

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

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

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

            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl>q'
            toolbox.toolbar.insert(stop_button, -1)
            stop_button.show()
Exemple #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.
        """

        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:
 def __init__(self, activity):
     ToolbarBox.__init__(self)
     self._parent = activity
     separator = gtk.SeparatorToolItem()
     separator.set_draw(False)
     separator.set_expand(True)
     separator.show()
     self.toolbar.insert(separator, -1)
     self.stopbutton = StopButton(activity)
     self.toolbar.insert(self.stopbutton, -1)
     self.stopbutton.show()
Exemple #28
0
    def build_toolbar(self):

        self.max_participants = 1

        toolbox = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        toolbox.toolbar.insert(activity_button, -1)
        activity_button.show()

        pano_toolbar = toolbox.toolbar

        new_button = ToolButton('stock_refresh')
        new_button.set_tooltip(_('New Panorama'))
        new_button.connect('clicked', self.new_event)
        pano_toolbar.insert(new_button, -1)
        new_button.show()

        capture_button = ToolButton('add_capture')
        capture_button.set_tooltip(_('Add a capture to the Panorama'))
        capture_button.connect('clicked', self.capture_event)
        pano_toolbar.insert(capture_button, -1)
        capture_button.show()

        stitch_button = ToolButton('format-columns-triple')
        stitch_button.set_tooltip(_('Stitch Panorama'))
        stitch_button.connect('clicked', self.stitch_event)
        pano_toolbar.insert(stitch_button, -1)
        stitch_button.show()

        stiching_auto = ToolButton('media-playback-start')
        stiching_auto.set_tooltip(_('Enable auto-stitch'))
        stiching_auto.connect('clicked', self.change_stich)
        pano_toolbar.insert(stiching_auto, -1)

        save_button = ToolButton('filesave')
        save_button.set_tooltip(_('Save Panorama'))
        save_button.connect('clicked', self.save_event)
        pano_toolbar.insert(save_button, -1)
        save_button.show()

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

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        pano_toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbox)

        toolbox.show_all()
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars.. """

        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()
            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)
            toolbar = games_toolbar

        # Add the buttons and labels to the toolbars
        self.level_button = button_factory(
            LEVEL_ICONS[self._play_level], toolbar, self.change_play_level_cb,
            tooltip=_('Set difficulty level.'))
        mode = self._play_mode
        mode += 1
        if mode == len(GAME_ICONS):
            mode = 0
        self.game_buttons = []
        for i in range(len(GAME_ICONS)):
            if i==0:
                self.game_buttons.append(radio_factory(
                        GAME_ICONS[0], toolbar, self.change_play_mode_cb,
                        cb_arg=0, tooltip=_('Select game.'), group=None))
            else:
                self.game_buttons.append(radio_factory(
                        GAME_ICONS[i], toolbar, self.change_play_mode_cb,
                        cb_arg=i, tooltip=_('Select game.'),
                        group=self.game_buttons[0]))
        self.game_buttons[mode].set_active(True)
        separator_factory(toolbar, False, True)
        self.status_label = label_factory(toolbar, _("drag to swap"))

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

            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl>q'
            toolbox.toolbar.insert(stop_button, -1)
            stop_button.show()
Exemple #30
0
    def __init__(self, handle):

        activity.Activity.__init__(self, handle)

        self.max_participants = 1

        toolbar_box = ToolbarBox()

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

        jugarc_button = ToolButton('chico')
        jugarc_button.set_tooltip(('Jugar el juego en pantalla chica'))
        jugarc_button.connect('clicked', self._jugar_chico)
        toolbar_box.toolbar.insert(jugarc_button, -1)
        jugarc_button.show

        jugarm_button = ToolButton('mediano')
        jugarm_button.set_tooltip(('Jugar el juego en pantalla mediana'))
        jugarm_button.connect('clicked', self._jugar_mediano)
        toolbar_box.toolbar.insert(jugarm_button, -1)
        jugarm_button.show

        jugarg_button = ToolButton('grande')
        jugarg_button.set_tooltip(('Jugar el juego en pantalla grande'))
        jugarg_button.connect('clicked', self._jugar_grande)
        toolbar_box.toolbar.insert(jugarg_button, -1)
        jugarg_button.show

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

        self.create_help(toolbar_box.toolbar)

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

        self._filechooser = gtk.FileChooserWidget(\
        action=gtk.FILE_CHOOSER_ACTION_OPEN,backend=None)
        self._filechooser.set_current_folder("/")
        self.botonJugar = gtk.Button("Jugar rom")
        self.botonJugar.connect('clicked', self._jugar_mediano)
        self.botonJugar.show()
        self._filechooser.set_extra_widget(self.botonJugar)
        self.set_canvas(self._filechooser)
        self.show_all()
Exemple #31
0
    def __init__(self, handle):
        """Set up the HelloWorld activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # advanced example widgets
        vbox = gtk.VBox()
        self.label = gtk.Label()
        self.entry = gtk.Entry()
        self.text = gtk.TextView()

        vbox.add(self.label)
        vbox.add(self.entry)
        vbox.add(self.text)

        self.set_canvas(vbox)
        vbox.show_all()

        self._logging_example()
        self._i18n_example()
Exemple #32
0
    def __init__(self, handle):

        activity.Activity.__init__(self, handle)

        self.max_participants = 10

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.back_button = BackButton()
        self.back_button.connect("clicked", self.show_options1)
        toolbar_box.toolbar.insert(self.back_button, 0)
        self.back_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        self.show_options()

        self._logger = logging.getLogger("hellomesh-activity")

        self.hellotube = None  # Shared session
        self.initiating = False

        # get the Presence Service
        self.pservice = presenceservice.get_instance()
        # Buddy object for you
        owner = self.pservice.get_owner()
        self.owner = owner

        self.connect("shared", self._shared_cb)
        self.connect("joined", self._joined_cb)
Exemple #33
0
    def __init__(self, handle):
        """Set up the Pilas activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features,
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        socket = gtk.Socket()
        socket.connect("plug-added", self._on_plugged_event)
        socket.set_flags(gtk.CAN_FOCUS)
        self.set_canvas(socket)
        self.set_focus(socket)
        socket.show()

        screen_width = gtk.gdk.screen_width()
        screen_height = gtk.gdk.screen_height()

        Popen(["python", "pilas_plug.py", str(socket.get_id()),
               str(screen_width), str(screen_height)], env=new_env)
    def __init__(self, handle):

        activity.Activity.__init__(self, handle)

        self.max_participants = 10

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.back_button = BackButton()
        self.back_button.connect('clicked', self.show_options1)
        toolbar_box.toolbar.insert(self.back_button, 0)
        self.back_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        self.show_options()

        self._logger = logging.getLogger('hellomesh-activity')

        self.hellotube = None  # Shared session
        self.initiating = False

        # get the Presence Service
        self.pservice = presenceservice.get_instance()
        # Buddy object for you
        owner = self.pservice.get_owner()
        self.owner = owner

        self.connect('shared', self._shared_cb)
        self.connect('joined', self._joined_cb)
Exemple #35
0
    def __init__(self, pca):
        self.ca = pca
        # listen for ctrl+c & escape key
        self.ca.connect('key-press-event', self._key_press_event_cb)
        self.ACTIVE = False
        self.LAUNCHING = True
        self.ca.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.ca.connect("visibility-notify-event", self._visible_notify_cb)

        self.control_bar_ht = 60

        # True when we're showing live video feed in the primary screen
        self.CAPTUREMODE = True

        #self.inset = self.__class__.dim_INSET

        #init
        self.mapped = False
        self.setup = False

        self.tbars = {Constants.MODE_VIDEO: 1,
                      Constants.MODE_HELP: 2}

        # Use 0.86 toolbar design
        self.toolbox = ToolbarBox()

        # Buttons added to the Activity toolbar
        activity_button = ActivityToolbarButton(self.ca)
        self.toolbox.toolbar.insert(activity_button, 0)
        activity_button.show()
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        separator.show()
        self.toolbox.toolbar.insert(separator, -1)

        # The ever-present Stop Button
        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>Q'
        self.toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.ca.set_toolbar_box(self.toolbox)
        self.toolbox.show()
        self.toolbox_ht = self.toolbox.size_request()[1]
        self.vh = gtk.gdk.screen_height() - \
                  (self.toolbox_ht + self.control_bar_ht)
        self.vw = int(self.vh / .75)

        main_box = gtk.VBox()
        self.ca.set_canvas(main_box)
        main_box.get_parent().modify_bg(gtk.STATE_NORMAL,
                                        Constants.color_black.gColor)
        main_box.show()

        self._play_button = PlayButton()
        self._play_button.connect('clicked', self._button_play_click)
        main_box.pack_start(self._play_button, expand=True)
        self._play_button.show()
        self.setup_windows()
Exemple #36
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        toolbar = toolbar_box.toolbar

        activity = ActivityToolbarButton(self)
        stop = StopButton(self)
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)

        retroness = gtk.Adjustment(3, 0, MAX_DELAY, 1, 10, 0)
        retroness.connect("value_changed", self.retroness_adjusted_cb)

        retro_bar = gtk.HScale(retroness)
        retro_bar.set_digits(0)
        retro_bar.set_value_pos(gtk.POS_RIGHT)
        retro_bar.set_size_request(240, 15)

        retro_tool = gtk.ToolItem()
        retro_tool.add(retro_bar)

        label = gtk.ToolItem()
        label.add(gtk.Label(_("Seconds Delayed:")))

        toolbar.insert(activity, -1)
        toolbar.insert(gtk.SeparatorToolItem(), -1)
        toolbar.insert(label, -1)
        toolbar.insert(retro_tool, -1)
        toolbar.insert(separator, -1)
        toolbar.insert(stop, -1)

        return toolbar_box
    def __init__(self, handle):
        super(Agenda, self).__init__(handle, True)
        tool = ToolbarBox()
        toolbar = tool.toolbar
        activitybtn = ActivityToolbarButton(self)
        self.separator = gtk.SeparatorToolItem()
        self.separator.props.draw = False
        self.separator.set_expand(True)
        stpbtn = StopButton(self)
        self.addbtn = ToolButton('add')
        self.addbtn.connect('clicked', self._show_palette_add_button)
        toolbar.insert(activitybtn, 0)
        toolbar.insert(gtk.SeparatorToolItem(), -1)
        toolbar.insert(self.addbtn, -1)
        toolbar.insert(self.separator, -1)
        toolbar.insert(stpbtn, -1)

        self.canvas = canvas()
        self.toolarea = AddTelephoneArea(self.addbtn, self.canvas)

        self.set_toolbar_box(tool)
        self.set_canvas(self.canvas)
        self.addbtn.set_tooltip(_('Add a new contact'))
        self._create_palette_add_button(self.addbtn)
        self.show_all()
Exemple #38
0
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)

        toolbar_box.toolbar.insert(separator, -1)
        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()
Exemple #39
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.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        if Config.HAVE_TOOLBOX:
            from sugar.graphics.toolbarbox import ToolbarBox
            from sugar.activity import widgets
            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:
                pass

            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.set_canvas(self.mini)

        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()
Exemple #40
0
    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()
Exemple #41
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.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)

        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()
    def __init__(self, handle):
        """Set up the HelloWorld activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # label with the text, make the string translatable
        #label = gtk.Label(_("Hello World!"))
        main = Main()

        self.set_canvas(main)
        main.show()
Exemple #43
0
    def __init__(self, handle):
        """Set up the ActivityTemplate activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # Code changes made by glucosa team, the three lines
        # makes the game graphic area.
        self.game = Game()
        self.set_canvas(self.game.canvas)

        self.game.canvas.show()
Exemple #44
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.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()
Exemple #45
0
 def add_line2(self):
     self.line = gtk.HBox()
     
     self.label = gtk.Label(_("sugar.activity.widgets.ActivityButton()"))
     self.line.add(self.label)        
     self.label.show()    
    
     toolbar_box1 = ToolbarBox()        
     self.line.add(toolbar_box1) 
     toolbar_box1.show()
     
     activity_button1 = ActivityButton(self)
     toolbar_box1.toolbar.insert(activity_button1, 0)
     activity_button1.show()       
     
     self.label1 = gtk.Label(_("Some Description"))
     self.line.add(self.label1)          
     self.label1.show()    
     
     self.container.add(self.line) 
     self.line.show() 
Exemple #46
0
 def add_line8(self):
     self.line = gtk.HBox()
     
     self.label = gtk.Label(_("sugar.activity.widgets.PasteButton()"))      
     self.line.add(self.label)  
     self.label.show()    
    
     toolbar_box1 = ToolbarBox()        
     self.line.add(toolbar_box1) 
     toolbar_box1.show()
     
     title_entry1 = PasteButton()
     toolbar_box1.toolbar.insert(title_entry1, 0)
     title_entry1.show()
      
     self.label1 = gtk.Label(_("Some Description"))
     self.line.add(self.label1)          
     self.label1.show()    
    
     self.container.add(self.line) 
     self.line.show() 
Exemple #47
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)

        toolbar_box.toolbar.insert(gtk.SeparatorToolItem(), -1)

        self.image_viewer = ImageCollectionViewer(False)

        prev_bt = ToolButton("go-previous-paired")
        prev_bt.connect("clicked", self.image_viewer.prev_anim_clicked_cb,
                None)
        toolbar_box.toolbar.insert(prev_bt, -1)

        next_bt = ToolButton("go-next-paired")
        next_bt.connect("clicked", self.image_viewer.next_anim_clicked_cb,
                None)
        toolbar_box.toolbar.insert(next_bt, -1)

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()

        self.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color())
        self.set_canvas(self.image_viewer)
Exemple #48
0
    def build_toolbar(self):
        """Build our Activity toolbar for the Sugar system."""

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

        separator = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        easier_button = ToolButton('create-easier')
        easier_button.set_tooltip(_('Easier level'))
        easier_button.connect('clicked', self._easier_button_cb)
        toolbar_box.toolbar.insert(easier_button, -1)

        harder_button = ToolButton('create-harder')
        harder_button.set_tooltip(_('Harder level'))
        harder_button.connect('clicked', self._harder_button_cb)
        toolbar_box.toolbar.insert(harder_button, -1)

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show_all()

        self.connect("destroy", self.__stop_pygame)

        return toolbar_box
    def __init__(self, handle):
        """Set up the LiveDemo activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityButton(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()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        # box principal
        main_box = gtk.VBox()
        self.init_gui(main_box)
        self.set_canvas(main_box)
        self.set_toolbar_box(toolbar_box)
        self.set_canvas(main_box)
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
        main_box.show_all()
        
        self.__path = os.path.dirname(os.path.abspath(__file__))
        self.__recognizer = helper.RecognitionHelper(self.__path)
        self.__recognizer.listen(self.final_result)
        self.__recognizer.start_listening()
Exemple #50
0
    def __init__(self, handle):
        """Set up the HelloWorld activity."""
        activity.Activity.__init__(self, handle)

        # Change the following number to change max participants
        self.max_participants = 1

        toolbar_box = ToolbarBox()

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

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # Change the following text to change the message (Default: 'Hello World!'
        label = gtk.Label(_("Hello World!"))
        self.set_canvas(label)
        label.show()
Exemple #51
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self._name = handle

        self.num = mynum.Numbers()
        
        if NEW_TOOLBARS:
            toolbar_box = ToolbarBox()
            
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            toolbar_box.toolbar.insert(separator, -1)
            separator.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()

        else:
            toolbox = ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.show()

        if self.num.widget.parent:
            self.num.widget.parent.remove(self.num.widget)
            
        
        self.num.widget.show()
        self.set_canvas(self.num.widget)
        self.show_all()
        self.num.setActivity(self)
Exemple #52
0
class TamTamMini(activity.Activity):

    __gtype_name__ = 'TamTamMiniWindow'

    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.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        if Config.HAVE_TOOLBOX:
            from sugar.graphics.toolbarbox import ToolbarBox
            from sugar.activity import widgets
            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:
                pass

            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.set_canvas(self.mini)

        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()

    def do_size_allocate(self, allocation):

        activity.Activity.do_size_allocate(self, allocation)

        if self.mini is not None:
            self.mini.updateInstrumentPanel()

    def onActive(self, widget=None, event=None):

        if widget.props.active == False:
            csnd = new_csound_client()
            csnd.connect(False)

        else:
            csnd = new_csound_client()
            csnd.connect(True)

    def onDestroy(self, arg2):
        if Config.DEBUG:
            print 'DEBUG: TamTam::onDestroy()'

        self.mini.onDestroy()

        csnd = new_csound_client()
        csnd.connect(False)
        csnd.destroy()

        gtk.main_quit()

    # no more dir created by TamTam
    def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
    def build_toolbar(self):
        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, -1)
        activity_button.show()

        tool_group = None

        self.game_button = RadioToolButton()
        self.game_button.props.icon_name = 'gamecanvas'
        self.game_button.set_tooltip(_('Juego'))
        self.game_button.accelerator = "<Ctrl>1"
        self.game_button.props.group = tool_group
        self.game_button.connect('clicked', self.show_game)
        toolbar_box.toolbar.insert(self.game_button, -1)
        self.game_button.show()
        tool_group = self.game_button

        button = RadioToolButton()
        button.props.icon_name = 'view-source'
        button.set_tooltip(_('Editor'))
        button.accelerator = "<Ctrl>2"
        button.props.group = tool_group
        button.connect('clicked', self.show_editor)
        toolbar_box.toolbar.insert(button, -1)
        button.show()

        self.save_button = ToolButton('dialog-ok')
        self.save_button.set_tooltip(_('Guardar'))
        self.save_button.accelerator = "<Ctrl>s"
        self.save_button.connect('clicked', self.save_file)
        self.save_button.set_sensitive(False)
        toolbar_box.toolbar.insert(self.save_button, -1)
        self.save_button.show()

        separator = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        button = ToolButton('system-restart')
        button.set_tooltip(_('Reiniciar juego'))
        button.accelerator = "<Alt><Shift>r"
        button.connect('clicked', self.restart_game)
        toolbar_box.toolbar.insert(button, -1)
        button.show()

        self.editor_button = ToolButton('sources')
        self.editor_button.set_tooltip(_('Consola'))
        self.editor_button.accelerator = "<Ctrl>grave"
        self.editor_button.connect('clicked', self.toggle_console)
        toolbar_box.toolbar.insert(self.editor_button, -1)
        self.editor_button.show()

        separator = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        button = helpbutton.HelpButton(self)
        toolbar_box.toolbar.insert(button, -1)
        button.show()

        button = ToolButton()
        button.props.icon_name = 'activity-about'
        button.set_tooltip(_('Acerca de'))
        button.accelerator = "<Ctrl>i"
        button.connect('clicked', self.run_credits)
        toolbar_box.toolbar.insert(button, -1)
        button.show()

        # Blank space (separator) and Stop button at the end:

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
	def __init__(self, handle):
		"""Set up the HelloWorld activity."""
		activity.Activity.__init__(self, handle)

		self._logger = logging.getLogger('home-work-viewer')
                self._logger.setLevel(logging.DEBUG)
	
		self._logger.debug("Inside to __init__ of HomeWorkViewer")	
		ts = time.time()
		self._logger.debug(ts)
		#self._logger.debug( datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))

		'''Obtenemos el JSON de la Actividad'''
		json_data=open('json.txt')
		self.activity = json.load(json_data, object_hook=lambda d: namedtuple('Activity', d.keys())(*d.values()))
		json_data.close()

		
		# we do not have collaboration features
		# make the share option insensitive
		self.max_participants = 1

		# toolbar with the new toolbar redesign
		toolbar_box = ToolbarBox()

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

		title_entry = TitleEntry(self)
		toolbar_box.toolbar.insert(title_entry, 1)
		title_entry.show()

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

		self.buttonBefore = ToolButton('go-previous')
		self.buttonBefore.set_tooltip(_('Back'))
		self.buttonBefore.connect("clicked", self.backButtonCallBack)
		toolbar_box.toolbar.insert(self.buttonBefore, 2)
		self.buttonBefore.show()

		self.buttonNext = ToolButton('go-next')
		self.buttonNext.set_tooltip(_('Next'))
		self.buttonNext.connect("clicked", self.nextButtonCallBack)
		toolbar_box.toolbar.insert(self.buttonNext, 3)
		self.buttonNext.show()		

		stop_button = StopButton(self)
		toolbar_box.toolbar.insert(stop_button, -1)
		stop_button.show()

		self.set_toolbar_box(toolbar_box)
		toolbar_box.show()

		self.vBoxMain = gtk.VBox(True, 2)
		self.vBoxMain.show()
		self.set_canvas(self.vBoxMain)
		
		self.jsonState = None
		self.createWindowExercises()	
		"""Leave this line always in the last"""
Exemple #55
0
class TamTamSynthLab(activity.Activity):
    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()

    def onPreloadTimeout(self):
        if Config.DEBUG > 4: 
                print "TamTam::onPreloadTimeout", self.preloadList

        t = time.time()
        if self.preloadList[0].load(t + 0.100):  # finished preloading this object
            self.preloadList.pop(0)
            if not len(self.preloadList):
                if Config.DEBUG > 1: 
                        print "TamTam::finished preloading", time.time() - t
                self.preloadTimeout = False
                return False  # finished preloading everything

        if Config.DEBUG > 4: 
                print "TamTam::preload returned after", time.time() - t

        return True

    def onActive(self, widget=None, event=None):
        if widget.props.active == False:
            logging.debug('TamTamSynthLab.onActivate disconnecting csound')
            csnd = new_csound_client()
            csnd.connect(False)
        else:
            logging.debug('TamTamSynthLab.onActivate connecting csound')
            csnd = new_csound_client()
            csnd.connect(True)

    def onKeyPress(self, widget, event):
        pass

    def onKeyRelease(self, widget, event):
        pass

    def onDestroy(self, arg2):
        if Config.DEBUG: 
                print 'DEBUG: TamTam::onDestroy()'

        self.synthLab.onDestroy()

        csnd = new_csound_client()
        csnd.connect(False)
        csnd.destroy()

        gtk.main_quit()

# No more dir created by TamTam
    def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
Exemple #56
0
  def __init__(self, handle):
    """Set up the activity."""
    activity.Activity.__init__(self, handle)

    """Create the user interface."""
    self.stack = gtk.VBox()
    self.add(self.stack)
    self.hpaned = gtk.HPaned()
    self.stack.pack_end(self.hpaned)
    self.vpaned = gtk.VPaned()
    self.hpaned.pack2(self.vpaned, shrink=False)
    self.hpaned.set_position(200)
    self.plugins = window.PluginTabs()
    self.hpaned.pack1(self.plugins.widget, shrink=False)

    self.model = Abominade(self)

    self.plugins.add_main(self.model.buffers)
    self.plugins.add_tab(self.model.files)
    self.plugins.add_tab(self.model.bookmarks)
    self.plugins.add_tab(self.model.terminals)
    self.vpaned.pack1(self.model.vim.widget, resize=True, shrink=False)
    self.vpaned.pack2(self.model.terminals.book, resize=False, shrink=False)
    # make sure buffers list isn't zero-height
    if self.plugins.stack.get_position() < 200:
      self.plugins.stack.set_position(200)
    
    self.stack.show_all()
    self.set_canvas(self.stack)

    self.init_interpreter()
    label = gtk.Label("Consola")
    self.model.terminals.book.prepend_page(self.interpreter, tab_label=label)

    # we do not have collaboration features
    # make the share option insensitive
    self.max_participants = 1

    # toolbar with the new toolbar redesign
    toolbar_box = ToolbarBox()

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

    title_entry = TitleEntry(self)
    toolbar_box.toolbar.insert(title_entry, -1)
    title_entry.show()

    self.sidebar_button = ToggleToolButton('folder')
    self.sidebar_button.set_active(True)
    self.sidebar_button.set_tooltip('Consola')
    self.sidebar_button.accelerator = "<Ctrl>grave"
    self.sidebar_button.connect('clicked', self.toggle_sidebar)
    toolbar_box.toolbar.insert(self.sidebar_button, -1)
    self.sidebar_button.show()

    self.bottom_button = ToggleToolButton('tray-show')
    self.bottom_button.set_active(True)
    self.bottom_button.set_tooltip('Consola')
    self.bottom_button.accelerator = "<Ctrl>grave"
    self.bottom_button.connect('clicked', self.toggle_bottom)
    toolbar_box.toolbar.insert(self.bottom_button, -1)
    self.bottom_button.show()

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

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

    stop_button = StopButton(self)
    toolbar_box.toolbar.insert(stop_button, -1)
    stop_button.show()

    self.set_toolbar_box(toolbar_box)
    toolbar_box.show()

    self.model.start()
Exemple #57
0
class Record(activity.Activity):
    def __init__(self, handle):
        super(Record, self).__init__(handle)
        self.props.enable_fullscreen_mode = False
        Instance(self)

        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.connect("visibility-notify-event", self._visibility_changed)

        # the main classes
        self.model = Model(self)
        self.ui_init()

        # CSCL
        self.connect("shared", self._shared_cb)
        if self.get_shared_activity():
            # have you joined or shared this activity yourself?
            if self.get_shared():
                self._joined_cb(self)
            else:
                self.connect("joined", self._joined_cb)

        # Realize the video view widget so that it knows its own window XID
        self._media_view.realize_video()

        # Changing to the first toolbar kicks off the rest of the setup
        if self.model.get_has_camera():
            self.model.change_mode(constants.MODE_PHOTO)
        else:
            self.model.change_mode(constants.MODE_AUDIO)

        # Restore critical hidden mixer controls to default
        model = hw.get_xo_version()
        if model == 1.75 or model == 4:
            args = ["amixer", "set", "Analog Mic Boost", "100%"]
            try:
                subprocess.check_output(args)
            except:
                pass

    def read_file(self, path):
        self.model.read_file(path)

    def write_file(self, path):
        self.model.write_file(path)

    def close(self):
        self.model.gplay.stop()
        self.model.glive.stop()
        super(Record, self).close()

    def _visibility_changed(self, widget, event):
        self.model.set_visible(event.state != gtk.gdk.VISIBILITY_FULLY_OBSCURED)

    def _shared_cb(self, activity):
        self.model.collab.set_activity_shared()

    def _joined_cb(self, activity):
        self.model.collab.joined()

    def ui_init(self):
        self._fullscreen = False
        self._showing_info = False

        # FIXME: if _thumb_tray becomes some kind of button group, we wouldn't
        # have to track which recd is active
        self._active_recd = None

        self.connect_after("key-press-event", self._key_pressed)

        self._active_toolbar_idx = 0

        self._toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        self._toolbar_box.toolbar.insert(activity_button, 0)
        self.set_toolbar_box(self._toolbar_box)
        self._toolbar = self.get_toolbar_box().toolbar

        tool_group = None
        if self.model.get_has_camera():
            self._photo_button = RadioToolButton()
            self._photo_button.props.group = tool_group
            tool_group = self._photo_button
            self._photo_button.props.icon_name = "camera-external"
            self._photo_button.props.label = _("Photo")
            self._photo_button.mode = constants.MODE_PHOTO
            self._photo_button.connect("clicked", self._mode_button_clicked)
            self._toolbar.insert(self._photo_button, -1)

            self._video_button = RadioToolButton()
            self._video_button.props.group = tool_group
            self._video_button.props.icon_name = "media-video"
            self._video_button.props.label = _("Video")
            self._video_button.mode = constants.MODE_VIDEO
            self._video_button.connect("clicked", self._mode_button_clicked)
            self._toolbar.insert(self._video_button, -1)
        else:
            self._photo_button = None
            self._video_button = None

        self._audio_button = RadioToolButton()
        self._audio_button.props.group = tool_group
        self._audio_button.props.icon_name = "media-audio"
        self._audio_button.props.label = _("Audio")
        self._audio_button.mode = constants.MODE_AUDIO
        self._audio_button.connect("clicked", self._mode_button_clicked)
        self._toolbar.insert(self._audio_button, -1)

        self._toolbar.insert(gtk.SeparatorToolItem(), -1)

        self._toolbar_controls = RecordControl(self._toolbar)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self._toolbar.insert(separator, -1)
        self._toolbar.insert(StopButton(self), -1)
        self.get_toolbar_box().show_all()

        main_box = gtk.VBox()
        self.set_canvas(main_box)
        main_box.get_parent().modify_bg(gtk.STATE_NORMAL, COLOR_BLACK)
        main_box.show()

        self._media_view = MediaView()
        self._media_view.connect("media-clicked", self._media_view_media_clicked)
        self._media_view.connect("pip-clicked", self._media_view_pip_clicked)
        self._media_view.connect("info-clicked", self._media_view_info_clicked)
        self._media_view.connect("full-clicked", self._media_view_full_clicked)
        self._media_view.connect("tags-changed", self._media_view_tags_changed)
        self._media_view.show()

        self._controls_hbox = gtk.HBox()
        self._controls_hbox.show()

        self._shutter_button = ShutterButton()
        self._shutter_button.connect("clicked", self._shutter_clicked)
        self._controls_hbox.pack_start(self._shutter_button, expand=True, fill=False)

        self._countdown_image = CountdownImage()
        self._controls_hbox.pack_start(self._countdown_image, expand=True, fill=False)

        self._play_button = PlayButton()
        self._play_button.connect("clicked", self._play_pause_clicked)
        self._controls_hbox.pack_start(self._play_button, expand=False)

        self._playback_scale = PlaybackScale(self.model)
        self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True)

        self._progress = ProgressInfo()
        self._controls_hbox.pack_start(self._progress, expand=True, fill=True)

        self._title_label = gtk.Label()
        self._title_label.set_markup("<b><span foreground='white'>" + _("Title:") + "</span></b>")
        self._controls_hbox.pack_start(self._title_label, expand=False)

        self._title_entry = gtk.Entry()
        self._title_entry.modify_bg(gtk.STATE_INSENSITIVE, COLOR_BLACK)
        self._title_entry.connect("changed", self._title_changed)
        self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10)

        self._record_container = RecordContainer(self._media_view, self._controls_hbox)
        main_box.pack_start(self._record_container, expand=True, fill=True, padding=6)
        self._record_container.show()

        self._thumb_tray = HTray()
        self._thumb_tray.set_size_request(-1, 150)
        main_box.pack_end(self._thumb_tray, expand=False)
        self._thumb_tray.show_all()

    def serialize(self):
        data = {}

        data["timer"] = self._toolbar_controls.get_timer_idx()
        data["duration"] = self._toolbar_controls.get_duration_idx()
        data["quality"] = self._toolbar_controls.get_quality()

        return data

    def deserialize(self, data):
        self._toolbar_controls.set_timer_idx(data.get("timer", 0))
        self._toolbar_controls.set_duration_idx(data.get("duration", 0))
        self._toolbar_controls.set_quality(data.get("quality", 0))

    def _key_pressed(self, widget, event):
        key = event.keyval

        if key == gtk.keysyms.KP_Page_Up:  # game key O
            if self._shutter_button.props.visible:
                if self._shutter_button.props.sensitive:
                    self._shutter_button.clicked()
            else:  # return to live mode
                self.model.set_state(constants.STATE_READY)

        if self.model.ui_frozen():
            return False

        if key == gtk.keysyms.c and event.state == gdk.CONTROL_MASK:
            self._copy_to_clipboard(self._active_recd)
        elif key == gtk.keysyms.i:
            self._toggle_info()
        elif key == gtk.keysyms.Escape:
            if self._fullscreen:
                self._toggle_fullscreen()

        return False

    def _play_pause_clicked(self, widget):
        self.model.play_pause()

    def set_mode(self, mode):
        self._toolbar_controls.set_mode(mode)

    # can be called from gstreamer thread, so must not do any GTK+ stuff
    def set_glive_sink(self, sink):
        return self._media_view.set_video_sink(sink)

    # can be called from gstreamer thread, so must not do any GTK+ stuff
    def set_gplay_sink(self, sink):
        return self._media_view.set_video2_sink(sink)

    def get_selected_quality(self):
        return self._toolbar_controls.get_quality()

    def get_selected_timer(self):
        return self._toolbar_controls.get_timer()

    def get_selected_duration(self):
        return self._toolbar_controls.get_duration() * 60  # convert to secs

    def set_progress(self, value, text):
        self._progress.set_progress(value)
        self._progress.set_text(text)

    def set_countdown(self, value):
        if value == 0:
            self._shutter_button.show()
            self._countdown_image.hide()
            self._countdown_image.clear()
            return

        self._shutter_button.hide()
        self._countdown_image.show()
        self._countdown_image.set_value(value)

    def _title_changed(self, widget):
        self._active_recd.setTitle(self._title_entry.get_text())

    def _media_view_media_clicked(self, widget):
        if self._play_button.props.visible and self._play_button.props.sensitive:
            self._play_button.clicked()

    def _media_view_pip_clicked(self, widget):
        # clicking on the PIP always returns to live mode
        self.model.set_state(constants.STATE_READY)

    def _media_view_info_clicked(self, widget):
        self._toggle_info()

    def _toggle_info(self):
        recd = self._active_recd
        if not recd:
            return

        if self._showing_info:
            self._show_recd(recd, play=False)
            return

        self._showing_info = True
        if self.model.get_mode() in (constants.MODE_PHOTO, constants.MODE_AUDIO):
            func = self._media_view.show_info_photo
        else:
            func = self._media_view.show_info_video

        self._play_button.hide()
        self._progress.hide()
        self._playback_scale.hide()
        self._title_entry.set_text(recd.title)
        self._title_entry.show()
        self._title_label.show()
        self._record_container.set_title_visible(True)

        func(recd.recorderName, recd.colorStroke, recd.colorFill, utils.getDateString(recd.time), recd.tags)

    def _media_view_full_clicked(self, widget):
        self._toggle_fullscreen()

    def _media_view_tags_changed(self, widget, tbuffer):
        text = tbuffer.get_text(tbuffer.get_start_iter(), tbuffer.get_end_iter())
        self._active_recd.setTags(text)

    def _toggle_fullscreen(self):
        if not self._fullscreen:
            self._toolbar_box.hide()
            self._thumb_tray.hide()
        else:
            self._toolbar_box.show()
            self._thumb_tray.show()

        self._fullscreen = not self._fullscreen
        self._media_view.set_fullscreen(self._fullscreen)

    def _mode_button_clicked(self, button):
        self.model.change_mode(button.mode)

    def _shutter_clicked(self, arg):
        self.model.do_shutter()

    def set_shutter_sensitive(self, value):
        self._shutter_button.set_sensitive(value)

    def set_state(self, state):
        radio_state = state == constants.STATE_READY
        for item in (self._photo_button, self._audio_button, self._video_button):
            if item:
                item.set_sensitive(radio_state)

        self._showing_info = False
        if state == constants.STATE_READY:
            self._set_cursor_default()
            self._active_recd = None
            self._title_entry.hide()
            self._title_label.hide()
            self._record_container.set_title_visible(False)
            self._play_button.hide()
            self._playback_scale.hide()
            self._progress.hide()
            self._controls_hbox.set_child_packing(
                self._shutter_button, expand=True, fill=False, padding=0, pack_type=gtk.PACK_START
            )
            self._shutter_button.set_normal()
            self._shutter_button.set_sensitive(True)
            self._shutter_button.show()
            self._media_view.show_live()
        elif state == constants.STATE_RECORDING:
            self._shutter_button.set_recording()
            self._controls_hbox.set_child_packing(
                self._shutter_button, expand=False, fill=False, padding=0, pack_type=gtk.PACK_START
            )
            self._progress.show()
        elif state == constants.STATE_PROCESSING:
            self._set_cursor_busy()
            self._shutter_button.hide()
            self._progress.show()
        elif state == constants.STATE_DOWNLOADING:
            self._shutter_button.hide()
            self._progress.show()

    def set_paused(self, value):
        if value:
            self._play_button.set_play()
        else:
            self._play_button.set_pause()

    def _thumbnail_clicked(self, button, recd):
        if self.model.ui_frozen():
            return

        self._active_recd = recd
        self._show_recd(recd)

    def add_thumbnail(self, recd, scroll_to_end):
        button = RecdButton(recd)
        clicked_handler = button.connect("clicked", self._thumbnail_clicked, recd)
        remove_handler = button.connect("remove-requested", self._remove_recd)
        clipboard_handler = button.connect("copy-clipboard-requested", self._thumbnail_copy_clipboard)
        button.set_data("handler-ids", (clicked_handler, remove_handler, clipboard_handler))
        self._thumb_tray.add_item(button)
        button.show()
        if scroll_to_end:
            self._thumb_tray.scroll_to_end()

    def _copy_to_clipboard(self, recd):
        if recd == None:
            return
        if not recd.isClipboardCopyable():
            return

        media_path = recd.getMediaFilepath()
        tmp_path = utils.getUniqueFilepath(media_path, 0)
        shutil.copyfile(media_path, tmp_path)
        gtk.Clipboard().set_with_data([("text/uri-list", 0, 0)], self._clipboard_get, self._clipboard_clear, tmp_path)

    def _clipboard_get(self, clipboard, selection_data, info, path):
        selection_data.set("text/uri-list", 8, "file://" + path)

    def _clipboard_clear(self, clipboard, path):
        if os.path.exists(path):
            os.unlink(path)

    def _thumbnail_copy_clipboard(self, recdbutton):
        self._copy_to_clipboard(recdbutton.get_recd())

    def _remove_recd(self, recdbutton):
        recd = recdbutton.get_recd()
        self.model.delete_recd(recd)
        if self._active_recd == recd:
            self.model.set_state(constants.STATE_READY)

        self._remove_thumbnail(recdbutton)

    def _remove_thumbnail(self, recdbutton):
        handlers = recdbutton.get_data("handler-ids")
        for handler in handlers:
            recdbutton.disconnect(handler)

        self._thumb_tray.remove_item(recdbutton)
        recdbutton.cleanup()

    def remove_all_thumbnails(self):
        for child in self._thumb_tray.get_children():
            self._remove_thumbnail(child)

    def show_still(self, pixbuf):
        self._media_view.show_still(pixbuf)

    def _show_photo(self, recd):
        path = self._get_photo_path(recd)
        self._media_view.show_photo(path)
        self._title_entry.set_text(recd.title)
        self._title_entry.show()
        self._title_label.show()
        self._record_container.set_title_visible(True)
        self._shutter_button.hide()
        self._progress.hide()

    def _show_audio(self, recd, play):
        self._progress.hide()
        self._shutter_button.hide()
        self._title_entry.hide()
        self._title_label.hide()
        self._record_container.set_title_visible(False)
        self._play_button.show()
        self._playback_scale.show()
        path = recd.getAudioImageFilepath()
        self._media_view.show_photo(path)
        if play:
            self.model.play_audio(recd)

    def _show_video(self, recd, play):
        self._progress.hide()
        self._shutter_button.hide()
        self._title_entry.hide()
        self._title_label.hide()
        self._record_container.set_title_visible(False)
        self._play_button.show()
        self._playback_scale.show()
        self._media_view.show_video()
        if play:
            self.model.play_video(recd)

    def set_playback_scale(self, value):
        self._playback_scale.set_value(value)

    def _get_photo_path(self, recd):
        # FIXME should live (partially) in recd?

        # downloading = self.ca.requestMeshDownload(recd)
        # self.MESHING = downloading

        if True:  # not downloading:
            # self.progressWindow.updateProgress(0, "")
            return recd.getMediaFilepath()

        # maybe it is not downloaded from the mesh yet...
        # but we can show the low res thumb in the interim
        return recd.getThumbFilepath()

    def _show_recd(self, recd, play=True):
        self._showing_info = False

        if recd.buddy and not recd.downloadedFromBuddy:
            self.model.request_download(recd)
        elif recd.type == constants.TYPE_PHOTO:
            self._show_photo(recd)
        elif recd.type == constants.TYPE_AUDIO:
            self._show_audio(recd, play)
        elif recd.type == constants.TYPE_VIDEO:
            self._show_video(recd, play)

    def remote_recd_available(self, recd):
        if recd == self._active_recd:
            self._show_recd(recd)

    def update_download_progress(self, recd):
        if recd != self._active_recd:
            return

        if not recd.meshDownloading:
            msg = _("Download failed.")
        elif recd.meshDownloadingProgress:
            msg = _("Downloading...")
        else:
            msg = _("Requesting...")

        self.set_progress(recd.meshDownlodingPercent, msg)

    def _set_cursor_busy(self):
        self.window.set_cursor(gdk.Cursor(gdk.WATCH))

    def _set_cursor_default(self):
        self.window.set_cursor(None)
Exemple #58
0
    def ui_init(self):
        self._fullscreen = False
        self._showing_info = False

        # FIXME: if _thumb_tray becomes some kind of button group, we wouldn't
        # have to track which recd is active
        self._active_recd = None

        self.connect_after("key-press-event", self._key_pressed)

        self._active_toolbar_idx = 0

        self._toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        self._toolbar_box.toolbar.insert(activity_button, 0)
        self.set_toolbar_box(self._toolbar_box)
        self._toolbar = self.get_toolbar_box().toolbar

        tool_group = None
        if self.model.get_has_camera():
            self._photo_button = RadioToolButton()
            self._photo_button.props.group = tool_group
            tool_group = self._photo_button
            self._photo_button.props.icon_name = "camera-external"
            self._photo_button.props.label = _("Photo")
            self._photo_button.mode = constants.MODE_PHOTO
            self._photo_button.connect("clicked", self._mode_button_clicked)
            self._toolbar.insert(self._photo_button, -1)

            self._video_button = RadioToolButton()
            self._video_button.props.group = tool_group
            self._video_button.props.icon_name = "media-video"
            self._video_button.props.label = _("Video")
            self._video_button.mode = constants.MODE_VIDEO
            self._video_button.connect("clicked", self._mode_button_clicked)
            self._toolbar.insert(self._video_button, -1)
        else:
            self._photo_button = None
            self._video_button = None

        self._audio_button = RadioToolButton()
        self._audio_button.props.group = tool_group
        self._audio_button.props.icon_name = "media-audio"
        self._audio_button.props.label = _("Audio")
        self._audio_button.mode = constants.MODE_AUDIO
        self._audio_button.connect("clicked", self._mode_button_clicked)
        self._toolbar.insert(self._audio_button, -1)

        self._toolbar.insert(gtk.SeparatorToolItem(), -1)

        self._toolbar_controls = RecordControl(self._toolbar)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self._toolbar.insert(separator, -1)
        self._toolbar.insert(StopButton(self), -1)
        self.get_toolbar_box().show_all()

        main_box = gtk.VBox()
        self.set_canvas(main_box)
        main_box.get_parent().modify_bg(gtk.STATE_NORMAL, COLOR_BLACK)
        main_box.show()

        self._media_view = MediaView()
        self._media_view.connect("media-clicked", self._media_view_media_clicked)
        self._media_view.connect("pip-clicked", self._media_view_pip_clicked)
        self._media_view.connect("info-clicked", self._media_view_info_clicked)
        self._media_view.connect("full-clicked", self._media_view_full_clicked)
        self._media_view.connect("tags-changed", self._media_view_tags_changed)
        self._media_view.show()

        self._controls_hbox = gtk.HBox()
        self._controls_hbox.show()

        self._shutter_button = ShutterButton()
        self._shutter_button.connect("clicked", self._shutter_clicked)
        self._controls_hbox.pack_start(self._shutter_button, expand=True, fill=False)

        self._countdown_image = CountdownImage()
        self._controls_hbox.pack_start(self._countdown_image, expand=True, fill=False)

        self._play_button = PlayButton()
        self._play_button.connect("clicked", self._play_pause_clicked)
        self._controls_hbox.pack_start(self._play_button, expand=False)

        self._playback_scale = PlaybackScale(self.model)
        self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True)

        self._progress = ProgressInfo()
        self._controls_hbox.pack_start(self._progress, expand=True, fill=True)

        self._title_label = gtk.Label()
        self._title_label.set_markup("<b><span foreground='white'>" + _("Title:") + "</span></b>")
        self._controls_hbox.pack_start(self._title_label, expand=False)

        self._title_entry = gtk.Entry()
        self._title_entry.modify_bg(gtk.STATE_INSENSITIVE, COLOR_BLACK)
        self._title_entry.connect("changed", self._title_changed)
        self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10)

        self._record_container = RecordContainer(self._media_view, self._controls_hbox)
        main_box.pack_start(self._record_container, expand=True, fill=True, padding=6)
        self._record_container.show()

        self._thumb_tray = HTray()
        self._thumb_tray.set_size_request(-1, 150)
        main_box.pack_end(self._thumb_tray, expand=False)
        self._thumb_tray.show_all()