Mercurial > libervia-web
comparison src/browser/sat_browser/contact.py @ 485:5911f71acc80
browser side: move contacts list's avatar from right to top
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 18 Jun 2014 13:06:09 +0200 |
parents | 50b286866739 |
children | 587fe75d1b16 |
comparison
equal
deleted
inserted
replaced
484:ae86b32b959c | 485:5911f71acc80 |
---|---|
71 | 71 |
72 def onClick(self, sender): | 72 def onClick(self, sender): |
73 self.host.getOrCreateLiberviaWidget(panels.MicroblogPanel, self.group) | 73 self.host.getOrCreateLiberviaWidget(panels.MicroblogPanel, self.group) |
74 | 74 |
75 | 75 |
76 class ContactLabel(base_widget.DragLabel, HTML, ClickHandler): | 76 class ContactLabel(HTML): |
77 def __init__(self, host, jid, name=None, handleClick=True): | 77 def __init__(self, jid, name=None): |
78 HTML.__init__(self) | 78 HTML.__init__(self) |
79 self.host = host | |
80 self.name = name or jid | 79 self.name = name or jid |
81 self.waiting = False | 80 self.waiting = False |
82 self.jid = jid | |
83 self.refresh() | 81 self.refresh() |
84 self.setStyleName('contactLabel') | 82 self.setStyleName('contactLabel') |
85 base_widget.DragLabel.__init__(self, jid, "CONTACT") | |
86 if handleClick: | |
87 ClickHandler.__init__(self) | |
88 self.addClickListener(self) | |
89 | 83 |
90 def refresh(self): | 84 def refresh(self): |
91 if self.waiting: | 85 if self.waiting: |
92 wait_html = "<b>(*)</b> " | 86 wait_html = "<b>(*)</b> " |
93 self.setHTML("%(wait)s%(name)s" % {'wait': wait_html, | 87 self.setHTML("%(wait)s%(name)s" % {'wait': wait_html, |
98 | 92 |
99 @param waiting: True if message are waiting""" | 93 @param waiting: True if message are waiting""" |
100 self.waiting = waiting | 94 self.waiting = waiting |
101 self.refresh() | 95 self.refresh() |
102 | 96 |
97 | |
98 class ContactBox(base_widget.DragLabel, VerticalPanel, ClickHandler): | |
99 def __init__(self, host, jid, name=None, handleClick=True): | |
100 VerticalPanel.__init__(self, StyleName='contactBox', VerticalAlignment='middle') | |
101 base_widget.DragLabel.__init__(self, jid, "CONTACT") | |
102 self.host = host | |
103 self.jid = jid | |
104 self.label = ContactLabel(jid, name) | |
105 self.avatar = Image() | |
106 self.updateAvatar(host.getAvatar(jid)) | |
107 self.add(self.avatar) | |
108 self.add(self.label) | |
109 if handleClick: | |
110 ClickHandler.__init__(self) | |
111 self.addClickListener(self) | |
112 | |
113 def setMessageWaiting(self, waiting): | |
114 """Show a visual indicator if message are waiting | |
115 | |
116 @param waiting: True if message are waiting""" | |
117 self.label.setMessageWaiting(waiting) | |
118 | |
119 def updateAvatar(self, url): | |
120 """Update the avatar | |
121 | |
122 @param url (str): image url | |
123 """ | |
124 self.avatar.setVisible(url != C.DEFAULT_AVATAR) | |
125 self.avatar.setUrl(url) | |
126 | |
103 def onClick(self, sender): | 127 def onClick(self, sender): |
104 self.host.getOrCreateLiberviaWidget(panels.ChatPanel, self.jid) | 128 self.host.getOrCreateLiberviaWidget(panels.ChatPanel, self.jid) |
105 | |
106 | |
107 class ContactBox(HorizontalPanel): | |
108 def __init__(self, host, jid, name=None, handleClick=True): | |
109 HorizontalPanel.__init__(self, StyleName='contactBox', VerticalAlignment='middle') | |
110 self.jid = jid | |
111 self.label = ContactLabel(host, jid, name, handleClick) | |
112 self.avatar = Image() | |
113 self.updateAvatar(host.getAvatar(jid)) | |
114 self.add(self.label) | |
115 spacer = Label(' ') | |
116 self.add(spacer) | |
117 self.setCellWidth(spacer, '100%') | |
118 self.add(self.avatar) | |
119 self.setCellHorizontalAlignment(self.avatar, 'right') | |
120 | |
121 def setMessageWaiting(self, waiting): | |
122 """Show a visual indicator if message are waiting | |
123 | |
124 @param waiting: True if message are waiting""" | |
125 self.label.setMessageWaiting(waiting) | |
126 | |
127 def updateAvatar(self, url): | |
128 """Update the avatar | |
129 | |
130 @param url (str): image url | |
131 """ | |
132 self.avatar.setVisible(url != C.DEFAULT_AVATAR) | |
133 self.avatar.setUrl(url) | |
134 | 129 |
135 | 130 |
136 class GroupList(VerticalPanel): | 131 class GroupList(VerticalPanel): |
137 | 132 |
138 def __init__(self, parent): | 133 def __init__(self, parent): |