diff 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
line wrap: on
line diff
--- a/browser_side/contact.py	Fri Nov 15 15:34:57 2013 +0100
+++ b/browser_side/contact.py	Mon Nov 11 10:44:44 2013 +0100
@@ -50,7 +50,7 @@
 
 
 class ContactLabel(DragLabel, HTML, ClickHandler):
-    def __init__(self, host, jid, name=None):
+    def __init__(self, host, jid, name=None, handleClick=True):
         HTML.__init__(self)
         self.host = host
         self.name = name or jid
@@ -59,8 +59,9 @@
         self._fill()
         self.setStyleName('contact')
         DragLabel.__init__(self, jid, "CONTACT")
-        ClickHandler.__init__(self)
-        self.addClickListener(self)
+        if handleClick:
+            ClickHandler.__init__(self)
+            self.addClickListener(self)
 
     def _fill(self):
         if self.waiting:
@@ -107,10 +108,11 @@
     the one that is displayed on the left side. Special features like popup menu
     panel or changing the contact states must be done in a sub-class."""
 
-    def __init__(self, host):
+    def __init__(self, host, handleClick=False):
         VerticalPanel.__init__(self)
         self.host = host
         self.contacts = []
+        self.handleClick = handleClick
 
     def add(self, jid, name=None, item_cb=None):
         if jid in self.contacts:
@@ -121,7 +123,7 @@
                 break
             index += 1
         self.contacts.insert(index, jid)
-        _item = ContactLabel(self.host, jid, name)
+        _item = ContactLabel(self.host, jid, name, handleClick=self.handleClick)
         DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer")
         VerticalPanel.insert(self, _item, index)
         if item_cb is not None:
@@ -154,7 +156,7 @@
     """The contact list that is displayed on the left side."""
 
     def __init__(self, host):
-        GenericContactList.__init__(self, host)
+        GenericContactList.__init__(self, host, handleClick=True)
         self.menu_entries = {"blog": {"title": "Public blog..."}}
         self.context_menu = PopupMenuPanel(entries=self.menu_entries,
                                            hide=self.contextMenuHide,