comparison browser_side/panels.py @ 55:d5266c41ca24

Roster list update, contact deletion + some refactoring
author Goffi <goffi@goffi.org>
date Sun, 29 May 2011 02:13:53 +0200
parents f25c4077f6b9
children 5fa710058e2d
comparison
equal deleted inserted replaced
54:f25c4077f6b9 55:d5266c41ca24
77 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract")) 77 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract"))
78 menu_general.addItem("About", MenuCmd(self, "onAbout")) 78 menu_general.addItem("About", MenuCmd(self, "onAbout"))
79 79
80 menu_contacts = MenuBar(vertical=True) 80 menu_contacts = MenuBar(vertical=True)
81 menu_contacts.addItem("add contact", MenuCmd(self, "onAddContact")) 81 menu_contacts.addItem("add contact", MenuCmd(self, "onAddContact"))
82 menu_contacts.addItem("update contact", MenuCmd(self, "onUpdateContact"))
83 menu_contacts.addItem("remove contact", MenuCmd(self, "onRemoveContact"))
82 84
83 menu_group = MenuBar(vertical=True) 85 menu_group = MenuBar(vertical=True)
84 menu_group.addItem("join room", MenuCmd(self, "onJoinRoom")) 86 menu_group.addItem("join room", MenuCmd(self, "onJoinRoom"))
85 87
86 menu_games = MenuBar(vertical=True) 88 menu_games = MenuBar(vertical=True)
130 label = Label("new contact identifier (JID):") 132 label = Label("new contact identifier (JID):")
131 edit.setText('@libervia.org') 133 edit.setText('@libervia.org')
132 edit.setWidth('100%') 134 edit.setWidth('100%')
133 _dialog = dialog.GroupSelector([label, edit], self.host.contact_panel.getGroups(), [], addContactCb) 135 _dialog = dialog.GroupSelector([label, edit], self.host.contact_panel.getGroups(), [], addContactCb)
134 _dialog.setHTML('<b>Adding contact</b>') 136 _dialog.setHTML('<b>Adding contact</b>')
137 _dialog.show()
138
139 def onUpdateContact(self):
140 pass
141
142 def onRemoveContact(self):
143 _dialog = None
144 _contacts_list = ListBox()
145
146 def secondConfirmCb(confirm):
147 if confirm:
148 for contact in _contacts_list.getSelectedValues():
149 self.host.bridge.call('delContact', None, contact)
150 else:
151 _dialog.show()
152
153 def dialogCb(confirm):
154 if confirm:
155 html_list = ''.join(['<li>%s</li>' % html_sanitize(contact) for contact in _contacts_list.getSelectedValues()])
156 html_body = "Are you sure to remove the following contacts from your contact list ?<ul>%s</ul>" % html_list
157 dialog.ConfirmDialog(secondConfirmCb, html_body).show()
158
159 for contact in self.host.contact_panel.getContacts():
160 _contacts_list.addItem(contact)
161 _dialog = dialog.GenericConfirmDialog([_contacts_list], dialogCb, "Who do you want to remove from your contacts ?")
135 _dialog.show() 162 _dialog.show()
136 163
137 #Group menu 164 #Group menu
138 def onJoinRoom(self): 165 def onJoinRoom(self):
139 _dialog = None 166 _dialog = None
311 self.host = host 338 self.host = host
312 339
313 def addKey(self, key): 340 def addKey(self, key):
314 self.getCompletionItems().completions.append(key) 341 self.getCompletionItems().completions.append(key)
315 342
343 def removeKey(self, key):
344 try:
345 self.getCompletionItems().completions.remove(key)
346 except KeyError:
347 print "WARNING: trying to remove an unknown key"
348
349
316 def showWarning(self, target_data): 350 def showWarning(self, target_data):
317 type, target = target_data 351 type, target = target_data
318 if type == "PUBLIC": 352 if type == "PUBLIC":
319 msg = "This message will be PUBLIC and everybody will be able to see it, even people you don't know" 353 msg = "This message will be PUBLIC and everybody will be able to see it, even people you don't know"
320 style = "targetPublic" 354 style = "targetPublic"