Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/frontends/wix/chat.py Thu May 06 20:47:48 2010 +0930 +++ b/frontends/wix/chat.py Fri May 07 17:09:30 2010 +0930 @@ -24,13 +24,14 @@ import wx import os.path import pdb -from logging import debug, info, error +from logging import debug, info, error, warning from tools.jid import JID from quick_frontend.quick_chat import QuickChat from contact_list import ContactList idSEND = 1 +idTAROT = 2 class Chat(wx.Frame, QuickChat): """The chat Window for one to one conversations""" @@ -85,19 +86,22 @@ self.__createPresents() self.subjectBox.Show() self.__eraseMenus() + self.__createMenus_group() self.historyPrint(profile=self.host.profile) elif type is 'one2one' and self.splitter.IsSplit(): self.splitter.Unsplit(self.present_panel) del self.present_panel self.GetMenuBar().Show() self.subjectBox.Hide() + self.__eraseMenus() self.__createMenus_O2O() self.nick = None else: self.subjectBox.Hide() + self.__eraseMenus() self.__createMenus_O2O() self.historyPrint(profile=self.host.profile) - + def setPresents(self, nicks): """Set the users presents in the contact list for a group chat @param nicks: list of nicknames @@ -107,7 +111,9 @@ error (_("[INTERNAL] trying to set presents nicks for a non group chat window")) return for nick in nicks: - self.present_panel.presents.replace(nick) + self.present_panel.presents.replace(nick) + if nick != self.nick: + self.occupants.add(nick) def replaceUser(self, nick): @@ -117,6 +123,8 @@ error (_("[INTERNAL] trying to replace user for a non group chat window")) return self.present_panel.presents.replace(nick) + if nick != self.nick: + self.occupants.add(nick) def removeUser(self, nick): """Remove a user from the group list""" @@ -125,6 +133,7 @@ error (_("[INTERNAL] trying to remove user for a non group chat window")) return self.present_panel.presents.remove(nick) + self.occupants.remove(nick) def setSubject(self, subject): """Set title for a group chat""" @@ -153,6 +162,18 @@ #events wx.EVT_MENU(self, idSEND, self.onSendFile) + def __createMenus_group(self): + """create menu bar for group chat""" + info("Creating menus") + self.__eraseMenus() + menuBar = self.GetMenuBar() + actionMenu = wx.Menu() + actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp + menuBar.Append(actionMenu,_("&Games")) + + #events + wx.EVT_MENU(self, idTAROT, self.onStartTarot) + def __del__(self): wx.Frame.__del__(self) @@ -200,3 +221,7 @@ id = self.host.bridge.sendFile(full_jid, filename) self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename)) + def onStartTarot(self, e): + debug (_("Starting Tarot game")) + warning (_("FIXME: temporary menu, must be changed")) + self.host.bridge.createTarotGame(self.id, list(self.occupants), self.host.profile)