libervia-backend/frontends/primitivus/chat.py
Goffi dbb3520a4f 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
2010-07-08 14:12:18 +08:00

54 lines
2 KiB
Python

#!/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,LabelLine,SurroundedText
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 = LabelLine(
urwid.Frame(self.text_list), SurroundedText(str(target))
)
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 setSubject(self, subject):
"""Set title for a group chat"""
QuickChat.setSubject(self, subject)
self._w.base_widget.header = urwid.AttrMap(urwid.Text(unicode(subject),align='center'),'title')
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()