[banshee/source-contents] Allow ISourceContents to provide widgets to extend the ViewContainer header.



commit cdf84801650124729e35af89a5e835c0dcfcd44e
Author: Chris Howie <cdhowie gmail com>
Date:   Thu May 7 13:17:31 2009 -0400

    Allow ISourceContents to provide widgets to extend the ViewContainer header.
---
 src/Clients/Nereid/Nereid/ViewContainer.cs         |   32 ++++++++++++++++++++
 .../FilteredListSourceContents.cs                  |    4 ++
 .../Banshee.Sources.Gui/ISourceContents.cs         |    1 +
 .../ObjectListSourceContents.cs                    |    4 ++
 .../Banshee.Sources.Gui/SourceContentNotebook.cs   |   17 ++++++++++
 .../Banshee.Dap.Gui/DapPropertiesDisplay.cs        |    4 ++
 .../Banshee.Daap/Banshee.Daap/DaapErrorView.cs     |    4 ++
 .../Banshee.Lastfm.Radio/LastfmSourceContents.cs   |    4 ++
 .../Banshee.NowPlaying/NowPlayingInterface.cs      |    4 ++
 9 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/src/Clients/Nereid/Nereid/ViewContainer.cs b/src/Clients/Nereid/Nereid/ViewContainer.cs
index a4af8ed..42a0178 100644
--- a/src/Clients/Nereid/Nereid/ViewContainer.cs
+++ b/src/Clients/Nereid/Nereid/ViewContainer.cs
@@ -55,6 +55,7 @@ namespace Nereid
         private Banshee.ContextPane.ContextPane context_pane;
         private VBox footer;
         private MenuButton title_button;
+        private Alignment header_extension_container;
         
         private ISourceContents explicit_content;
         private SourceContentNotebook notebook;
@@ -66,6 +67,7 @@ namespace Nereid
             Spacing = 8;
             content_manager = ServiceManager.Get<SourceContentManager> ();
             notebook = new SourceContentNotebook ();
+            notebook.SourceContentActivated += OnSourceContentActivated;
 
             BuildHeader ();
 
@@ -98,11 +100,14 @@ namespace Nereid
             
             search_label = new Label (Catalog.GetString ("_Search:"));
             search_label.MnemonicWidget = search_entry.InnerEntry;
+
+            header_extension_container = new Alignment (1f, 0.5f, 0f, 0f);
             
             header.PackStart (title_label, false, false, 0);
             header.PackStart (title_button, false, false, 0);
             header.PackEnd (search_entry, false, false, 0);
             header.PackEnd (search_label, false, false, 5);
+            header.PackEnd (header_extension_container, false, false, 5);
             
             InterfaceActionService uia = ServiceManager.Get<InterfaceActionService> ();
             if (uia != null) {
@@ -237,6 +242,8 @@ namespace Nereid
                 explicit_content.Widget.Hide ();
                 explicit_content = null;
             }
+            
+            RemoveHeaderExtension ();
 
             // If the Source has an explicit view set in its Properties, then honor that, otherwise
             // determine what content to show from the content extensions that are compatible
@@ -279,6 +286,31 @@ namespace Nereid
 
             Show ();
         }
+        
+        private void OnSourceContentActivated (object sender, SourceContentActivatedEventArgs e)
+        {
+            AddHeaderExtension (e.Contents.HeaderExtension);
+        }
+        
+        private void RemoveHeaderExtension ()
+        {
+            if (header_extension_container.Child != null) {
+                header_extension_container.Remove (header_extension_container.Child);
+                header_extension_container.Hide ();
+            }
+        }
+        
+        private void AddHeaderExtension (Widget widget)
+        {
+            RemoveHeaderExtension ();
+            
+            if (widget == null) {
+                return;
+            }
+            
+            header_extension_container.Add (widget);
+            header_extension_container.Show ();
+        }
 
         public ISourceContents Content {
             get { return explicit_content ?? notebook.Content; }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs
index 175f9e3..deb0a15 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/FilteredListSourceContents.cs
@@ -375,6 +375,10 @@ namespace Banshee.Sources.Gui
         public Widget Widget {
             get { return this; }
         }
+                    
+        public Widget HeaderExtension {
+            get { return null; }
+        }
 
 #endregion
         
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ISourceContents.cs b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ISourceContents.cs
index b91d7c9..36302e2 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ISourceContents.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ISourceContents.cs
@@ -40,5 +40,6 @@ namespace Banshee.Sources.Gui
         void ResetSource ();
         ISource Source { get; }
         Widget Widget { get; }
+        Widget HeaderExtension { get; }
     }
 }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ObjectListSourceContents.cs b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ObjectListSourceContents.cs
index e61162b..46ff977 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ObjectListSourceContents.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/ObjectListSourceContents.cs
@@ -104,5 +104,9 @@ namespace Banshee.Sources.Gui
         public Widget Widget {
             get { return this; }
         }
+        
+        public Widget HeaderExtension {
+            get { return null; }
+        }
     }
 }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceContentNotebook.cs b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceContentNotebook.cs
index ace0e42..0ed0035 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceContentNotebook.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceContentNotebook.cs
@@ -51,6 +51,8 @@ namespace Banshee.Sources.Gui
     {
         private Source source;
         private ISourceContents content;
+        
+        public event EventHandler<SourceContentActivatedEventArgs> SourceContentActivated;
 
         public SourceContentNotebook () : base ()
         {
@@ -77,10 +79,25 @@ namespace Banshee.Sources.Gui
             }
 
             CurrentPage = PageNum (content.Widget);
+            
+            var handler = SourceContentActivated;
+            if (handler != null) {
+                handler (this, new SourceContentActivatedEventArgs (content));
+            }
         }
 
         public ISourceContents Content {
             get { return content; }
         }
     }
+    
+    public class SourceContentActivatedEventArgs : EventArgs
+    {
+        public ISourceContents Contents { get; private set; }
+        
+        public SourceContentActivatedEventArgs (ISourceContents contents)
+        {
+            Contents = contents;
+        }
+    }
 }
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDisplay.cs b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDisplay.cs
index 9950c23..aa8f957 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDisplay.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapPropertiesDisplay.cs
@@ -137,6 +137,10 @@ namespace Banshee.Dap.Gui
             get { return this; }
         }
         
+        public Widget HeaderExtension {
+            get { return null; }
+        }
+        
 #endregion
 
     }
diff --git a/src/Extensions/Banshee.Daap/Banshee.Daap/DaapErrorView.cs b/src/Extensions/Banshee.Daap/Banshee.Daap/DaapErrorView.cs
index 8182326..6dcf8ef 100644
--- a/src/Extensions/Banshee.Daap/Banshee.Daap/DaapErrorView.cs
+++ b/src/Extensions/Banshee.Daap/Banshee.Daap/DaapErrorView.cs
@@ -57,6 +57,10 @@ namespace Banshee.Daap
             get { return this; }
         }
         
+        public Widget HeaderExtension {
+            get { return null; }
+        }
+        
         public DaapErrorView (DaapSource source, DaapErrorType failure) : base()
         {
             //AppPaintable = true;
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSourceContents.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSourceContents.cs
index 3060521..682c809 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSourceContents.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSourceContents.cs
@@ -94,6 +94,10 @@ namespace Banshee.Lastfm.Radio
         public Widget Widget {
             get { return this; }
         }
+        
+        public Widget HeaderExtension {
+            get { return null; }
+        }
 
         public void Refresh ()
         {
diff --git a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
index 8050bb1..88ed1dc 100644
--- a/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
+++ b/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
@@ -219,6 +219,10 @@ namespace Banshee.NowPlaying
             get { return this; }
         }
         
+        public Widget HeaderExtension {
+            get { return null; }
+        }
+        
 #endregion
 
     }



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