예제 #1
0
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = MAX_HANDS

        if have_toolbox:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button = ActivityToolbarButton(self)

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

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

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

        self._new_game_button = button_factory(
            'new-game', 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()
예제 #2
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()
예제 #3
0
    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()
예제 #4
0
    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()
예제 #5
0
    def _setup_toolbars(self):
        ''' Setup the toolbars. '''

        self.max_participants = 1  # no sharing

        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

            adjust_toolbar = gtk.Toolbar()
            adjust_toolbar_button = ToolbarButton(
                label=_('Adjust'),
                page=adjust_toolbar,
                icon_name='preferences-system')
            adjust_toolbar.show_all()
            adjust_toolbar_button.show()
        else:
            # Use pre-0.86 toolbar design
            primary_toolbar = gtk.Toolbar()
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.add_toolbar(_('Page'), primary_toolbar)
            adjust_toolbar = gtk.Toolbar()
            toolbox.add_toolbar(_('Adjust'), adjust_toolbar)
            toolbox.show()
            toolbox.set_current_toolbar(1)
            self.toolbar = primary_toolbar

        self._prev_button = button_factory('go-previous-inactive',
                                           _('Prev slide'),
                                           self._prev_cb,
                                           self.toolbar,
                                           accelerator='<Ctrl>P')

        self._next_button = button_factory('go-next',
                                           _('Next slide'),
                                           self._next_cb,
                                           self.toolbar,
                                           accelerator='<Ctrl>N')

        separator_factory(self.toolbar)

        self._auto_button = button_factory('media-playlist-repeat',
                                           _('Autoplay'), self._autoplay_cb,
                                           self.toolbar)

        if HAVE_TOOLBOX:
            toolbox.toolbar.insert(adjust_toolbar_button, -1)

        label = label_factory(_('Adjust playback speed'), adjust_toolbar)
        label.show()

        self._unit_combo = combo_factory(UNITS, TEN,
                                         _('Adjust playback speed'),
                                         self._unit_combo_cb, adjust_toolbar)
        self._unit_combo.show()

        separator_factory(self.toolbar)

        self._thumb_button = button_factory('thumbs-view', _('Thumbnail view'),
                                            self._thumbs_cb, self.toolbar)

        button_factory('view-fullscreen',
                       _('Fullscreen'),
                       self.do_fullscreen_cb,
                       self.toolbar,
                       accelerator='<Alt>Return')

        separator_factory(self.toolbar)

        self._save_button = button_factory('save-as-html', _('Save as HTML'),
                                           self._save_as_html_cb, 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()
예제 #6
0
    def __init__(self, handle):
        ''' Init canvas, toolbars, etc.
        The toolbars are in sensor_toolbar.py and toolbar_side.py
        The audio controls are in audiograb.py
        The rendering happens in drawwaveform.py
        Logging is in journal.py '''

        activity.Activity.__init__(self, handle)

        self.mode_images = {}
        self.mode_images['sound'] = gtk.gdk.pixbuf_new_from_file_at_size(
            os.path.join(ICONS_DIR, 'media-audio.svg'), 45, 45)
        self.mode_images['resistance'] = gtk.gdk.pixbuf_new_from_file_at_size(
            os.path.join(ICONS_DIR, 'resistance.svg'), 45, 45)
        self.mode_images['voltage'] = gtk.gdk.pixbuf_new_from_file_at_size(
            os.path.join(ICONS_DIR, 'voltage.svg'), 45, 45)

        self._using_gconf = _using_gconf
        self.icon_colors = self.get_icon_colors_from_sugar()
        self.stroke_color, self.fill_color = self.icon_colors.split(',')
        self.nick = self.get_nick_from_sugar()
        self.CONTEXT = ''
        self.adjustmentf = None  # Freq. slider control
        self.hw = _get_hardware()
        self.new_recording = False
        self.session_id = 0
        self.read_metadata()

        self._active = True
        self._dsobject = None

        self.connect('notify::active', self._notify_active_cb)
        self.connect('destroy', self.on_quit)

        self.data_logger = DataLogger(self)

        self.hw = _get_hardware()
        log.debug('running on %s hardware' % (self.hw))
        self.wave = DrawWaveform(self)
        if self.hw == XO15:
            self.audiograb = AudioGrab_XO15(self.wave.new_buffer, self)
        elif self.hw == XO175:
            self.audiograb = AudioGrab_XO175(self.wave.new_buffer, self)
        elif self.hw == XO1:
            self.audiograb = AudioGrab_XO1(self.wave.new_buffer, self)
        else:
            self.audiograb = AudioGrab_Unknown(self.wave.new_buffer, self)

        # no sharing
        self.max_participants = 1

        self.has_toolbarbox = _has_toolbarbox

        box3 = gtk.HBox(False, 0)
        box3.pack_start(self.wave, True, True, 0)

        # We need event boxes in order to set the background color.
        side_eventboxes = []
        self.side_toolbars = []
        for i in range(self.audiograb.channels):
            side_eventboxes.append(gtk.EventBox())
            side_eventboxes[i].modify_bg(
                gtk.STATE_NORMAL, style.COLOR_TOOLBAR_GREY.get_gdk_color())
            self.side_toolbars.append(SideToolbar(self, channel=i))
            side_eventboxes[i].add(self.side_toolbars[i].box1)
            box3.pack_start(side_eventboxes[i], False, True, 0)

        event_box = gtk.EventBox()
        self.text_box = gtk.Label()
        self.text_box.set_justify(gtk.JUSTIFY_LEFT)
        alist = pango.AttrList()
        alist.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))
        self.text_box.set_attributes(alist)
        event_box.add(self.text_box)
        event_box.modify_bg(gtk.STATE_NORMAL,
                            style.COLOR_TOOLBAR_GREY.get_gdk_color())

        box1 = gtk.VBox(False, 0)
        box1.pack_start(box3, True, True, 0)
        box1.pack_start(event_box, False, True, 0)

        self.set_canvas(box1)

        if self.has_toolbarbox:
            toolbox = ToolbarBox()

            activity_button = ActivityToolbarButton(self)
            toolbox.toolbar.insert(activity_button, 0)
            activity_button.show()
        else:
            toolbox = ActivityToolbox(self)

            # no sharing
            if hasattr(toolbox, 'share'):
                toolbox.share.hide()
            elif hasattr(toolbox, 'props'):
                toolbox.props.visible = False
            self.set_toolbox(toolbox)

        self.sensor_toolbar = SensorToolbar(self, self.audiograb.channels)
        #Added by Butia
        # Enciendo el bobot Server
        log.debug('Starting Bobot-Server...')
        os.system(bobot_cmd_on)
        log.debug("Start : %s" % time.ctime())
        time.sleep(bobot_delay_start)
        log.debug("Started : %s" % time.ctime())
        self.butia_toolbar = ButiaToolbar(self, self.audiograb.channels)
        #Butia end
        self.tuning_toolbar = TuningToolbar(self)
        self.new_instrument_toolbar = InstrumentToolbar(self)
        self.control_toolbar = gtk.Toolbar()
        if self.has_toolbarbox:
            sensor_button = ToolbarButton(label=_('Sensors'),
                                          page=self.sensor_toolbar,
                                          icon_name='sensor-tools')
            toolbox.toolbar.insert(sensor_button, -1)
            #Added by Butia
            sensor_button.connect('clicked', self._sensor_toolbar_cb)
            #Butia end
            sensor_button.show()
            #Added by Butia
            butia_button = ToolbarButton(label=_('Butia'),
                                         page=self.butia_toolbar,
                                         icon_name='butia-tools')
            toolbox.toolbar.insert(butia_button, -1)
            butia_button.connect('clicked', self._butia_toolbar_cb)
            butia_button.show()
            #Butia end
            tuning_button = ToolbarButton(
                # TRANS: Tuning insruments
                label=_('Tuning'),
                page=self.tuning_toolbar,
                icon_name='tuning-tools')
            toolbox.toolbar.insert(tuning_button, -1)
            tuning_button.show()
            new_instrument_button = ToolbarButton(
                label=_('Add instrument'),
                page=self.new_instrument_toolbar,
                icon_name='view-source')
            toolbox.toolbar.insert(new_instrument_button, -1)
            new_instrument_button.show()
        else:
            toolbox.add_toolbar(_('Sensors'), self.sensor_toolbar)
            #Added by butia
            toolbox.add_toolbar(_('Butia'), self.butia_toolbar)
            #Butia end
            # TRANS: Tuning insruments
            toolbox.add_toolbar(_('Tuning'), self.tuning_toolbar)
            toolbox.add_toolbar(_('Add instrument'),
                                self.new_instrument_toolbar)
            toolbox.add_toolbar(_('Controls'), self.control_toolbar)
        self.sensor_toolbar.show()
        #Added by butia
        self.butia_toolbar.show()
        #Butia end

        if self.has_toolbarbox:
            # Set up Frequency-domain Button
            self.freq = ToolButton('domain-time')
            toolbox.toolbar.insert(self.freq, -1)
            self.freq.show()
            self.freq.set_tooltip(_('Time Base'))
            self.freq.connect('clicked', self.timefreq_control)

            self.sensor_toolbar.add_frequency_slider(toolbox.toolbar)
            self._pause = ToolButton('media-playback-pause')
            toolbox.toolbar.insert(self._pause, -1)
            self._pause.set_tooltip(_('Freeze the display'))
            self._pause.connect('clicked', self._pause_play_cb)

            self._capture = ToolButton('image-saveoff')
            toolbox.toolbar.insert(self._capture, -1)
            self._capture.set_tooltip(_('Capture sample now'))
            self._capture.connect('clicked', self._capture_cb)

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

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

            self.set_toolbox(toolbox)
            sensor_button.set_expanded(True)

        else:
            # Set up Frequency-domain Button
            self.freq = ToolButton('domain-time')
            self.control_toolbar.insert(self.freq, -1)
            self.freq.show()
            self.freq.set_tooltip(_('Time Base'))
            self.freq.connect('clicked', self.timefreq_control)

            self.sensor_toolbar.add_frequency_slider(self.control_toolbar)

            separator = gtk.SeparatorToolItem()
            separator.props.draw = True
            self.control_toolbar.insert(separator, -1)
            separator.show()

            self._pause = ToolButton('media-playback-pause')
            self.control_toolbar.insert(self._pause, -1)
            self._pause.set_tooltip(_('Freeze the display'))
            self._pause.connect('clicked', self._pause_play_cb)

            self._capture = ToolButton('image-saveoff')
            self.control_toolbar.insert(self._capture, -1)
            self._capture.set_tooltip(_('Capture sample now'))
            self._capture.connect('clicked', self._capture_cb)

            toolbox.set_current_toolbar(1)

        toolbox.show()
        self.sensor_toolbar.update_page_size()

        self.show_all()

        self._first = True

        # Always start in 'sound' mode.
        self.sensor_toolbar.set_mode('sound')
        self.sensor_toolbar.set_sound_context()
        self.sensor_toolbar.set_show_hide_windows()
        self.wave.set_active(True)
        self.wave.set_context_on()
예제 #7
0
    def _setup_toolbars(self):
        ''' Setup the toolbars. '''

        self.max_participants = 6

        if HAVE_TOOLBOX:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button_toolbar = ActivityToolbarButton(self)

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

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

            self.record_toolbar = gtk.Toolbar()
            record_toolbar_button = ToolbarButton(
                label=_('Record a sound'),
                page=self.record_toolbar,
                icon_name='media-audio')
            self.record_toolbar.show_all()
            record_toolbar_button.show()
            toolbox.toolbar.insert(record_toolbar_button, -1)
        else:
            # Use pre-0.86 toolbar design
            primary_toolbar = gtk.Toolbar()
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.add_toolbar(_('Page'), primary_toolbar)
            self.record_toolbar = gtk.Toolbar()
            toolbox.add_toolbar(_('Record'), self.record_toolbar)
            toolbox.show()
            toolbox.set_current_toolbar(1)
            self.toolbar = primary_toolbar

        self._prev_button = button_factory(
            'go-previous-inactive', self.toolbar, self._prev_cb,
            tooltip=_('Prev slide'), accelerator='<Ctrl>P')

        self._next_button = button_factory(
            'go-next', self.toolbar, self._next_cb,
            tooltip=_('Next slide'), accelerator='<Ctrl>N')


        separator_factory(self.toolbar)

        slide_button = radio_factory('slide-view', self.toolbar,
                                     self._slides_cb, group=None,
                                     tooltip=_('Slide view'))
        radio_factory('thumbs-view', self.toolbar, self._thumbs_cb,
                      tooltip=_('Thumbnail view'),
                      group=slide_button)

        button_factory('view-fullscreen', self.toolbar,
                       self.do_fullscreen_cb, tooltip=_('Fullscreen'),
                       accelerator='<Alt>Return')

        separator_factory(self.toolbar)

        journal_button = button_factory(
            'write-journal', self.toolbar, self._do_journal_cb,
            tooltip=_('Update description'))
        self._palette = journal_button.get_palette()
        msg_box = gtk.HBox()

        sw = gtk.ScrolledWindow()
        sw.set_size_request(int(gtk.gdk.screen_width() / 2),
                            2 * style.GRID_CELL_SIZE)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self._text_view = gtk.TextView()
        self._text_view.set_left_margin(style.DEFAULT_PADDING)
        self._text_view.set_right_margin(style.DEFAULT_PADDING)
        self._text_view.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        self._text_view.connect('focus-out-event',
                               self._text_view_focus_out_event_cb)
        sw.add(self._text_view)
        sw.show()
        msg_box.pack_start(sw, expand=False)
        msg_box.show_all()

        self._palette.set_content(msg_box)

        label_factory(self.record_toolbar, _('Record a sound') + ':')
        self._record_button = button_factory(
            'media-record', self.record_toolbar,
            self._record_cb, tooltip=_('Start recording'))

        separator_factory(self.record_toolbar)

        # Look to see if we have audio previously recorded
        obj_id = self._get_audio_obj_id()
        dsobject = self._search_for_audio_note(obj_id)
        if dsobject is not None:
            _logger.debug('Found previously recorded audio')
            self._add_playback_button(profile.get_nick_name(),
                                      self.colors,
                                      dsobject.file_path)

        if HAVE_TOOLBOX:
            button_factory('system-restart', activity_button_toolbar,
                           self._resend_cb, tooltip=_('Refresh'))
            separator_factory(activity_button_toolbar)
            self._save_pdf = button_factory(
                'save-as-pdf', activity_button_toolbar,
                self._save_as_pdf_cb, tooltip=_('Save as PDF'))
        else:
            separator_factory(self.toolbar)
            self._save_pdf = button_factory(
                'save-as-pdf', self.toolbar,
                self._save_as_pdf_cb, tooltip=_('Save as PDF'))

        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()
    def _setup_toolbars(self):
        ''' Setup the toolbars.. '''

        # no sharing
        self.max_participants = 1

        if _HAVE_TOOLBOX:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button = ActivityToolbarButton(self)

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

            lesson_toolbar = gtk.Toolbar()
            lesson_toolbar_button = ToolbarButton(label=_('Select a lesson'),
                                                  page=lesson_toolbar,
                                                  icon_name='text-x-generic')
            record_toolbar = gtk.Toolbar()
            record_toolbar_button = ToolbarButton(label=_('Record a sound'),
                                                  page=record_toolbar,
                                                  icon_name='media-audio')

            self.set_toolbar_box(toolbox)
            toolbox.show()
            lesson_toolbar_button.show()
            toolbox.toolbar.insert(lesson_toolbar_button, -1)
            record_toolbar_button.show()
            toolbox.toolbar.insert(record_toolbar_button, -1)
            primary_toolbar = toolbox.toolbar

        else:
            # Use pre-0.86 toolbar design
            primary_toolbar = gtk.Toolbar()
            lesson_toolbar = gtk.Toolbar()
            record_toolbar = gtk.Toolbar()
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.add_toolbar(_('Page'), primary_toolbar)
            toolbox.show()
            toolbox.add_toolbar(_('Lesson'), lesson_toolbar)
            toolbox.show()
            toolbox.add_toolbar(_('Record'), record_toolbar)
            toolbox.show()
            toolbox.set_current_toolbar(1)

            # no sharing
            if hasattr(toolbox, 'share'):
                toolbox.share.hide()
            elif hasattr(toolbox, 'props'):
                toolbox.props.visible = False

        _label_factory(_('Select a lesson') + ':', lesson_toolbar)
        self._levels = self._get_levels(self._lessons_path)
        self._levels_combo = _combo_factory(self._levels, _('Select a lesson'),
                                            lesson_toolbar, self._levels_cb)

        _separator_factory(lesson_toolbar)

        self._lesson_button = _button_factory(
            'load-from-journal', _('Load a new lesson from the Journal'),
            self._lesson_cb, lesson_toolbar)

        _separator_factory(lesson_toolbar)

        self._create_lesson_button = _button_factory('view-source-insensitive',
                                                     _('Create a new lesson'),
                                                     self._create_lesson_cb,
                                                     lesson_toolbar)

        self._save_lesson_button = _button_factory(
            'save-to-journal-insensitive', _('Nothing to save'),
            self._save_lesson_cb, lesson_toolbar)

        self._sounds = self._get_sounds()
        self.sounds_combo = _combo_factory(self._sounds, _('Record a sound'),
                                           record_toolbar, self._sounds_cb)

        _separator_factory(record_toolbar)

        _label_factory(_('Record a sound') + ':', record_toolbar)
        self._record_lesson_button = _button_factory('media-record',
                                                     _('Start recording'),
                                                     self._record_lesson_cb,
                                                     record_toolbar)

        _separator_factory(record_toolbar)

        self._playback_button = _button_factory(
            'media-playback-start-insensitive', _('Nothing to play'),
            self._playback_recording_cb, record_toolbar)

        self._save_recording_button = _button_factory('sound-save-insensitive',
                                                      _('Nothing to save'),
                                                      self._save_recording_cb,
                                                      record_toolbar)

        _separator_factory(primary_toolbar)

        self._list_button = _button_factory('letter-list', _('Letter list'),
                                            self._list_cb, primary_toolbar)

        self._prev_page_button = _button_factory('previous-letter-insensitive',
                                                 _('Previous letter'),
                                                 self._prev_page_cb,
                                                 primary_toolbar)

        self._next_page_button = _button_factory('next-letter',
                                                 _('Next letter'),
                                                 self._next_page_cb,
                                                 primary_toolbar)

        _separator_factory(primary_toolbar)

        self._read_button = _button_factory('read',
                                            _('Read the sounds one at a time'),
                                            self._read_cb, primary_toolbar)

        _separator_factory(primary_toolbar)

        self._test_button = _button_factory('go-right', _('Self test'),
                                            self._test_cb, primary_toolbar)

        self.status = _label_factory('', primary_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()
        lesson_toolbar.show()
        record_toolbar.show()
예제 #9
0
    def __init__(self, handle):
        """ Init canvas, toolbars, etc.
        The toolbars are in toolbar_top.py and toolbar_side.py
        The audio controls are in audiograb.py
        The rendering happens in drawwaveform.py
        Logging (Journal interactions) are in journal.py """

        activity.Activity.__init__(self, handle)

        try:
            tmp_dir = path.join(activity.get_activity_root(), "data")
        except AttributeError:
            # Early versions of Sugar (e.g., 656) didn't support
            # get_activity_root()
            tmp_dir = path.join(
                environ['HOME'],
                ".sugar/default/org.laptop.MeasureActivity/data")
        self.using_gconf = _using_gconf
        self.icon_colors = self.get_icon_colors_from_sugar()
        self.stroke_color, self.fill_color = self.icon_colors.split(',')
        self.nick = self.get_nick_from_sugar()
        self.active_status = True
        self.ACTIVE = True
        self.LOGGING_IN_SESSION = False
        self.CONTEXT = ''
        self.adjustmentf = None  # Freq. slider control
        self.connect('notify::active', self._active_cb)
        self.connect('destroy', self.on_quit)
        self.hw = _get_hardware()

        self.closedSound = None
        self.openedSound = None

        self.session_id = 0

        self.ji = JournalInteraction(self)
        colorBlack = Color()
        colorBlack.init_rgba(0, 0, 0, 255)
        self.playsoundWin = PlayVideoWindow(colorBlack.gColor)
        self.playsound = Gplay()
        self.playsound.window = self.playsoundWin
        self.wave = DrawWaveform(self, self.playsound)

        self.hw = _get_hardware()
        log.debug('running on %s hardware' % (self.hw))
        if self.hw == XO15:
            self.audiograb = AudioGrab_XO15(self.wave.new_buffer, self)
        elif self.hw == XO1:
            self.audiograb = AudioGrab_XO1(self.wave.new_buffer, self)
        else:
            self.audiograb = AudioGrab_Unknown(self.wave.new_buffer, self)

        # no sharing
        self.max_participants = 1

        self.has_toolbarbox = _has_toolbarbox

        self.side_toolbar = SideToolbar(self)
        self.text_box = TextBox()

        self.box3 = gtk.HBox(False, 0)
        self.box3.pack_start(self.wave, True, True, 0)
        self.box3.pack_start(self.side_toolbar.box1, False, True, 0)

        self.box1 = gtk.VBox(False, 0)
        self.box1.pack_start(self.box3, True, True, 0)
        self.box1.pack_start(self.text_box.box_main, False, True, 0)

        self.set_canvas(self.box1)
        self.toolbox = None

        if self.has_toolbarbox:
            toolbox = ToolbarBox()
            self.toolbox = toolbox
            activity_button = ActivityToolbarButton(self)
            toolbox.toolbar.insert(activity_button, 0)
            activity_button.show()
        else:
            toolbox = ActivityToolbox(self)
            self.toolbox = toolbox
            # no sharing
            if hasattr(toolbox, 'share'):
                toolbox.share.hide()
            elif hasattr(toolbox, 'props'):
                toolbox.props.visible = False

            self.set_toolbox(toolbox)
            toolbox.connect('current-toolbar-changed',
                            self._toolbar_changed_cb)

        self.sound_toolbar = SoundToolbar(self)
        if self.has_toolbarbox:
            self._sound_button = ToolbarButton(label=_('Sound'),
                                               page=self.sound_toolbar,
                                               icon_name='sound-tools')
            toolbox.toolbar.insert(self._sound_button, -1)
            self._sound_button.show()
        else:
            toolbox.add_toolbar(_('Sound'), self.sound_toolbar)
        self.sound_toolbar.show()

        if _is_xo(self.hw):
            self.sensor_toolbar = SensorToolbar(self)
            if self.has_toolbarbox:
                self._sensor_button = ToolbarButton(label=_('Sensors'),
                                                    page=self.sensor_toolbar,
                                                    icon_name='sensor-tools')
                toolbox.toolbar.insert(self._sensor_button, -1)
                self._sensor_button.show()
            else:
                toolbox.add_toolbar(_('Sensors'), self.sensor_toolbar)
            self.sensor_toolbar.show()

        if self.has_toolbarbox:
            _separator = gtk.SeparatorToolItem()
            _separator.props.draw = False
            toolbox.toolbar.insert(_separator, -1)
            _separator.show()

            # add a "dummy" button to indicate what capture mode we are in
            self.label_button = ToolButton('domain-time2')
            toolbox.toolbar.insert(self.label_button, -1)
            self.label_button.show()
            self.label_button.set_tooltip(_('Time Base'))
            self.label_button.connect('clicked', self._label_cb)

            self.sound_toolbar.add_frequency_slider(toolbox.toolbar)

            _separator = gtk.SeparatorToolItem()
            _separator.props.draw = False
            _separator.set_expand(True)
            toolbox.toolbar.insert(_separator, -1)
            _separator.show()
            _stop_button = StopButton(self)
            _stop_button.props.accelerator = _('<Ctrl>Q')
            toolbox.toolbar.insert(_stop_button, -1)
            _stop_button.show()

            self.set_toolbox(toolbox)
            self._sound_button.set_expanded(True)

        else:
            toolbox.set_current_toolbar(TOOLBARS.index('sensor'))

        toolbox.show()
        self.sound_toolbar.update_page_size()

        self.show_all()

        self.first = True

        self.set_sound_context()
        self.set_sensor_context()
        self.set_show_hide_windows()
        self.wave.set_active(True)
        self.wave.set_context_on()

        self.set_show_hide_windows()