comparison src/browser/sat_browser/contact.py @ 510:db3436c85fb1

browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
author souliane <souliane@mailoo.org>
date Thu, 21 Aug 2014 16:44:39 +0200
parents 60be99de3808
children 3d8e8f693576
comparison
equal deleted inserted replaced
509:35ccb3ff8245 510:db3436c85fb1
37 import base_widget 37 import base_widget
38 import panels 38 import panels
39 import html_tools 39 import html_tools
40 40
41 41
42 def setPresenceStyle(widget, presence, base_style="contactLabel"): 42 def buildPresenceStyle(presence, base_style=None):
43 """Return the CSS classname to be used for displaying the given presence information.
44 @param presence (str): presence is a value in ('', 'chat', 'away', 'dnd', 'xa')
45 @param base_style (str): base classname
46 @return: str
47 """
48 if not base_style:
49 base_style = "contactLabel"
50 return '%s-%s' % (base_style, presence or 'connected')
51
52
53 def setPresenceStyle(widget, presence, base_style=None):
43 """ 54 """
44 Set the CSS style of a contact's element according to its presence. 55 Set the CSS style of a contact's element according to its presence.
45 56
46 @param widget (Widget): the UI element of the contact 57 @param widget (Widget): the UI element of the contact
47 @param presence (str): a value in ("", "chat", "away", "dnd", "xa"). 58 @param presence (str): a value in ("", "chat", "away", "dnd", "xa").
48 @param base_style (str): the base name of the style to apply 59 @param base_style (str): the base name of the style to apply
49 """ 60 """
50 if not hasattr(widget, 'presence_style'): 61 if not hasattr(widget, 'presence_style'):
51 widget.presence_style = None 62 widget.presence_style = None
52 style = '%s-%s' % (base_style, presence or 'connected') 63 style = buildPresenceStyle(presence, base_style)
53 if style == widget.presence_style: 64 if style == widget.presence_style:
54 return 65 return
55 if widget.presence_style is not None: 66 if widget.presence_style is not None:
56 widget.removeStyleName(widget.presence_style) 67 widget.removeStyleName(widget.presence_style)
57 widget.addStyleName(style) 68 widget.addStyleName(style)