Mercurial > libervia-backend
comparison frontends/wix/chat.py @ 79:db0a0f000e37
Chat presentation enhancement
- core: message signal is not sent anymore for groupchat type, cause MUC chat server do it for us
- wix: user nick can now be specified to chat windows, usefull for colorization
- memory: full jid are now sent
- wix: message from user are now in black for group chat
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 31 Mar 2010 19:56:43 +1100 |
parents | ace2af8abc5a |
children | 9681f18d06bd |
comparison
equal
deleted
inserted
replaced
78:ace2af8abc5a | 79:db0a0f000e37 |
---|---|
50 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND) | 50 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND) |
51 self.conv_panel.sizer.Add(self.textBox, flag=wx.EXPAND) | 51 self.conv_panel.sizer.Add(self.textBox, flag=wx.EXPAND) |
52 self.conv_panel.SetSizer(self.conv_panel.sizer) | 52 self.conv_panel.SetSizer(self.conv_panel.sizer) |
53 self.splitter.Initialize(self.conv_panel) | 53 self.splitter.Initialize(self.conv_panel) |
54 self.SetMenuBar(wx.MenuBar()) | 54 self.SetMenuBar(wx.MenuBar()) |
55 self.setType(self.type) | |
56 | 55 |
57 #events | 56 #events |
58 self.Bind(wx.EVT_CLOSE, self.onClose, self) | 57 self.Bind(wx.EVT_CLOSE, self.onClose, self) |
59 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox) | 58 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox) |
60 | 59 |
61 #fonts | 60 #fonts |
62 self.font={} | 61 self.font={} |
63 self.font["points"] = self.chatWindow.GetFont().GetPointSize() | 62 self.font["points"] = self.chatWindow.GetFont().GetPointSize() |
64 self.font["family"] = self.chatWindow.GetFont().GetFamily() | 63 self.font["family"] = self.chatWindow.GetFont().GetFamily() |
65 | 64 |
66 self.historyPrint(profile=self.host.profile) | 65 self.setType(self.type) |
67 | 66 |
68 #misc | 67 #misc |
69 self.textBox.SetFocus() | 68 self.textBox.SetFocus() |
70 self.Hide() #We hide because of the show toggle | 69 self.Hide() #We hide because of the show toggle |
71 | 70 |
72 def __createPresents(self): | 71 def __createPresents(self): |
84 QuickChat.setType(self, type) | 83 QuickChat.setType(self, type) |
85 if type is 'group' and not self.splitter.IsSplit(): | 84 if type is 'group' and not self.splitter.IsSplit(): |
86 self.__createPresents() | 85 self.__createPresents() |
87 self.subjectBox.Show() | 86 self.subjectBox.Show() |
88 self.__eraseMenus() | 87 self.__eraseMenus() |
89 | 88 self.historyPrint(profile=self.host.profile) |
90 elif type is 'one2one' and self.splitter.IsSplit(): | 89 elif type is 'one2one' and self.splitter.IsSplit(): |
91 self.splitter.Unsplit(self.present_panel) | 90 self.splitter.Unsplit(self.present_panel) |
92 del self.present_panel | 91 del self.present_panel |
93 self.GetMenuBar().Show() | 92 self.GetMenuBar().Show() |
94 self.subjectBox.Hide() | 93 self.subjectBox.Hide() |
95 self.__createMenus_O2O() | 94 self.__createMenus_O2O() |
95 self.nick = None | |
96 else: | 96 else: |
97 self.subjectBox.Hide() | 97 self.subjectBox.Hide() |
98 self.__createMenus_O2O() | 98 self.__createMenus_O2O() |
99 | 99 self.historyPrint(profile=self.host.profile) |
100 | |
100 def setPresents(self, nicks): | 101 def setPresents(self, nicks): |
101 """Set the users presents in the contact list for a group chat | 102 """Set the users presents in the contact list for a group chat |
102 @param nicks: list of nicknames | 103 @param nicks: list of nicknames |
103 """ | 104 """ |
104 debug (_("Adding users %s to room") % nicks) | 105 debug (_("Adding users %s to room") % nicks) |
174 | 175 |
175 | 176 |
176 def printMessage(self, from_jid, msg, profile, timestamp=""): | 177 def printMessage(self, from_jid, msg, profile, timestamp=""): |
177 """Print the message with differents colors depending on where it comes from.""" | 178 """Print the message with differents colors depending on where it comes from.""" |
178 jid=JID(from_jid) | 179 jid=JID(from_jid) |
180 print "printMessage, jid=",jid,"type=",self.type | |
179 nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid) | 181 nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid) |
180 mymess = (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user | 182 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 |
181 _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) | 183 _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
182 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font)) | 184 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font)) |
183 self.chatWindow.AppendText("[%s] " % nick) | 185 self.chatWindow.AppendText("[%s] " % nick) |
184 _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) | 186 _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) |
185 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font)) | 187 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font)) |