Mercurial > libervia-desktop-kivy
diff cagou/core/cagou_main.py @ 184:c63922860f80
chat: show desktop notification and/or note when suitable
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 10 May 2018 08:32:46 +0200 |
parents | 2cfef8fbfd4e |
children | 0abd24ab81b1 |
line wrap: on
line diff
--- a/cagou/core/cagou_main.py Tue May 01 21:53:33 2018 +0200 +++ b/cagou/core/cagou_main.py Thu May 10 08:32:46 2018 +0200 @@ -66,6 +66,11 @@ import cagou.kv from kivy import utils as kivy_utils import sys +try: + from plyer import notification +except ImportError: + notification = None + log.warning(_(u"Can't import plyer, some features disabled")) # we want white background by default Window.clearcolor = (1, 1, 1, 1) @@ -727,3 +732,12 @@ # TODO log.info(u"FIXME: showDialog not implemented") log.info(u"message: {} -- {}".format(title, message)) + + + def desktop_notif(self, message, title=u'', duration=5000): + if notification is not None: + notification.notify(title=title, + message=message, + app_name=C.APP_NAME, + app_icon=self.app.icon, + timeout = duration)