Mercurial > libervia-web
comparison browser_side/contact.py @ 262:30c01671e338
browser_side: small changes for contact list and "add group" panel:
- GenericContactList get a boolean argument "handleClick" to enable/disable the click handler at instanciation
- textbox in "add group" panel can be accessed from outside
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 11 Nov 2013 10:44:44 +0100 |
parents | da0487f0a2e7 |
children | 56a307f08ffe |
comparison
equal
deleted
inserted
replaced
261:3df0c3634c29 | 262:30c01671e338 |
---|---|
48 def onClick(self, sender): | 48 def onClick(self, sender): |
49 self.host.getOrCreateLiberviaWidget(MicroblogPanel, self.group) | 49 self.host.getOrCreateLiberviaWidget(MicroblogPanel, self.group) |
50 | 50 |
51 | 51 |
52 class ContactLabel(DragLabel, HTML, ClickHandler): | 52 class ContactLabel(DragLabel, HTML, ClickHandler): |
53 def __init__(self, host, jid, name=None): | 53 def __init__(self, host, jid, name=None, handleClick=True): |
54 HTML.__init__(self) | 54 HTML.__init__(self) |
55 self.host = host | 55 self.host = host |
56 self.name = name or jid | 56 self.name = name or jid |
57 self.waiting = False | 57 self.waiting = False |
58 self.jid = jid | 58 self.jid = jid |
59 self._fill() | 59 self._fill() |
60 self.setStyleName('contact') | 60 self.setStyleName('contact') |
61 DragLabel.__init__(self, jid, "CONTACT") | 61 DragLabel.__init__(self, jid, "CONTACT") |
62 ClickHandler.__init__(self) | 62 if handleClick: |
63 self.addClickListener(self) | 63 ClickHandler.__init__(self) |
64 self.addClickListener(self) | |
64 | 65 |
65 def _fill(self): | 66 def _fill(self): |
66 if self.waiting: | 67 if self.waiting: |
67 _wait_html = "<b>(*)</b> " | 68 _wait_html = "<b>(*)</b> " |
68 self.setHTML("%(wait)s%(name)s" % {'wait': _wait_html, | 69 self.setHTML("%(wait)s%(name)s" % {'wait': _wait_html, |
105 class GenericContactList(VerticalPanel): | 106 class GenericContactList(VerticalPanel): |
106 """Class that can be used to represent a contact list, but not necessarily | 107 """Class that can be used to represent a contact list, but not necessarily |
107 the one that is displayed on the left side. Special features like popup menu | 108 the one that is displayed on the left side. Special features like popup menu |
108 panel or changing the contact states must be done in a sub-class.""" | 109 panel or changing the contact states must be done in a sub-class.""" |
109 | 110 |
110 def __init__(self, host): | 111 def __init__(self, host, handleClick=False): |
111 VerticalPanel.__init__(self) | 112 VerticalPanel.__init__(self) |
112 self.host = host | 113 self.host = host |
113 self.contacts = [] | 114 self.contacts = [] |
115 self.handleClick = handleClick | |
114 | 116 |
115 def add(self, jid, name=None, item_cb=None): | 117 def add(self, jid, name=None, item_cb=None): |
116 if jid in self.contacts: | 118 if jid in self.contacts: |
117 return | 119 return |
118 index = 0 | 120 index = 0 |
119 for contact_ in self.contacts: | 121 for contact_ in self.contacts: |
120 if contact_ > jid: | 122 if contact_ > jid: |
121 break | 123 break |
122 index += 1 | 124 index += 1 |
123 self.contacts.insert(index, jid) | 125 self.contacts.insert(index, jid) |
124 _item = ContactLabel(self.host, jid, name) | 126 _item = ContactLabel(self.host, jid, name, handleClick=self.handleClick) |
125 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") | 127 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") |
126 VerticalPanel.insert(self, _item, index) | 128 VerticalPanel.insert(self, _item, index) |
127 if item_cb is not None: | 129 if item_cb is not None: |
128 item_cb(_item) | 130 item_cb(_item) |
129 | 131 |
152 | 154 |
153 class ContactList(GenericContactList): | 155 class ContactList(GenericContactList): |
154 """The contact list that is displayed on the left side.""" | 156 """The contact list that is displayed on the left side.""" |
155 | 157 |
156 def __init__(self, host): | 158 def __init__(self, host): |
157 GenericContactList.__init__(self, host) | 159 GenericContactList.__init__(self, host, handleClick=True) |
158 self.menu_entries = {"blog": {"title": "Public blog..."}} | 160 self.menu_entries = {"blog": {"title": "Public blog..."}} |
159 self.context_menu = PopupMenuPanel(entries=self.menu_entries, | 161 self.context_menu = PopupMenuPanel(entries=self.menu_entries, |
160 hide=self.contextMenuHide, | 162 hide=self.contextMenuHide, |
161 callback=self.contextMenuCallback, | 163 callback=self.contextMenuCallback, |
162 vertical=False, menu_style="menu") | 164 vertical=False, menu_style="menu") |