# HG changeset patch # User Goffi # Date 1523023988 -7200 # Node ID 091e288838e1f87fe745daa7a3da1f876e7e9abc # Parent 1cca97e27a691862b7438a160d5157e0ac058f9c plugin chat: use new Symbol widget to display encryption button diff -r 1cca97e27a69 -r 091e288838e1 cagou/core/common.py --- a/cagou/core/common.py Fri Apr 06 16:13:08 2018 +0200 +++ b/cagou/core/common.py Fri Apr 06 16:13:08 2018 +0200 @@ -75,3 +75,7 @@ log.warning(_(u"Invalid symbol {symbol}").format(symbol=symbol)) else: self.text = unichr(code) + + +class SymbolButton(ButtonBehavior, Symbol): + pass diff -r 1cca97e27a69 -r 091e288838e1 cagou/plugins/plugin_wid_chat.kv --- a/cagou/plugins/plugin_wid_chat.kv Fri Apr 06 16:13:08 2018 +0200 +++ b/cagou/plugins/plugin_wid_chat.kv Fri Apr 06 16:13:08 2018 +0200 @@ -126,8 +126,8 @@ : size_hint: None, 1 width: dp(30) - allow_stretch: True - source: self.getIconSource() + color: self.getColor() + symbol: self.getSymbol() : size_hint: None, None diff -r 1cca97e27a69 -r 091e288838e1 cagou/plugins/plugin_wid_chat.py --- 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: