Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/frontends/primitivus/chat.py Mon Jul 05 19:13:36 2010 +0800 @@ -0,0 +1,48 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +Primitivus: a SAT frontend +Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +import urwid +from quick_frontend.quick_contact_list import QuickContactList +from quick_frontend.quick_chat import QuickChat +from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert,SelectableText + + +class Chat(urwid.WidgetWrap, QuickChat): + + def __init__(self, target, host, type='one2one'): + QuickChat.__init__(self, target, host, type) + self.content = urwid.SimpleListWalker([]) + self.text_list = urwid.ListBox(self.content) + main_widget = urwid.LineBox( + urwid.Frame(self.text_list, urwid.AttrMap(urwid.Text(str(target),'center'),'title')) + ) + urwid.WidgetWrap.__init__(self, main_widget) + self.setType(type) + + def setType(self, type): + QuickChat.setType(self, type) + if type == 'one2one': + self.historyPrint(profile=self.host.profile) + + def printMessage(self, from_jid, msg, profile, timestamp=""): + self.content.append(SelectableText("[%s] " % from_jid + msg)) + self.text_list.set_focus(len(self.content)-1) + self.host.redraw()