comparison browser_side/panels.py @ 402:d7e78cb78dfc

browser_side: HTMLTextEditor and LightTextEditor factorization
author souliane <souliane@mailoo.org>
date Thu, 13 Mar 2014 16:05:35 +0100
parents ea03f898067f
children c393e7dc9ae6
comparison
equal deleted inserted replaced
401:ea03f898067f 402:d7e78cb78dfc
942 if self.host.contact_panel.isContactInGroup(group, jid): 942 if self.host.contact_panel.isContactInGroup(group, jid):
943 return True 943 return True
944 return False 944 return False
945 945
946 946
947 class StatusPanel(HTMLTextEditor, ClickHandler): 947 class StatusPanel(HTMLTextEditor):
948 948
949 EMPTY_STATUS = '&lt;click to set a status&gt;' 949 EMPTY_STATUS = '&lt;click to set a status&gt;'
950 950
951 def __init__(self, host, status=''): 951 def __init__(self, host, status=''):
952 self.host = host 952 self.host = host
953 modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True 953 modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True
954 HTMLTextEditor.__init__(self, {'text': status}, modifiedCb, None, single_line=True) 954 HTMLTextEditor.__init__(self, {'text': status}, modifiedCb, None, single_line=True, listen_click=True)
955 self.edit(False) 955 self.edit(False)
956 self.setStyleName('statusPanel') 956 self.setStyleName('statusPanel')
957 ClickHandler.__init__(self)
958 self.addClickListener(self)
959 957
960 @property 958 @property
961 def status(self): 959 def status(self):
962 return self._original_content['text'] 960 return self._original_content['text']
963 961
983 if not status: 981 if not status:
984 if presence and presence in Const.PRESENCE: 982 if presence and presence in Const.PRESENCE:
985 status = Const.PRESENCE[presence] 983 status = Const.PRESENCE[presence]
986 else: 984 else:
987 status = self.EMPTY_STATUS 985 status = self.EMPTY_STATUS
988 self.setHTML(addURLToText(status)) 986 self.display.setHTML(addURLToText(status))
989
990 def onClick(self, sender):
991 self.edit(True)
992 987
993 988
994 class PresenceStatusPanel(HorizontalPanel, ClickHandler): 989 class PresenceStatusPanel(HorizontalPanel, ClickHandler):
995 990
996 def __init__(self, host, presence="", status=""): 991 def __init__(self, host, presence="", status=""):