[banshee] [Audiobook] Start working on a new view



commit 7742161741949069a04879bec340c0a7122dae29
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Dec 18 16:37:39 2009 -0800

    [Audiobook] Start working on a new view

 .../Banshee.Audiobook/AudiobookContent.cs          |   89 ++++++++++++++++++++
 .../Banshee.Audiobook/AudiobookGrid.cs             |   72 ++++++++++++++++
 .../Banshee.Audiobook/AudiobookLibrarySource.cs    |   29 ++++++-
 .../Banshee.Audiobook/AudiobookModel.cs            |   57 +++++++++++++
 src/Extensions/Banshee.Audiobook/Makefile.am       |    5 +-
 5 files changed, 250 insertions(+), 2 deletions(-)
---
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs
new file mode 100644
index 0000000..92e5156
--- /dev/null
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs
@@ -0,0 +1,89 @@
+//
+// AudiobookContent.cs
+//
+// Author:
+//   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.Unix;
+using Gtk;
+
+using Hyena;
+using Hyena.Data;
+using Hyena.Data.Gui;
+
+using Banshee.Widgets;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Collection.Gui;
+using Banshee.Gui;
+using Banshee.Gui.Widgets;
+using Banshee.Sources.Gui;
+using Banshee.Web;
+
+namespace Banshee.Audiobook
+{
+    public class AudiobookContent : ISourceContents
+    {
+        private AudiobookLibrarySource library;
+        private AudiobookGrid grid;
+
+        public AudiobookContent ()
+        {
+            grid = new AudiobookGrid ();
+        }
+
+        public bool SetSource (ISource src)
+        {
+            if (src != null && src == library)
+                return true;
+
+            library = src as AudiobookLibrarySource;
+            if (library == null) {
+                return false;
+            }
+
+            grid.SetModel (library.BooksModel);
+            return true;
+        }
+
+        public ISource Source {
+            get { return library; }
+        }
+
+        public void ResetSource ()
+        {
+            library = null;
+        }
+
+        public Widget Widget {
+            get { return grid; }
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs
new file mode 100644
index 0000000..9f8b6f2
--- /dev/null
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs
@@ -0,0 +1,72 @@
+//
+// AudiobookGrid.cs
+//
+// Author:
+//   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.Unix;
+using Gtk;
+
+using Hyena;
+using Hyena.Data;
+using Hyena.Data.Gui;
+
+using Banshee.Widgets;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Collection.Gui;
+using Banshee.Gui;
+using Banshee.Gui.Widgets;
+using Banshee.Sources.Gui;
+using Banshee.Web;
+
+namespace Banshee.Audiobook
+{
+    public class AudiobookGrid : SearchableListView<AlbumInfo>
+    {
+        private ColumnCellAlbum renderer;
+
+        public AudiobookGrid ()
+        {
+            renderer = new ColumnCellAlbum () { LayoutStyle = DataViewLayoutStyle.Grid };
+            var column_controller = new ColumnController ();
+            column_controller.Add (new Column ("Album", renderer, 1.0));
+
+            LayoutStyle = DataViewLayoutStyle.Grid;
+            ColumnController = column_controller;
+            //RowActivated += OnRowActivated;
+        }
+
+        protected override Gdk.Size OnMeasureChild ()
+        {
+            return renderer.Measure (this);
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
index efb11ef..d5c248e 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
@@ -36,11 +36,19 @@ using Hyena;
 using Banshee.Library;
 using Banshee.Collection;
 using Banshee.SmartPlaylist;
+using Banshee.Collection.Database;
+using Banshee.Sources;
+using Banshee.Database;
+using Banshee.ServiceStack;
+
+using Banshee.Sources.Gui;
 
 namespace Banshee.Audiobook
 {
     public class AudiobookLibrarySource : LibrarySource
     {
+        private AudiobookModel books_model;
+
         public AudiobookLibrarySource () : base (Catalog.GetString ("Audiobooks, etc"), "AudiobookLibrary", 49)
         {
             MediaTypes = TrackMediaAttributes.AudioBook;
@@ -69,8 +77,23 @@ namespace Banshee.Audiobook
             var pattern = new AudiobookFileNamePattern ();
             pattern.FolderSchema = CreateSchema<string> ("folder_pattern", pattern.DefaultFolder, "", "");
             pattern.FileSchema   = CreateSchema<string> ("file_pattern",   pattern.DefaultFile, "", "");
-
             SetFileNamePattern (pattern);
+
+            Properties.Set<ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents<AudiobookContent> ());
+        }
+
+        protected override IEnumerable<IFilterListModel> CreateFiltersFor (DatabaseSource src)
+        {
+            var books_model = new AudiobookModel (this, this.DatabaseTrackModel, ServiceManager.DbConnection, this.UniqueId);
+            if (src == this) {
+                this.books_model = books_model;
+            }
+
+            yield return books_model;
+        }
+
+        public DatabaseAlbumListModel BooksModel {
+            get { return books_model; }
         }
 
         public override string DefaultBaseDirectory {
@@ -85,6 +108,10 @@ namespace Banshee.Audiobook
             get { return false; }
         }
 
+        public override bool CanShuffle {
+            get { return false; }
+        }
+
         public override IEnumerable<SmartPlaylistDefinition> DefaultSmartPlaylists {
             get { yield break; }
         }
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs
new file mode 100644
index 0000000..199b604
--- /dev/null
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookModel.cs
@@ -0,0 +1,57 @@
+//
+// AudiobookModel.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008-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.Unix;
+
+using Banshee.Library;
+using Banshee.Collection;
+using Banshee.SmartPlaylist;
+using Banshee.Collection.Database;
+using Banshee.Sources;
+using Banshee.Database;
+using Banshee.ServiceStack;
+
+using Banshee.Sources.Gui;
+
+namespace Banshee.Audiobook
+{
+    public class AudiobookModel : DatabaseAlbumListModel
+    {
+        public AudiobookModel (DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) : base (source, trackModel, connection, uuid)
+        {
+        }
+
+        public override void UpdateSelectAllItem (long count)
+        {
+            select_all_item.Title = String.Format (Catalog.GetString ("All Works ({0})"), count);
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Audiobook/Makefile.am b/src/Extensions/Banshee.Audiobook/Makefile.am
index 9291598..272ac22 100644
--- a/src/Extensions/Banshee.Audiobook/Makefile.am
+++ b/src/Extensions/Banshee.Audiobook/Makefile.am
@@ -5,7 +5,10 @@ INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
 SOURCES =  \
 	Banshee.Audiobook/AudiobookFileNamePattern.cs \
-	Banshee.Audiobook/AudiobookLibrarySource.cs
+	Banshee.Audiobook/AudiobookLibrarySource.cs \
+	Banshee.Audiobook/AudiobookContent.cs \
+	Banshee.Audiobook/AudiobookGrid.cs \
+	Banshee.Audiobook/AudiobookModel.cs
 
 RESOURCES = Banshee.Audiobook.addin.xml
 



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