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

        self.max_participants = MAX_HANDS

        if have_toolbox:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button = ActivityToolbarButton(self)

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

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

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

        self._new_game_button = button_factory(
            'new-game', 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()
Exemplo n.º 2
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = MAX_HANDS

        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

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

        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()
Exemplo n.º 3
0
 def _load_custom_buttons(self, toolbar):
     ''' Entry fields and buttons for adding custom fractions '''
     self.numerator = entry_factory('', toolbar, tooltip=_('numerator'))
     label_factory(toolbar, '   /   ')
     self.denominator = entry_factory('', toolbar,
                                       tooltip=_('denominator'))
     separator_factory(toolbar, expand=False, visible=False)
     self.enter_button = button_factory('list-add', toolbar,
                                        self._add_fraction_cb,
                                        tooltip=_('add new fraction'),
                                        accelerator='Return')
     separator_factory(toolbar, expand=False, visible=True)
     self._ball_selector = combo_factory(BALLS, toolbar, self._combo_cb,
                                         default=_('basketball'),
                                         tooltip=_('choose a ball'))
Exemplo n.º 4
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 4

        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

        self._new_game_button_h = button_factory('new-game',
                                                 self.toolbar,
                                                 self._new_game_cb,
                                                 tooltip=_('Start a game.'))

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

        separator_factory(toolbox.toolbar, True, False)

        self.solver = button_factory('help-toolbar',
                                     self.toolbar,
                                     self._solve_cb,
                                     tooltip=_('Solve the puzzle'))

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
Exemplo n.º 5
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 4

        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

        self._new_game_button_h = button_factory(
            'new-game', self.toolbar, self._new_game_cb,
            tooltip=_('Start a game.'))

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

        separator_factory(toolbox.toolbar, True, False)

        self.solver = button_factory(
            'help-toolbar', self.toolbar,
            self._solve_cb,
            tooltip=_('Solve the puzzle'))

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
Exemplo n.º 6
0
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = 4
        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

        self.radio = []
        self.radio.append(
            radio_factory(
                "game-1",
                self.toolbar,
                self._new_game_cb,
                cb_arg=0,
                tooltip=_("Play attention game (repeated symbol)."),
                group=None,
            )
        )
        self.radio.append(
            radio_factory(
                "game-2",
                self.toolbar,
                self._new_game_cb,
                cb_arg=1,
                tooltip=_("Play attention game (missing symbol)."),
                group=self.radio[0],
            )
        )
        self.radio.append(
            radio_factory(
                "game-4", self.toolbar, self._new_game_cb, cb_arg=2, tooltip=_("Play n-back game."), group=self.radio[0]
            )
        )
        """
        # Game mode disabled
        self.radio.append(radio_factory(
            'game-3', self.toolbar, self._new_game_cb,
            cb_arg=3, tooltip=_('Play attention game (color symbols).'),
            group=self.radio[0]))
        """

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

        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()
Exemplo n.º 7
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 4

        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

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

        separator_factory(toolbox.toolbar, False, True)

        self._true_button = button_factory(
            'true',
            self.toolbar,
            self._true_cb,
            tooltip=_('The pattern matches the rule.'))

        self._false_button = button_factory(
            'false',
            self.toolbar,
            self._false_cb,
            tooltip=_('The pattern does not match the rule.'))

        separator_factory(toolbox.toolbar, False, True)

        self._example_button = button_factory(
            'example',
            self.toolbar,
            self._example_cb,
            tooltip=_('Explore some examples.'))

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

        separator_factory(toolbox.toolbar, True, False)

        self._gear_button = button_factory('view-source',
                                           self.toolbar,
                                           self._gear_cb,
                                           tooltip=_('Load a custom level.'))

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
Exemplo n.º 8
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()
Exemplo n.º 9
0
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = 4
        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

        self.radio = []
        self.radio.append(
            radio_factory('game-1',
                          self.toolbar,
                          self._new_game_cb,
                          cb_arg=0,
                          tooltip=_('Play attention game (repeated symbol).'),
                          group=None))
        self.radio.append(
            radio_factory('game-2',
                          self.toolbar,
                          self._new_game_cb,
                          cb_arg=1,
                          tooltip=_('Play attention game (missing symbol).'),
                          group=self.radio[0]))
        self.radio.append(
            radio_factory('game-4',
                          self.toolbar,
                          self._new_game_cb,
                          cb_arg=2,
                          tooltip=_('Play n-back game.'),
                          group=self.radio[0]))
        """
        # Game mode disabled
        self.radio.append(radio_factory(
            'game-3', self.toolbar, self._new_game_cb,
            cb_arg=3, tooltip=_('Play attention game (color symbols).'),
            group=self.radio[0]))
        """

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

        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()
Exemplo n.º 10
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 4

        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

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

        separator_factory(toolbox.toolbar, False, True)

        self._true_button = button_factory(
            'true', self.toolbar, self._true_cb,
            tooltip=_('The pattern matches the rule.'))

        self._false_button = button_factory(
            'false', self.toolbar, self._false_cb,
            tooltip=_('The pattern does not match the rule.'))

        separator_factory(toolbox.toolbar, False, True)

        self._example_button = button_factory(
            'example', self.toolbar, self._example_cb,
            tooltip=_('Explore some examples.'))

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

        separator_factory(toolbox.toolbar, True, False)

        self._gear_button = button_factory(
            'view-source', self.toolbar,
            self._gear_cb,
            tooltip=_('Load a custom level.'))

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
Exemplo n.º 11
0
 def _load_standard_buttons(self, toolbar):
     ''' Load buttons onto whichever toolbar we are using '''
     self.fraction_button = radio_factory('fraction', toolbar,
                                          self._fraction_cb,
                                          tooltip=_('fractions'),
                                          group=None)
     self.percent_button = radio_factory('percent', toolbar,
                                         self._percent_cb,
                                         tooltip=_('percents'),
                                         group=self.fraction_button)
     self.player = image_factory(
         svg_str_to_pixbuf(generate_xo_svg(scale=0.8,
                                       colors=['#282828', '#000000'])),
         toolbar, tooltip=self.nick)
     separator_factory(toolbar, expand=False, visible=True)
     self.challenge = label_factory(toolbar, _("Click the ball to start."))
Exemplo n.º 12
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """
        self.max_participants = 1

        toolbox = ToolbarBox()

        activity_button = ActivityToolbarButton(self)

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

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

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

        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()
Exemplo n.º 13
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 4

        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

        export_scores = button_factory(
            'score-copy',
            activity_button,
            self._write_scores_to_clipboard,
            tooltip=_('Export scores to clipboard'))

        self._new_game_button_h = button_factory(
            'new-game',
            self.toolbar,
            self._new_game_cb,
            tooltip=_('Start a new game.'))

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

        separator_factory(toolbox.toolbar, True, False)

        stop_button = StopButton(self)
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
    def _setup_toolbars(self):
        ''' Setup the toolbars. '''
        self.max_participants = 2

        self.edit_toolbar = Gtk.Toolbar()
        self.view_toolbar = Gtk.Toolbar()
        self.adjust_toolbar = Gtk.Toolbar()
        self.custom_toolbar = Gtk.Toolbar()

        toolbox = ToolbarBox()

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

        edit_toolbar_button = ToolbarButton(label=_("Edit"),
                                            page=self.edit_toolbar,
                                            icon_name='toolbar-edit')
        self.edit_toolbar.show()
        toolbox.toolbar.insert(edit_toolbar_button, -1)
        edit_toolbar_button.show()

        view_toolbar_button = ToolbarButton(label=_("View"),
                                            page=self.view_toolbar,
                                            icon_name='toolbar-view')
        self.view_toolbar.show()
        toolbox.toolbar.insert(view_toolbar_button, -1)
        view_toolbar_button.show()

        adjust_toolbar_button = ToolbarButton(label=_('Adjust'),
                                              page=self.adjust_toolbar,
                                              icon_name='preferences-system')
        self.adjust_toolbar.show()
        toolbox.toolbar.insert(adjust_toolbar_button, -1)
        adjust_toolbar_button.show()

        custom_toolbar_button = ToolbarButton(label=_("Custom"),
                                              page=self.custom_toolbar,
                                              icon_name='view-source')
        self.custom_toolbar.show()
        toolbox.toolbar.insert(custom_toolbar_button, -1)
        custom_toolbar_button.show()

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

        adjust_toolbar_button.set_expanded(True)

        button_factory('edit-copy',
                       self.edit_toolbar,
                       self._copy_cb,
                       tooltip=_('Copy'),
                       accelerator='<Ctrl>c')

        button_factory('edit-paste',
                       self.edit_toolbar,
                       self._paste_cb,
                       tooltip=_('Paste'),
                       accelerator='<Ctrl>v')

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

        button_factory('media-playback-start',
                       self.view_toolbar,
                       self._play_history_cb,
                       tooltip=_('Play game history'))

        self.history_button = button_factory('list-numbered',
                                             self.view_toolbar,
                                             self._show_history_cb,
                                             tooltip=_('Show game history'))

        separator_factory(self.view_toolbar, False, True)

        label_factory(self.view_toolbar, _('White: '))
        self.white_entry = entry_factory('',
                                         self.view_toolbar,
                                         tooltip=_("White's move"))

        separator_factory(self.view_toolbar, False, False)

        label_factory(self.view_toolbar, _('Black: '))
        self.black_entry = entry_factory('',
                                         self.view_toolbar,
                                         tooltip=_("Black's move"))

        separator_factory(self.view_toolbar, False, True)

        skin_button1 = radio_factory('white-knight',
                                     self.view_toolbar,
                                     self.do_default_skin_cb,
                                     tooltip=_('Default pieces'),
                                     group=None)

        skin_button2 = radio_factory('white-knight-sugar',
                                     self.view_toolbar,
                                     self.do_sugar_skin_cb,
                                     tooltip=_('Sugar-style pieces'),
                                     group=skin_button1)
        xocolors = XoColor(','.join(self.colors))
        icon = Icon(icon_name='white-knight-sugar', xo_color=xocolors)
        icon.show()
        skin_button2.set_icon_widget(icon)

        self.skin_button3 = radio_factory('white-knight-custom',
                                          self.view_toolbar,
                                          self.do_custom_skin_cb,
                                          tooltip=_('Custom pieces'),
                                          group=skin_button1)
        skin_button1.set_active(True)

        self.play_white_button = radio_factory('white-rook',
                                               self.adjust_toolbar,
                                               self._play_white_cb,
                                               group=None,
                                               tooltip=_('Play White'))

        self.play_black_button = radio_factory('black-rook',
                                               self.adjust_toolbar,
                                               self._play_black_cb,
                                               group=self.play_white_button,
                                               tooltip=_('Play Black'))

        self.play_white_button.set_active(True)

        separator_factory(self.adjust_toolbar, False, True)

        self.easy_button = radio_factory('beginner',
                                         self.adjust_toolbar,
                                         self._easy_cb,
                                         group=None,
                                         tooltip=_('Beginner'))

        self.hard_button = radio_factory('expert',
                                         self.adjust_toolbar,
                                         self._hard_cb,
                                         group=self.easy_button,
                                         tooltip=_('Expert'))

        self.easy_button.set_active(True)

        separator_factory(self.adjust_toolbar, False, True)

        self.robot_button = radio_factory(
            'robot',
            self.adjust_toolbar,
            self._robot_cb,
            group=None,
            tooltip=_('Play against the computer'))

        self.human_button = radio_factory('human',
                                          self.adjust_toolbar,
                                          self._human_cb,
                                          group=self.robot_button,
                                          tooltip=_('Play against a person'))

        separator_factory(self.adjust_toolbar, False, False)

        self.opponent = label_factory(self.adjust_toolbar, '')

        separator_factory(self.adjust_toolbar, False, True)

        self.timer_button = ToolButton('timer-0')
        self.timer_button.set_tooltip(_('Timer'))
        self.timer_button.connect('clicked', self._timer_button_cb)
        self.toolbar.insert(self.timer_button, -1)
        self._setup_timer_palette()
        self.timer_button.show()
        self.timer_button.set_sensitive(True)

        self.robot_button.set_active(True)

        button_factory('new-game',
                       self.toolbar,
                       self._new_gnuchess_cb,
                       tooltip=_('New game'))

        button_factory('edit-undo',
                       self.toolbar,
                       self._undo_cb,
                       tooltip=_('Undo'))

        button_factory('hint', self.toolbar, self._hint_cb, tooltip=_('Hint'))

        separator_factory(self.toolbar, False, False)
        self.status = label_factory(self.toolbar, '', width=150)
        self.status.set_label(_("It is White's move."))

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

        for piece in list(PIECES.keys()):
            for color in ['white', 'black']:
                button_factory('%s-%s' % (color, piece),
                               self.custom_toolbar,
                               self._reskin_cb,
                               cb_arg='%s_%s' % (color, piece),
                               tooltip=PIECES[piece][color])
Exemplo n.º 15
0
    def __init__(self, handle):
        ''' Initiate activity. '''
        super(AbacusActivity, self).__init__(handle)

        self._setting_up = True
        self.bead_colors = profile.get_color().to_string().split(',')

        # no sharing
        self.max_participants = 1

        self.sep = []
        self.abacus_toolbar = Gtk.Toolbar()
        custom_toolbar = Gtk.Toolbar()
        edit_toolbar = Gtk.Toolbar()

        toolbox = ToolbarBox()

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

        edit_toolbar_button = ToolbarButton(label=_('Edit'),
                                            page=edit_toolbar,
                                            icon_name='toolbar-edit')
        edit_toolbar_button.show()
        toolbox.toolbar.insert(edit_toolbar_button, -1)
        edit_toolbar_button.show()

        self.abacus_toolbar_button = ToolbarButton(
            page=self.abacus_toolbar,
            icon_name='abacus-list')
        self.abacus_toolbar.show()
        toolbox.toolbar.insert(self.abacus_toolbar_button, -1)
        self.abacus_toolbar_button.show()

        self.custom_toolbar_button = ToolbarButton(
            page=custom_toolbar,
            icon_name='view-source')
        custom_toolbar.show()
        toolbox.toolbar.insert(self.custom_toolbar_button, -1)
        self.custom_toolbar_button.show()

        separator_factory(toolbox.toolbar, False, True)

        button_factory('edit-delete', toolbox.toolbar,
                       self._reset_cb, tooltip=_('Reset'))

        separator_factory(toolbox.toolbar, False, True)

        self._label = label_factory(NAMES['suanpan'], toolbox.toolbar)

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

        self.set_toolbar_box(toolbox)
        toolbox.show()

        self.abacus_buttons = {}

        # Traditional
        self._add_abacus_button('decimal', None)
        self._add_abacus_button('soroban', self.abacus_buttons['decimal'])
        self._add_abacus_button('suanpan', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Bases other than 10
        self._add_abacus_button('nepohualtzintzin',
                                self.abacus_buttons['decimal'])
        self._add_abacus_button('hexadecimal', self.abacus_buttons['decimal'])
        self._add_abacus_button('binary', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Fractions
        self._add_abacus_button('schety', self.abacus_buttons['decimal'])
        # self._add_abacus_button('fraction', self.abacus_buttons['decimal'])
        self._add_abacus_button('caacupe', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Non-traditional
        self._add_abacus_button('cuisenaire', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Custom
        self._add_abacus_button('custom', self.abacus_buttons['decimal'])

        preferences_button = ToolButton('preferences-system')
        preferences_button.set_tooltip(_('Custom'))
        custom_toolbar.insert(preferences_button, -1)
        preferences_button.palette_invoker.props.toggle_palette = True
        preferences_button.palette_invoker.props.lock_palette = True
        preferences_button.props.hide_tooltip_on_click = False
        preferences_button.show()

        self._palette = preferences_button.get_palette()
        button_box = Gtk.VBox()
        # TRANS: Number of rods on the abacus
        self._rods_spin = add_spinner_and_label(
            15, 1, MAX_RODS, _('Rods:'), self._rods_spin_cb, button_box)
        # TRANS: Number of beads in the top section of the abacus
        self._top_spin = add_spinner_and_label(
            2, 0, MAX_TOP, _('Top:'), self._top_spin_cb, button_box)
        # TRANS: Number of beads in the bottom section of the abacus
        self._bottom_spin = add_spinner_and_label(
            5, 0, MAX_BOT, _('Bottom:'), self._bottom_spin_cb, button_box)
        # TRANS: Scale factor between bottom and top beads
        self._value_spin = add_spinner_and_label(
            5, 1, MAX_BOT + 1, _('Factor:'), self._value_spin_cb, button_box)
        # TRANS: Scale factor between rods
        self._base_spin = add_spinner_and_label(
            10, 1, (MAX_TOP + 1) * MAX_BOT, _('Base:'), self._base_spin_cb,
            button_box)
        hbox = Gtk.HBox()
        hbox.pack_start(button_box, True, True, style.DEFAULT_SPACING)
        hbox.show_all()
        self._palette.set_content(hbox)

        separator_factory(custom_toolbar, False, False)

        self.custom_maker = button_factory('new-abacus', custom_toolbar,
                                           self._custom_cb,
                                           tooltip=_('Custom'))

        button_factory('edit-copy', edit_toolbar, self._copy_cb,
                       tooltip=_('Copy'), accelerator='<Ctrl>c')
        button_factory('edit-paste', edit_toolbar, self._paste_cb,
                       tooltip=_('Paste'), accelerator='<Ctrl>v')

        # Create a canvas
        canvas = Gtk.DrawingArea()
        canvas.set_size_request(Gdk.Screen.width(),
                                Gdk.Screen.height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        # Initialize the canvas
        self.abacus = Abacus(canvas, self)

        self._setting_up = False

        # Read the current mode from the Journal
        if 'rods' in self.metadata:
            self._rods_spin.set_value(int(self.metadata['rods']))
        if 'top' in self.metadata:
            self._top_spin.set_value(int(self.metadata['top']))
        if 'bottom' in self.metadata:
            self._bottom_spin.set_value(int(self.metadata['bottom']))
        if 'factor' in self.metadata:
            self._value_spin.set_value(int(self.metadata['factor']))
        if 'base' in self.metadata:
            self._base_spin.set_value(int(self.metadata['base']))
        if 'abacus' in self.metadata:
            if self.metadata['abacus'] in self.abacus_buttons:
                _logger.debug('restoring %s', self.metadata['abacus'])
                if self.metadata['abacus'] == 'custom':
                    self._custom_cb()
                self.abacus_buttons[self.metadata['abacus']].set_active(True)
            else:  # Default is Chinese
                self.abacus_buttons['suanpan'].set_active(True)

            if 'value' in self.metadata:
                _logger.debug('restoring value %s', self.metadata['value'])
                self.abacus.mode.set_value(self.metadata['value'])
                self.abacus.mode.label(self.abacus.generate_label())

        self.abacus.init()

        # Start with abacus toolbar expanded and suanpan as default
        self.abacus_toolbar_button.set_expanded(True)
Exemplo n.º 16
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 1

        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

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

        separator_factory(self.toolbar, False, True)

        self.beginner_button = radio_factory(
            'beginner',
            self.toolbar,
            self._level_cb,
            cb_arg=BEGINNER,
            tooltip=LEVEL_LABELS[BEGINNER],
            group=None)
        self.intermediate_button = radio_factory(
            'intermediate',
            self.toolbar,
            self._level_cb,
            cb_arg=INTERMEDIATE,
            tooltip=LEVEL_LABELS[INTERMEDIATE],
            group=self.beginner_button)
        self.expert_button = radio_factory(
            'expert',
            self.toolbar,
            self._level_cb,
            cb_arg=EXPERT,
            tooltip=LEVEL_LABELS[EXPERT],
            group=self.beginner_button)
        self.custom_button = radio_factory(
            'view-source',
            self.toolbar,
            self._level_cb,
            cb_arg=CUSTOM,
            tooltip=LEVEL_LABELS[CUSTOM],
            group=self.beginner_button)

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

        separator_factory(toolbox.toolbar, True, False)

        self.load_python = button_factory(
            'pippy-openoff', self.toolbar,
            self._do_load_python_cb,
            tooltip=_('Load strategy from Journal'))

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
Exemplo n.º 17
0
    def _setup_toolbars(self):
        ''' Setup the toolbars. '''

        self.max_participants = 4

        toolbox = ToolbarBox()

        activity_button = ActivityToolbarButton(self)

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

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

        my_colors = radio_factory('my-colors',
                                  self.toolbar,
                                  self._my_colors_cb,
                                  group=None)

        radio_factory('toolbar-colors',
                      self.toolbar,
                      self._roygbiv_colors_cb,
                      group=my_colors)

        self._new_game_button_h = button_factory(
            'new-game-horizontal',
            self.toolbar,
            self._new_game_cb,
            cb_arg='horizontal',
            tooltip=_('Start a new horizontal-reflection game.'))

        self._new_game_button_v = button_factory(
            'new-game-vertical',
            self.toolbar,
            self._new_game_cb,
            cb_arg='vertical',
            tooltip=_('Start a new vertical-reflection game.'))

        self._new_game_button_b = button_factory(
            'new-game-bilateral',
            self.toolbar,
            self._new_game_cb,
            cb_arg='bilateral',
            tooltip=_('Start a new bilateral-reflection game.'))

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

        separator_factory(toolbox.toolbar, False, True)

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

        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()
Exemplo n.º 18
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()
Exemplo n.º 19
0
    def _setup_toolbars(self):
        ''' Setup the toolbars. '''

        self.max_participants = 1  # no sharing

        toolbox = ToolbarBox()

        # Activity toolbar
        activity_button = ActivityToolbarButton(self)

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

        self._bones_toolbar = Gtk.Toolbar()
        self._bones_toolbar_button = ToolbarButton(label=_('Select a bone'),
                                                       page=self._bones_toolbar,
                                                       icon_name='bones')

        self._bones_toolbar_button.show()
        toolbox.toolbar.insert(self._bones_toolbar_button, -1)
        self.set_toolbar_box(toolbox)
        toolbox.show()
        self.toolbar = toolbox.toolbar


        self._new_calc_button = button_factory(
            'erase', self.toolbar, self._new_calc_cb, tooltip=_('Clear'))

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

        button_factory('number-0', self._bones_toolbar, self._number_cb,
                        cb_arg=0, tooltip=_('zero'))

        button_factory('number-1', self._bones_toolbar, self._number_cb,
                        cb_arg=1, tooltip=_('one'))

        button_factory('number-2', self._bones_toolbar, self._number_cb,
                        cb_arg=2, tooltip=_('two'))

        button_factory('number-3', self._bones_toolbar, self._number_cb,
                        cb_arg=3, tooltip=_('three'))

        button_factory('number-4', self._bones_toolbar, self._number_cb,
                        cb_arg=4, tooltip=_('four'))

        button_factory('number-5', self._bones_toolbar, self._number_cb,
                        cb_arg=5, tooltip=_('five'))

        button_factory('number-6', self._bones_toolbar, self._number_cb,
                        cb_arg=6, tooltip=_('six'))

        button_factory('number-7', self._bones_toolbar, self._number_cb,
                        cb_arg=7, tooltip=_('seven'))

        button_factory('number-8', self._bones_toolbar, self._number_cb,
                        cb_arg=8, tooltip=_('eight'))

        button_factory('number-9', self._bones_toolbar, self._number_cb,
                        cb_arg=9, tooltip=_('nine'))

        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()
        self._bones_toolbar_button.set_expanded(True)
Exemplo n.º 20
0
    def _setup_toolbars(self):
        ''' Setup the toolbars. '''

        self.max_participants = 1  # no sharing

        toolbox = ToolbarBox()

        # Activity toolbar
        activity_button = ActivityToolbarButton(self)

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

        self._bones_toolbar = Gtk.Toolbar()
        self._bones_toolbar_button = ToolbarButton(label=_('Select a bone'),
                                                   page=self._bones_toolbar,
                                                   icon_name='bones')

        self._bones_toolbar_button.show()
        toolbox.toolbar.insert(self._bones_toolbar_button, -1)
        self.set_toolbar_box(toolbox)
        toolbox.show()
        self.toolbar = toolbox.toolbar

        self._new_calc_button = button_factory('erase',
                                               self.toolbar,
                                               self._new_calc_cb,
                                               tooltip=_('Clear'))

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

        button_factory('number-0',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=0,
                       tooltip=_('zero'))

        button_factory('number-1',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=1,
                       tooltip=_('one'))

        button_factory('number-2',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=2,
                       tooltip=_('two'))

        button_factory('number-3',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=3,
                       tooltip=_('three'))

        button_factory('number-4',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=4,
                       tooltip=_('four'))

        button_factory('number-5',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=5,
                       tooltip=_('five'))

        button_factory('number-6',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=6,
                       tooltip=_('six'))

        button_factory('number-7',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=7,
                       tooltip=_('seven'))

        button_factory('number-8',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=8,
                       tooltip=_('eight'))

        button_factory('number-9',
                       self._bones_toolbar,
                       self._number_cb,
                       cb_arg=9,
                       tooltip=_('nine'))

        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()
        self._bones_toolbar_button.set_expanded(True)
Exemplo n.º 21
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 1  # No collaboration

        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

        name_game_button = radio_factory(
            'name-game',
            toolbox.toolbar,
            self._level_cb,
            cb_arg=0,
            tooltip=_(LABELS[0]),
            group=None)
        group_game_button = radio_factory(
            'group-game',
            toolbox.toolbar,
            self._level_cb,
            cb_arg=1,
            tooltip=_(LABELS[1]),
            group=name_game_button)
        calorie_game_button = radio_factory(
            'calorie-game',
            toolbox.toolbar,
            self._level_cb,
            cb_arg=2,
            tooltip=_(LABELS[2]),
            group=name_game_button)
        pyramid_game_button = radio_factory(
            'pyramid-game',
            toolbox.toolbar,
            self._level_cb,
            cb_arg=3,
            tooltip=_(LABELS[3]),
            group=name_game_button)
        balance_game_button = radio_factory(
            'balance-game',
            toolbox.toolbar,
            self._level_cb,
            cb_arg=4,
            tooltip=_(LABELS[4]),
            group=name_game_button)

        separator_factory(toolbox.toolbar, False, True)
        self._label = label_factory(toolbox.toolbar, LABELS[0], width=150)

        separator_factory(toolbox.toolbar, True, False)
        tools_toolbar = Gtk.Toolbar()
        tools_toolbar_button = ToolbarButton(
            page=tools_toolbar,
            icon_name='view-source')
        tools_toolbar.show()
        toolbox.toolbar.insert(tools_toolbar_button, -1)
        tools_toolbar_button.show()

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

        self.name_entry = entry_factory(
            _('food name'),
            tools_toolbar,
            tooltip=_('Enter a name for the new food item.'),
            max=20)
        self.calories_entry = entry_factory(
            _('calories'),
            tools_toolbar,
            tooltip=_('Enter the calories in for the new food item.'),
            max=8)
        self.food_spinner = combo_factory(
            PYRAMID,
            tools_toolbar,
            self._food_pyramid_cb,
            default=PYRAMID[2],
            tooltip=_('Select level in the Food Pyramid.'))
        image_button = button_factory(
            'image-tools',
            tools_toolbar,
            self._load_image_cb,
            tooltip=_('Load a picture of the new food item.'))

        separator_factory(tools_toolbar, True, False)
        create_button = button_factory(
            'new-food',
            tools_toolbar,
            self._create_custom_food_cb,
            tooltip=_('Add a new food item.'))
Exemplo n.º 22
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()
Exemplo n.º 23
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 1  # No collaboration

        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

        name_game_button = radio_factory('name-game',
                                         toolbox.toolbar,
                                         self._level_cb,
                                         cb_arg=0,
                                         tooltip=_(LABELS[0]),
                                         group=None)
        group_game_button = radio_factory('group-game',
                                          toolbox.toolbar,
                                          self._level_cb,
                                          cb_arg=1,
                                          tooltip=_(LABELS[1]),
                                          group=name_game_button)
        calorie_game_button = radio_factory('calorie-game',
                                            toolbox.toolbar,
                                            self._level_cb,
                                            cb_arg=2,
                                            tooltip=_(LABELS[2]),
                                            group=name_game_button)
        pyramid_game_button = radio_factory('pyramid-game',
                                            toolbox.toolbar,
                                            self._level_cb,
                                            cb_arg=3,
                                            tooltip=_(LABELS[3]),
                                            group=name_game_button)
        balance_game_button = radio_factory('balance-game',
                                            toolbox.toolbar,
                                            self._level_cb,
                                            cb_arg=4,
                                            tooltip=_(LABELS[4]),
                                            group=name_game_button)

        separator_factory(toolbox.toolbar, False, True)
        self._label = label_factory(toolbox.toolbar, LABELS[0], width=150)

        separator_factory(toolbox.toolbar, True, False)
        tools_toolbar = Gtk.Toolbar()
        tools_toolbar_button = ToolbarButton(page=tools_toolbar,
                                             icon_name='view-source')
        tools_toolbar.show()
        toolbox.toolbar.insert(tools_toolbar_button, -1)
        tools_toolbar_button.show()

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

        self.name_entry = entry_factory(
            _('food name'),
            tools_toolbar,
            tooltip=_('Enter a name for the new food item.'),
            max=20)
        self.calories_entry = entry_factory(
            _('calories'),
            tools_toolbar,
            tooltip=_('Enter the calories in for the new food item.'),
            max=8)
        self.food_spinner = combo_factory(
            PYRAMID,
            tools_toolbar,
            self._food_pyramid_cb,
            default=PYRAMID[2],
            tooltip=_('Select level in the Food Pyramid.'))
        image_button = button_factory(
            'image-tools',
            tools_toolbar,
            self._load_image_cb,
            tooltip=_('Load a picture of the new food item.'))

        separator_factory(tools_toolbar, True, False)
        create_button = button_factory('new-food',
                                       tools_toolbar,
                                       self._create_custom_food_cb,
                                       tooltip=_('Add a new food item.'))
Exemplo n.º 24
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = 4

        yupana_toolbar = Gtk.Toolbar()
        self.custom_toolbar = Gtk.Toolbar()
        toolbox = ToolbarBox()

        # Activity toolbar
        activity_button = ActivityToolbarButton(self)

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

        yupana_toolbar_button = ToolbarButton(label=_("Mode"),
                                              page=yupana_toolbar,
                                              icon_name='preferences-system')
        yupana_toolbar.show()
        toolbox.toolbar.insert(yupana_toolbar_button, -1)
        yupana_toolbar_button.show()

        custom_toolbar_button = ToolbarButton(label=_("Custom"),
                                              page=self.custom_toolbar,
                                              icon_name='view-source')
        self.custom_toolbar.show()
        toolbox.toolbar.insert(custom_toolbar_button, -1)
        custom_toolbar_button.show()

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

        self._new_yupana_button = button_factory(
            'edit-delete',
            self.toolbar,
            self._new_yupana_cb,
            tooltip=_('Clear the yupana.'))

        separator_factory(yupana_toolbar, False, True)

        self.ten_button = radio_factory('ten',
                                        yupana_toolbar,
                                        self._ten_cb,
                                        tooltip=_('decimal mode'),
                                        group=None)
        self.twenty_button = radio_factory('twenty',
                                           yupana_toolbar,
                                           self._twenty_cb,
                                           tooltip=_('base-twenty mode'),
                                           group=self.ten_button)
        self.factor_button = radio_factory('factor',
                                           yupana_toolbar,
                                           self._factor_cb,
                                           tooltip=_('prime-factor mode'),
                                           group=self.ten_button)
        self.fibonacci_button = radio_factory('fibonacci',
                                              yupana_toolbar,
                                              self._fibonacci_cb,
                                              tooltip=_('Fibonacci mode'),
                                              group=self.ten_button)
        self.custom_button = radio_factory('view-source',
                                           yupana_toolbar,
                                           self._custom_cb,
                                           tooltip=_('custom mode'),
                                           group=self.ten_button)

        separator_factory(self.toolbar, False, False)
        self.status = label_factory(self.toolbar, '', width=200)
        self.status.set_label(_('decimal mode'))

        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()
Exemplo n.º 25
0
    def __init__(self, handle):
        ''' Initiate activity. '''
        super(AbacusActivity, self).__init__(handle)

        self._setting_up = True
        self.bead_colors = profile.get_color().to_string().split(',')

        # no sharing
        self.max_participants = 1

        self.sep = []
        self.abacus_toolbar = Gtk.Toolbar()
        custom_toolbar = Gtk.Toolbar()
        edit_toolbar = Gtk.Toolbar()

        toolbox = ToolbarBox()

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

        edit_toolbar_button = ToolbarButton(label=_('Edit'),
                                            page=edit_toolbar,
                                            icon_name='toolbar-edit')
        edit_toolbar_button.show()
        toolbox.toolbar.insert(edit_toolbar_button, -1)
        edit_toolbar_button.show()

        self.abacus_toolbar_button = ToolbarButton(
            page=self.abacus_toolbar,
            icon_name='abacus-list')
        self.abacus_toolbar.show()
        toolbox.toolbar.insert(self.abacus_toolbar_button, -1)
        self.abacus_toolbar_button.show()

        self.custom_toolbar_button = ToolbarButton(
            page=custom_toolbar,
            icon_name='view-source')
        custom_toolbar.show()
        toolbox.toolbar.insert(self.custom_toolbar_button, -1)
        self.custom_toolbar_button.show()

        separator_factory(toolbox.toolbar, False, True)

        button_factory('edit-delete', toolbox.toolbar,
                       self._reset_cb, tooltip=_('Reset'))

        separator_factory(toolbox.toolbar, False, True)

        self._label = label_factory(NAMES['suanpan'], toolbox.toolbar)

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

        self.set_toolbar_box(toolbox)
        toolbox.show()

        self.abacus_buttons = {}

        # Traditional
        self._add_abacus_button('decimal', None)
        self._add_abacus_button('soroban', self.abacus_buttons['decimal'])
        self._add_abacus_button('suanpan', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Bases other than 10
        self._add_abacus_button('nepohualtzintzin',
                                self.abacus_buttons['decimal'])
        self._add_abacus_button('hexadecimal', self.abacus_buttons['decimal'])
        self._add_abacus_button('binary', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Fractions
        self._add_abacus_button('schety', self.abacus_buttons['decimal'])
        # self._add_abacus_button('fraction', self.abacus_buttons['decimal'])
        self._add_abacus_button('caacupe', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Non-traditional
        self._add_abacus_button('cuisenaire', self.abacus_buttons['decimal'])

        self.sep.append(separator_factory(self.abacus_toolbar))

        # Custom
        self._add_abacus_button('custom', self.abacus_buttons['decimal'])

        preferences_button = ToolButton('preferences-system')
        preferences_button.set_tooltip(_('Custom'))
        custom_toolbar.insert(preferences_button, -1)
        preferences_button.palette_invoker.props.toggle_palette = True
        preferences_button.palette_invoker.props.lock_palette = True
        preferences_button.props.hide_tooltip_on_click = False
        preferences_button.show()

        self._palette = preferences_button.get_palette()
        button_box = Gtk.VBox()
        # TRANS: Number of rods on the abacus
        self._rods_spin = add_spinner_and_label(
            15, 1, MAX_RODS, _('Rods:'), self._rods_spin_cb, button_box)
        # TRANS: Number of beads in the top section of the abacus
        self._top_spin = add_spinner_and_label(
            2, 0, MAX_TOP, _('Top:'), self._top_spin_cb, button_box)
        # TRANS: Number of beads in the bottom section of the abacus
        self._bottom_spin = add_spinner_and_label(
            5, 0, MAX_BOT, _('Bottom:'), self._bottom_spin_cb, button_box)
        # TRANS: Scale factor between bottom and top beads
        self._value_spin = add_spinner_and_label(
            5, 1, MAX_BOT + 1, _('Factor:'), self._value_spin_cb, button_box)
        # TRANS: Scale factor between rods
        self._base_spin = add_spinner_and_label(
            10, 1, (MAX_TOP + 1) * MAX_BOT, _('Base:'), self._base_spin_cb,
            button_box)
        hbox = Gtk.HBox()
        hbox.pack_start(button_box, True, True, style.DEFAULT_SPACING)
        hbox.show_all()
        self._palette.set_content(hbox)

        separator_factory(custom_toolbar, False, False)

        self.custom_maker = button_factory('new-abacus', custom_toolbar,
                                           self._custom_cb,
                                           tooltip=_('Custom'))

        button_factory('edit-copy', edit_toolbar, self._copy_cb,
                       tooltip=_('Copy'), accelerator='<Ctrl>c')
        button_factory('edit-paste', edit_toolbar, self._paste_cb,
                       tooltip=_('Paste'), accelerator='<Ctrl>v')

        # Create a canvas
        canvas = Gtk.DrawingArea()
        canvas.set_size_request(Gdk.Screen.width(),
                                Gdk.Screen.height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        # Initialize the canvas
        self.abacus = Abacus(canvas, self)

        self._setting_up = False

        # Read the current mode from the Journal
        if 'rods' in self.metadata:
            self._rods_spin.set_value(int(self.metadata['rods']))
        if 'top' in self.metadata:
            self._top_spin.set_value(int(self.metadata['top']))
        if 'bottom' in self.metadata:
            self._bottom_spin.set_value(int(self.metadata['bottom']))
        if 'factor' in self.metadata:
            self._value_spin.set_value(int(self.metadata['factor']))
        if 'base' in self.metadata:
            self._base_spin.set_value(int(self.metadata['base']))
        if 'abacus' in self.metadata:
            if self.metadata['abacus'] in self.abacus_buttons:
                _logger.debug('restoring %s', self.metadata['abacus'])
                if self.metadata['abacus'] == 'custom':
                    self._custom_cb()
                self.abacus_buttons[self.metadata['abacus']].set_active(True)
            else:  # Default is Chinese
                self.abacus_buttons['suanpan'].set_active(True)

            if 'value' in self.metadata:
                _logger.debug('restoring value %s', self.metadata['value'])
                self.abacus.mode.set_value(self.metadata['value'])
                self.abacus.mode.label(self.abacus.generate_label())

        self.abacus.init()

        # Start with abacus toolbar expanded and suanpan as default
        self.abacus_toolbar_button.set_expanded(True)
Exemplo n.º 26
0
    def __init__(self, handle):
        super(CardSortActivity,self).__init__(handle)

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

        self.grid2x2 = radio_factory('2x2on',
                                     toolbar_box.toolbar,
                                     self._grid2x2_cb,
                                     tooltip=_('2x2'),
                                     group = None)
        self.grid3x2 = radio_factory('3x2on',
                                     toolbar_box.toolbar,
                                     self._grid3x2_cb,
                                     tooltip=_('3x2'),
                                     group = self.grid2x2)
        self.grid2x3 = radio_factory('2x3on',
                                     toolbar_box.toolbar,
                                     self._grid2x3_cb,
                                     tooltip=_('2x3'),
                                     group = self.grid2x2)
        self.grid3x3 = radio_factory('3x3on',
                                     toolbar_box.toolbar,
                                     self._grid3x3_cb,
                                     tooltip=_('3x3'),
                                     group = self.grid2x2)

        separator_factory(toolbar_box.toolbar,
                          visible=False)

	self.results_label = label_factory(toolbar_box.toolbar,
                                           _("click to rotate; drag to swap"),
                                           width=300)

        separator_factory(toolbar_box.toolbar,
                          expand=True,
                          visible=False)

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

	self.set_toolbar_box(toolbar_box)
	toolbar_box.show()

         # Create a canvas
        canvas = Gtk.DrawingArea()
        canvas.set_size_request(Gdk.Screen.width(),
                                Gdk.Screen.height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        # Initialize the canvas
        self.game = Game(canvas, os.path.join(
                activity.get_bundle_path(), 'images'), self)

        # Read the mode from the Journal
        try:
            if self.metadata['grid'] == '2x2':
                self.show_grid2x2()
            elif self.metadata['grid'] == '3x2':
                self.show_grid3x2()
            elif self.metadata['grid'] == '2x3':
                self.show_grid2x3()
            elif self.metadata['grid'] == '3x3':
                self.show_grid3x3()
        except:
            self.metadata['grid'] = "2x2"
            self.show_grid2x2()