[banshee] [Banshee.Moblin] Reworked Moblin panel startup



commit bf8ac65bd4d2384046471f469f75590ebc9b2ef0
Author: Aaron Bockover <abockover novell com>
Date:   Wed Oct 14 19:09:54 2009 -0400

    [Banshee.Moblin] Reworked Moblin panel startup
    
    Hook into the new PostInitializeGtk extension point to create
    the Moblin panel integration. Move the panel creation to the
    new MoblinPanel singleton, and populate it from MoblinService
    when the rest of the GTK services are initialized.

 .../Banshee.Moblin/Banshee.Moblin.addin.xml        |    4 +
 .../Banshee.Moblin/Banshee.Moblin.csproj           |    3 +
 .../Banshee.Moblin/Banshee.Moblin/MoblinPanel.cs   |   84 ++++++++++++++++++++
 .../Banshee.Moblin/Banshee.Moblin/MoblinService.cs |   44 +++++------
 src/Extensions/Banshee.Moblin/Makefile.am          |    4 +-
 5 files changed, 113 insertions(+), 26 deletions(-)
---
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin.addin.xml b/src/Extensions/Banshee.Moblin/Banshee.Moblin.addin.xml
index 57f48d3..f76bd55 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin.addin.xml
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin.addin.xml
@@ -19,5 +19,9 @@
   <Extension path="/Banshee/ServiceManager/Service">
     <Service class="Banshee.Moblin.MoblinService"/>
   </Extension>
+  
+  <Extension path="/Banshee/ThickClient/GtkBaseClient/PostInitializeGtk">
+    <PostInitializeGtk class="Banshee.Moblin.MoblinPanel"/>
+  </Extension>
    
 </Addin>
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj b/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj
index 16b4e90..5b4214d 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin.csproj
@@ -97,5 +97,8 @@
     <Compile Include="Banshee.Moblin\PlayQueueBox.cs" />
     <Compile Include="Banshee.Moblin\PlaybackBox.cs" />
     <Compile Include="Banshee.Moblin\MoblinTrackInfoDisplay.cs" />
+    <Compile Include="Banshee.Moblin\RecentAlbumsList.cs" />
+    <Compile Include="Banshee.Moblin\MoblinPanel.cs" />
+    <Compile Include="Mutter\SetSizeHandler.cs" />
   </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinPanel.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinPanel.cs
new file mode 100644
index 0000000..77af3e0
--- /dev/null
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinPanel.cs
@@ -0,0 +1,84 @@
+// 
+// MoblinPanel.cs
+//  
+// Author:
+//   Aaron Bockover <abockover novell com>
+// 
+// Copyright 2009 Novell, Inc.
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+using Gtk;
+using Mutter;
+using Hyena;
+using Banshee.Base;
+
+namespace Banshee.Moblin
+{
+    public class MoblinPanel : IDisposable
+    {
+        public static MoblinPanel Instance { get; private set; }
+        
+        public PanelGtk ToolbarPanel { get; private set; }
+        public Container ParentContainer { get; private set; }
+        
+        public uint ToolbarPanelWidth { get; private set; }
+        public uint ToolbarPanelHeight { get; private set; }
+
+        public MoblinPanel ()
+        {
+            if (Instance != null) {
+                throw new ApplicationException ("Only one MoblinPanel instance can exist");
+            }
+            
+            if (ApplicationContext.CommandLine.Contains ("mutter-panel")) {
+                BuildPanel ();
+                Instance = this;
+            }
+        }
+        
+        public void Dispose ()
+        {
+        }
+        
+        private void BuildPanel ()
+        {
+            try {
+                ToolbarPanel = new PanelGtk ("media", "media", null, "media-button", true);
+                ParentContainer = ToolbarPanel.Window;
+                ParentContainer.ModifyBg (StateType.Normal, ParentContainer.Style.White);
+                ToolbarPanel.SetSizeEvent += (o, e) => {
+                    ToolbarPanelWidth = e.Width;
+                    ToolbarPanelHeight = e.Height;
+                };
+            } catch (Exception e) {
+                Log.Exception ("Could not bind to Moblin panel", e);
+                
+                var window = new Gtk.Window ("Moblin Media Panel");
+                window.SetDefaultSize (1000, 500);
+                window.WindowPosition = Gtk.WindowPosition.Center;
+                ParentContainer = window;
+            }
+            
+            ParentContainer.ShowAll ();
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs
index 45facd0..fba5f71 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs
@@ -28,10 +28,14 @@
 
 using System;
 
+using Hyena;
+
 using Banshee.Base;
 using Banshee.ServiceStack;
 using Banshee.Gui;
 
+using Mutter;
+
 namespace Banshee.Moblin
 {
     public class MoblinService : IExtensionService
@@ -39,8 +43,6 @@ namespace Banshee.Moblin
         private GtkElementsService elements_service;
         private InterfaceActionService interface_action_service;
         
-        private Gtk.Widget media_panel_window;
-        
         public MoblinService ()
         {
         }
@@ -81,39 +83,31 @@ namespace Banshee.Moblin
         
         private void Initialize ()
         {
-            if (ApplicationContext.CommandLine.Contains ("mutter-panel")) {
-                BuildPanel ();
+            if (MoblinPanel.Instance != null) {
+                var container = MoblinPanel.Instance.ParentContainer;
+                foreach (var child in container.Children) {
+                    container.Remove (child);
+                }
+                container.Add (new MediaPanelContents ());
+                container.ShowAll ();
+                
+                if (MoblinPanel.Instance.ToolbarPanel != null) {
+                    container.SetSizeRequest (
+                        (int)MoblinPanel.Instance.ToolbarPanelWidth,
+                        (int)MoblinPanel.Instance.ToolbarPanelHeight);
+                }
             }
         }
         
         public void Dispose ()
         {
-            if (media_panel_window != null) {
-                media_panel_window.Hide ();
-                media_panel_window.Destroy ();
-                media_panel_window = null;
+            if (MoblinPanel.Instance != null) {
+                MoblinPanel.Instance.Dispose ();
             }
             
             interface_action_service = null;
             elements_service = null;
         }
-        
-#region Media Panel
-
-        private void BuildPanel ()
-        {
-            var window = new Gtk.Window ("Moblin Media Panel");
-            window.SetDefaultSize (990, 460);
-            window.WindowPosition = Gtk.WindowPosition.Center;
-            window.Add (new MediaPanelContents ());
-            window.ShowAll ();
-
-            elements_service.RegisterContentWindow (window);
-
-            media_panel_window = window;
-        }
-
-#endregion        
 
         string IService.ServiceName {
             get { return "MoblinService"; }
diff --git a/src/Extensions/Banshee.Moblin/Makefile.am b/src/Extensions/Banshee.Moblin/Makefile.am
index 241d5c8..b6110d6 100644
--- a/src/Extensions/Banshee.Moblin/Makefile.am
+++ b/src/Extensions/Banshee.Moblin/Makefile.am
@@ -5,6 +5,7 @@ INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
 SOURCES =  \
 	Banshee.Moblin/MediaPanelContents.cs \
+	Banshee.Moblin/MoblinPanel.cs \
 	Banshee.Moblin/MoblinService.cs \
 	Banshee.Moblin/MoblinTrackInfoDisplay.cs \
 	Banshee.Moblin/PlaybackBox.cs \
@@ -14,7 +15,8 @@ SOURCES =  \
 	Banshee.Moblin/SearchEntry.cs \
 	Banshee.Moblin/SearchHeader.cs \
 	Mutter/PanelClient.cs \
-	Mutter/PanelGtk.cs
+	Mutter/PanelGtk.cs \
+	Mutter/SetSizeHandler.cs
 
 RESOURCES = Banshee.Moblin.addin.xml
 



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