primitivus: freedesktop notifications (if available) when somebody is talking to us and we have not focus, or our nick is pinged and we have not focus.

This need python-Xlib to work, if it's not present, notification are silently ignored.
This commit is contained in:
Goffi 2011-08-27 17:15:41 +02:00
commit 1b2d81d373

View file

@ -231,6 +231,11 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.content.append(ChatText(self, timestamp or None, nick, mymess, msg))
self.text_list.set_focus(len(self.content)-1)
self.host.redraw()
if not self.host.notify.hasFocus():
if self.type=="one2one":
self.host.notify.sendNotification("Primitivus: %s is talking to you" % from_jid)
elif self.getUserNick().lower() in msg.lower():
self.host.notify.sendNotification("Primitivus: Somebody pinged your name in %s room" % self.target)
def printInfo(self, msg, type='normal'):
"""Print general info
@ -242,6 +247,11 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.content.append(sat_widgets.ClickableText(msg))
self.text_list.set_focus(len(self.content)-1)
self.host.redraw()
if not self.host.notify.hasFocus():
if self.type=="one2one":
self.host.notify.sendNotification("Primitivus: there is a message about you")
elif self.getUserNick().lower() in msg.lower():
self.host.notify.sendNotification("Primitivus: Somebody is talking about you in %s room" % self.target)
def startGame(self, game_type, referee, players):
"""Configure the chat window to start a game"""