comparison frontends/wix/chat.py @ 85:fc7583282d40

Tarot Game plugin: first draft - SàT: beginning of the plugin - Tarot Plugin: 1 method createTarotGame et 1 signal tarotGameStarted - wix: added "Game" menu in group chat to start Tarot game
author Goffi <goffi@goffi.org>
date Fri, 07 May 2010 17:09:30 +0930
parents 9681f18d06bd
children 4b5f2d55b6ac
comparison
equal deleted inserted replaced
84:7471ffcda33b 85:fc7583282d40
22 22
23 23
24 import wx 24 import wx
25 import os.path 25 import os.path
26 import pdb 26 import pdb
27 from logging import debug, info, error 27 from logging import debug, info, error, warning
28 from tools.jid import JID 28 from tools.jid import JID
29 from quick_frontend.quick_chat import QuickChat 29 from quick_frontend.quick_chat import QuickChat
30 from contact_list import ContactList 30 from contact_list import ContactList
31 31
32 32
33 idSEND = 1 33 idSEND = 1
34 idTAROT = 2
34 35
35 class Chat(wx.Frame, QuickChat): 36 class Chat(wx.Frame, QuickChat):
36 """The chat Window for one to one conversations""" 37 """The chat Window for one to one conversations"""
37 38
38 def __init__(self, target, host, type='one2one'): 39 def __init__(self, target, host, type='one2one'):
83 QuickChat.setType(self, type) 84 QuickChat.setType(self, type)
84 if type is 'group' and not self.splitter.IsSplit(): 85 if type is 'group' and not self.splitter.IsSplit():
85 self.__createPresents() 86 self.__createPresents()
86 self.subjectBox.Show() 87 self.subjectBox.Show()
87 self.__eraseMenus() 88 self.__eraseMenus()
89 self.__createMenus_group()
88 self.historyPrint(profile=self.host.profile) 90 self.historyPrint(profile=self.host.profile)
89 elif type is 'one2one' and self.splitter.IsSplit(): 91 elif type is 'one2one' and self.splitter.IsSplit():
90 self.splitter.Unsplit(self.present_panel) 92 self.splitter.Unsplit(self.present_panel)
91 del self.present_panel 93 del self.present_panel
92 self.GetMenuBar().Show() 94 self.GetMenuBar().Show()
93 self.subjectBox.Hide() 95 self.subjectBox.Hide()
96 self.__eraseMenus()
94 self.__createMenus_O2O() 97 self.__createMenus_O2O()
95 self.nick = None 98 self.nick = None
96 else: 99 else:
97 self.subjectBox.Hide() 100 self.subjectBox.Hide()
101 self.__eraseMenus()
98 self.__createMenus_O2O() 102 self.__createMenus_O2O()
99 self.historyPrint(profile=self.host.profile) 103 self.historyPrint(profile=self.host.profile)
100 104
101 def setPresents(self, nicks): 105 def setPresents(self, nicks):
102 """Set the users presents in the contact list for a group chat 106 """Set the users presents in the contact list for a group chat
103 @param nicks: list of nicknames 107 @param nicks: list of nicknames
104 """ 108 """
105 debug (_("Adding users %s to room") % nicks) 109 debug (_("Adding users %s to room") % nicks)
106 if self.type != "group": 110 if self.type != "group":
107 error (_("[INTERNAL] trying to set presents nicks for a non group chat window")) 111 error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
108 return 112 return
109 for nick in nicks: 113 for nick in nicks:
110 self.present_panel.presents.replace(nick) 114 self.present_panel.presents.replace(nick)
115 if nick != self.nick:
116 self.occupants.add(nick)
111 117
112 118
113 def replaceUser(self, nick): 119 def replaceUser(self, nick):
114 """Add user if it is not in the group list""" 120 """Add user if it is not in the group list"""
115 debug (_("Replacing user %s") % nick) 121 debug (_("Replacing user %s") % nick)
116 if self.type != "group": 122 if self.type != "group":
117 error (_("[INTERNAL] trying to replace user for a non group chat window")) 123 error (_("[INTERNAL] trying to replace user for a non group chat window"))
118 return 124 return
119 self.present_panel.presents.replace(nick) 125 self.present_panel.presents.replace(nick)
126 if nick != self.nick:
127 self.occupants.add(nick)
120 128
121 def removeUser(self, nick): 129 def removeUser(self, nick):
122 """Remove a user from the group list""" 130 """Remove a user from the group list"""
123 debug(_("Removing user %s") % nick) 131 debug(_("Removing user %s") % nick)
124 if self.type != "group": 132 if self.type != "group":
125 error (_("[INTERNAL] trying to remove user for a non group chat window")) 133 error (_("[INTERNAL] trying to remove user for a non group chat window"))
126 return 134 return
127 self.present_panel.presents.remove(nick) 135 self.present_panel.presents.remove(nick)
136 self.occupants.remove(nick)
128 137
129 def setSubject(self, subject): 138 def setSubject(self, subject):
130 """Set title for a group chat""" 139 """Set title for a group chat"""
131 debug(_("Setting subject to %s") % subject) 140 debug(_("Setting subject to %s") % subject)
132 if self.type != "group": 141 if self.type != "group":
151 menuBar.Append(actionMenu,_("&Action")) 160 menuBar.Append(actionMenu,_("&Action"))
152 161
153 #events 162 #events
154 wx.EVT_MENU(self, idSEND, self.onSendFile) 163 wx.EVT_MENU(self, idSEND, self.onSendFile)
155 164
165 def __createMenus_group(self):
166 """create menu bar for group chat"""
167 info("Creating menus")
168 self.__eraseMenus()
169 menuBar = self.GetMenuBar()
170 actionMenu = wx.Menu()
171 actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp
172 menuBar.Append(actionMenu,_("&Games"))
173
174 #events
175 wx.EVT_MENU(self, idTAROT, self.onStartTarot)
176
156 def __del__(self): 177 def __del__(self):
157 wx.Frame.__del__(self) 178 wx.Frame.__del__(self)
158 179
159 def onClose(self, event): 180 def onClose(self, event):
160 """Close event: we only hide the frame.""" 181 """Close event: we only hide the frame."""
198 debug(_("filename: %s"),filename) 219 debug(_("filename: %s"),filename)
199 full_jid = self.host.CM.get_full(self.target) 220 full_jid = self.host.CM.get_full(self.target)
200 id = self.host.bridge.sendFile(full_jid, filename) 221 id = self.host.bridge.sendFile(full_jid, filename)
201 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename)) 222 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename))
202 223
224 def onStartTarot(self, e):
225 debug (_("Starting Tarot game"))
226 warning (_("FIXME: temporary menu, must be changed"))
227 self.host.bridge.createTarotGame(self.id, list(self.occupants), self.host.profile)