changeset 3164:9dc170635bee

quick frontend(app): added listener for selected widget
author Goffi <goffi@goffi.org>
date Mon, 10 Feb 2020 22:02:31 +0100
parents d10b2368684e
children 7699a08ba8fb
files sat_frontends/quick_frontend/constants.py sat_frontends/quick_frontend/quick_app.py
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/quick_frontend/constants.py	Mon Feb 10 22:01:53 2020 +0100
+++ b/sat_frontends/quick_frontend/constants.py	Mon Feb 10 22:02:31 2020 +0100
@@ -98,6 +98,7 @@
         "avatar",
         "nick",
         "presence",
+        "selected",
         "profilePlugged",
         "contactsFilled",
         "disconnect",
--- a/sat_frontends/quick_frontend/quick_app.py	Mon Feb 10 22:01:53 2020 +0100
+++ b/sat_frontends/quick_frontend/quick_app.py	Mon Feb 10 22:02:31 2020 +0100
@@ -1,6 +1,5 @@
 #!/usr/bin/env python3
 
-
 # helper class for making a SAT frontend
 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
 
@@ -450,6 +449,8 @@
 
         Must be set by frontend
         """
+        if self._selected_widget == wid:
+            return
         self._selected_widget = wid
         try:
             onSelected = wid.onSelected
@@ -458,6 +459,8 @@
         else:
             onSelected()
 
+        self.callListeners("selected", wid)
+
     # backend state management
 
     @property
@@ -554,6 +557,8 @@
                 args: (entity, new_nick, profile)
             - presence: called when a presence is received
                 args: (entity, show, priority, statuses, profile)
+            - selected: called when a widget is selected
+                args: (selected_widget,)
             - notification: called when a new notification is emited
                 args: (entity, notification_data, profile)
             - notification_clear: called when notifications are cleared