Added support for sound notification plugins which use

the desktop sound theme, with pycanberra for example. Plugin name should
start with 'theme' in that case, whereas the name of plugins playing the
sound file starts with 'file'.
This commit is contained in:
Dmitri Bogomolov 2017-03-11 13:40:33 +02:00
parent 84a903f116
commit 289a6c5bfa
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 13 additions and 3 deletions

View File

@ -285,7 +285,8 @@ if __name__ == "__main__":
'[notify2]' '[notify2]'
], ],
'notification.sound': [ 'notification.sound': [
'fallback = pybitmessage.plugins.sound_playfile [sound]' 'file.fallback = pybitmessage.plugins.sound_playfile'
'[sound]'
], ],
# 'console_scripts': [ # 'console_scripts': [
# 'pybitmessage = pybitmessage.bitmessagemain:main' # 'pybitmessage = pybitmessage.bitmessagemain:main'

View File

@ -1387,6 +1387,7 @@ class MyForm(settingsmixin.SMainWindow):
soundFilename = state.appdata + 'sounds/' + label soundFilename = state.appdata + 'sounds/' + label
ext = _choose_ext(soundFilename) ext = _choose_ext(soundFilename)
if not ext: if not ext:
category = self.SOUND_KNOWN
soundFilename = None soundFilename = None
if soundFilename is None: if soundFilename is None:
@ -1417,6 +1418,7 @@ class MyForm(settingsmixin.SMainWindow):
soundFilename = state.appdata + 'sounds/green' soundFilename = state.appdata + 'sounds/green'
if soundFilename is None: if soundFilename is None:
logger.warning("Probably wrong category number in playSound()")
return return
if not self.isConnectionSound(category): if not self.isConnectionSound(category):
@ -1428,6 +1430,9 @@ class MyForm(settingsmixin.SMainWindow):
except (TypeError, NameError): except (TypeError, NameError):
ext = _choose_ext(soundFilename) ext = _choose_ext(soundFilename)
if not ext: if not ext:
try: # if no user sound file found try to play from theme
return self._theme_player(category, label)
except TypeError:
return return
soundFilename += ext soundFilename += ext
@ -1450,6 +1455,10 @@ class MyForm(settingsmixin.SMainWindow):
_plugin = get_plugin('notification.message') _plugin = get_plugin('notification.message')
if _plugin: if _plugin:
self._notifier = _plugin self._notifier = _plugin
else:
logger.warning("No notification.message plugin found")
self._theme_player = get_plugin('notification.sound', 'theme')
if not QtGui.QSound.isAvailable(): if not QtGui.QSound.isAvailable():
_plugin = get_plugin( _plugin = get_plugin(
@ -1457,7 +1466,7 @@ class MyForm(settingsmixin.SMainWindow):
if _plugin: if _plugin:
self._player = _plugin self._player = _plugin
else: else:
logger.warning("No sound player plugin found!") logger.warning("No notification.sound plugin found")
def notifierShow( def notifierShow(
self, title, subtitle, category, label=None, icon=None): self, title, subtitle, category, label=None, icon=None):