quick frontends (widgets): added widgetNew and widgetDelete listeners:
- `widgetNew` is called when a brand new widget is created (not when a new instance is created if there is already an existing one) - `widgetDelete` is called when all instances of a widget (with a given widget_hash) have been deleted.
This commit is contained in:
parent
03204f56b9
commit
aa203d4a49
1 changed files with 13 additions and 4 deletions
|
|
@ -231,9 +231,10 @@ class QuickWidgetsManager(object):
|
|||
|
||||
if widget is None:
|
||||
# we need to create a new widget
|
||||
log.debug("Creating new widget for target {} {}".format(target, cls))
|
||||
log.debug(f"Creating new widget for target {target} {cls}")
|
||||
widget = cls(*_args, **_kwargs)
|
||||
widgets_map.setdefault(hash_, []).append(widget)
|
||||
self.host.callListeners("widgetNew", widget)
|
||||
|
||||
if on_new_widget == C.WIDGET_NEW:
|
||||
self.host.newWidget(widget)
|
||||
|
|
@ -341,6 +342,7 @@ class QuickWidgetsManager(object):
|
|||
del widgets_map[widget_hash]
|
||||
log.debug("All instances of {cls} with hash {widget_hash!r} have been deleted"
|
||||
.format(cls=class_, widget_hash=widget_hash))
|
||||
self.host.callListeners("widgetDeleted", widget_to_delete)
|
||||
|
||||
|
||||
class QuickWidget(object):
|
||||
|
|
|
|||
Loading…
Reference in a new issue