Mercurial > libervia-backend
comparison frontends/wix/chat.py @ 190:31632472e857
quick_frontend, wix, primitivus: informations in chat window
- user joined/left information
- messages starting with /me are managed
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Aug 2010 21:42:30 +0800 |
parents | 9ee4a1d0d7fb |
children |
comparison
equal
deleted
inserted
replaced
189:757518d05833 | 190:31632472e857 |
---|---|
196 event.GetString(), | 196 event.GetString(), |
197 type = "groupchat" if self.type=='group' else "chat", | 197 type = "groupchat" if self.type=='group' else "chat", |
198 profile_key=self.host.profile) | 198 profile_key=self.host.profile) |
199 self.textBox.Clear() | 199 self.textBox.Clear() |
200 | 200 |
201 | 201 def __blink(self): |
202 """Do wizzz and buzzz to show window to user or | |
203 at least inform him of something new""" | |
204 #TODO: use notification system | |
205 if not self.IsActive(): | |
206 self.RequestUserAttention() | |
207 if not self.IsShown(): | |
208 self.Show() | |
202 | 209 |
203 def printMessage(self, from_jid, msg, profile, timestamp=""): | 210 def printMessage(self, from_jid, msg, profile, timestamp=""): |
204 """Print the message with differents colors depending on where it comes from.""" | 211 """Print the message with differents colors depending on where it comes from.""" |
205 jid=JID(from_jid) | 212 try: |
213 jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp) | |
214 except TypeError: | |
215 return | |
206 print "printMessage, jid=",jid,"type=",self.type | 216 print "printMessage, jid=",jid,"type=",self.type |
207 nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node) | |
208 mymess = (jid.resource == self.nick) if self.type == "group" else (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user | |
209 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) | 217 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
210 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) | 218 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) |
211 _font_italic = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) | 219 _font_italic = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) |
212 self.chatWindow.SetDefaultStyle(wx.TextAttr("GREY", font=_font_normal)) | 220 self.chatWindow.SetDefaultStyle(wx.TextAttr("GREY", font=_font_normal)) |
213 msg_time = time.localtime(timestamp or None) | 221 msg_time = time.localtime(timestamp or None) |
216 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font_bold)) | 224 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font_bold)) |
217 self.chatWindow.AppendText("[%s] " % nick) | 225 self.chatWindow.AppendText("[%s] " % nick) |
218 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) | 226 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) |
219 self.chatWindow.AppendText("%s\n" % msg) | 227 self.chatWindow.AppendText("%s\n" % msg) |
220 if not mymess: | 228 if not mymess: |
221 #TODO: use notification system | 229 self.__blink() |
222 if not self.IsActive(): | 230 |
223 self.RequestUserAttention() | 231 def printInfo(self, msg, type='normal'): |
224 if not self.IsShown(): | 232 """Print general info |
225 self.Show() | 233 @param msg: message to print |
234 @type: one of: | |
235 normal: general info like "toto has joined the room" | |
236 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" | |
237 """ | |
238 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) | |
239 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) | |
240 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type == 'normal' else _font_normal)) | |
241 self.chatWindow.AppendText("%s\n" % msg) | |
242 if type=="me": | |
243 self.__blink() | |
226 | 244 |
227 ### events ### | 245 ### events ### |
228 | 246 |
229 def onSendFile(self, e): | 247 def onSendFile(self, e): |
230 debug(_("Send File")) | 248 debug(_("Send File")) |