banshee r4238 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Extensions/Banshee.AudioCd/Banshee.AudioCd src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4238 - in trunk/banshee: . src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Extensions/Banshee.AudioCd/Banshee.AudioCd src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui
- Date: Tue, 22 Jul 2008 14:33:10 +0000 (UTC)
Author: gburt
Date: Tue Jul 22 14:33:10 2008
New Revision: 4238
URL: http://svn.gnome.org/viewvc/banshee?rev=4238&view=rev
Log:
2008-07-21 Gabriel Burt <gabriel burt gmail com>
This commit does the backend (non-UI) work to make filters (eg
artist/album/genre/etc browsers) on sources customizable. All the UI work
still needs to be done - actually supporting showing an arbitrary number
and set of filters, and the UI, perhaps menus, to actually
add/remove/replace filters.
* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs:
* src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs:
Since the FilterModels property was removed from the ITrackModelSource, no
longer need to implement it for sources that aren't filterable.
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs:
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs:
* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs:
Renamed FilterModels property to CurrentFilters.
* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs:
Use the new AvailableFilters and DefaultFilters properties instead of just
overriding the FilterModels property.
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs:
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs:
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseQueryFilterModel.cs:
* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastFeedModel.cs:
Pass a name and label to the filter ctor, so we can expose the label in a
menu later to make the filters customizable.
* src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs:
Make the changes necessary to display a genre browser, but keep it hidden
for now because the Composite widget is hard coded to show three filters,
even if a source only has one.
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseFilterListModel.cs:
Set the FilterName and Label from the new ctor args.
* src/Core/Banshee.Services/Makefile.am:
* src/Core/Banshee.Services/Banshee.Services.mdp:
* src/Core/Banshee.Services/Banshee.Sources/IFilterableSource.cs: New
interface that exposes CurrentFilters property and a FiltersChanged event.
* src/Core/Banshee.Services/Banshee.Sources/ITrackModelSource.cs: Remove
the FilterModels property (and comment cruft).
* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Add a bunch
of methods for allowing customization of filters -
adding/removing/replacing them, and saving/loading to/from gconf.
* src/Core/Banshee.Services/Banshee.Sources/Source.cs: Add CreateSchema
convenience methods that given a name and a T give you a source-scoped
SchemaEntry.
* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs: Avoid NRE by
using a lazily-loaded property instead of its backing variable.
* src/Core/Banshee.Services/Banshee.Collection/IFilterListModel.cs:
* src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs: Add
InvalidateCache method.
Added:
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/IFilterableSource.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseFilterListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseQueryFilterModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/IFilterListModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ITrackModelSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
trunk/banshee/src/Core/Banshee.Services/Makefile.am
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs
trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs
trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastFeedModel.cs
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs Tue Jul 22 14:33:10 2008
@@ -43,7 +43,8 @@
public class DatabaseAlbumListModel : DatabaseFilterListModel<DatabaseAlbumInfo, AlbumInfo>
{
public DatabaseAlbumListModel ( Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
- : base (source, trackModel, connection, DatabaseAlbumInfo.Provider, new AlbumInfo (null), uuid)
+ : base (Banshee.Query.BansheeQuery.AlbumField.Name, Banshee.Query.BansheeQuery.AlbumField.Label,
+ source, trackModel, connection, DatabaseAlbumInfo.Provider, new AlbumInfo (null), uuid)
{
ReloadFragmentFormat = @"
FROM CoreAlbums WHERE CoreAlbums.AlbumID IN
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs Tue Jul 22 14:33:10 2008
@@ -42,7 +42,8 @@
public class DatabaseArtistListModel : DatabaseFilterListModel<DatabaseArtistInfo, ArtistInfo>
{
public DatabaseArtistListModel (Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
- : base (source, trackModel, connection, DatabaseArtistInfo.Provider, new ArtistInfo (null), uuid)
+ : base (Banshee.Query.BansheeQuery.ArtistField.Name, Banshee.Query.BansheeQuery.ArtistField.Label,
+ source, trackModel, connection, DatabaseArtistInfo.Provider, new ArtistInfo (null), uuid)
{
ReloadFragmentFormat = @"
FROM CoreArtists WHERE CoreArtists.ArtistID IN
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseFilterListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseFilterListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseFilterListModel.cs Tue Jul 22 14:33:10 2008
@@ -58,10 +58,13 @@
protected readonly U select_all_item;
- public DatabaseFilterListModel (Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, HyenaSqliteConnection connection, SqliteModelProvider<T> provider, U selectAllItem, string uuid)
+ public DatabaseFilterListModel (string name, string label, Banshee.Sources.DatabaseSource source,
+ DatabaseTrackListModel trackModel, HyenaSqliteConnection connection, SqliteModelProvider<T> provider, U selectAllItem, string uuid)
: base (trackModel)
{
this.source = source;
+ FilterName = name;
+ FilterLabel = label;
select_all_item = selectAllItem;
cache = new BansheeModelCache <T> (connection, uuid, this, provider);
@@ -102,7 +105,7 @@
private IEnumerable<IFilterListModel> UpstreamFilters {
get {
- foreach (IFilterListModel model in source.FilterModels) {
+ foreach (IFilterListModel model in source.CurrentFilters) {
if (this == model) {
break;
} else {
@@ -194,7 +197,7 @@
}
}
- public void InvalidateCache ()
+ public override void InvalidateCache ()
{
cache.ClearManagedCache ();
OnReloaded ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseQueryFilterModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseQueryFilterModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseQueryFilterModel.cs Tue Jul 22 14:33:10 2008
@@ -45,7 +45,7 @@
public DatabaseQueryFilterModel (Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel,
HyenaSqliteConnection connection, string select_all_fmt, string uuid, QueryField field, string filter_column)
- : base (source, trackModel, connection, QueryFilterInfo<T>.CreateProvider (filter_column, field), new QueryFilterInfo<T> (), String.Format ("{0}-{1}", uuid, field.Name))
+ : base (field.Name, field.Label, source, trackModel, connection, QueryFilterInfo<T>.CreateProvider (filter_column, field), new QueryFilterInfo<T> (), String.Format ("{0}-{1}", uuid, field.Name))
{
this.field = field;
this.select_all_fmt = select_all_fmt;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs Tue Jul 22 14:33:10 2008
@@ -223,10 +223,10 @@
List<IFilterListModel> reload_models = new List<IFilterListModel> ();
bool found = (reloadTrigger == null);
- foreach (IFilterListModel model in source.FilterModels) {
+ foreach (IFilterListModel filter in source.CurrentFilters) {
if (found) {
- reload_models.Add (model);
- } else if (model == reloadTrigger) {
+ reload_models.Add (filter);
+ } else if (filter == reloadTrigger) {
found = true;
}
}
@@ -241,8 +241,8 @@
}
bool have_filters = false;
- foreach (IFilterListModel model in source.FilterModels) {
- have_filters |= !model.Selection.AllSelected;
+ foreach (IFilterListModel filter in source.CurrentFilters) {
+ have_filters |= !filter.Selection.AllSelected;
}
// Unless both artist/album selections are "all" (eg unfiltered), reload
@@ -277,11 +277,11 @@
qb.Append (UnfilteredQuery);
if (with_filters) {
- foreach (IFilterListModel model in source.FilterModels) {
- string filter = model.GetSqlFilter ();
- if (filter != null) {
+ foreach (IFilterListModel filter in source.CurrentFilters) {
+ string filter_sql = filter.GetSqlFilter ();
+ if (filter_sql != null) {
qb.Append (" AND ");
- qb.Append (filter);
+ qb.Append (filter_sql);
}
}
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/FilterListModel.cs Tue Jul 22 14:33:10 2008
@@ -88,6 +88,10 @@
get { return filter_label; }
protected set { filter_label = value; }
}
+
+ public virtual void InvalidateCache ()
+ {
+ }
#endregion
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/IFilterListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/IFilterListModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/IFilterListModel.cs Tue Jul 22 14:33:10 2008
@@ -38,5 +38,6 @@
void Reload (bool notify);
string FilterName { get; }
string FilterLabel { get; }
+ void InvalidateCache ();
}
}
\ No newline at end of file
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp Tue Jul 22 14:33:10 2008
@@ -179,6 +179,7 @@
<File name="Banshee.Collection.Database/DatabaseQueryFilterModel.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Collection.Database/FilterModelProvider.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Collection.Database/QueryFilterInfo.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Sources/IFilterableSource.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
@@ -206,4 +207,4 @@
<AsmRefVar />
<ProjectRefVar />
</MonoDevelop.Autotools.MakefileInfo>
-</Project>
\ No newline at end of file
+</Project>
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs Tue Jul 22 14:33:10 2008
@@ -28,6 +28,7 @@
//
using System;
+using System.Text;
using System.Collections.Generic;
using Mono.Unix;
@@ -43,12 +44,15 @@
using Banshee.Sources;
using Banshee.Collection;
using Banshee.Collection.Database;
+using Banshee.Configuration;
using Banshee.Query;
namespace Banshee.Sources
{
- public abstract class DatabaseSource : Source, ITrackModelSource, IDurationAggregator, IFileSizeAggregator
+ public abstract class DatabaseSource : Source, ITrackModelSource, IFilterableSource, IDurationAggregator, IFileSizeAggregator
{
+ public event EventHandler FiltersChanged;
+
protected delegate void TrackRangeHandler (DatabaseTrackListModel model, RangeCollection.Range range);
protected DatabaseTrackListModel track_model;
@@ -56,6 +60,13 @@
protected DatabaseArtistListModel artist_model;
private DatabaseQueryFilterModel<string> genre_model;
+ protected DatabaseQueryFilterModel<string> GenreModel {
+ get {
+ return genre_model ??
+ genre_model = new Banshee.Collection.Database.DatabaseQueryFilterModel<string> (this, DatabaseTrackModel, ServiceManager.DbConnection,
+ Catalog.GetString ("All Genres ({0})"), UniqueId, BansheeQuery.GenreField, "Genre");
+ }
+ }
protected RateLimiter reload_limiter;
@@ -109,13 +120,20 @@
private void DatabaseSourceInitialize ()
{
InitializeTrackModel ();
+
+ current_filters_schema = CreateSchema<string[]> ("current_filters");
if (HasArtistAlbum) {
- genre_model = new Banshee.Collection.Database.DatabaseQueryFilterModel<string> (this, DatabaseTrackModel, ServiceManager.DbConnection,
- Catalog.GetString ("All Genres ({0})"), UniqueId, BansheeQuery.GenreField, "Genre");
-
artist_model = new DatabaseArtistListModel (this, DatabaseTrackModel, ServiceManager.DbConnection, UniqueId);
album_model = new DatabaseAlbumListModel (this, DatabaseTrackModel, ServiceManager.DbConnection, UniqueId);
+
+ AvailableFilters.Add (GenreModel);
+ AvailableFilters.Add (artist_model);
+ AvailableFilters.Add (album_model);
+
+ DefaultFilters.Add (GenreModel);
+ DefaultFilters.Add (artist_model);
+ DefaultFilters.Add (album_model);
}
reload_limiter = new RateLimiter (RateLimitedReload);
@@ -227,19 +245,6 @@
get { return DatabaseTrackModel; }
}
- public virtual IEnumerable<IFilterListModel> FilterModels {
- get {
- if (genre_model != null)
- yield return genre_model;
-
- if (artist_model != null)
- yield return artist_model;
-
- if (album_model != null)
- yield return album_model;
- }
- }
-
public virtual bool ShowBrowser {
get { return true; }
}
@@ -256,6 +261,94 @@
}
#endregion
+
+#region Filters (aka Browsers)
+
+ private IList<IFilterListModel> available_filters;
+ public IList<IFilterListModel> AvailableFilters {
+ get { return available_filters ?? available_filters = new List<IFilterListModel> (); }
+ protected set { available_filters = value; }
+ }
+
+ private IList<IFilterListModel> default_filters;
+ public IList<IFilterListModel> DefaultFilters {
+ get { return default_filters ?? default_filters = new List<IFilterListModel> (); }
+ protected set { default_filters = value; }
+ }
+
+ private IList<IFilterListModel> current_filters;
+ public IList<IFilterListModel> CurrentFilters {
+ get {
+ if (current_filters == null) {
+ current_filters = new List<IFilterListModel> ();
+ string [] current = current_filters_schema.Get ();
+ if (current != null) {
+ foreach (string filter_name in current) {
+ foreach (IFilterListModel filter in AvailableFilters) {
+ if (filter.FilterName == filter_name) {
+ current_filters.Add (filter);
+ break;
+ }
+ }
+ }
+ } else {
+ foreach (IFilterListModel filter in DefaultFilters) {
+ current_filters.Add (filter);
+ }
+ }
+ }
+ return current_filters;
+ }
+ protected set { current_filters = value; }
+ }
+
+ public void ReplaceFilter (IFilterListModel old_filter, IFilterListModel new_filter)
+ {
+ int i = current_filters.IndexOf (old_filter);
+ if (i != -1) {
+ current_filters[i] = new_filter;
+ SaveCurrentFilters ();
+ }
+ }
+
+ public void AppendFilter (IFilterListModel filter)
+ {
+ if (current_filters.IndexOf (filter) == -1) {
+ current_filters.Add (filter);
+ SaveCurrentFilters ();
+ }
+ }
+
+ public void RemoveFilter (IFilterListModel filter)
+ {
+ if (current_filters.Remove (filter)) {
+ SaveCurrentFilters ();
+ }
+ }
+
+ private void SaveCurrentFilters ()
+ {
+ Reload ();
+ if (current_filters == null) {
+ current_filters_schema.Set (null);
+ } else {
+ string [] filters = new string [current_filters.Count];
+ int i = 0;
+ foreach (IFilterListModel filter in CurrentFilters) {
+ filters[i++] = filter.FilterName;
+ }
+ current_filters_schema.Set (filters);
+ }
+
+ EventHandler handler = FiltersChanged;
+ if (handler != null) {
+ handler (this, EventArgs.Empty);
+ }
+ }
+
+ private SchemaEntry<string[]> current_filters_schema;
+
+#endregion
#region Public Methods
@@ -531,16 +624,10 @@
protected void InvalidateCaches ()
{
track_model.InvalidateCache ();
-
- if (genre_model != null)
- genre_model.InvalidateCache ();
-
- // TODO invalidate cache on all FilterModels
- if (artist_model != null)
- artist_model.InvalidateCache ();
- if (album_model != null)
- album_model.InvalidateCache ();
+ foreach (IFilterListModel filter in CurrentFilters) {
+ filter.InvalidateCache ();
+ }
}
protected virtual void PruneArtistsAlbums ()
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/IFilterableSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/IFilterableSource.cs Tue Jul 22 14:33:10 2008
@@ -0,0 +1,43 @@
+//
+// IFilterableSource.cs
+//
+// Author:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 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 NDesk.DBus;
+
+using Banshee.Collection;
+
+namespace Banshee.Sources
+{
+ public interface IFilterableSource : ISource
+ {
+ event EventHandler FiltersChanged;
+ IList<Banshee.Collection.Database.IFilterListModel> CurrentFilters { get; }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ITrackModelSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ITrackModelSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/ITrackModelSource.cs Tue Jul 22 14:33:10 2008
@@ -38,11 +38,6 @@
public interface ITrackModelSource : ISource
{
TrackListModel TrackModel { get; }
-
- IEnumerable<Banshee.Collection.Database.IFilterListModel> FilterModels { get; }
-
- //AlbumListModel AlbumModel { get; }
- //ArtistListModel ArtistModel { get; }
void Reload ();
bool HasDependencies { get; }
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs Tue Jul 22 14:33:10 2008
@@ -232,7 +232,7 @@
private void PrimarySourceInitialize ()
{
// Scope the tracks to this primary source
- track_model.AddCondition (String.Format ("CoreTracks.PrimarySourceID = {0}", DbId));
+ DatabaseTrackModel.AddCondition (String.Format ("CoreTracks.PrimarySourceID = {0}", DbId));
primary_sources[DbId] = this;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs Tue Jul 22 14:33:10 2008
@@ -554,6 +554,16 @@
set { ConfigurationClient.Set<int> (String.Format ("sources.{0}", ConfigurationId), "status_format", value); }
}
+ public SchemaEntry<T> CreateSchema<T> (string name)
+ {
+ return CreateSchema<T> (name, default(T), null, null);
+ }
+
+ public SchemaEntry<T> CreateSchema<T> (string name, T defaultValue, string shotDescription, string longDescription)
+ {
+ return new SchemaEntry<T> (String.Format ("sources.{0}", ConfigurationId), name, defaultValue, shotDescription, longDescription);
+ }
+
public void CycleStatusFormat ()
{
int new_status_format = CurrentStatusFormat + 1;
Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am Tue Jul 22 14:33:10 2008
@@ -159,6 +159,7 @@
Banshee.Sources/IDiskUsageReporter.cs \
Banshee.Sources/IDurationAggregator.cs \
Banshee.Sources/IFileSizeAggregator.cs \
+ Banshee.Sources/IFilterableSource.cs \
Banshee.Sources/IImportable.cs \
Banshee.Sources/ISource.cs \
Banshee.Sources/ISourceManager.cs \
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs Tue Jul 22 14:33:10 2008
@@ -138,9 +138,9 @@
public override bool SetSource (ISource source)
{
- //Console.WriteLine ("CTSC.set_source 1");
ITrackModelSource track_source = source as ITrackModelSource;
- if (track_source == null) {
+ IFilterableSource filterable_source = source as IFilterableSource;
+ if (track_source == null || filterable_source == null) {
return false;
}
@@ -148,32 +148,31 @@
SetModel (track_view, track_source.TrackModel);
- foreach (IListModel model in track_source.FilterModels) {
- if (model is IListModel<ArtistInfo>)
- SetModel (artist_view, (model as IListModel<ArtistInfo>));
- else if (model is IListModel<AlbumInfo>)
- SetModel (album_view, (model as IListModel<AlbumInfo>));
- else if (model is IListModel<QueryFilterInfo<string>>)
- SetModel (genre_view, (model as IListModel<QueryFilterInfo<string>>));
- else
- Hyena.Log.DebugFormat ("CompositeTrackSourceContents got non-album/artist filter model: {0}", model);
+ if (filterable_source.CurrentFilters != null) {
+ foreach (IListModel model in filterable_source.CurrentFilters) {
+ if (model is IListModel<ArtistInfo>)
+ SetModel (artist_view, (model as IListModel<ArtistInfo>));
+ else if (model is IListModel<AlbumInfo>)
+ SetModel (album_view, (model as IListModel<AlbumInfo>));
+ else if (model is IListModel<QueryFilterInfo<string>>)
+ SetModel (genre_view, (model as IListModel<QueryFilterInfo<string>>));
+ else
+ Hyena.Log.DebugFormat ("CompositeTrackSourceContents got non-album/artist filter model: {0}", model);
+ }
}
track_view.HeaderVisible = true;
- //Console.WriteLine ("CTSC.set_source 2");
return true;
}
public override void ResetSource ()
{
- //Console.WriteLine ("CTSC.reset_source 1");
source = null;
track_view.SetModel (null);
artist_view.SetModel (null);
album_view.SetModel (null);
genre_view.SetModel (null);
track_view.HeaderVisible = false;
- //Console.WriteLine ("CTSC.reset_source 2");
}
#endregion
Modified: trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.AudioCd/Banshee.AudioCd/AudioCdSource.cs Tue Jul 22 14:33:10 2008
@@ -27,6 +27,7 @@
//
using System;
+using System.Collections.Generic;
using System.Threading;
using Mono.Unix;
@@ -35,6 +36,7 @@
using Banshee.ServiceStack;
using Banshee.Sources;
using Banshee.Collection;
+using Banshee.Collection.Database;
using Gtk;
using Banshee.Gui;
@@ -67,7 +69,7 @@
disc_model.MetadataQueryFinished += OnMetadataQueryFinished;
disc_model.EnabledCountChanged += OnEnabledCountChanged;
disc_model.LoadModelFromDisc ();
-
+
SetupGui ();
}
@@ -82,10 +84,6 @@
}
}
- public System.Collections.Generic.IEnumerable<Banshee.Collection.Database.IFilterListModel> FilterModels {
- get { yield break; }
- }
-
public void StopPlayingDisc ()
{
if (DiscIsPlaying) {
Modified: trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs Tue Jul 22 14:33:10 2008
@@ -52,14 +52,13 @@
}
private uint ui_id;
- // private InternetRadioSourceContents source_contents;
- public InternetRadioSource () : base (Catalog.GetString ("Radio"),
- Catalog.GetString ("Radio"), "internet-radio", 220)
+ public InternetRadioSource () : base (Catalog.GetString ("Radio"), Catalog.GetString ("Radio"), "internet-radio", 220)
{
Properties.SetString ("Icon.Name", "radio");
IsLocal = false;
+ InternetRadioInitialize ();
AfterInitialized ();
InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
@@ -75,9 +74,6 @@
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
Properties.SetString ("GtkActionPath", "/InternetRadioContextMenu");
- // source_contents = new InternetRadioSourceContents ();
- // Properties.Set<ISourceContents> ("Nereid.SourceContents", source_contents);
-
Properties.SetString ("TrackPropertiesActionLabel", Catalog.GetString ("Edit Station"));
Properties.Set<InvokeHandler> ("TrackPropertiesActionHandler", delegate {
if (TrackModel.SelectedItems == null || TrackModel.SelectedItems.Count <= 0) {
@@ -101,7 +97,7 @@
<add-default column=""IndicatorColumn"" />
<add-default column=""GenreColumn"" />
<column modify-default=""GenreColumn"">
- <visible>true</visible>
+ <visible>false</visible>
</column>
<add-default column=""TitleColumn"" />
<add-default column=""ArtistColumn"" />
@@ -137,6 +133,18 @@
}
}
+ protected override void Initialize ()
+ {
+ base.Initialize ();
+ InternetRadioInitialize ();
+ }
+
+ private void InternetRadioInitialize ()
+ {
+ AvailableFilters.Add (GenreModel);
+ DefaultFilters.Add (GenreModel);
+ }
+
public override void Dispose ()
{
base.Dispose ();
@@ -235,7 +243,8 @@
public override bool CanDeleteTracks {
get { return false; }
}
-
+
+ // TODO change this to true once the Composite widget is made to work w/ variable number/type of filters
public override bool ShowBrowser {
get { return false; }
}
@@ -243,5 +252,9 @@
public override bool CanRename {
get { return false; }
}
+
+ protected override bool HasArtistAlbum {
+ get { return false; }
+ }
}
}
Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs Tue Jul 22 14:33:10 2008
@@ -114,10 +114,6 @@
get { return Convert.ToString (dbid); }
}
- public System.Collections.Generic.IEnumerable<Banshee.Collection.Database.IFilterListModel> FilterModels {
- get { yield break; }
- }
-
// For StationSources that already exist in the db
protected StationSource (LastfmSource lastfm, int dbId, string name, string type, string arg, int playCount) : base (generic_name, name, 150)
{
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastFeedModel.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastFeedModel.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastFeedModel.cs Tue Jul 22 14:33:10 2008
@@ -44,7 +44,7 @@
public class PodcastFeedModel : DatabaseFilterListModel<Feed, Feed>
{
public PodcastFeedModel (Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
- : base (source, trackModel, connection, Feed.Provider, new Feed (null, FeedAutoDownload.None), uuid)
+ : base ("podcast", Catalog.GetString ("Podcast"), source, trackModel, connection, Feed.Provider, new Feed (null, FeedAutoDownload.None), uuid)
{
ReloadFragmentFormat = @"
FROM PodcastSyndications WHERE FeedID IN
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastSource.cs Tue Jul 22 14:33:10 2008
@@ -158,6 +158,12 @@
unheard_model = new PodcastUnheardFilterModel (DatabaseTrackModel);
+ AvailableFilters.Add (unheard_model);
+ AvailableFilters.Add (feed_model);
+
+ DefaultFilters.Add (unheard_model);
+ DefaultFilters.Add (feed_model);
+
AfterInitialized ();
}
@@ -191,13 +197,6 @@
base.AddTrack (track);
}*/
- public override System.Collections.Generic.IEnumerable<Banshee.Collection.Database.IFilterListModel> FilterModels {
- get {
- yield return unheard_model;
- yield return feed_model;
- }
- }
-
public override bool ShowBrowser {
get { return true; }
}
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackInfo.cs Tue Jul 22 14:33:10 2008
@@ -231,6 +231,7 @@
protected override void ProviderSave ()
{
+ MediaAttributes |= TrackMediaAttributes.Podcast;
Provider.Save (this);
}
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastSourceContents.cs Tue Jul 22 14:33:10 2008
@@ -100,7 +100,7 @@
SetModel (track_view, track_source.TrackModel);
- foreach (IListModel model in track_source.FilterModels) {
+ foreach (IListModel model in track_source.CurrentFilters) {
if (model is PodcastFeedModel)
SetModel (feed_view, (model as IListModel<Feed>));
else if (model is PodcastUnheardFilterModel)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]