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