Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/frontends/wix/chat.py Wed Aug 18 20:50:45 2010 +0800 +++ b/frontends/wix/chat.py Wed Aug 18 21:42:30 2010 +0800 @@ -198,14 +198,22 @@ profile_key=self.host.profile) self.textBox.Clear() - + def __blink(self): + """Do wizzz and buzzz to show window to user or + at least inform him of something new""" + #TODO: use notification system + if not self.IsActive(): + self.RequestUserAttention() + if not self.IsShown(): + self.Show() def printMessage(self, from_jid, msg, profile, timestamp=""): """Print the message with differents colors depending on where it comes from.""" - jid=JID(from_jid) + try: + jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp) + except TypeError: + return print "printMessage, jid=",jid,"type=",self.type - nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node) - 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 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) _font_italic = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) @@ -218,11 +226,21 @@ self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) self.chatWindow.AppendText("%s\n" % msg) if not mymess: - #TODO: use notification system - if not self.IsActive(): - self.RequestUserAttention() - if not self.IsShown(): - self.Show() + self.__blink() + + def printInfo(self, msg, type='normal'): + """Print general info + @param msg: message to print + @type: one of: + normal: general info like "toto has joined the room" + me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" + """ + _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) + _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) + self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type == 'normal' else _font_normal)) + self.chatWindow.AppendText("%s\n" % msg) + if type=="me": + self.__blink() ### events ###