diff cagou/plugins/plugin_wid_chat.kv @ 126:cd99f70ea592

global file reorganisation: - follow common convention by puttin cagou in "cagou" instead of "src/cagou" - added VERSION in cagou with current version - updated dates - moved main executable in /bin - moved buildozer files in root directory - temporary moved platform to assets/platform
author Goffi <goffi@goffi.org>
date Thu, 05 Apr 2018 17:11:21 +0200
parents src/cagou/plugins/plugin_wid_chat.kv@dcd6fbb3f010
children 36fc269e2a32
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cagou/plugins/plugin_wid_chat.kv	Thu Apr 05 17:11:21 2018 +0200
@@ -0,0 +1,146 @@
+# Cagou: desktop/mobile frontend for Salut à Toi XMPP client
+# Copyright (C) 2016-2018 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 Affero 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 Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#:import TransferMenu cagou.core.menu.TransferMenu
+#:import SimpleXHTMLWidget cagou.core.simple_xhtml.SimpleXHTMLWidget
+#:import _ sat.core.i18n._
+#:import C cagou.core.constants.Const
+
+
+<MessAvatar>:
+    size_hint: None, None
+    size: dp(30), dp(30)
+
+<MessagesWidget>:
+    cols: 1
+    padding: dp(10)
+    spacing: dp(5)
+    size_hint: 1, None
+    height: self.minimum_height
+
+<MessageWidget>:
+    cols: 1
+    mess_xhtml: mess_xhtml
+    padding: dp(10)
+    spacing: dp(5)
+    size_hint: 1, None
+    height: self.minimum_height
+    on_width: self.widthAdjust()
+    avatar: avatar
+    delivery: delivery
+    BoxLayout:
+        id: header_box
+        size_hint: 1, None
+        height: avatar.height if root.mess_data.type != C.MESS_TYPE_INFO else 0
+        opacity: 1 if root.mess_data.type != C.MESS_TYPE_INFO else 0
+        MessAvatar:
+            id: avatar
+        Label:
+            id: time_label
+            text_size: None, None
+            size_hint: None, None
+            size: self.texture_size
+            padding: dp(5), 0
+            text: u"{}, {}".format(root.mess_data.nick, root.mess_data.time_text)
+        Label:
+            id: delivery
+            text_size: None, None
+            size_hint: None, None
+            size: self.texture_size
+            padding: dp(5), 0
+            # XXX: DejaVuSans font is needed as check mark is not in Roboto
+            # this can be removed when Kivy will be able to handle fallback mechanism
+            # which will allow us to use fonts with more unicode characters
+            font_name: "DejaVuSans"
+            text: u''
+            color: 0, 1, 0, 1
+    BoxLayout:
+        # BoxLayout is needed here, else GridLayout won't let the Label choose its width
+        size_hint: 1, None
+        height: mess_xhtml.height
+        on_size: root.widthAdjust()
+        SimpleXHTMLWidget:
+            canvas.before:
+                Color:
+                    rgba: 1, 1, 1, 1
+                BorderImage:
+                    source: app.expand("{media}/misc/black.png") if root.mess_data.type == "info" else app.expand("{media}/misc/borders/{}.jpg", "blue" if root.mess_data.own_mess else "gray")
+                    pos: self.pos
+                    size: self.content_width, self.height
+            id: mess_xhtml
+            size_hint: 0.8, None
+            height: self.minimum_height
+            xhtml: root.message_xhtml or self.escape(root.message or u' ')
+            color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1)
+            padding: root.mess_padding
+            bold: True if root.mess_data.type == "info" else False
+
+<Chat>:
+    messages_widget: messages_widget
+    ScrollView:
+        size_hint: 1, 0.8
+        scroll_y: 0
+        do_scroll_x: False
+        MessagesWidget:
+            id: messages_widget
+    MessageInputBox:
+        size_hint: 1, None
+        height: dp(40)
+        message_input: message_input
+        MessageInputWidget:
+            id: message_input
+            size_hint: 1, 1
+            hint_text: _(u"Enter your message here")
+            on_text_validate: root.onSend(args[0])
+        IconButton
+            # transfer button
+            source: app.expand("{media}/icons/tango/actions/32/list-add.png")
+            allow_stretch: True
+            size_hint: None, 1
+            width: max(self.texture_size[0], dp(40))
+            on_release: TransferMenu(callback=root.onTransferOK).show(self)
+
+<EncryptionButton>:
+    size_hint: None, 1
+    width: dp(30)
+    allow_stretch: True
+    source: self.getIconSource()
+
+<OtrButton@Button>:
+    size_hint: None, None
+    size: self.texture_size
+    padding: dp(5), dp(10)
+
+<OtrMenu>:
+    size_hint_x: None
+    width: start_btn.width
+    auto_width: False
+    canvas.before:
+        Color:
+            rgba: 0, 0, 0, 1
+        Rectangle:
+            pos: self.pos
+            size: self.size
+    OtrButton:
+        id: start_btn
+        text: _(u"Start/Refresh encrypted session")
+        on_release: root.otr_start()
+    OtrButton:
+        text: _(u"Finish encrypted session")
+        on_release: root.otr_end()
+    OtrButton:
+        text: _(u"Authenticate destinee")
+        on_release: root.otr_authenticate()