Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
15:78bfc398926b | 16:099c05a0dcab |
---|---|
29 | 29 |
30 from pyjamas.dnd import makeDraggable | 30 from pyjamas.dnd import makeDraggable |
31 from pyjamas.ui.DragWidget import DragWidget, DragContainer | 31 from pyjamas.ui.DragWidget import DragWidget, DragContainer |
32 from tools.jid import JID | 32 from tools.jid import JID |
33 | 33 |
34 class GroupLabel(DragWidget, Label): | 34 class DragLabel(DragWidget): |
35 def __init__(self, group): | 35 |
36 Label.__init__(self, group) #, Element=DOM.createElement('div') | 36 def __init__(self, text, type): |
37 self.group = group | |
38 self.setStyleName('group') | |
39 DragWidget.__init__(self) | 37 DragWidget.__init__(self) |
38 self._text = text | |
39 self._type = type | |
40 | 40 |
41 def onDragStart(self, event): | 41 def onDragStart(self, event): |
42 print "onDragStart" | 42 print "onDragStart" |
43 dt = event.dataTransfer | 43 dt = event.dataTransfer |
44 #self.addMessage('types is %s' % dt.getTypes()) | 44 #self.addMessage('types is %s' % dt.getTypes()) |
45 dt.setData('Text', self.group) | 45 dt.setData('Text', self._text) |
46 dt.setData('type', "GROUP") | 46 dt.setData('type', self._type) |
47 #self.addMessage('after setting, len is %s' % len(dt.dataStore.items)) | 47 #self.addMessage('after setting, len is %s' % len(dt.dataStore.items)) |
48 #self.addMessage('types is %s' % dt.getTypes()) | 48 #self.addMessage('types is %s' % dt.getTypes()) |
49 dt.setDragImage(self.getElement(), 15, 15) | 49 dt.setDragImage(self.getElement(), 15, 15) |
50 #dt.effectAllowed = 'copy' | 50 #dt.effectAllowed = 'copy' |
51 #self.addMessage('mode is %s' % dt.dataStore.items.mode) | 51 #self.addMessage('mode is %s' % dt.dataStore.items.mode) |
59 print "addMessage" | 59 print "addMessage" |
60 #parent = self.getParent() | 60 #parent = self.getParent() |
61 #while not hasattr(parent, 'addMessage'): | 61 #while not hasattr(parent, 'addMessage'): |
62 # parent = parent.getParent() | 62 # parent = parent.getParent() |
63 #parent.addMessage(message) | 63 #parent.addMessage(message) |
64 | |
65 class GroupLabel(DragLabel, Label): | |
66 def __init__(self, group): | |
67 self.group = group | |
68 Label.__init__(self, group) #, Element=DOM.createElement('div') | |
69 self.setStyleName('group') | |
70 DragLabel.__init__(self, group, "GROUP") | |
71 | |
64 | 72 |
65 class ContactLabel(Label): | 73 class ContactLabel(Label): |
66 def __init__(self, jid, name=None): | 74 def __init__(self, jid, name=None): |
67 if not name: | 75 if not name: |
68 name=jid | 76 name=jid |
95 _item = ContactLabel(jid, name) | 103 _item = ContactLabel(jid, name) |
96 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") | 104 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") |
97 VerticalPanel.add(self, _item) | 105 VerticalPanel.add(self, _item) |
98 self.contacts.append(_item) | 106 self.contacts.append(_item) |
99 | 107 |
108 class ContactTitleLabel(DragLabel, Label): | |
109 def __init__(self, text): | |
110 Label.__init__(self, text) #, Element=DOM.createElement('div') | |
111 self.setStyleName('contactTitle') | |
112 DragLabel.__init__(self, text, "CONTACT") | |
113 | |
100 class ContactPanel(SimplePanel): | 114 class ContactPanel(SimplePanel): |
101 """Manage the contacts and groups""" | 115 """Manage the contacts and groups""" |
102 | 116 |
103 def __init__(self, host): | 117 def __init__(self, host): |
104 SimplePanel.__init__(self) | 118 SimplePanel.__init__(self) |
105 self.host = host | 119 self.host = host |
106 self.groups={} | 120 self.groups={} |
107 | 121 |
108 self.vPanel = VerticalPanel() | 122 self.vPanel = VerticalPanel() |
109 _title = Label('Contacts') | 123 _title = ContactTitleLabel('Contacts') |
110 _title.setStyleName('contactTitle') | 124 DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer") |
111 | 125 |
112 self._contactList = ContactList() | 126 self._contactList = ContactList() |
113 self._contactList.setStyleName('contactList') | 127 self._contactList.setStyleName('contactList') |
114 self._groupList = GroupList(self) | 128 self._groupList = GroupList(self) |
115 self._groupList.setStyleName('groupList') | 129 self._groupList.setStyleName('groupList') |
127 @param groups: list of groups""" | 141 @param groups: list of groups""" |
128 for group in groups: | 142 for group in groups: |
129 if not self.groups.has_key(group): | 143 if not self.groups.has_key(group): |
130 self.groups[group] = set() | 144 self.groups[group] = set() |
131 self._groupList.add(group) | 145 self._groupList.add(group) |
132 self.host.magicBox.addKey("@%s: " % group) | 146 self.host.uniBox.addKey("@%s: " % group) |
133 self.groups[group].add(jid) | 147 self.groups[group].add(jid) |
134 self._contactList.add(jid) | 148 self._contactList.add(jid) |
135 | 149 |
136 def isContactInGroup(self, group, contact_jid): | 150 def isContactInGroup(self, group, contact_jid): |
137 """Test if the contact_jid is in the group | 151 """Test if the contact_jid is in the group |