comparison frontends/primitivus/chat.py @ 119:ded2431cea5a

Primitivus: chat window / text sending. Primitivus has now the most basics features \o/ - core: new getVersion method - primitivus: new debug key (C-d), only work if SàT is in dev version (D in version) - quick_app: new post_init method, used for automatique task like auto-plug - primitivus: lists now use genericList (Box) or List (Flow) - primitivus: List now manage correctly its size - primitivus: new FocusFrame widget which manage focus changing with 'tab' - primitivus: advancedEdit now manage 'click' signal - primitivus: contactList now manager 'change' and 'click' signals - primitivus: Chat window now working
author Goffi <goffi@goffi.org>
date Mon, 05 Jul 2010 19:13:36 +0800
parents
children 1ca5f254ce41
comparison
equal deleted inserted replaced
118:76055a209ed9 119:ded2431cea5a
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 """
5 Primitivus: a SAT frontend
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """
21
22 import urwid
23 from quick_frontend.quick_contact_list import QuickContactList
24 from quick_frontend.quick_chat import QuickChat
25 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert,SelectableText
26
27
28 class Chat(urwid.WidgetWrap, QuickChat):
29
30 def __init__(self, target, host, type='one2one'):
31 QuickChat.__init__(self, target, host, type)
32 self.content = urwid.SimpleListWalker([])
33 self.text_list = urwid.ListBox(self.content)
34 main_widget = urwid.LineBox(
35 urwid.Frame(self.text_list, urwid.AttrMap(urwid.Text(str(target),'center'),'title'))
36 )
37 urwid.WidgetWrap.__init__(self, main_widget)
38 self.setType(type)
39
40 def setType(self, type):
41 QuickChat.setType(self, type)
42 if type == 'one2one':
43 self.historyPrint(profile=self.host.profile)
44
45 def printMessage(self, from_jid, msg, profile, timestamp=""):
46 self.content.append(SelectableText("[%s] " % from_jid + msg))
47 self.text_list.set_focus(len(self.content)-1)
48 self.host.redraw()