def onSelectionChanged(self, selection): model, treeiter = selection.get_selected() a_row_is_selected = False if treeiter is not None: a_row_is_selected = True game = model.get_value(treeiter, 0) if (isinstance(game, FICSAdjournedGame) and self.connection.stored_owner == self.connection.username): make_sensitive_if_available(self.widgets["resumeButton"], game.opponent) for button in ("resignButton", "abortButton", "drawButton"): self.widgets[button].set_sensitive(True) else: for button in ( "resignButton", "abortButton", "drawButton", "resumeButton", ): self.widgets[button].set_sensitive(False) else: self.widgets["resumeButton"].set_sensitive(False) self.widgets["resumeButton"].set_tooltip_text("") for button in ("resignButton", "abortButton", "drawButton"): self.widgets[button].set_sensitive(False) self.widgets["previewButton"].set_sensitive(a_row_is_selected) self.widgets["examineButton"].set_sensitive(a_row_is_selected)
def status_changed(self, player, prop, game): log.debug("AdjournedTabSection.status_changed: %s %s" % (repr(player), repr(game))) try: message = self.messages[player] except KeyError: pass else: make_sensitive_if_available(message.buttons[0], player) self.onSelectionChanged(self.selection) return False
def status_changed(self, player, prop, game): log.debug("AdjournedTabSection.status_changed: %s %s" % (repr(player), repr(game))) try: message = self.messages[player] except KeyError: pass else: make_sensitive_if_available(message.buttons[0], player) self.onSelectionChanged(self.selection) return False
def _infobar_adjourned_message(self, game, player): if player not in self.messages: text = _(" with whom you have an adjourned <b>%(timecontrol)s</b> " + "<b>%(gametype)s</b> game is online.") % { "timecontrol": game.display_timecontrol, "gametype": game.game_type.display_text, } content = get_infobarmessage_content(player, text, gametype=game.game_type) def callback(infobar, response, message): log.debug( "%s" % player, extra={ "task": ( self.connection.username, "_infobar_adjourned_message.callback", ) }, ) if response == Gtk.ResponseType.ACCEPT: self.connection.client.run_command("match %s" % player.name) elif response == Gtk.ResponseType.HELP: self.connection.adm.queryMoves(game) else: try: self.messages[player].dismiss() del self.messages[player] except KeyError: pass return False message = InfoBarMessage(Gtk.MessageType.QUESTION, content, callback) message.add_button( InfoBarMessageButton(_("Request Continuation"), Gtk.ResponseType.ACCEPT)) message.add_button( InfoBarMessageButton(_("Examine Adjourned Game"), Gtk.ResponseType.HELP)) message.add_button( InfoBarMessageButton(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL)) make_sensitive_if_available(message.buttons[0], player) self.messages[player] = message self.infobar.push_message(message)
def _infobar_adjourned_message(self, game, player): if player not in self.messages: text = _(" with whom you have an adjourned <b>%(timecontrol)s</b> " + "<b>%(gametype)s</b> game is online.") % \ {"timecontrol": game.display_timecontrol, "gametype": game.game_type.display_text} content = get_infobarmessage_content(player, text, gametype=game.game_type) def callback(infobar, response, message): log.debug( "%s" % player, extra={"task": (self.connection.username, "_infobar_adjourned_message.callback")}) if response == Gtk.ResponseType.ACCEPT: self.connection.client.run_command("match %s" % player.name) elif response == Gtk.ResponseType.HELP: self.connection.adm.queryMoves(game) else: try: self.messages[player].dismiss() del self.messages[player] except KeyError: pass return False message = InfoBarMessage(Gtk.MessageType.QUESTION, content, callback) message.add_button(InfoBarMessageButton( _("Request Continuation"), Gtk.ResponseType.ACCEPT)) message.add_button(InfoBarMessageButton( _("Examine Adjourned Game"), Gtk.ResponseType.HELP)) message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL)) make_sensitive_if_available(message.buttons[0], player) self.messages[player] = message self.infobar.push_message(message)
def onSelectionChanged(self, selection): model, treeiter = selection.get_selected() a_row_is_selected = False if treeiter is not None: a_row_is_selected = True game = model.get_value(treeiter, 0) if isinstance(game, FICSAdjournedGame) and \ self.connection.stored_owner == self.connection.username: make_sensitive_if_available(self.widgets["resumeButton"], game.opponent) for button in ("resignButton", "abortButton", "drawButton"): self.widgets[button].set_sensitive(True) else: for button in ("resignButton", "abortButton", "drawButton", "resumeButton"): self.widgets[button].set_sensitive(False) else: self.widgets["resumeButton"].set_sensitive(False) self.widgets["resumeButton"].set_tooltip_text("") for button in ("resignButton", "abortButton", "drawButton"): self.widgets[button].set_sensitive(False) self.widgets["previewButton"].set_sensitive(a_row_is_selected) self.widgets["examineButton"].set_sensitive(a_row_is_selected)
def status_changed(player, prop, message): make_sensitive_if_available(message.buttons[0], player) make_sensitive_if_playing(message.buttons[1], player)
def status_changed (player, prop, message): make_sensitive_if_available(message.buttons[0], player) make_sensitive_if_playing(message.buttons[1], player)