[pitivi] Use the GSound libcanberra wrapper



commit 7ab280ffae8688a1e12d744b7df5a4acb3449192
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Dec 30 23:09:13 2016 +0100

    Use the GSound libcanberra wrapper
    
    The "complete" sound we need is part of sound-theme-freedesktop. This
    means we won't use the system's xdg sound theme. There is no other way
    currently.
    
    Fixes https://phabricator.freedesktop.org/T7598
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D1577

 build/flatpak/pitivi.template.json |   20 ++++++++++++++++++++
 pitivi/check.py                    |    4 ++--
 pitivi/render.py                   |   18 +++++++++++-------
 3 files changed, 33 insertions(+), 9 deletions(-)
---
diff --git a/build/flatpak/pitivi.template.json b/build/flatpak/pitivi.template.json
index eb0b31a..2b5feae 100644
--- a/build/flatpak/pitivi.template.json
+++ b/build/flatpak/pitivi.template.json
@@ -35,6 +35,26 @@
             ]
         },
         {
+            "name": "sound-theme-freedesktop",
+            "sources": [
+                {
+                    "type": "git",
+                    "url": "https://anongit.freedesktop.org/git/sound-theme-freedesktop.git";,
+                    "branch": "0.8"
+                }
+            ]
+        },
+        {
+            "name": "gsound",
+            "sources": [
+                {
+                    "type": "git",
+                    "url": "https://git.gnome.org/browse/gsound";,
+                    "branch": "1.0.2"
+                }
+            ]
+        },
+        {
             "name": "x264",
             "config-opts": ["--enable-shared", "--enable-static", "--enable-pic", "--disable-lavf"],
             "sources": [
diff --git a/pitivi/check.py b/pitivi/check.py
index 09d0a04..76eaa5d 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -373,8 +373,8 @@ HARD_DEPENDENCIES = [GICheck("3.20.0"),
                      ]
 
 SOFT_DEPENDENCIES = (
-    ClassicDependency("pycanberra", None,
-                      _("enables sound notifications when rendering is complete")),
+    GIDependency("GSound", "1.0", None,
+                 _("enables sound notifications when rendering is complete")),
     GIDependency("Notify", "0.7", None,
                  _("enables visual notifications when rendering is complete")),
     GstPluginDependency("libav", None,
diff --git a/pitivi/render.py b/pitivi/render.py
index ad819b2..38d8d90 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -885,13 +885,17 @@ class RenderDialog(Loggable):
     def destroy(self):
         self.window.destroy()
 
-    @staticmethod
-    def _maybePlayFinishedSound():
-        if "pycanberra" in missing_soft_deps:
+    def _maybe_play_finished_sound(self):
+        """Plays a sound to signal the render operation is done."""
+        if "GSound" in missing_soft_deps:
             return
-        import pycanberra
-        canberra = pycanberra.Canberra()
-        canberra.play(1, pycanberra.CA_PROP_EVENT_ID, "complete-media", None)
+        from gi.repository import GSound
+        sound_context = GSound.Context()
+        try:
+            sound_context.init()
+            sound_context.play_simple({GSound.ATTR_EVENT_ID: "complete"})
+        except GLib.Error as e:
+            self.warning("GSound failed to play: %s", e)
 
     def __maybeUseSourceAsset(self):
         if self.__always_use_proxies.get_active():
@@ -1042,7 +1046,7 @@ class RenderDialog(Loggable):
                     '"%s" has finished rendering.' % self.fileentry.get_text())
                 self.notification = self.app.system.desktopMessage(
                     _("Render complete"), notification, "pitivi")
-            self._maybePlayFinishedSound()
+            self._maybe_play_finished_sound()
             self.progress.play_rendered_file_button.show()
             self.progress.close_button.show()
             self.progress.cancel_button.hide()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]