comparison frontends/src/wix/chat.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children 84a6e83157c2
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
39 class Chat(wx.Frame, QuickChat): 39 class Chat(wx.Frame, QuickChat):
40 """The chat Window for one to one conversations""" 40 """The chat Window for one to one conversations"""
41 41
42 def __init__(self, target, host, type='one2one'): 42 def __init__(self, target, host, type='one2one'):
43 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200)) 43 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200))
44 QuickChat.__init__(self, target, host, type) 44 QuickChat.__init__(self, target, host, type)
45 45
46 self.sizer = wx.BoxSizer(wx.VERTICAL) 46 self.sizer = wx.BoxSizer(wx.VERTICAL)
47 self.SetSizer(self.sizer) 47 self.SetSizer(self.sizer)
48 48
49 self.splitter = wx.SplitterWindow(self, -1) 49 self.splitter = wx.SplitterWindow(self, -1)
50 self.sizer.Add(self.splitter, 1, flag = wx.EXPAND) 50 self.sizer.Add(self.splitter, 1, flag = wx.EXPAND)
51 51
52 self.conv_panel = wx.Panel(self.splitter) 52 self.conv_panel = wx.Panel(self.splitter)
53 self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL) 53 self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL)
58 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND) 58 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND)
59 self.conv_panel.sizer.Add(self.textBox, 0, flag=wx.EXPAND) 59 self.conv_panel.sizer.Add(self.textBox, 0, flag=wx.EXPAND)
60 self.conv_panel.SetSizer(self.conv_panel.sizer) 60 self.conv_panel.SetSizer(self.conv_panel.sizer)
61 self.splitter.Initialize(self.conv_panel) 61 self.splitter.Initialize(self.conv_panel)
62 self.SetMenuBar(wx.MenuBar()) 62 self.SetMenuBar(wx.MenuBar())
63 63
64 #events 64 #events
65 self.Bind(wx.EVT_CLOSE, self.onClose, self) 65 self.Bind(wx.EVT_CLOSE, self.onClose, self)
66 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox) 66 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox)
67 67
68 #fonts 68 #fonts
69 self.font={} 69 self.font={}
70 self.font["points"] = self.chatWindow.GetFont().GetPointSize() 70 self.font["points"] = self.chatWindow.GetFont().GetPointSize()
71 self.font["family"] = self.chatWindow.GetFont().GetFamily() 71 self.font["family"] = self.chatWindow.GetFont().GetFamily()
72 72
73 73
74 #misc 74 #misc
75 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time 75 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time
76 self.setType(self.type) 76 self.setType(self.type)
77 self.textBox.SetFocus() 77 self.textBox.SetFocus()
78 self.Hide() #We hide because of the show toggle 78 self.Hide() #We hide because of the show toggle
79 79
80 def __createPresents(self): 80 def __createPresents(self):
81 """Create a list of present people in a group chat""" 81 """Create a list of present people in a group chat"""
82 self.present_panel = wx.Panel(self.splitter) 82 self.present_panel = wx.Panel(self.splitter)
83 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL) 83 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL)
84 self.present_panel.presents = ContactList(self.present_panel, self.host, type='nicks') 84 self.present_panel.presents = ContactList(self.present_panel, self.host, type='nicks')
106 else: 106 else:
107 self.subjectBox.Hide() 107 self.subjectBox.Hide()
108 self.__eraseMenus() 108 self.__eraseMenus()
109 self.__createMenus_O2O() 109 self.__createMenus_O2O()
110 self.historyPrint(profile=self.host.profile) 110 self.historyPrint(profile=self.host.profile)
111 111
112 def startGame(self, game_type, referee, players): 112 def startGame(self, game_type, referee, players):
113 """Configure the chat window to start a game""" 113 """Configure the chat window to start a game"""
114 if game_type=="Tarot": 114 if game_type=="Tarot":
115 debug (_("configure chat window for Tarot game")) 115 debug (_("configure chat window for Tarot game"))
116 self.tarot_panel = CardPanel(self, referee, players, self.nick) 116 self.tarot_panel = CardPanel(self, referee, players, self.nick)
128 128
129 def getGame(self, game_type): 129 def getGame(self, game_type):
130 """Return class managing the game type""" 130 """Return class managing the game type"""
131 #TODO: check that the game is launched, and manage errors 131 #TODO: check that the game is launched, and manage errors
132 if game_type=="Tarot": 132 if game_type=="Tarot":
133 return self.tarot_panel 133 return self.tarot_panel
134 elif game_type=="Quiz": 134 elif game_type=="Quiz":
135 return self.quiz_panel 135 return self.quiz_panel
136 136
137 def setPresents(self, nicks): 137 def setPresents(self, nicks):
138 """Set the users presents in the contact list for a group chat 138 """Set the users presents in the contact list for a group chat
139 @param nicks: list of nicknames 139 @param nicks: list of nicknames
140 """ 140 """
141 QuickChat.setPresents(self, nicks) 141 QuickChat.setPresents(self, nicks)
142 for nick in nicks: 142 for nick in nicks:
143 self.present_panel.presents.replace(nick) 143 self.present_panel.presents.replace(nick)
144 144
145 def replaceUser(self, nick, show_info=True): 145 def replaceUser(self, nick, show_info=True):
146 """Add user if it is not in the group list""" 146 """Add user if it is not in the group list"""
147 debug (_("Replacing user %s") % nick) 147 debug (_("Replacing user %s") % nick)
148 if self.type != "group": 148 if self.type != "group":
149 error (_("[INTERNAL] trying to replace user for a non group chat window")) 149 error (_("[INTERNAL] trying to replace user for a non group chat window"))
164 def __eraseMenus(self): 164 def __eraseMenus(self):
165 """erase all menus""" 165 """erase all menus"""
166 menuBar = self.GetMenuBar() 166 menuBar = self.GetMenuBar()
167 for i in range(menuBar.GetMenuCount()): 167 for i in range(menuBar.GetMenuCount()):
168 menuBar.Remove(i) 168 menuBar.Remove(i)
169 169
170 def __createMenus_O2O(self): 170 def __createMenus_O2O(self):
171 """create menu bar for one 2 one chat""" 171 """create menu bar for one 2 one chat"""
172 info("Creating menus") 172 info("Creating menus")
173 self.__eraseMenus() 173 self.__eraseMenus()
174 menuBar = self.GetMenuBar() 174 menuBar = self.GetMenuBar()
188 actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp 188 actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp
189 menuBar.Append(actionMenu,_("&Games")) 189 menuBar.Append(actionMenu,_("&Games"))
190 190
191 #events 191 #events
192 wx.EVT_MENU(self, idTAROT, self.onStartTarot) 192 wx.EVT_MENU(self, idTAROT, self.onStartTarot)
193 193
194 def __del__(self): 194 def __del__(self):
195 wx.Frame.__del__(self) 195 wx.Frame.__del__(self)
196 196
197 def onClose(self, event): 197 def onClose(self, event):
198 """Close event: we only hide the frame.""" 198 """Close event: we only hide the frame."""
200 self.Hide() 200 self.Hide()
201 201
202 def onEnterPressed(self, event): 202 def onEnterPressed(self, event):
203 """Behaviour when enter pressed in send line.""" 203 """Behaviour when enter pressed in send line."""
204 self.host.sendMessage(self.target.short if self.type=='group' else self.target, 204 self.host.sendMessage(self.target.short if self.type=='group' else self.target,
205 event.GetString(), 205 event.GetString(),
206 mess_type = "groupchat" if self.type=='group' else "chat", 206 mess_type = "groupchat" if self.type=='group' else "chat",
207 profile_key=self.host.profile) 207 profile_key=self.host.profile)
208 self.textBox.Clear() 208 self.textBox.Clear()
209 209
210 def __blink(self): 210 def __blink(self):
234 self.chatWindow.AppendText("[%s] " % nick) 234 self.chatWindow.AppendText("[%s] " % nick)
235 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) 235 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic))
236 self.chatWindow.AppendText("%s\n" % msg) 236 self.chatWindow.AppendText("%s\n" % msg)
237 if not mymess: 237 if not mymess:
238 self.__blink() 238 self.__blink()
239 239
240 def printInfo(self, msg, type='normal'): 240 def printInfo(self, msg, type='normal'):
241 """Print general info 241 """Print general info
242 @param msg: message to print 242 @param msg: message to print
243 @type: one of: 243 @type: one of:
244 normal: general info like "toto has joined the room" 244 normal: general info like "toto has joined the room"
263 if last_resource: 263 if last_resource:
264 full_jid = JID("%s/%s" % (self.target.short, last_resource)) 264 full_jid = JID("%s/%s" % (self.target.short, last_resource))
265 else: 265 else:
266 full_jid = self.target 266 full_jid = self.target
267 id = self.host.bridge.sendFile(full_jid, filename, {}, self.host.profile) 267 id = self.host.bridge.sendFile(full_jid, filename, {}, self.host.profile)
268 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), self.host.profile) 268 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), self.host.profile)
269 269
270 def onStartTarot(self, e): 270 def onStartTarot(self, e):
271 debug (_("Starting Tarot game")) 271 debug (_("Starting Tarot game"))
272 warning (_("FIXME: temporary menu, must be changed")) 272 warning (_("FIXME: temporary menu, must be changed"))
273 if len(self.occupants) != 4: 273 if len(self.occupants) != 4: