/usr/share/pychess/sidepanel/chatPanel.py is in pychess 0.10.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # -*- coding: UTF-8 -*-
import gtk
import pango
import time
from pychess.System import uistuff
from pychess.System import glock
from pychess.System.Log import log
from pychess.System.prefix import addDataPrefix
from pychess.Utils.const import LOCAL, WHITE, BLACK
from pychess.widgets.ChatView import ChatView
__title__ = _("Chat")
__icon__ = addDataPrefix("glade/panel_chat.svg")
__desc__ = _("The chat panel lets you communicate with your opponent during the game, assuming he or she is interested")
class Sidepanel:
def load (self, gmwidg):
self.chatView = ChatView()
self.chatView.disable("Waiting for game to load")
self.chatView.connect("messageTyped", self.onMessageSent)
self.gamemodel = gmwidg.gamemodel
glock.glock_connect(self.gamemodel, "game_started", self.onGameStarted)
return self.chatView
def onGameStarted (self, gamemodel):
if gamemodel.players[0].__type__ == LOCAL:
self.player = gamemodel.players[0]
self.opplayer = gamemodel.players[1]
if gamemodel.players[1].__type__ == LOCAL:
log.warn("Chatpanel loaded with two local players")
elif gamemodel.players[1].__type__ == LOCAL:
self.player = gamemodel.players[1]
self.opplayer = gamemodel.players[0]
else:
log.log("Chatpanel loaded with no local players\n")
self.chatView.hide()
if hasattr(self, "player"):
self.player.connect("messageRecieved", self.onMessageReieved)
self.chatView.enable()
def onMessageReieved (self, player, text):
self.chatView.addMessage(repr(self.opplayer), text)
def onMessageSent (self, chatView, text):
self.player.sendMessage(text)
self.chatView.addMessage(repr(self.player), text)
|