From f16e277e8feb9509bff05b86679fb445a274beaf Mon Sep 17 00:00:00 2001 From: souliane Date: Tue, 12 Jan 2016 17:54:38 +0100 Subject: [PATCH] quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed): - for now this is only used by Libervia --- frontends/src/primitivus/primitivus | 7 +++++++ frontends/src/quick_frontend/quick_app.py | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/frontends/src/primitivus/primitivus b/frontends/src/primitivus/primitivus index acda14b6..f21b024c 100755 --- a/frontends/src/primitivus/primitivus +++ b/frontends/src/primitivus/primitivus @@ -479,6 +479,13 @@ class PrimitivusApp(QuickApp, InputHistory): else: del self._early_popup + def isHidden(self): + """Tells if the frontend window is hidden. + + @return bool + """ + return False # FIXME: implement when necessary + def alert(self, title, message): """Shortcut method to create an alert message diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 8b46b199..4d1a1f7d 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -516,7 +516,10 @@ class QuickApp(object): if isinstance(widget, quick_chat.QuickChat) and widget.manageMessage(from_jid, type_): visible = True break - if not visible: + if visible: + if self.isHidden(): # the window is hidden + self.updateAlertsCounter(extra_inc=1) + else: contact_list.addAlert(from_jid.bare if type_ == C.MESS_TYPE_GROUPCHAT else from_jid) def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key=C.PROF_KEY_NONE): @@ -701,9 +704,17 @@ class QuickApp(object): """Callback used when an action result in a progress id""" log.info(u"Progress ID received: {}".format(progress_id)) - def updateAlertsCounter(self): - """Update the over whole alerts counter + def isHidden(self): + """Tells if the frontend window is hidden. + @return bool + """ + raise NotImplementedError + + def updateAlertsCounter(self, extra_inc=0): + """Update the over whole alerts counter. + + @param extra_inc (int): extra counter """ pass