changeset 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 447d28b1b4ec
children 1a61b18703c4
files frontends/src/quick_frontend/quick_widgets.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_widgets.py	Fri Feb 06 19:02:10 2015 +0100
+++ b/frontends/src/quick_frontend/quick_widgets.py	Fri Feb 06 19:03:13 2015 +0100
@@ -193,6 +193,18 @@
                         break
         return widget
 
+    def deleteWidget(self, widget_to_delete):
+        """Delete a widget
+
+        widget's onDelete method will be called before deletion
+        """
+        widget_to_delete.onDelete()
+
+        for widget_map in self._widgets.itervalues():
+            for hash_, widget in widget_map.iteritems():
+                if widget_to_delete is widget:
+                    del widget_map[hash_]
+
 
 class QuickWidget(object):
     """generic widget base"""
@@ -261,3 +273,7 @@
         @return: a hash (can correspond to one or many targets or profiles, depending of widget class)
         """
         return unicode(target) # by defaut, there is one hash for one target
+
+    def onDelete(self):
+        """Called when a widget is deleted"""
+        log.debug(u"deleting widget {}".format(self)) # Must be implemented by frontends