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()
def _append_player(self, nick, colors): ''' Keep a list of players, their colors, and an XO pixbuf ''' if not nick in self._game.buddies: self._game.buddies.append(nick) self._player_colors.append(colors) self._player_pixbuf.append( svg_str_to_pixbuf(generate_xo(scale=0.8, colors=colors)))
def _append_player(self, nick, colors): ''' Keep a list of players, their colors, and an XO pixbuf ''' if not nick in self._game.buddies: self._game.buddies.append(nick) self._player_colors.append(colors) self._player_pixbuf.append(svg_str_to_pixbuf( generate_xo(scale=0.8, colors=colors)))
def _setup_toolbars(self, have_toolbox): """ Setup the toolbars. """ self.max_participants = MAX_HANDS if have_toolbox: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() self.toolbar = toolbox.toolbar else: # Use pre-0.86 toolbar design games_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Game'), games_toolbar) toolbox.show() toolbox.set_current_toolbar(1) self.toolbar = games_toolbar self._new_game_button = _button_factory( 'new-game', _('Start a new game.'), self._new_game_cb, self.toolbar) self.robot_button = _button_factory( 'robot-off', _('Play with the robot.'), self._robot_cb, self.toolbar) self.player = _image_factory( svg_str_to_pixbuf(generate_xo(scale=0.8, colors=['#303030', '#303030'])), self.toolbar, tooltip=self.nick) self.dialog_button = _button_factory('go-next', _('Turn complete'), self._dialog_cb, self.toolbar) self.status = _label_factory('', self.toolbar) self.hint_button = _button_factory('help-toolbar', _('Help'), self._hint_cb, self.toolbar) self.score = _label_factory(_('Score: ') + '0', self.toolbar) if _have_toolbox: _separator_factory(toolbox.toolbar, False, True) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
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()
def _setup_presence_service(self): """ Setup the Presence Service. """ self.pservice = presenceservice.get_instance() self.initiating = None # sharing (True) or joining (False) owner = self.pservice.get_owner() self.owner = owner self._game.buddies.append(self.nick) self._player_colors = [self.colors] self._player_pixbuf = [svg_str_to_pixbuf( generate_xo(scale=0.8, colors=self.colors))] self._share = "" self.connect('shared', self._shared_cb) self.connect('joined', self._joined_cb)