annotate frontends/primitivus/chat.py @ 124:961e0898271f

primitivus chat window - management of one 2 one / group chat - timestamp displayed - added shortcuts for showing/hiding panels - color used - fixed vcard bug (contact displayed even if not from current profile if vcard changed/not in cache) - added VerticalSeparator widget - *List widgets can now use an other widget than SelectableText - new UnselectableText widget
author Goffi <goffi@goffi.org>
date Thu, 08 Jul 2010 19:47:54 +0800
parents 1ca5f254ce41
children 8d611eb9ae48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
3
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Primitivus: a SAT frontend
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
7
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
12
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU General Public License for more details.
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
17
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
21
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import urwid
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from quick_frontend.quick_contact_list import QuickContactList
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from quick_frontend.quick_chat import QuickChat
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
25 import custom_widgets
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
26 import time
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
27 from tools.jid import JID
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
28
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
29
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
30 class ChatText(urwid.FlowWidget):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
31 """Manage the printing of chat message"""
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
32
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
33 def __init__(self, parent, timestamp, my_jid, from_jid, message, align='left'):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
34 self.parent = parent
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
35 self.timestamp = time.localtime(timestamp)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
36 self.my_jid = my_jid
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
37 self.from_jid = from_jid
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
38 self.message = unicode(message)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
39 self.align = align
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
40
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
41 def selectable(self):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
42 return True
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
43
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
44 def keypress(self, size, key):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
45 return key
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
46
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
47 def rows(self,size,focus=False):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
48 return self.display_widget(size, focus).rows(size, focus)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
49
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
50 def render(self, size, focus=False):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
51 return self.display_widget(size, focus).render(size, focus)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
52
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
53 def display_widget(self, size, focus):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
54 my_mess = (self.from_jid.resource == self.parent.nick) if self.parent.type == "group" else (self.from_jid.short == self.my_jid.short) #mymess = True if message comes from local user
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
55 render_txt = []
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
56 if self.parent.show_timestamp:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
57 time_format = "%c" if self.timestamp < self.parent.day_change else "%H:%M" #if the message was sent before today, we print the full date
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
58 render_txt.append(('date',"[%s]" % time.strftime(time_format, self.timestamp)))
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
59 if self.parent.show_short_nick:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
60 render_txt.append(('my_nick' if my_mess else 'other_nick',"**" if my_mess else "*"))
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
61 else:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
62 render_txt.append(('my_nick' if my_mess else 'other_nick',"[%s] " % self.from_jid))
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
63 render_txt.append(self.message)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
64 return urwid.Text(render_txt, align=self.align)
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
65
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
66 class Chat(urwid.WidgetWrap, QuickChat):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
67
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
68 def __init__(self, target, host, type='one2one'):
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
69 self.target = target
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
70 QuickChat.__init__(self, target, host, type)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
71 self.content = urwid.SimpleListWalker([])
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
72 self.text_list = urwid.ListBox(self.content)
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
73 self.chat_widget = urwid.Frame(self.text_list)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
74 self.columns = urwid.Columns([('weight', 8, self.chat_widget)])
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
75 urwid.WidgetWrap.__init__(self, self.__getDecoration(self.columns))
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
76 self.setType(type)
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
77 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
78 self.show_timestamp = True
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
79 self.show_short_nick = False
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
80 self.show_title = True
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
81 self.subject = None
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
82
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
83 def keypress(self, size, key):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
84 if key == "meta p": #user wants to (un)hide the presents panel
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
85 if self.type == 'group':
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
86 widgets = self.columns.widget_list
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
87 if self.present_panel in widgets:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
88 self.__removePresentPanel()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
89 else:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
90 self.__appendPresentPanel()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
91 elif key == "meta t": #user wants to (un)hide timestamp
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
92 self.show_timestamp = not self.show_timestamp
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
93 for wid in self.content:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
94 wid._invalidate()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
95 elif key == "meta n": #user wants to (not) use short nick
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
96 self.show_short_nick = not self.show_short_nick
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
97 for wid in self.content:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
98 wid._invalidate()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
99 elif key == "meta l": #user wants to (un)hide widget decoration
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
100 show = not self._w.__class__ == custom_widgets.LabelLine
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
101 self.showDecoration(show)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
102 self._invalidate()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
103 elif key == "meta s": #user wants to (un)hide group's subject
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
104 if self.subject:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
105 self.show_title = not self.show_title
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
106 if self.show_title:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
107 self.setSubject(self.subject)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
108 else:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
109 self.chat_widget.header = None
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
110 self._invalidate()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
111
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
112
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
113 return super(Chat, self).keypress(size, key)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
114
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def setType(self, type):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
116 QuickChat.setType(self, type)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
117 if type == 'one2one':
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
118 self.historyPrint(profile=self.host.profile)
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
119 elif type == 'group':
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
120 if len(self.columns.widget_list) == 1:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
121 present_widget = self.__buildPresentList()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
122 self.present_panel = custom_widgets.VerticalSeparator(present_widget)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
123 self.__appendPresentPanel()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
125 def __getDecoration(self, widget):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
126 return custom_widgets.LabelLine(widget, custom_widgets.SurroundedText(unicode(self.target)))
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
127
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
128 def showDecoration(self, show=True):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
129 if show:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
130 main_widget = self.__getDecoration(self.columns)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
131 else:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
132 main_widget = self.columns
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
133 self._w = main_widget
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
134
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
135
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
136 def __buildPresentList(self):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
137 self.present_wid = custom_widgets.GenericList([],option_type = custom_widgets.UnselectableText)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
138 return self.present_wid
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
139
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
140 def __appendPresentPanel(self):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
141 self.columns.widget_list.append(self.present_panel)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
142 self.columns.column_types.append(('weight', 2))
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
143
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
144 def __removePresentPanel(self):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
145 self.columns.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.columns
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
146 self.columns.widget_list.remove(self.present_panel)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
147 del self.columns.column_types[-1]
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
148
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
149 def setSubject(self, subject):
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
150 """Set title for a group chat"""
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
151 QuickChat.setSubject(self, subject)
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
152 self.subject = subject
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
153 self.chat_widget.header = urwid.AttrMap(urwid.Text(unicode(subject),align='center'),'title')
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
154
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
155 def setPresents(self, param_nicks):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
156 """Set the users presents in the contact list for a group chat
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
157 @param nicks: list of nicknames
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
158 """
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
159 nicks = [unicode(nick) for nick in param_nicks] #FIXME: should be done in DBus bridge
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
160 nicks.sort()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
161 QuickChat.setPresents(self, nicks)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
162 self.present_wid.changeValues(nicks)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
163 self.host.redraw()
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
164
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
165 def replaceUser(self, param_nick):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
166 """Add user if it is not in the group list"""
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
167 nick = unicode(param_nick) #FIXME: should be done in DBus bridge
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
168 if "facebook" in nick:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
169 self.host.debug()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
170 QuickChat.replaceUser(self, nick)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
171 presents = self.present_wid.getAllValues()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
172 if nick not in presents:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
173 presents.append(nick)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
174 presents.sort()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
175 self.present_wid.changeValues(presents)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
176 self.host.redraw()
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
177
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
178 def removeUser(self, param_nick):
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
179 """Remove a user from the group list"""
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
180 nick = unicode(param_nick) #FIXME: should be done in DBus bridge
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
181 QuickChat.removeUser(self, nick)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
182 self.present_wid.deleteValue(nick)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
183 self.host.redraw()
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
184
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
185 def printMessage(self, from_jid, msg, profile, timestamp=""):
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
186 assert (from_jid.__class__ == JID)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
187 my_jid = self.host.profiles[profile]['whoami']
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
188 self.content.append(ChatText(self, timestamp or None, my_jid, from_jid, msg))
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
189 self.text_list.set_focus(len(self.content)-1)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
190 self.host.redraw()