[banshee/stable-1.6] [VolumeButton] Fix initialization



commit 79b6ae2b589f038f0a2126c27089a97dea4c65b3
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Jun 17 13:48:18 2010 -0700

    [VolumeButton] Fix initialization
    
    Wait for the PlayerEngine to be initialized if needed.

 .../Banshee.Gui.Widgets/ConnectedVolumeButton.cs   |   24 ++++++++++++++++---
 1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs
index 0671ee3..4d75155 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs
@@ -39,10 +39,21 @@ namespace Banshee.Gui.Widgets
 
         public ConnectedVolumeButton () : base()
         {
-            emit_lock = true;
-            Volume = ServiceManager.PlayerEngine.Volume;
-            emit_lock = false;
-            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.Volume);
+            var player = ServiceManager.PlayerEngine;
+
+            if (player.ActiveEngine != null && player.ActiveEngine.IsInitialized) {
+                SetVolume ();
+            } else {
+                Sensitive = false;
+                player.EngineAfterInitialize += (e) => {
+                    Hyena.ThreadAssist.ProxyToMain (delegate {
+                        SetVolume ();
+                        Sensitive = true;
+                    });
+                };
+            }
+
+            player.ConnectEvent (OnPlayerEvent, PlayerEvent.Volume);
         }
 
         public ConnectedVolumeButton (bool classic) : this ()
@@ -52,6 +63,11 @@ namespace Banshee.Gui.Widgets
 
         private void OnPlayerEvent (PlayerEventArgs args)
         {
+            SetVolume ();
+        }
+
+        private void SetVolume ()
+        {
             emit_lock = true;
             Volume = ServiceManager.PlayerEngine.Volume;
             emit_lock = false;



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