annotate 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
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
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert,SelectableText
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
26
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
27
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
28 class Chat(urwid.WidgetWrap, QuickChat):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
29
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
30 def __init__(self, target, host, type='one2one'):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
31 QuickChat.__init__(self, target, host, type)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
32 self.content = urwid.SimpleListWalker([])
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
33 self.text_list = urwid.ListBox(self.content)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
34 main_widget = urwid.LineBox(
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
35 urwid.Frame(self.text_list, urwid.AttrMap(urwid.Text(str(target),'center'),'title'))
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
36 )
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
37 urwid.WidgetWrap.__init__(self, main_widget)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
38 self.setType(type)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
39
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
40 def setType(self, type):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
41 QuickChat.setType(self, type)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
42 if type == 'one2one':
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
43 self.historyPrint(profile=self.host.profile)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
44
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
45 def printMessage(self, from_jid, msg, profile, timestamp=""):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.content.append(SelectableText("[%s] " % from_jid + msg))
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.text_list.set_focus(len(self.content)-1)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.host.redraw()