annotate src/cagou/plugins/plugin_wid_chat.kv @ 22:74117b733bac

plugin chat: first draft: - only one 2 one display is handled for now - own messages are displayed in blue, other ones in gray - by default we display our own jid (for now) - to change target, contact in contact widget can be clicked, or a jid can be entered in header input - disco is called on jid entered in header, if it's a conference a MUCJoin will be called (not implemented yet), else a new chat widget with the jid replace the current one
author Goffi <goffi@goffi.org>
date Mon, 08 Aug 2016 01:07:43 +0200
parents
children f9869f34f629
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # This program is free software: you can redistribute it and/or modify
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # it under the terms of the GNU Affero General Public License as published by
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # the Free Software Foundation, either version 3 of the License, or
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # (at your option) any later version.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # This program is distributed in the hope that it will be useful,
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # GNU Affero General Public License for more details.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # You should have received a copy of the GNU Affero General Public License
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 <MessagesWidget>:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 spacing: self._spacing
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 padding: self._padding
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 <MessageInputWidget>:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 size_hint: 1,None
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 height: 40
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 hint_text: "Enter your message here"
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 <MessageWidget>:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 canvas.before:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 Color:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 rgba: 1, 1, 1, 1
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 BorderImage:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 source: "cagou/images/border_{}.jpg".format("blue" if root.mess_data.own_mess else "gray")
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 pos: self.pos
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 size: self.size
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 mess_label: mess_label
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 size_hint: None,None
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 pos_hint: {'x': 0} if root.mess_data.own_mess else {'right': 1}
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 height: max(mess_label.height, 20)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 width: mess_label.width
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 on_height: if root.parent: root.parent.sizeAdjust()
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 BoxLayout:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 # Label:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 # id: nick_label
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 # text: root.mess_data.nick
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 # # text: unicode(self.texture_size)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 # padding: 5, 5
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 # bold: True
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 # # text_size: None, self.height
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 # # height: 20
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 # size_hint: None, None
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 # size: self.texture_size
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 # pos_hint: {'top': 0}
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 # # width: self.texture_size[0]
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 # # height: max(self.texture_size[1], mess_label.height)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 # # size_hint: None, 1
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 # # valign: "top"
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 Label:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 id: mess_label
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 color: 0, 0, 0, 1
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 padding: 5, 5
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 text_size: None, None
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 size_hint: None, None
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 size: self.texture_size
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 # text: 'root:{} nick:{} self:{}'.format(root.height, nick_label.height, self.height)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 text: root.message or u' '
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 # haligh: "left"
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 on_texture_size: root.adjustMax(self.texture_size)