From 289a6c5bfa9218e0bec83bbc970160d56525ff5b Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Sat, 11 Mar 2017 13:40:33 +0200 Subject: [PATCH] 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'. --- setup.py | 3 ++- src/bitmessageqt/__init__.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c7f7fab5..eb79c3b7 100644 --- a/setup.py +++ b/setup.py @@ -285,7 +285,8 @@ if __name__ == "__main__": '[notify2]' ], 'notification.sound': [ - 'fallback = pybitmessage.plugins.sound_playfile [sound]' + 'file.fallback = pybitmessage.plugins.sound_playfile' + '[sound]' ], # 'console_scripts': [ # 'pybitmessage = pybitmessage.bitmessagemain:main' diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 39202d17..fd0bcdc1 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -1387,6 +1387,7 @@ class MyForm(settingsmixin.SMainWindow): soundFilename = state.appdata + 'sounds/' + label ext = _choose_ext(soundFilename) if not ext: + category = self.SOUND_KNOWN soundFilename = None if soundFilename is None: @@ -1417,6 +1418,7 @@ class MyForm(settingsmixin.SMainWindow): soundFilename = state.appdata + 'sounds/green' if soundFilename is None: + logger.warning("Probably wrong category number in playSound()") return if not self.isConnectionSound(category): @@ -1428,7 +1430,10 @@ class MyForm(settingsmixin.SMainWindow): except (TypeError, NameError): ext = _choose_ext(soundFilename) if not ext: - return + try: # if no user sound file found try to play from theme + return self._theme_player(category, label) + except TypeError: + return soundFilename += ext @@ -1450,6 +1455,10 @@ class MyForm(settingsmixin.SMainWindow): _plugin = get_plugin('notification.message') if _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(): _plugin = get_plugin( @@ -1457,7 +1466,7 @@ class MyForm(settingsmixin.SMainWindow): if _plugin: self._player = _plugin else: - logger.warning("No sound player plugin found!") + logger.warning("No notification.sound plugin found") def notifierShow( self, title, subtitle, category, label=None, icon=None):