[banshee] GnomeScreensaver: Catch errors from Inhibit calls



commit 737064b3d08d6c09aa32560d079ba6cacd008df1
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Apr 1 19:35:17 2011 -0500

    GnomeScreensaver: Catch errors from Inhibit calls
    
    The Inhibit API was removed in 2.91.91; see bgo#646499 for more info

 .../GnomeScreensaverManager.cs                     |   22 ++++++++++++++-----
 1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeScreensaverManager.cs b/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeScreensaverManager.cs
index 17ceefc..336c396 100644
--- a/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeScreensaverManager.cs
+++ b/src/Backends/Banshee.Gnome/Banshee.GnomeBackend/GnomeScreensaverManager.cs
@@ -73,19 +73,29 @@ namespace Banshee.GnomeBackend
             }
         }
 
+        static bool logged_error;
         public void Inhibit ()
         {
-            if (!cookie.HasValue && Manager != null) {
-                cookie = Manager.Inhibit ("Banshee", Catalog.GetString ("Fullscreen video playback active"));
+            try {
+                if (!cookie.HasValue && Manager != null) {
+                    cookie = Manager.Inhibit ("Banshee", Catalog.GetString ("Fullscreen video playback active"));
+                }
+            } catch (Exception e) {
+                if (!logged_error) {
+                    Log.Information ("Error trying to Inhibit GNOME screensaver; probably running >= 2.91.91 gnome-screensaver which removed this API", e.Message);
+                    logged_error = true;
+                }
             }
         }
 
         public void UnInhibit ()
         {
-            if (cookie.HasValue && Manager != null) {
-                Manager.UnInhibit (cookie.Value);
-                cookie = null;
-            }
+            try {
+                if (cookie.HasValue && Manager != null) {
+                    Manager.UnInhibit (cookie.Value);
+                    cookie = null;
+                }
+            } catch {}
         }
     }
 }



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