Mercurial > libervia-backend
diff frontends/wix/chat.py @ 122:29998cd0ed8d
wix: time is now printed in chat window
- replaceUser is fixed
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 08 Jul 2010 18:26:30 +0800 |
parents | 1ca5f254ce41 |
children | 34766e0cf970 |
line wrap: on
line diff
--- a/frontends/wix/chat.py Thu Jul 08 14:19:30 2010 +0800 +++ b/frontends/wix/chat.py Thu Jul 08 18:26:30 2010 +0800 @@ -23,6 +23,7 @@ import wx import os.path +import time import pdb from logging import debug, info, error, warning from tools.jid import JID @@ -68,9 +69,10 @@ self.font["points"] = self.chatWindow.GetFont().GetPointSize() self.font["family"] = self.chatWindow.GetFont().GetFamily() - self.setType(self.type) #misc + self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time + self.setType(self.type) self.textBox.SetFocus() self.Hide() #We hide because of the show toggle @@ -92,7 +94,6 @@ self.subjectBox.Show() self.__eraseMenus() self.__createMenus_group() - self.historyPrint(profile=self.host.profile) self.sizer.Layout() elif type is 'one2one' and self.splitter.IsSplit(): self.splitter.Unsplit(self.present_panel) @@ -133,7 +134,6 @@ self.present_panel.presents.replace(nick) self.occupants.add(nick) - def replaceUser(self, nick): """Add user if it is not in the group list""" debug (_("Replacing user %s") % nick) @@ -141,6 +141,8 @@ error (_("[INTERNAL] trying to replace user for a non group chat window")) return QuickChat.replaceUser(self, nick) + self.present_panel.presents.replace(nick) + self.occupants.add(nick) def removeUser(self, nick): """Remove a user from the group list""" @@ -210,11 +212,16 @@ 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 = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) - self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font)) + _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) + self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_normal)) + msg_time = time.localtime(timestamp or None) + time_format = "%c" if msg_time < self.day_change else "%H:%M" #if the message was sent before today, we print the full date + self.chatWindow.AppendText("[%s]" % time.strftime(time_format, msg_time )) + self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font_bold)) self.chatWindow.AppendText("[%s] " % nick) - _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) - self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font)) + self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) self.chatWindow.AppendText("%s\n" % msg) if not mymess: #TODO: use notification system