diff cagou/plugins/plugin_wid_chat.py @ 287:5d96bcd3bfec

chat: added an extra menu (3 dots menu): first entry is this menu display bookmarks. This menu will be used in the future to show advances actions like showing occupants or configuring room.
author Goffi <goffi@goffi.org>
date Wed, 27 Mar 2019 22:22:51 +0100
parents ca4daced4638
children 717c6c368f70
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py	Wed Mar 27 22:22:51 2019 +0100
+++ b/cagou/plugins/plugin_wid_chat.py	Wed Mar 27 22:22:51 2019 +0100
@@ -23,6 +23,7 @@
 import sys
 from sat.core import log as logging
 from sat.core.i18n import _
+from sat.core import exceptions
 from cagou.core.constants import Const as C
 from kivy.uix.boxlayout import BoxLayout
 from kivy.uix.gridlayout import GridLayout
@@ -174,6 +175,24 @@
         menu.TransferMenu(callback=self.chat.onTransferOK).show(self)
 
 
+class ExtraMenu(DropDown):
+    chat = properties.ObjectProperty()
+
+    def on_select(self, menu):
+        if menu == 'bookmark':
+            G.host.bridge.menuLaunch(C.MENU_GLOBAL, (u"groups", u"bookmarks"),
+                                     {}, C.NO_SECURITY_LIMIT, self.chat.profile,
+                                     callback=partial(
+                                        G.host.actionManager, profile=self.chat.profile),
+                                     errback=G.host.errback)
+        else:
+            raise exceptions.InternalError(u"Unknown menu: {}".format(menu))
+
+
+class ExtraButton(SymbolButton):
+    chat = properties.ObjectProperty()
+
+
 class EncryptionMainButton(SymbolButton):
 
     def __init__(self, chat, **kwargs):
@@ -181,7 +200,6 @@
         @param chat(Chat): Chat instance
         """
         self.chat = chat
-        # for now we do a simple ContextMenu as we have only OTR
         self.encryption_menu = EncryptionMenu(chat)
         super(EncryptionMainButton, self).__init__(**kwargs)
         self.bind(on_release=self.encryption_menu.open)
@@ -393,6 +411,9 @@
         if type_ == C.CHAT_ONE2ONE:
             self.encryption_btn = EncryptionMainButton(self)
             self.headerInputAddExtra(self.encryption_btn)
+        self.extra_menu = ExtraMenu(chat=self)
+        extra_btn = ExtraButton(chat=self)
+        self.headerInputAddExtra(extra_btn)
         self.header_input.hint_text = u"{}".format(target)
         self.postInit()