Mercurial > libervia-backend
comparison frontends/wix/chat.py @ 77:1ae680f9682e
wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 Mar 2010 16:08:44 +1100 |
parents | 8becde8a967c |
children | ace2af8abc5a |
comparison
equal
deleted
inserted
replaced
76:8becde8a967c | 77:1ae680f9682e |
---|---|
151 ## TODO: check this and repport bug to wxpython devs | 151 ## TODO: check this and repport bug to wxpython devs |
152 self.Hide() | 152 self.Hide() |
153 | 153 |
154 def onEnterPressed(self, event): | 154 def onEnterPressed(self, event): |
155 """Behaviour when enter pressed in send line.""" | 155 """Behaviour when enter pressed in send line.""" |
156 self.host.bridge.sendMessage(self.target, event.GetString(), profile_key=self.host.profile) | 156 self.host.bridge.sendMessage(self.target.short if self.type=='group' else self.target, |
157 event.GetString(), | |
158 type = "groupchat" if self.type=='group' else "chat", | |
159 profile_key=self.host.profile) | |
157 self.textBox.Clear() | 160 self.textBox.Clear() |
158 | 161 |
159 | 162 |
160 | 163 |
161 def printMessage(self, from_jid, msg, profile, timestamp=""): | 164 def printMessage(self, from_jid, msg, profile, timestamp=""): |
162 """Print the message with differents colors depending on where it comes from.""" | 165 """Print the message with differents colors depending on where it comes from.""" |
163 jid=JID(from_jid) | 166 jid=JID(from_jid) |
167 nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid) | |
164 mymess = (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user | 168 mymess = (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user |
165 _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) | 169 _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
166 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font)) | 170 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font)) |
167 self.chatWindow.AppendText("[%s] " % jid) | 171 self.chatWindow.AppendText("[%s] " % nick) |
168 _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) | 172 _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) |
169 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font)) | 173 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font)) |
170 self.chatWindow.AppendText("%s\n" % msg) | 174 self.chatWindow.AppendText("%s\n" % msg) |
171 if not mymess: | 175 if not mymess: |
172 self.Raise() #FIXME: too intrusive | 176 self.Raise() #FIXME: too intrusive |