Mercurial > libervia-desktop-kivy
comparison 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 |
comparison
equal
deleted
inserted
replaced
286:4772ba26623f | 287:5d96bcd3bfec |
---|---|
21 from functools import partial | 21 from functools import partial |
22 import mimetypes | 22 import mimetypes |
23 import sys | 23 import sys |
24 from sat.core import log as logging | 24 from sat.core import log as logging |
25 from sat.core.i18n import _ | 25 from sat.core.i18n import _ |
26 from sat.core import exceptions | |
26 from cagou.core.constants import Const as C | 27 from cagou.core.constants import Const as C |
27 from kivy.uix.boxlayout import BoxLayout | 28 from kivy.uix.boxlayout import BoxLayout |
28 from kivy.uix.gridlayout import GridLayout | 29 from kivy.uix.gridlayout import GridLayout |
29 from kivy.uix.textinput import TextInput | 30 from kivy.uix.textinput import TextInput |
30 from kivy.metrics import sp, dp | 31 from kivy.metrics import sp, dp |
172 | 173 |
173 def on_release(self, *args): | 174 def on_release(self, *args): |
174 menu.TransferMenu(callback=self.chat.onTransferOK).show(self) | 175 menu.TransferMenu(callback=self.chat.onTransferOK).show(self) |
175 | 176 |
176 | 177 |
178 class ExtraMenu(DropDown): | |
179 chat = properties.ObjectProperty() | |
180 | |
181 def on_select(self, menu): | |
182 if menu == 'bookmark': | |
183 G.host.bridge.menuLaunch(C.MENU_GLOBAL, (u"groups", u"bookmarks"), | |
184 {}, C.NO_SECURITY_LIMIT, self.chat.profile, | |
185 callback=partial( | |
186 G.host.actionManager, profile=self.chat.profile), | |
187 errback=G.host.errback) | |
188 else: | |
189 raise exceptions.InternalError(u"Unknown menu: {}".format(menu)) | |
190 | |
191 | |
192 class ExtraButton(SymbolButton): | |
193 chat = properties.ObjectProperty() | |
194 | |
195 | |
177 class EncryptionMainButton(SymbolButton): | 196 class EncryptionMainButton(SymbolButton): |
178 | 197 |
179 def __init__(self, chat, **kwargs): | 198 def __init__(self, chat, **kwargs): |
180 """ | 199 """ |
181 @param chat(Chat): Chat instance | 200 @param chat(Chat): Chat instance |
182 """ | 201 """ |
183 self.chat = chat | 202 self.chat = chat |
184 # for now we do a simple ContextMenu as we have only OTR | |
185 self.encryption_menu = EncryptionMenu(chat) | 203 self.encryption_menu = EncryptionMenu(chat) |
186 super(EncryptionMainButton, self).__init__(**kwargs) | 204 super(EncryptionMainButton, self).__init__(**kwargs) |
187 self.bind(on_release=self.encryption_menu.open) | 205 self.bind(on_release=self.encryption_menu.open) |
188 | 206 |
189 def selectAlgo(self, name): | 207 def selectAlgo(self, name): |
391 transfer_btn = TransferButton(chat=self) | 409 transfer_btn = TransferButton(chat=self) |
392 self.headerInputAddExtra(transfer_btn) | 410 self.headerInputAddExtra(transfer_btn) |
393 if type_ == C.CHAT_ONE2ONE: | 411 if type_ == C.CHAT_ONE2ONE: |
394 self.encryption_btn = EncryptionMainButton(self) | 412 self.encryption_btn = EncryptionMainButton(self) |
395 self.headerInputAddExtra(self.encryption_btn) | 413 self.headerInputAddExtra(self.encryption_btn) |
414 self.extra_menu = ExtraMenu(chat=self) | |
415 extra_btn = ExtraButton(chat=self) | |
416 self.headerInputAddExtra(extra_btn) | |
396 self.header_input.hint_text = u"{}".format(target) | 417 self.header_input.hint_text = u"{}".format(target) |
397 self.postInit() | 418 self.postInit() |
398 | 419 |
399 def __unicode__(self): | 420 def __unicode__(self): |
400 return u"Chat({})".format(self.target) | 421 return u"Chat({})".format(self.target) |