diff contact.py @ 16:099c05a0dcab

browser side: microblog panel improvments - panels can now be changed by DnD - contacts panel's title can be used by DnD for the global microblog panel - microblogs now appear in reverse order (from bottom to top) - MicroblogPanel now use a ScrollPanel and 100% space - user's message now appear in correct group when using groupblog - MagicBox renamed to UniBox
author Goffi <goffi@goffi.org>
date Fri, 15 Apr 2011 02:01:34 +0200
parents 0110d4e1d816
children
line wrap: on
line diff
--- a/contact.py	Sat Apr 09 13:14:39 2011 +0200
+++ b/contact.py	Fri Apr 15 02:01:34 2011 +0200
@@ -31,19 +31,19 @@
 from pyjamas.ui.DragWidget import DragWidget, DragContainer
 from tools.jid import JID
 
-class GroupLabel(DragWidget, Label):
-    def __init__(self, group):
-        Label.__init__(self, group) #, Element=DOM.createElement('div')
-        self.group = group
-        self.setStyleName('group')
+class DragLabel(DragWidget):
+
+    def __init__(self, text, type):
         DragWidget.__init__(self)
+        self._text = text
+        self._type = type
     
     def onDragStart(self, event):
         print "onDragStart"
         dt = event.dataTransfer
         #self.addMessage('types is %s' % dt.getTypes())
-        dt.setData('Text', self.group)
-        dt.setData('type', "GROUP")
+        dt.setData('Text', self._text)
+        dt.setData('type', self._type)
         #self.addMessage('after setting, len is %s' % len(dt.dataStore.items))
         #self.addMessage('types is %s' % dt.getTypes())
         dt.setDragImage(self.getElement(), 15, 15)
@@ -62,6 +62,14 @@
         #    parent = parent.getParent()
         #parent.addMessage(message)
 
+class GroupLabel(DragLabel, Label):
+    def __init__(self, group):
+        self.group = group
+        Label.__init__(self, group) #, Element=DOM.createElement('div')
+        self.setStyleName('group')
+        DragLabel.__init__(self, group, "GROUP")
+    
+
 class ContactLabel(Label):
     def __init__(self, jid, name=None):
         if not name:
@@ -97,6 +105,12 @@
         VerticalPanel.add(self, _item)
         self.contacts.append(_item)
 
+class ContactTitleLabel(DragLabel, Label):
+    def __init__(self, text):
+        Label.__init__(self, text) #, Element=DOM.createElement('div')
+        self.setStyleName('contactTitle')
+        DragLabel.__init__(self, text, "CONTACT")
+
 class ContactPanel(SimplePanel):
     """Manage the contacts and groups"""
     
@@ -106,8 +120,8 @@
         self.groups={}
 
         self.vPanel = VerticalPanel()
-        _title = Label('Contacts')
-        _title.setStyleName('contactTitle')
+        _title = ContactTitleLabel('Contacts')
+        DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer")
 
         self._contactList = ContactList()
         self._contactList.setStyleName('contactList')
@@ -129,7 +143,7 @@
             if not self.groups.has_key(group):
                 self.groups[group] = set()
                 self._groupList.add(group)
-                self.host.magicBox.addKey("@%s: " % group)
+                self.host.uniBox.addKey("@%s: " % group)
             self.groups[group].add(jid)
         self._contactList.add(jid)