Mercurial > libervia-backend
annotate frontends/src/wix/chat.py @ 640:8211b462af6b
Added Soul to contributors
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 08 Sep 2013 19:18:46 +0200 |
parents | 6821fc06a324 |
children | f7878ad3c846 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # wix: a SAT frontend |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
20 | |
21 | |
22 import wx | |
23 import os.path | |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
24 import time |
0 | 25 import pdb |
85 | 26 from logging import debug, info, error, warning |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
27 from sat.tools.jid import JID |
227 | 28 from sat_frontends.quick_frontend.quick_chat import QuickChat |
29 from sat_frontends.wix.contact_list import ContactList | |
30 from sat_frontends.wix.card_game import CardPanel | |
361 | 31 from sat_frontends.wix.quiz_game import QuizPanel |
0 | 32 |
33 | |
34 idSEND = 1 | |
85 | 35 idTAROT = 2 |
0 | 36 |
37 class Chat(wx.Frame, QuickChat): | |
38 """The chat Window for one to one conversations""" | |
39 | |
72 | 40 def __init__(self, target, host, type='one2one'): |
41 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200)) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
42 QuickChat.__init__(self, target, host, type) |
0 | 43 |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
44 self.sizer = wx.BoxSizer(wx.VERTICAL) |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
45 self.SetSizer(self.sizer) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
46 |
72 | 47 self.splitter = wx.SplitterWindow(self, -1) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
48 self.sizer.Add(self.splitter, 1, flag = wx.EXPAND) |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
49 |
72 | 50 self.conv_panel = wx.Panel(self.splitter) |
51 self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL) | |
76 | 52 self.subjectBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_READONLY) |
72 | 53 self.chatWindow = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_MULTILINE | wx.TE_RICH | wx.TE_READONLY) |
54 self.textBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_PROCESS_ENTER) | |
76 | 55 self.conv_panel.sizer.Add(self.subjectBox, flag=wx.EXPAND) |
72 | 56 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
57 self.conv_panel.sizer.Add(self.textBox, 0, flag=wx.EXPAND) |
72 | 58 self.conv_panel.SetSizer(self.conv_panel.sizer) |
59 self.splitter.Initialize(self.conv_panel) | |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
60 self.SetMenuBar(wx.MenuBar()) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
61 |
0 | 62 #events |
63 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
64 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox) | |
65 | |
66 #fonts | |
67 self.font={} | |
68 self.font["points"] = self.chatWindow.GetFont().GetPointSize() | |
69 self.font["family"] = self.chatWindow.GetFont().GetFamily() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
70 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
71 |
0 | 72 #misc |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
73 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
74 self.setType(self.type) |
0 | 75 self.textBox.SetFocus() |
76 self.Hide() #We hide because of the show toggle | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
77 |
72 | 78 def __createPresents(self): |
79 """Create a list of present people in a group chat""" | |
80 self.present_panel = wx.Panel(self.splitter) | |
81 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL) | |
82 self.present_panel.presents = ContactList(self.present_panel, self.host, type='nicks') | |
83 self.present_panel.presents.SetMinSize(wx.Size(80,20)) | |
84 self.present_panel.sizer.Add(self.present_panel.presents, 1, wx.EXPAND) | |
85 self.present_panel.SetSizer(self.present_panel.sizer) | |
86 self.splitter.SplitVertically(self.present_panel, self.conv_panel, 80) | |
87 | |
88 def setType(self, type): | |
89 QuickChat.setType(self, type) | |
90 if type is 'group' and not self.splitter.IsSplit(): | |
91 self.__createPresents() | |
76 | 92 self.subjectBox.Show() |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
93 self.__eraseMenus() |
85 | 94 self.__createMenus_group() |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
95 self.sizer.Layout() |
72 | 96 elif type is 'one2one' and self.splitter.IsSplit(): |
97 self.splitter.Unsplit(self.present_panel) | |
98 del self.present_panel | |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
99 self.GetMenuBar().Show() |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
100 self.subjectBox.Hide() |
85 | 101 self.__eraseMenus() |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
102 self.__createMenus_O2O() |
79 | 103 self.nick = None |
76 | 104 else: |
105 self.subjectBox.Hide() | |
85 | 106 self.__eraseMenus() |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
107 self.__createMenus_O2O() |
79 | 108 self.historyPrint(profile=self.host.profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
109 |
90 | 110 def startGame(self, game_type, referee, players): |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
111 """Configure the chat window to start a game""" |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
112 if game_type=="Tarot": |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
113 debug (_("configure chat window for Tarot game")) |
90 | 114 self.tarot_panel = CardPanel(self, referee, players, self.nick) |
87 | 115 self.sizer.Prepend(self.tarot_panel, 0, flag=wx.EXPAND) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
116 self.sizer.Layout() |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
117 self.Fit() |
321
1a990a88bff2
wix: force updating of splitterWindow in ChatWindow (needed when Tarot game is launched)
Goffi <goffi@goffi.org>
parents:
276
diff
changeset
|
118 self.splitter.UpdateSize() |
361 | 119 elif game_type=="Quiz": |
120 debug (_("configure chat window for Quiz game")) | |
121 self.quiz_panel = QuizPanel(self, referee, players, self.nick) | |
122 self.sizer.Prepend(self.quiz_panel, 0, flag=wx.EXPAND) | |
123 self.sizer.Layout() | |
124 self.Fit() | |
125 self.splitter.UpdateSize() | |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
126 |
87 | 127 def getGame(self, game_type): |
128 """Return class managing the game type""" | |
129 #TODO: check that the game is launched, and manage errors | |
130 if game_type=="Tarot": | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
131 return self.tarot_panel |
361 | 132 elif game_type=="Quiz": |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
133 return self.quiz_panel |
85 | 134 |
72 | 135 def setPresents(self, nicks): |
136 """Set the users presents in the contact list for a group chat | |
137 @param nicks: list of nicknames | |
138 """ | |
120 | 139 QuickChat.setPresents(self, nicks) |
72 | 140 for nick in nicks: |
85 | 141 self.present_panel.presents.replace(nick) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
142 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
143 def replaceUser(self, nick, show_info=True): |
75 | 144 """Add user if it is not in the group list""" |
145 debug (_("Replacing user %s") % nick) | |
146 if self.type != "group": | |
147 error (_("[INTERNAL] trying to replace user for a non group chat window")) | |
148 return | |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
149 QuickChat.replaceUser(self, nick, show_info) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
150 self.present_panel.presents.replace(nick) |
120 | 151 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
152 def removeUser(self, nick, show_info=True): |
75 | 153 """Remove a user from the group list""" |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
154 QuickChat.removeUser(self, nick, show_info) |
75 | 155 self.present_panel.presents.remove(nick) |
156 | |
76 | 157 def setSubject(self, subject): |
158 """Set title for a group chat""" | |
120 | 159 QuickChat.setSubject(self, subject) |
76 | 160 self.subjectBox.SetValue(subject) |
75 | 161 |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
162 def __eraseMenus(self): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
163 """erase all menus""" |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
164 menuBar = self.GetMenuBar() |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
165 for i in range(menuBar.GetMenuCount()): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
166 menuBar.Remove(i) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
167 |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
168 def __createMenus_O2O(self): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
169 """create menu bar for one 2 one chat""" |
0 | 170 info("Creating menus") |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
171 self.__eraseMenus() |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
172 menuBar = self.GetMenuBar() |
0 | 173 actionMenu = wx.Menu() |
70 | 174 actionMenu.Append(idSEND, _("&SendFile CTRL-s"),_(" Send a file to contact")) |
175 menuBar.Append(actionMenu,_("&Action")) | |
0 | 176 |
177 #events | |
178 wx.EVT_MENU(self, idSEND, self.onSendFile) | |
179 | |
85 | 180 def __createMenus_group(self): |
181 """create menu bar for group chat""" | |
182 info("Creating menus") | |
183 self.__eraseMenus() | |
184 menuBar = self.GetMenuBar() | |
185 actionMenu = wx.Menu() | |
186 actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp | |
187 menuBar.Append(actionMenu,_("&Games")) | |
188 | |
189 #events | |
190 wx.EVT_MENU(self, idTAROT, self.onStartTarot) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
191 |
0 | 192 def __del__(self): |
193 wx.Frame.__del__(self) | |
194 | |
195 def onClose(self, event): | |
196 """Close event: we only hide the frame.""" | |
197 event.Veto() | |
198 self.Hide() | |
199 | |
200 def onEnterPressed(self, event): | |
201 """Behaviour when enter pressed in send line.""" | |
638
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
202 self.host.sendMessage(self.target.short if self.type == 'group' else self.target, |
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
203 event.GetString(), |
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
204 mess_type="groupchat" if self.type == 'group' else "chat", |
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
205 profile_key=self.host.profile) |
0 | 206 self.textBox.Clear() |
207 | |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
208 def __blink(self): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
209 """Do wizzz and buzzz to show window to user or |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
210 at least inform him of something new""" |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
211 #TODO: use notification system |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
212 if not self.IsActive(): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
213 self.RequestUserAttention() |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
214 if not self.IsShown(): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
215 self.Show() |
0 | 216 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
217 def printMessage(self, from_jid, msg, profile, timestamp=""): |
0 | 218 """Print the message with differents colors depending on where it comes from.""" |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
219 try: |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
220 jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
221 except TypeError: |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
222 return |
79 | 223 print "printMessage, jid=",jid,"type=",self.type |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
224 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
225 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
226 _font_italic = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) |
123
34766e0cf970
wix: chat: date is now printed in grey
Goffi <goffi@goffi.org>
parents:
122
diff
changeset
|
227 self.chatWindow.SetDefaultStyle(wx.TextAttr("GREY", font=_font_normal)) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
228 msg_time = time.localtime(timestamp or None) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
229 time_format = "%c" if msg_time < self.day_change else "%H:%M" #if the message was sent before today, we print the full date |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
230 self.chatWindow.AppendText("[%s]" % time.strftime(time_format, msg_time )) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
231 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font_bold)) |
77
1ae680f9682e
wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
Goffi <goffi@goffi.org>
parents:
76
diff
changeset
|
232 self.chatWindow.AppendText("[%s] " % nick) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
233 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) |
0 | 234 self.chatWindow.AppendText("%s\n" % msg) |
235 if not mymess: | |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
236 self.__blink() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
237 |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
238 def printInfo(self, msg, type='normal'): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
239 """Print general info |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
240 @param msg: message to print |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
241 @type: one of: |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
242 normal: general info like "toto has joined the room" |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
243 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
244 """ |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
245 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
246 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
247 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type == 'normal' else _font_normal)) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
248 self.chatWindow.AppendText("%s\n" % msg) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
249 if type=="me": |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
250 self.__blink() |
0 | 251 |
252 ### events ### | |
253 | |
254 def onSendFile(self, e): | |
70 | 255 debug(_("Send File")) |
256 filename = wx.FileSelector(_("Choose a file to send"), flags = wx.FD_FILE_MUST_EXIST) | |
0 | 257 if filename: |
70 | 258 debug(_("filename: %s"),filename) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
259 #FIXME: check last_resource: what if self.target.resource exists ? |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
260 last_resource = self.host.bridge.getLastResource(unicode(self.target.short), self.host.profile) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
261 if last_resource: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
262 full_jid = JID("%s/%s" % (self.target.short, last_resource)) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
263 else: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
264 full_jid = self.target |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
265 id = self.host.bridge.sendFile(full_jid, filename, {}, self.host.profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
266 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), self.host.profile) |
0 | 267 |
85 | 268 def onStartTarot(self, e): |
269 debug (_("Starting Tarot game")) | |
270 warning (_("FIXME: temporary menu, must be changed")) | |
87 | 271 if len(self.occupants) != 4: |
272 err_dlg = wx.MessageDialog(self, _("You need to be exactly 4 peoples in the room to start a Tarot game"), _("Can't start game"), style = wx.OK | wx.ICON_ERROR) #FIXME: gof: temporary only, need to choose the people with who the game has to be started | |
273 err_dlg.ShowModal() | |
274 else: | |
90 | 275 self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile) |