Exemple #1
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'))
Exemple #2
0
    def _make_custom_toolbar(self):
        self._ones = entry_factory(str(self._yupana.custom[0]),
                                   self.custom_toolbar,
                                   tooltip=_('one row'))
        self._twos = entry_factory(str(self._yupana.custom[1]),
                                   self.custom_toolbar,
                                   tooltip=_('two row'))
        self._threes = entry_factory(str(self._yupana.custom[2]),
                                     self.custom_toolbar,
                                     tooltip=_('three row'))
        self._fives = entry_factory(str(self._yupana.custom[3]),
                                    self.custom_toolbar,
                                    tooltip=_('five row'))

        separator_factory(self.custom_toolbar, False, True)
        self._base = entry_factory(str(self._yupana.custom[4]),
                                   self.custom_toolbar,
                                   tooltip=_('base'))

        separator_factory(self.custom_toolbar, False, True)
        button_factory('view-refresh',
                       self.custom_toolbar,
                       self._custom_cb,
                       tooltip=_('Reload custom values.'))
    def _setup_toolbars(self):
        """ Setup the toolbars.. """
        project_toolbar = Gtk.Toolbar()
        custom_slide_toolbar = Gtk.Toolbar()
        custom_stator_toolbar = Gtk.Toolbar()
        edit_toolbar = Gtk.Toolbar()

        # no sharing
        self.max_participants = 1

        toolbox = ToolbarBox()

        # Activity toolbar
        activity_button = ActivityToolbarButton(self)

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

        project_toolbar_button = ToolbarButton(page=project_toolbar,
                                               icon_name='sliderule')
        project_toolbar.show()
        toolbox.toolbar.insert(project_toolbar_button, -1)
        project_toolbar_button.show()

        custom_slide_toolbar_button = ToolbarButton(page=custom_slide_toolbar,
                                                    icon_name='custom-slide')
        custom_slide_toolbar.show()
        toolbox.toolbar.insert(custom_slide_toolbar_button, -1)
        custom_slide_toolbar_button.show()

        custom_stator_toolbar_button = ToolbarButton(
            page=custom_stator_toolbar, icon_name='custom-stator')
        custom_stator_toolbar.show()
        toolbox.toolbar.insert(custom_stator_toolbar_button, -1)
        custom_stator_toolbar_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.set_toolbar_box(toolbox)
        toolbox.show()
        toolbar = toolbox.toolbar

        # Add the buttons to the toolbars
        self._function_combo = combo_factory(FUNCTIONS,
                                             project_toolbar,
                                             self._function_combo_cb,
                                             default=FC_multiply,
                                             tooltip=_('select function'))
        self.top_button = button_factory('C',
                                         project_toolbar,
                                         self._dummy_cb,
                                         tooltip=_('active slide'))
        self._slide_combo = combo_factory(SLIDE_TABLE,
                                          project_toolbar,
                                          self._slide_combo_cb,
                                          default=C_slide,
                                          tooltip=_('select slide'))
        self.bottom_button = button_factory('D',
                                            project_toolbar,
                                            self._dummy_cb,
                                            tooltip=_('active stator'))
        self._stator_combo = combo_factory(STATOR_TABLE,
                                           project_toolbar,
                                           self._stator_combo_cb,
                                           default=D_slide,
                                           tooltip=_('select stator'))

        separator_factory(project_toolbar)

        self.realign_button = button_factory('realign',
                                             project_toolbar,
                                             self.realign_cb,
                                             tooltip=_('realign slides'))

        self._offset_function = []
        self._calculate_function = []
        self._label_function = []
        self._domain_min = []
        self._domain_max = []
        self._step_size = []
        self.custom = []

        ENTRY = ['C', 'D']
        ENTRY_TOOLBAR = [custom_slide_toolbar, custom_stator_toolbar]
        ENTRY_BUTTON = ['custom-slide', 'custom-stator']
        ENTRY_TOOLTIP = [_('create custom slide'), _('create custom stator')]
        ENTRY_CALLBACK = [self._custom_slide_cb, self._custom_stator_cb]
        for i in range(2):
            self._offset_function.append(
                entry_factory(DEFINITIONS[ENTRY[i]][0],
                              ENTRY_TOOLBAR[i],
                              tooltip=_('position function'),
                              max=10))
            self._calculate_function.append(
                entry_factory(DEFINITIONS[ENTRY[i]][1],
                              ENTRY_TOOLBAR[i],
                              tooltip=_('result function'),
                              max=10))
            self._label_function.append(
                entry_factory(DEFINITIONS[ENTRY[i]][2],
                              ENTRY_TOOLBAR[i],
                              tooltip=_('label function'),
                              max=10))
            self._domain_min.append(
                entry_factory(DEFINITIONS[ENTRY[i]][3],
                              ENTRY_TOOLBAR[i],
                              tooltip=_('domain minimum'),
                              max=4))
            self._domain_max.append(
                entry_factory(DEFINITIONS[ENTRY[i]][4],
                              ENTRY_TOOLBAR[i],
                              tooltip=_('domain maximum'),
                              max=4))
            self._step_size.append(
                entry_factory(DEFINITIONS[ENTRY[i]][5],
                              ENTRY_TOOLBAR[i],
                              tooltip=_('step size'),
                              max=4))
            self.custom.append(
                button_factory(ENTRY_BUTTON[i],
                               ENTRY_TOOLBAR[i],
                               ENTRY_CALLBACK[i],
                               tooltip=ENTRY_TOOLTIP[i]))

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

        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()
        # workaround to #2050
        edit_toolbar_button.set_expanded(True)
        # start with project toolbar enabled
        project_toolbar_button.set_expanded(True)
    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.'))
    def _setup_toolbars(self):
        """ Setup the toolbars.. """
        project_toolbar = Gtk.Toolbar()
        custom_slide_toolbar = Gtk.Toolbar()
        custom_stator_toolbar = Gtk.Toolbar()
        edit_toolbar = Gtk.Toolbar()

        # no sharing
        self.max_participants = 1

        toolbox = ToolbarBox()

        # Activity toolbar
        activity_button = ActivityToolbarButton(self)

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

        project_toolbar_button = ToolbarButton(page=project_toolbar, icon_name="sliderule")
        project_toolbar.show()
        toolbox.toolbar.insert(project_toolbar_button, -1)
        project_toolbar_button.show()

        custom_slide_toolbar_button = ToolbarButton(page=custom_slide_toolbar, icon_name="custom-slide")
        custom_slide_toolbar.show()
        toolbox.toolbar.insert(custom_slide_toolbar_button, -1)
        custom_slide_toolbar_button.show()

        custom_stator_toolbar_button = ToolbarButton(page=custom_stator_toolbar, icon_name="custom-stator")
        custom_stator_toolbar.show()
        toolbox.toolbar.insert(custom_stator_toolbar_button, -1)
        custom_stator_toolbar_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.set_toolbar_box(toolbox)
        toolbox.show()
        toolbar = toolbox.toolbar

        # Add the buttons to the toolbars
        self._function_combo = combo_factory(
            FUNCTIONS, project_toolbar, self._function_combo_cb, default=FC_multiply, tooltip=_("select function")
        )
        self.top_button = button_factory("C", project_toolbar, self._dummy_cb, tooltip=_("active slide"))
        self._slide_combo = combo_factory(
            SLIDE_TABLE, project_toolbar, self._slide_combo_cb, default=C_slide, tooltip=_("select slide")
        )
        self.bottom_button = button_factory("D", project_toolbar, self._dummy_cb, tooltip=_("active stator"))
        self._stator_combo = combo_factory(
            STATOR_TABLE, project_toolbar, self._stator_combo_cb, default=D_slide, tooltip=_("select stator")
        )

        separator_factory(project_toolbar)

        self.realign_button = button_factory("realign", project_toolbar, self.realign_cb, tooltip=_("realign slides"))

        self._offset_function = []
        self._calculate_function = []
        self._label_function = []
        self._domain_min = []
        self._domain_max = []
        self._step_size = []
        self.custom = []

        ENTRY = ["C", "D"]
        ENTRY_TOOLBAR = [custom_slide_toolbar, custom_stator_toolbar]
        ENTRY_BUTTON = ["custom-slide", "custom-stator"]
        ENTRY_TOOLTIP = [_("create custom slide"), _("create custom stator")]
        ENTRY_CALLBACK = [self._custom_slide_cb, self._custom_stator_cb]
        for i in range(2):
            self._offset_function.append(
                entry_factory(DEFINITIONS[ENTRY[i]][0], ENTRY_TOOLBAR[i], tooltip=_("position function"), max=10)
            )
            self._calculate_function.append(
                entry_factory(DEFINITIONS[ENTRY[i]][1], ENTRY_TOOLBAR[i], tooltip=_("result function"), max=10)
            )
            self._label_function.append(
                entry_factory(DEFINITIONS[ENTRY[i]][2], ENTRY_TOOLBAR[i], tooltip=_("label function"), max=10)
            )
            self._domain_min.append(
                entry_factory(DEFINITIONS[ENTRY[i]][3], ENTRY_TOOLBAR[i], tooltip=_("domain minimum"), max=4)
            )
            self._domain_max.append(
                entry_factory(DEFINITIONS[ENTRY[i]][4], ENTRY_TOOLBAR[i], tooltip=_("domain maximum"), max=4)
            )
            self._step_size.append(
                entry_factory(DEFINITIONS[ENTRY[i]][5], ENTRY_TOOLBAR[i], tooltip=_("step size"), max=4)
            )
            self.custom.append(
                button_factory(ENTRY_BUTTON[i], ENTRY_TOOLBAR[i], ENTRY_CALLBACK[i], tooltip=ENTRY_TOOLTIP[i])
            )

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

        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()
        # workaround to #2050
        edit_toolbar_button.set_expanded(True)
        # start with project toolbar enabled
        project_toolbar_button.set_expanded(True)
    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.'))
    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])