annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #!/usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
goffi@necton2
parents:
diff changeset
4 """
goffi@necton2
parents:
diff changeset
5 wix: a SAT frontend
57
a5b5fb5fc9fd updated README and copyright note
Goffi <goffi@goffi.org>
parents: 0
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
7
goffi@necton2
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
goffi@necton2
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
goffi@necton2
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
goffi@necton2
parents:
diff changeset
11 (at your option) any later version.
goffi@necton2
parents:
diff changeset
12
goffi@necton2
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
goffi@necton2
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
goffi@necton2
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
goffi@necton2
parents:
diff changeset
16 GNU General Public License for more details.
goffi@necton2
parents:
diff changeset
17
goffi@necton2
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
goffi@necton2
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
goffi@necton2
parents:
diff changeset
20 """
goffi@necton2
parents:
diff changeset
21
goffi@necton2
parents:
diff changeset
22
goffi@necton2
parents:
diff changeset
23
goffi@necton2
parents:
diff changeset
24 import wx
goffi@necton2
parents:
diff changeset
25 import os.path
goffi@necton2
parents:
diff changeset
26 import pdb
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
27 from logging import debug, info, error, warning
0
goffi@necton2
parents:
diff changeset
28 from tools.jid import JID
goffi@necton2
parents:
diff changeset
29 from quick_frontend.quick_chat import QuickChat
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
30 from contact_list import ContactList
0
goffi@necton2
parents:
diff changeset
31
goffi@necton2
parents:
diff changeset
32
goffi@necton2
parents:
diff changeset
33 idSEND = 1
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
34 idTAROT = 2
0
goffi@necton2
parents:
diff changeset
35
goffi@necton2
parents:
diff changeset
36 class Chat(wx.Frame, QuickChat):
goffi@necton2
parents:
diff changeset
37 """The chat Window for one to one conversations"""
goffi@necton2
parents:
diff changeset
38
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
39 def __init__(self, target, host, type='one2one'):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
40 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
41 QuickChat.__init__(self, target, host, type)
0
goffi@necton2
parents:
diff changeset
42
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
43 self.splitter = wx.SplitterWindow(self, -1)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
44
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
45 self.conv_panel = wx.Panel(self.splitter)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
46 self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL)
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
47 self.subjectBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_READONLY)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
48 self.chatWindow = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_MULTILINE | wx.TE_RICH | wx.TE_READONLY)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
49 self.textBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_PROCESS_ENTER)
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
50 self.conv_panel.sizer.Add(self.subjectBox, flag=wx.EXPAND)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
51 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
52 self.conv_panel.sizer.Add(self.textBox, flag=wx.EXPAND)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
53 self.conv_panel.SetSizer(self.conv_panel.sizer)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
54 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
55 self.SetMenuBar(wx.MenuBar())
0
goffi@necton2
parents:
diff changeset
56
goffi@necton2
parents:
diff changeset
57 #events
goffi@necton2
parents:
diff changeset
58 self.Bind(wx.EVT_CLOSE, self.onClose, self)
goffi@necton2
parents:
diff changeset
59 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox)
goffi@necton2
parents:
diff changeset
60
goffi@necton2
parents:
diff changeset
61 #fonts
goffi@necton2
parents:
diff changeset
62 self.font={}
goffi@necton2
parents:
diff changeset
63 self.font["points"] = self.chatWindow.GetFont().GetPointSize()
goffi@necton2
parents:
diff changeset
64 self.font["family"] = self.chatWindow.GetFont().GetFamily()
goffi@necton2
parents:
diff changeset
65
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
66 self.setType(self.type)
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
67
0
goffi@necton2
parents:
diff changeset
68 #misc
goffi@necton2
parents:
diff changeset
69 self.textBox.SetFocus()
goffi@necton2
parents:
diff changeset
70 self.Hide() #We hide because of the show toggle
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
71
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
72 def __createPresents(self):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
73 """Create a list of present people in a group chat"""
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
74 self.present_panel = wx.Panel(self.splitter)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
75 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
76 self.present_panel.SetBackgroundColour(wx.BLUE)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
77 self.present_panel.presents = ContactList(self.present_panel, self.host, type='nicks')
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
78 self.present_panel.presents.SetMinSize(wx.Size(80,20))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
79 self.present_panel.sizer.Add(self.present_panel.presents, 1, wx.EXPAND)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
80 self.present_panel.SetSizer(self.present_panel.sizer)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
81 self.splitter.SplitVertically(self.present_panel, self.conv_panel, 80)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
82
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
83 def setType(self, type):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
84 QuickChat.setType(self, type)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
85 if type is 'group' and not self.splitter.IsSplit():
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
86 self.__createPresents()
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
87 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
88 self.__eraseMenus()
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
89 self.__createMenus_group()
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
90 self.historyPrint(profile=self.host.profile)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
91 elif type is 'one2one' and self.splitter.IsSplit():
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
92 self.splitter.Unsplit(self.present_panel)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
93 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
94 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
95 self.subjectBox.Hide()
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
96 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
97 self.__createMenus_O2O()
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
98 self.nick = None
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
99 else:
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
100 self.subjectBox.Hide()
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
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
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
103 self.historyPrint(profile=self.host.profile)
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
104
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
105 def setPresents(self, nicks):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
106 """Set the users presents in the contact list for a group chat
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
107 @param nicks: list of nicknames
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
108 """
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
109 debug (_("Adding users %s to room") % nicks)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
110 if self.type != "group":
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
111 error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
112 return
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
113 for nick in nicks:
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
114 self.present_panel.presents.replace(nick)
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
115 if nick != self.nick:
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
116 self.occupants.add(nick)
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
117
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
118
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
119 def replaceUser(self, nick):
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
120 """Add user if it is not in the group list"""
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
121 debug (_("Replacing user %s") % nick)
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
122 if self.type != "group":
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
123 error (_("[INTERNAL] trying to replace user for a non group chat window"))
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
124 return
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
125 self.present_panel.presents.replace(nick)
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
126 if nick != self.nick:
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
127 self.occupants.add(nick)
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
128
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
129 def removeUser(self, nick):
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
130 """Remove a user from the group list"""
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
131 debug(_("Removing user %s") % nick)
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
132 if self.type != "group":
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
133 error (_("[INTERNAL] trying to remove user for a non group chat window"))
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
134 return
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
135 self.present_panel.presents.remove(nick)
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
136 self.occupants.remove(nick)
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
137
76
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
138 def setSubject(self, subject):
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
139 """Set title for a group chat"""
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
140 debug(_("Setting subject to %s") % subject)
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
141 if self.type != "group":
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
142 error (_("[INTERNAL] trying to set subject for a non group chat window"))
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
143 return
8becde8a967c MUC: added subject management
Goffi <goffi@goffi.org>
parents: 75
diff changeset
144 self.subjectBox.SetValue(subject)
75
7322a41f8a8e Basic user joined/left management
Goffi <goffi@goffi.org>
parents: 72
diff changeset
145
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
146
78
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
147 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
148 """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
149 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
150 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
151 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
152
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
153 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
154 """create menu bar for one 2 one chat"""
0
goffi@necton2
parents:
diff changeset
155 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
156 self.__eraseMenus()
ace2af8abc5a Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents: 77
diff changeset
157 menuBar = self.GetMenuBar()
0
goffi@necton2
parents:
diff changeset
158 actionMenu = wx.Menu()
70
Goffi <goffi@goffi.org>
parents: 67
diff changeset
159 actionMenu.Append(idSEND, _("&SendFile CTRL-s"),_(" Send a file to contact"))
Goffi <goffi@goffi.org>
parents: 67
diff changeset
160 menuBar.Append(actionMenu,_("&Action"))
0
goffi@necton2
parents:
diff changeset
161
goffi@necton2
parents:
diff changeset
162 #events
goffi@necton2
parents:
diff changeset
163 wx.EVT_MENU(self, idSEND, self.onSendFile)
goffi@necton2
parents:
diff changeset
164
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
165 def __createMenus_group(self):
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
166 """create menu bar for group chat"""
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
167 info("Creating menus")
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
168 self.__eraseMenus()
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
169 menuBar = self.GetMenuBar()
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
170 actionMenu = wx.Menu()
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
171 actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
172 menuBar.Append(actionMenu,_("&Games"))
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
173
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
174 #events
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
175 wx.EVT_MENU(self, idTAROT, self.onStartTarot)
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
176
0
goffi@necton2
parents:
diff changeset
177 def __del__(self):
goffi@necton2
parents:
diff changeset
178 wx.Frame.__del__(self)
goffi@necton2
parents:
diff changeset
179
goffi@necton2
parents:
diff changeset
180 def onClose(self, event):
goffi@necton2
parents:
diff changeset
181 """Close event: we only hide the frame."""
goffi@necton2
parents:
diff changeset
182 event.Veto()
goffi@necton2
parents:
diff changeset
183 self.Show() ## this is a workaround to a wxpython bug:
goffi@necton2
parents:
diff changeset
184 ## with Raise on hidden frame, Hide doesn't work anymore
goffi@necton2
parents:
diff changeset
185 ## TODO: check this and repport bug to wxpython devs
goffi@necton2
parents:
diff changeset
186 self.Hide()
goffi@necton2
parents:
diff changeset
187
goffi@necton2
parents:
diff changeset
188 def onEnterPressed(self, event):
goffi@necton2
parents:
diff changeset
189 """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
190 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
191 event.GetString(),
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
192 type = "groupchat" if self.type=='group' else "chat",
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
193 profile_key=self.host.profile)
0
goffi@necton2
parents:
diff changeset
194 self.textBox.Clear()
goffi@necton2
parents:
diff changeset
195
goffi@necton2
parents:
diff changeset
196
goffi@necton2
parents:
diff changeset
197
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 57
diff changeset
198 def printMessage(self, from_jid, msg, profile, timestamp=""):
0
goffi@necton2
parents:
diff changeset
199 """Print the message with differents colors depending on where it comes from."""
goffi@necton2
parents:
diff changeset
200 jid=JID(from_jid)
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
201 print "printMessage, jid=",jid,"type=",self.type
80
9681f18d06bd wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents: 79
diff changeset
202 nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node)
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 78
diff changeset
203 mymess = (jid.resource == self.nick) if self.type == "group" else (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user
0
goffi@necton2
parents:
diff changeset
204 _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD)
goffi@necton2
parents:
diff changeset
205 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font))
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
206 self.chatWindow.AppendText("[%s] " % nick)
0
goffi@necton2
parents:
diff changeset
207 _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL)
goffi@necton2
parents:
diff changeset
208 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font))
goffi@necton2
parents:
diff changeset
209 self.chatWindow.AppendText("%s\n" % msg)
goffi@necton2
parents:
diff changeset
210 if not mymess:
goffi@necton2
parents:
diff changeset
211 self.Raise() #FIXME: too intrusive
goffi@necton2
parents:
diff changeset
212
goffi@necton2
parents:
diff changeset
213 ### events ###
goffi@necton2
parents:
diff changeset
214
goffi@necton2
parents:
diff changeset
215 def onSendFile(self, e):
70
Goffi <goffi@goffi.org>
parents: 67
diff changeset
216 debug(_("Send File"))
Goffi <goffi@goffi.org>
parents: 67
diff changeset
217 filename = wx.FileSelector(_("Choose a file to send"), flags = wx.FD_FILE_MUST_EXIST)
0
goffi@necton2
parents:
diff changeset
218 if filename:
70
Goffi <goffi@goffi.org>
parents: 67
diff changeset
219 debug(_("filename: %s"),filename)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
220 full_jid = self.host.CM.get_full(self.target)
0
goffi@necton2
parents:
diff changeset
221 id = self.host.bridge.sendFile(full_jid, filename)
70
Goffi <goffi@goffi.org>
parents: 67
diff changeset
222 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename))
0
goffi@necton2
parents:
diff changeset
223
85
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
224 def onStartTarot(self, e):
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
225 debug (_("Starting Tarot game"))
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
226 warning (_("FIXME: temporary menu, must be changed"))
fc7583282d40 Tarot Game plugin: first draft
Goffi <goffi@goffi.org>
parents: 80
diff changeset
227 self.host.bridge.createTarotGame(self.id, list(self.occupants), self.host.profile)