Mercurial > libervia-backend
comparison frontends/primitivus/chat.py @ 120:1ca5f254ce41
primitivus group chat & misc
primitivus: new widget: SurroundedText (text with a character repeated around it)
primitivus: new decorator LabelLine (like lineBox, but with a label on the top line)
wix & primitivus & quick_app: group chat method move to quick_chat
wix: when new message, window is not raised anymore, but RequestUserAttention is called instead
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 08 Jul 2010 14:12:18 +0800 |
parents | ded2431cea5a |
children | 961e0898271f |
comparison
equal
deleted
inserted
replaced
119:ded2431cea5a | 120:1ca5f254ce41 |
---|---|
20 """ | 20 """ |
21 | 21 |
22 import urwid | 22 import urwid |
23 from quick_frontend.quick_contact_list import QuickContactList | 23 from quick_frontend.quick_contact_list import QuickContactList |
24 from quick_frontend.quick_chat import QuickChat | 24 from quick_frontend.quick_chat import QuickChat |
25 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert,SelectableText | 25 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert,SelectableText,LabelLine,SurroundedText |
26 | 26 |
27 | 27 |
28 class Chat(urwid.WidgetWrap, QuickChat): | 28 class Chat(urwid.WidgetWrap, QuickChat): |
29 | 29 |
30 def __init__(self, target, host, type='one2one'): | 30 def __init__(self, target, host, type='one2one'): |
31 QuickChat.__init__(self, target, host, type) | 31 QuickChat.__init__(self, target, host, type) |
32 self.content = urwid.SimpleListWalker([]) | 32 self.content = urwid.SimpleListWalker([]) |
33 self.text_list = urwid.ListBox(self.content) | 33 self.text_list = urwid.ListBox(self.content) |
34 main_widget = urwid.LineBox( | 34 main_widget = LabelLine( |
35 urwid.Frame(self.text_list, urwid.AttrMap(urwid.Text(str(target),'center'),'title')) | 35 urwid.Frame(self.text_list), SurroundedText(str(target)) |
36 ) | 36 ) |
37 urwid.WidgetWrap.__init__(self, main_widget) | 37 urwid.WidgetWrap.__init__(self, main_widget) |
38 self.setType(type) | 38 self.setType(type) |
39 | 39 |
40 def setType(self, type): | 40 def setType(self, type): |
41 QuickChat.setType(self, type) | 41 QuickChat.setType(self, type) |
42 if type == 'one2one': | 42 if type == 'one2one': |
43 self.historyPrint(profile=self.host.profile) | 43 self.historyPrint(profile=self.host.profile) |
44 | |
45 def setSubject(self, subject): | |
46 """Set title for a group chat""" | |
47 QuickChat.setSubject(self, subject) | |
48 self._w.base_widget.header = urwid.AttrMap(urwid.Text(unicode(subject),align='center'),'title') | |
49 | |
44 | 50 |
45 def printMessage(self, from_jid, msg, profile, timestamp=""): | 51 def printMessage(self, from_jid, msg, profile, timestamp=""): |
46 self.content.append(SelectableText("[%s] " % from_jid + msg)) | 52 self.content.append(SelectableText("[%s] " % from_jid + msg)) |
47 self.text_list.set_focus(len(self.content)-1) | 53 self.text_list.set_focus(len(self.content)-1) |
48 self.host.redraw() | 54 self.host.redraw() |