comparison frontends/src/quick_frontend/quick_widgets.py @ 1410:e2e75c3c7c7b

quick_frontend, primitivus: fixes a couple of issues: - chat: notification was raising an error when you just entered the room and self.nick is None - quick_widget: deleting a widget was modifying a dict while looping on it + unselect widget when it's being deleted
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 17:17:28 +0200
parents 069ad98b360d
children d17772b0fe22
comparison
equal deleted inserted replaced
1409:3265a2639182 1410:e2e75c3c7c7b
230 widget's onDelete method will be called before deletion 230 widget's onDelete method will be called before deletion
231 """ 231 """
232 widget_to_delete.onDelete() 232 widget_to_delete.onDelete()
233 233
234 for widget_map in self._widgets.itervalues(): 234 for widget_map in self._widgets.itervalues():
235 to_delete = set()
235 for hash_, widget in widget_map.iteritems(): 236 for hash_, widget in widget_map.iteritems():
236 if widget_to_delete is widget: 237 if widget_to_delete is widget:
237 del widget_map[hash_] 238 to_delete.add(hash_)
239 for hash_ in to_delete:
240 del widget_map[hash_]
238 241
239 242
240 class QuickWidget(object): 243 class QuickWidget(object):
241 """generic widget base""" 244 """generic widget base"""
242 SINGLE=True # if True, there can be only one widget per target(s) 245 SINGLE=True # if True, there can be only one widget per target(s)
306 return unicode(target) # by defaut, there is one hash for one target 309 return unicode(target) # by defaut, there is one hash for one target
307 310
308 def onDelete(self): 311 def onDelete(self):
309 """Called when a widget is deleted""" 312 """Called when a widget is deleted"""
310 log.debug(u"deleting widget {}".format(self)) # Must be implemented by frontends 313 log.debug(u"deleting widget {}".format(self)) # Must be implemented by frontends
314 if self.host.selected_widget == self:
315 self.host.selected_widget = None
316