[banshee/amazon] First rough pass at making the recommendations pane into an extensible context pane, for eg lyrics,
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Subject: [banshee/amazon] First rough pass at making the recommendations pane into an extensible context pane, for eg lyrics,
- Date: Fri, 8 May 2009 19:39:40 -0400 (EDT)
commit a366dbc66b0ebdea015b5380440f8256e95f1647
Author: Gabriel Burt <gabriel burt gmail com>
Date: Wed May 6 12:58:50 2009 -0500
First rough pass at making the recommendations pane into an extensible context pane, for eg lyrics, wikipedia, etc
---
src/Clients/Nereid/Nereid/ViewContainer.cs | 3 +
src/Core/Banshee.Core/Banshee.Core.csproj | 2 +-
src/Core/Banshee.Services/Banshee.Services.csproj | 6 +-
.../Banshee.Gui.Widgets/ContextPane.cs | 140 ++++++++++++++++++++
.../Banshee.ThickClient.addin.xml | 5 +
.../Banshee.ThickClient/Banshee.ThickClient.csproj | 2 +
src/Core/Banshee.ThickClient/Makefile.am | 1 +
.../RecommendationPane.cs | 61 ++++++++-
.../RecommendationService.cs | 57 +--------
.../Banshee.Lastfm/Banshee.Lastfm.addin.xml | 4 +
src/Libraries/Hyena/Hyena.csproj | 7 +
11 files changed, 227 insertions(+), 61 deletions(-)
diff --git a/src/Clients/Nereid/Nereid/ViewContainer.cs b/src/Clients/Nereid/Nereid/ViewContainer.cs
index 41c51c3..4b3293b 100644
--- a/src/Clients/Nereid/Nereid/ViewContainer.cs
+++ b/src/Clients/Nereid/Nereid/ViewContainer.cs
@@ -112,6 +112,9 @@ namespace Nereid
PackStart (header, false, false, 0);
PackEnd (footer, false, false, 0);
+ var context_pane = new ContextPane ();
+ context_pane.Show ();
+ PackEnd (context_pane, false, false, 0);
PackEnd (new ConnectedMessageBar (), false, true, 0);
}
diff --git a/src/Core/Banshee.Core/Banshee.Core.csproj b/src/Core/Banshee.Core/Banshee.Core.csproj
index e5af764..805da77 100644
--- a/src/Core/Banshee.Core/Banshee.Core.csproj
+++ b/src/Core/Banshee.Core/Banshee.Core.csproj
@@ -69,7 +69,6 @@
<Compile Include="Banshee.Collection\TrackFilterType.cs" />
<Compile Include="Banshee.Base\PlatformHacks.cs" />
<Compile Include="Banshee.Streaming\CommonTags.cs" />
- <Compile Include="Banshee.Streaming\SaveTrackMetadataJob.cs" />
<Compile Include="Banshee.Streaming\StreamTag.cs" />
<Compile Include="Banshee.Streaming\StreamTagger.cs" />
<Compile Include="Banshee.Streaming\StreamPlaybackError.cs" />
@@ -106,6 +105,7 @@
<Compile Include="Banshee.IO\DirectoryScannerPipelineElement.cs" />
<Compile Include="Banshee.Configuration\MemoryConfigurationClient.cs" />
<Compile Include="Banshee.IO\ExtensionSet.cs" />
+ <Compile Include="Banshee.Base\Tests\CoverArtSpecTests.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\contributors.xml">
diff --git a/src/Core/Banshee.Services/Banshee.Services.csproj b/src/Core/Banshee.Services/Banshee.Services.csproj
index 5021339..066f4a6 100644
--- a/src/Core/Banshee.Services/Banshee.Services.csproj
+++ b/src/Core/Banshee.Services/Banshee.Services.csproj
@@ -87,7 +87,6 @@
<Compile Include="Banshee.Collection\ModelHelper.cs" />
<Compile Include="Banshee.Collection\TrackListModel.cs" />
<Compile Include="Banshee.MediaEngine\PlayerEngineService.cs" />
- <Compile Include="Banshee.ServiceStack\UserJobManager.cs" />
<Compile Include="Banshee.ServiceStack\IUserJob.cs" />
<Compile Include="Banshee.ServiceStack\UserJobEventHandler.cs" />
<Compile Include="Banshee.ServiceStack\UserJob.cs" />
@@ -228,7 +227,6 @@
<Compile Include="Banshee.Collection.Database\QueryFilterInfo.cs" />
<Compile Include="Banshee.Sources\IFilterableSource.cs" />
<Compile Include="Banshee.MediaEngine\IVisualizationDataSource.cs" />
- <Compile Include="Banshee.Collection\MoveOnInfoSaveJob.cs" />
<Compile Include="Banshee.ServiceStack\IRegisterOnDemandService.cs" />
<Compile Include="Banshee.Web\HttpRequest.cs" />
<Compile Include="Banshee.Collection.Indexer\CollectionIndexerService.cs" />
@@ -252,8 +250,10 @@
<Compile Include="Banshee.Preferences\SourcePage.cs" />
<Compile Include="Banshee.ServiceStack\DbIteratorJob.cs" />
<Compile Include="Banshee.Sources\SourceSortType.cs" />
- <Compile Include="Banshee.Library\LibraryLocationPreference.cs" />
<Compile Include="Banshee.Playlists.Formats\AsfReferencePlaylistFormat.cs" />
+ <Compile Include="Banshee.Metadata\SaveTrackMetadataJob.cs" />
+ <Compile Include="Banshee.Metadata\SaveTrackMetadataService.cs" />
+ <Compile Include="Banshee.ServiceStack\JobScheduler.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Banshee.Services.addin.xml" />
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs
new file mode 100644
index 0000000..533b2eb
--- /dev/null
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ContextPane.cs
@@ -0,0 +1,140 @@
+//
+// ContextNotebook.cs
+//
+// Authors:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 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 System.Collections.Generic;
+
+using Mono.Addins;
+
+using Gtk;
+
+using Hyena.Gui;
+
+using Banshee.Base;
+using Banshee.Gui;
+
+namespace Banshee.Gui.Widgets
+{
+ public abstract class ContextPanePage
+ {
+ public string Id { get; protected set; }
+ public string Name { get; protected set;}
+ public string [] IconNames { get; protected set;}
+ public abstract Widget Widget { get; }
+ }
+
+ public class ContextManager
+ {
+ private ContextPane pane;
+
+ public ContextManager (ContextPane pane)
+ {
+ this.pane = pane;
+ Mono.Addins.AddinManager.AddExtensionNodeHandler ("/Banshee/ThickClient/ContextPanePage", OnExtensionChanged);
+ }
+
+ private void OnExtensionChanged (object o, ExtensionNodeEventArgs args)
+ {
+ TypeExtensionNode node = (TypeExtensionNode)args.ExtensionNode;
+ var page = (ContextPanePage) (node.GetInstance () ?? node.CreateInstance ());
+
+ if (args.Change == ExtensionChange.Add) {
+ pane.AddPage (page);
+ } else {
+ pane.RemovePage (page);
+ }
+ }
+ }
+
+ public class ContextPane : Gtk.HBox
+ {
+ private object tooltip_host = TooltipSetter.CreateHost ();
+
+ private Gtk.Notebook notebook;
+ private VBox vbox;
+
+ private RadioButton radio_group = new RadioButton (null, "");
+
+ private Dictionary<ContextPanePage, RadioButton> pane_tabs = new Dictionary<ContextPanePage, RadioButton> ();
+ //private Dictionary<
+
+ public ContextPane ()
+ {
+ notebook = new Notebook () {
+ ShowBorder = false,
+ ShowTabs = false
+ };
+
+ vbox = new VBox ();
+
+ PackStart (notebook, true, true, 0);
+ PackStart (vbox, false, false, 6);
+ ShowAll ();
+
+ HeightRequest = 200;
+
+ // TODO remember/restore the last page
+
+ new ContextManager (this);
+ }
+
+ public void AddPage (ContextPanePage page)
+ {
+ var frame = new Hyena.Widgets.RoundedFrame ();
+ frame.Add (page.Widget);
+ frame.Show ();
+ page.Widget.Show ();
+ notebook.AppendPage (frame, null);
+
+ var tab_image = new Image (IconThemeUtils.LoadIcon (22, page.IconNames));
+ var toggle_button = new RadioButton (radio_group) {
+ Child = tab_image,
+ DrawIndicator = false
+ };
+ toggle_button.Relief = ReliefStyle.None;
+ toggle_button.Clicked += (s, e) => notebook.CurrentPage = notebook.PageNum (page.Widget);
+
+ TooltipSetter.Set (tooltip_host, toggle_button, page.Name);
+
+ toggle_button.ShowAll ();
+ vbox.PackStart (toggle_button, false, false, 0);
+ pane_tabs[page] = toggle_button;
+
+ if (notebook.NPages == 1) {
+ toggle_button.Active = true;
+ }
+ }
+
+ public void RemovePage (ContextPanePage page)
+ {
+ notebook.RemovePage (notebook.PageNum (page.Widget));
+ vbox.Remove (pane_tabs[page]);
+ pane_tabs.Remove (page);
+ }
+ }
+}
diff --git a/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml b/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
index 9b094b0..2dc7b10 100644
--- a/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
+++ b/src/Core/Banshee.ThickClient/Banshee.ThickClient.addin.xml
@@ -40,6 +40,11 @@
<Description>Defines a new GTK+ source view, possibly in conjunction with a Source extension.</Description>
<ExtensionNode name="SourceView"/>
</ExtensionPoint>
+
+ <ExtensionPoint path="/Banshee/ThickClient/ContextPanePage">
+ <Description>Defines a new GTK+ context pane, for showing contextual information beneath the main track source view.</Description>
+ <ExtensionNode name="ContextPanePage"/>
+ </ExtensionPoint>
<ExtensionPoint path="/Banshee/Gui/TrackEditor/NotebookPage">
<Description>Defines a new notebook page for the track editor.</Description>
diff --git a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
index 5133453..b14d088 100644
--- a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
+++ b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
@@ -227,6 +227,8 @@
<Compile Include="Banshee.Gui.TrackEditor\SortingPage.cs" />
<Compile Include="Banshee.Gui.Widgets\TaskStatusIcon.cs" />
<Compile Include="Banshee.Preferences.Gui\PageComboBox.cs" />
+ <Compile Include="Banshee.Gui.TrackEditor\LicenseEntry.cs" />
+ <Compile Include="Banshee.Gui.Widgets\ContextPane.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
diff --git a/src/Core/Banshee.ThickClient/Makefile.am b/src/Core/Banshee.ThickClient/Makefile.am
index 317e690..845b261 100644
--- a/src/Core/Banshee.ThickClient/Makefile.am
+++ b/src/Core/Banshee.ThickClient/Makefile.am
@@ -85,6 +85,7 @@ SOURCES = \
Banshee.Gui.Widgets/ConnectedMessageBar.cs \
Banshee.Gui.Widgets/ConnectedSeekSlider.cs \
Banshee.Gui.Widgets/ConnectedVolumeButton.cs \
+ Banshee.Gui.Widgets/ContextPane.cs \
Banshee.Gui.Widgets/LargeTrackInfoDisplay.cs \
Banshee.Gui.Widgets/MainMenu.cs \
Banshee.Gui.Widgets/NextButton.cs \
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs
index 1e23fba..20356bf 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationPane.cs
@@ -62,7 +62,22 @@ using Banshee.Lastfm.Radio;
namespace Banshee.Lastfm.Recommendations
{
- public class RecommendationPane : Hyena.Widgets.RoundedFrame
+ public class Page : Banshee.Gui.Widgets.ContextPanePage
+ {
+ public Page ()
+ {
+ Id = "lastfm-recommendations";
+ Name = Catalog.GetString ("Last.fm Recommendations");
+ IconNames = new string[] { "lastfm-audioscrobbler" };
+ }
+
+ private RecommendationPane recs;
+ public override Widget Widget {
+ get { return recs ?? (recs = new RecommendationPane ()); }
+ }
+ }
+
+ public class RecommendationPane : HBox
{
private HBox main_box;
private MessagePane no_artists_pane;
@@ -173,7 +188,7 @@ namespace Banshee.Lastfm.Recommendations
public RecommendationPane () : base ()
{
- main_box = new HBox ();
+ main_box = this;
main_box.BorderWidth = 5;
artist_box = new TitledList (Catalog.GetString ("Recommended Artists"));
@@ -219,8 +234,46 @@ namespace Banshee.Lastfm.Recommendations
main_box.PackStart (track_box, false, false, 5);
no_artists_pane.Hide ();
-
- Add (main_box);
+
+ ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.EndOfStream | PlayerEvent.TrackInfoUpdated);
+ }
+
+ // Dispose
+ // ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+
+ private void OnPlayerEvent (PlayerEventArgs args)
+ {
+ TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
+ if (track != null) {
+ ShowRecommendations (track.ArtistName);
+ }
+ }
+
+ private void UpdateVisibility ()
+ {
+ bool source_is_playback_source = (ServiceManager.SourceManager.ActiveSource as Banshee.Sources.ITrackModelSource) == ServiceManager.PlaybackController.Source;
+ //ShowWhenReady = ShowSchema.Get () && source_is_playback_source;
+ ShowWhenReady = source_is_playback_source;
+ if (!source_is_playback_source) {
+ HideWithTimeout ();
+ } else if (!ShowWhenReady) {
+ Hide ();
+ }
+ }
+
+ private void ShowRecommendations (string artist)
+ {
+ lock (this) {
+ if (Visible && Artist == artist) {
+ return;
+ }
+
+ if (!String.IsNullOrEmpty (artist)) {
+ Artist = artist;
+ }
+
+ UpdateVisibility ();
+ }
}
private void OnSideSizeAllocated (object o, SizeAllocatedArgs args)
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs
index 0d547c1..d71c323 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Recommendations/RecommendationService.cs
@@ -57,92 +57,43 @@ namespace Banshee.Lastfm.Recommendations
{
public class RecommendationService : IExtensionService
{
- private RecommendationPane pane;
private RecommendationActions actions;
void IExtensionService.Initialize ()
{
- pane = new RecommendationPane ();
-
- BaseClientWindow nereid = ServiceManager.Get<IService> ("NereidPlayerInterface") as Banshee.Gui.BaseClientWindow;
- if (nereid != null) {
- nereid.ViewContainer.PackEnd (pane, false, false, 0);
- }
-
actions = new RecommendationActions (this);
ServiceManager.PlaybackController.SourceChanged += OnSourceChanged;
ServiceManager.SourceManager.ActiveSourceChanged += OnActiveSourceChanged;
- ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.EndOfStream | PlayerEvent.TrackInfoUpdated);
}
public void Dispose ()
{
ServiceManager.PlaybackController.SourceChanged -= OnSourceChanged;
ServiceManager.SourceManager.ActiveSourceChanged -= OnActiveSourceChanged;
- ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
-
- if (pane != null) {
- pane.Destroy ();
- pane = null;
- }
actions.Dispose ();
}
private void OnActiveSourceChanged (EventArgs args)
{
- Banshee.Base.ThreadAssist.ProxyToMain (UpdateVisibility);
+ //Banshee.Base.ThreadAssist.ProxyToMain (UpdateVisibility);
}
private void OnSourceChanged (object sender, EventArgs args)
{
- Banshee.Base.ThreadAssist.ProxyToMain (UpdateVisibility);
- }
-
- private void OnPlayerEvent (PlayerEventArgs args)
- {
- TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
- if (track != null) {
- ShowRecommendations (track.ArtistName);
- }
- }
-
- private void UpdateVisibility ()
- {
- bool source_is_playback_source = (ServiceManager.SourceManager.ActiveSource as Banshee.Sources.ITrackModelSource) == ServiceManager.PlaybackController.Source;
- pane.ShowWhenReady = ShowSchema.Get () && source_is_playback_source;
- if (!source_is_playback_source) {
- pane.HideWithTimeout ();
- } else if (!pane.ShowWhenReady) {
- pane.Hide ();
- }
- }
-
- private void ShowRecommendations (string artist)
- {
- lock (this) {
- if (pane.Visible && pane.Artist == artist) {
- return;
- }
-
- if (!String.IsNullOrEmpty (artist)) {
- pane.Artist = artist;
- }
-
- UpdateVisibility ();
- }
+ //Banshee.Base.ThreadAssist.ProxyToMain (UpdateVisibility);
}
public bool RecommendationsShown {
- set {
+ set {/*
ShowSchema.Set (value);
TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
if (track != null) {
pane.Artist = track.ArtistName;
}
- UpdateVisibility ();
+ UpdateVisibility ();*/
}
}
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.addin.xml b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.addin.xml
index 8c55fd8..78947cc 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.addin.xml
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.addin.xml
@@ -19,6 +19,10 @@
<Extension path="/Banshee/SourceManager/Source">
<Source class="Banshee.Lastfm.Radio.LastfmSource"/>
</Extension>
+
+ <Extension path="/Banshee/ThickClient/ContextPanePage">
+ <ContextPanePage class="Banshee.Lastfm.Recommendations.Page"/>
+ </Extension>
<Extension path="/Banshee/ServiceManager/Service">
<Service class="Banshee.Lastfm.Audioscrobbler.AudioscrobblerService"/>
diff --git a/src/Libraries/Hyena/Hyena.csproj b/src/Libraries/Hyena/Hyena.csproj
index 392e5be..4b10ffc 100644
--- a/src/Libraries/Hyena/Hyena.csproj
+++ b/src/Libraries/Hyena/Hyena.csproj
@@ -140,6 +140,13 @@
<Compile Include="Hyena.Data.Sqlite\HyenaSqliteArrayDataReader.cs" />
<Compile Include="Hyena.Data.Sqlite\Tests\SqliteUtilTests.cs" />
<Compile Include="Hyena.Query\ExactStringQueryValue.cs" />
+ <Compile Include="Hyena.Jobs\Job.cs" />
+ <Compile Include="Hyena.Jobs\JobExtensions.cs" />
+ <Compile Include="Hyena.Jobs\PriorityHints.cs" />
+ <Compile Include="Hyena.Jobs\Resource.cs" />
+ <Compile Include="Hyena.Jobs\Scheduler.cs" />
+ <Compile Include="Hyena.Jobs\SimpleAsyncJob.cs" />
+ <Compile Include="Hyena.Jobs\Tests\SchedulerTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]