comparison frontends/src/quick_frontend/quick_widgets.py @ 1303:d3ef3894254d frontends_multi_profiles

quick frontend (quick_widgets): add deleteWidget method
author Goffi <goffi@goffi.org>
date Fri, 06 Feb 2015 19:03:13 +0100
parents afc57b34c0a3
children 1a61b18703c4
comparison
equal deleted inserted replaced
1302:447d28b1b4ec 1303:d3ef3894254d
191 else: 191 else:
192 log.debug(u"Widget already exists, a new one has been recreated with hash {}".format(new_kwargs['force_hash'])) 192 log.debug(u"Widget already exists, a new one has been recreated with hash {}".format(new_kwargs['force_hash']))
193 break 193 break
194 return widget 194 return widget
195 195
196 def deleteWidget(self, widget_to_delete):
197 """Delete a widget
198
199 widget's onDelete method will be called before deletion
200 """
201 widget_to_delete.onDelete()
202
203 for widget_map in self._widgets.itervalues():
204 for hash_, widget in widget_map.iteritems():
205 if widget_to_delete is widget:
206 del widget_map[hash_]
207
196 208
197 class QuickWidget(object): 209 class QuickWidget(object):
198 """generic widget base""" 210 """generic widget base"""
199 SINGLE=True # if True, there can be only one widget per target(s) 211 SINGLE=True # if True, there can be only one widget per target(s)
200 PROFILES_MULTIPLE=False 212 PROFILES_MULTIPLE=False
259 @param target: target to check 271 @param target: target to check
260 @param profiles: profile(s) associated to target, see __init__ docstring 272 @param profiles: profile(s) associated to target, see __init__ docstring
261 @return: a hash (can correspond to one or many targets or profiles, depending of widget class) 273 @return: a hash (can correspond to one or many targets or profiles, depending of widget class)
262 """ 274 """
263 return unicode(target) # by defaut, there is one hash for one target 275 return unicode(target) # by defaut, there is one hash for one target
276
277 def onDelete(self):
278 """Called when a widget is deleted"""
279 log.debug(u"deleting widget {}".format(self)) # Must be implemented by frontends