Mercurial > libervia-web
changeset 543:d02335553b5d
browser_side (plugin OTR): display OTR states with icons instead of a text
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 08 Sep 2014 15:32:33 +0200 |
parents | fb20b1423143 |
children | ad18eb65b6db |
files | src/browser/public/libervia.css src/browser/sat_browser/base_widget.py src/browser/sat_browser/panels.py src/browser/sat_browser/plugin_sec_otr.py |
diffstat | 4 files changed, 36 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/public/libervia.css Mon Sep 08 14:54:47 2014 +0200 +++ b/src/browser/public/libervia.css Mon Sep 08 15:32:33 2014 +0200 @@ -748,8 +748,16 @@ .widgetHeader_info { position: absolute; right: 90px; # FIXME: temporary dirty setting to fit a header menu with 3 icon buttons - margin-top: 4px !important; - color: white !important; + color: white; + background-color: white; + border-radius: 5px; + padding: 0px 4px; + top: 2px !important; +} + +.widgetHeader_info img { + padding: 2px; + height: 16px; } .widgetHeader_buttonsWrapper {
--- a/src/browser/sat_browser/base_widget.py Mon Sep 08 14:54:47 2014 +0200 +++ b/src/browser/sat_browser/base_widget.py Mon Sep 08 15:32:33 2014 +0200 @@ -29,6 +29,7 @@ from pyjamas.ui.TabPanel import TabPanel from pyjamas.ui.HTMLPanel import HTMLPanel from pyjamas.ui.Label import Label +from pyjamas.ui.HTML import HTML from pyjamas.ui.Button import Button from pyjamas.ui.Widget import Widget from pyjamas.ui.DragWidget import DragWidget @@ -204,7 +205,7 @@ """ @param parent (LiberviaWidget): LiberWidget instance @param host (SatWebFrontend): SatWebFrontend instance - @param title (Widget): text widget instance + @param title (Label, HTML): text widget instance @param info (Widget): text widget instance """ AbsolutePanel.__init__(self) @@ -244,7 +245,7 @@ self.__title = Label(title) self.__title.setStyleName('widgetHeader_title') if info: - self.__info = Label(info) + self.__info = HTML(info) self.__info.setStyleName('widgetHeader_info') else: self.__info = None @@ -392,7 +393,7 @@ """change the info in the header of the widget @param text: text of the new title""" try: - self.__info.setText(text) + self.__info.setHTML(text) except AttributeError: log.error("LiberviaWidget.setInfo: info widget has not been initialized!")
--- a/src/browser/sat_browser/panels.py Mon Sep 08 14:54:47 2014 +0200 +++ b/src/browser/sat_browser/panels.py Mon Sep 08 15:32:33 2014 +0200 @@ -1121,7 +1121,7 @@ self.type = type_ # FIXME: temporary dirty initialization to display the OTR state - header_info = _('Encryption: none') if type_ == 'one2one' else None + header_info = host.plugins['otr'].getInfoText() if type_ == 'one2one' else None base_widget.LiberviaWidget.__init__(self, host, title=target.bare, info=header_info, selectable=True) self.__body = AbsolutePanel()
--- a/src/browser/sat_browser/plugin_sec_otr.py Mon Sep 08 14:54:47 2014 +0200 +++ b/src/browser/sat_browser/plugin_sec_otr.py Mon Sep 08 15:32:33 2014 +0200 @@ -96,11 +96,20 @@ 'WHITESPACE_START_AKE': False, # FIXME: we need to complete messageReceivedTrigger before turning this to True } -# list a couple of texts (untrusted, trusted) for each state +# list a couple of texts or htmls (untrusted, trusted) for each state OTR_MSG_STATES = { - otr.context.STATE_PLAINTEXT: [_('none'), _('none')], - otr.context.STATE_ENCRYPTED: [_('untrusted'), _('trusted')], - otr.context.STATE_FINISHED: [_('finished'), _('finished')] + otr.context.STATE_PLAINTEXT: [ + '<img src="media/icons/silk/lock_open.png" /><img src="media/icons/silk/key_delete.png" />', + '<img src="media/icons/silk/lock_open.png" /><img src="media/icons/silk/key.png" />' + ], + otr.context.STATE_ENCRYPTED: [ + '<img src="media/icons/silk/lock.png" /><img src="media/icons/silk/key_delete.png" />', + '<img src="media/icons/silk/lock.png" /><img src="media/icons/silk/key.png" />' + ], + otr.context.STATE_FINISHED: [ + '<img src="media/icons/silk/lock_break.png" /><img src="media/icons/silk/key_delete.png" />', + '<img src="media/icons/silk/lock_break.png" /><img src="media/icons/silk/key.png" />' + ] } @@ -153,12 +162,6 @@ def messageErrorCb(self, error): log.error('error occured: %s' % error) - @classmethod - def getInfoText(self, state='', trust=''): - if not state: - state = OTR_MSG_STATES.keys()[0] - return 'Encryption: %s' % OTR_MSG_STATES[state][1 if trust else 0] - def setStateCb(self, msg_state, status): if status == otr.context.STATUS_AKE_INIT: return @@ -182,7 +185,7 @@ elif msg_state == otr.context.STATE_FINISHED: feedback = END_FINISHED - self.host.newMessageCb(self.peer, feedback.format(jid=other_jid_s), C.MESS_TYPE_INFO, self.host.whoami, {'header_info': Context.getInfoText(msg_state, trust)}) + self.host.newMessageCb(self.peer, feedback.format(jid=other_jid_s), C.MESS_TYPE_INFO, self.host.whoami, {'header_info': OTR.getInfoText(msg_state, trust)}) def setCurrentTrust(self, new_trust='', act='asked', type_='trust'): log.debug("setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act)) @@ -205,7 +208,7 @@ otr.context.Context.setCurrentTrust(self, new_trust) if old_trust != new_trust: feedback = AUTH_STATUS.format(state=(AUTH_TRUSTED if new_trust else AUTH_UNTRUSTED).lower()) - self.host.newMessageCb(self.peer, feedback, C.MESS_TYPE_INFO, self.host.whoami, {'header_info': Context.getInfoText(self.state, new_trust)}) + self.host.newMessageCb(self.peer, feedback, C.MESS_TYPE_INFO, self.host.whoami, {'header_info': OTR.getInfoText(self.state, new_trust)}) def fingerprintAuthCb(self): """OTR v2 authentication using manual fingerprint comparison""" @@ -349,6 +352,12 @@ self.last_resources = {} self.host.bridge._registerMethods(["skipOTR"]) + @classmethod + def getInfoText(self, state=otr.context.STATE_PLAINTEXT, trust=''): + if not state: + state = OTR_MSG_STATES.keys()[0] + return OTR_MSG_STATES[state][1 if trust else 0] + def inhibitMenus(self): """Tell the caller which dynamic menus should be inhibited""" return ["OTR"] # menu categories name to inhibit