Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 380:ede26abf6ca1
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 27 Aug 2011 17:15:41 +0200 |
parents | d62eb9003375 |
children | 1f7a14d0343d |
comparison
equal
deleted
inserted
replaced
379:adcc41e4d6ea | 380:ede26abf6ca1 |
---|---|
229 return | 229 return |
230 my_jid = self.host.profiles[profile]['whoami'] | 230 my_jid = self.host.profiles[profile]['whoami'] |
231 self.content.append(ChatText(self, timestamp or None, nick, mymess, msg)) | 231 self.content.append(ChatText(self, timestamp or None, nick, mymess, msg)) |
232 self.text_list.set_focus(len(self.content)-1) | 232 self.text_list.set_focus(len(self.content)-1) |
233 self.host.redraw() | 233 self.host.redraw() |
234 if not self.host.notify.hasFocus(): | |
235 if self.type=="one2one": | |
236 self.host.notify.sendNotification("Primitivus: %s is talking to you" % from_jid) | |
237 elif self.getUserNick().lower() in msg.lower(): | |
238 self.host.notify.sendNotification("Primitivus: Somebody pinged your name in %s room" % self.target) | |
234 | 239 |
235 def printInfo(self, msg, type='normal'): | 240 def printInfo(self, msg, type='normal'): |
236 """Print general info | 241 """Print general info |
237 @param msg: message to print | 242 @param msg: message to print |
238 @type: one of: | 243 @type: one of: |
240 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" | 245 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" |
241 """ | 246 """ |
242 self.content.append(sat_widgets.ClickableText(msg)) | 247 self.content.append(sat_widgets.ClickableText(msg)) |
243 self.text_list.set_focus(len(self.content)-1) | 248 self.text_list.set_focus(len(self.content)-1) |
244 self.host.redraw() | 249 self.host.redraw() |
250 if not self.host.notify.hasFocus(): | |
251 if self.type=="one2one": | |
252 self.host.notify.sendNotification("Primitivus: there is a message about you") | |
253 elif self.getUserNick().lower() in msg.lower(): | |
254 self.host.notify.sendNotification("Primitivus: Somebody is talking about you in %s room" % self.target) | |
245 | 255 |
246 def startGame(self, game_type, referee, players): | 256 def startGame(self, game_type, referee, players): |
247 """Configure the chat window to start a game""" | 257 """Configure the chat window to start a game""" |
248 if game_type=="Tarot": | 258 if game_type=="Tarot": |
249 try: | 259 try: |