Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_chat.py @ 135:091e288838e1
plugin chat: use new Symbol widget to display encryption button
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Apr 2018 16:13:08 +0200 |
parents | cd99f70ea592 |
children | 53fb221ad084 |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py Fri Apr 06 16:13:08 2018 +0200 +++ b/cagou/plugins/plugin_wid_chat.py Fri Apr 06 16:13:08 2018 +0200 @@ -32,7 +32,7 @@ from sat_frontends.tools import jid from cagou.core import cagou_widget from cagou.core.image import Image -from cagou.core.common import IconButton, JidWidget +from cagou.core.common import SymbolButton, JidWidget from kivy.uix.dropdown import DropDown from cagou import G import mimetypes @@ -130,7 +130,7 @@ pass -class EncryptionButton(IconButton): +class EncryptionButton(SymbolButton): def __init__(self, chat, **kwargs): """ @@ -142,18 +142,21 @@ super(EncryptionButton, self).__init__(**kwargs) self.bind(on_release=self.otr_menu.open) - def getIconSource(self): - """get path of icon""" - # TODO: use a more generic method to get icon name + def getColor(self): if self.chat.otr_state_encryption == OTR_STATE_UNENCRYPTED: - icon_name = 'cadenas_ouvert' + return (0.4, 0.4, 0.4, 1) + elif self.chat.otr_state_trust == OTR_STATE_TRUSTED: + return (0.29,0.87,0.0,1) else: - if self.chat.otr_state_trust == OTR_STATE_TRUSTED: - icon_name = 'cadenas_ferme' - else: - icon_name = 'cadenas_ferme_pas_authenthifie' + return (0.4, 0.4, 0.4, 1) - return G.host.app.expand("{media}/icons/muchoslava/png/" + icon_name + "_30.png") + def getSymbol(self): + if self.chat.otr_state_encryption == OTR_STATE_UNENCRYPTED: + return 'lock-open' + elif self.chat.otr_state_trust == OTR_STATE_TRUSTED: + return 'lock-filled' + else: + return 'lock' class OtrMenu(DropDown): @@ -445,7 +448,8 @@ else: log.error(_(u"Unknown OTR state received: {}".format(state))) return - self.encryption_btn.source = self.encryption_btn.getIconSource() + self.encryption_btn.symbol = self.encryption_btn.getSymbol() + self.encryption_btn.color = self.encryption_btn.getColor() def onDelete(self, force=False): if force==True: