Add support for showing a year column and searching track by year. The year
column visibility defaults to false.

 ChangeLog               |    9 +++++++++
 data/banshee.schemas.in |   22 ++++++++++++++++++++++
 src/PlayerInterface.cs  |    6 +++++-
 src/PlaylistView.cs     |   35 ++++++++++++++++++++++++++++++-----
 4 files changed, 66 insertions(+), 6 deletions(-)

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/banshee/ChangeLog,v
retrieving revision 1.525
diff -u -p -u -p -r1.525 ChangeLog
--- ChangeLog	10 Jul 2006 22:54:08 -0000	1.525
+++ ChangeLog	12 Jul 2006 10:52:01 -0000
@@ -1,3 +1,12 @@
+2006-07-12  Ruben Vermeersch  <ruben@Lambda1.be>
+
+	Patch by Bertrand Lorentz <bertrand.lorentz@gmail.com> (BGO #336761)
+
+	* data/banshee.schemas.in: 
+	* src/PlayerInterface.cs:
+	* src/PlaylistView.cs: Add support for showing a year column and searching
+	track by year. The year column visibility defaults to false.
+
 2006-07-11  Ruben Vermeersch  <ruben@Lambda1.be>
 
 	* src/Banshee.Base/Plugins/PluginFactory.cs: Create user plugin dir if it
Index: data/banshee.schemas.in
===================================================================
RCS file: /cvs/gnome/banshee/data/banshee.schemas.in,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 banshee.schemas.in
--- data/banshee.schemas.in	18 Apr 2006 03:25:39 -0000	1.17
+++ data/banshee.schemas.in	12 Jul 2006 10:52:02 -0000
@@ -288,6 +288,28 @@
       </locale>
     </schema>
     <schema>
+      <key>/schemas/apps/Banshee/PlaylistColumns/Year/Width</key>
+      <applyto>/apps/Banshee/PlaylistColumns/Year/Width</applyto>
+      <owner>banshee</owner>
+      <type>int</type>
+      <default>45</default>
+      <locale name="C">
+        <short>Width of Year Column.</short>
+        <long>Width of Year Column.</long>
+      </locale>
+    </schema>
+    <schema>
+      <key>/schemas/apps/Banshee/PlaylistColumns/Year/Visible</key>
+      <applyto>/apps/Banshee/PlaylistColumns/Year/Visible</applyto>
+      <owner>banshee</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Visibility of Year Column.</short>
+        <long>Visibility of Year Column.</long>
+      </locale>
+    </schema>
+    <schema>
       <key>/schemas/apps/Banshee/Volume</key>
       <applyto>/apps/Banshee/Volume</applyto>
       <owner>banshee</owner>
Index: src/PlayerInterface.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v
retrieving revision 1.197
diff -u -p -u -p -r1.197 PlayerInterface.cs
--- src/PlayerInterface.cs	3 Jul 2006 00:44:00 -0000	1.197
+++ src/PlayerInterface.cs	12 Jul 2006 10:52:05 -0000
@@ -431,6 +431,7 @@ namespace Banshee
             fields.Add(Catalog.GetString("Artist Name"));
             fields.Add(Catalog.GetString("Album Title"));
             fields.Add(Catalog.GetString("Genre"));
+            fields.Add(Catalog.GetString("Year"));
             
             searchEntry = new SearchEntry(fields);
             searchEntry.EnterPress += delegate(object o, EventArgs args) {
@@ -1311,12 +1312,15 @@ namespace Banshee
                 matches = new string [] { ti.Album };
             } else if(field == Catalog.GetString("Genre")) {
                 matches = new string [] { ti.Genre };
+            } else if(field == Catalog.GetString("Year")) {
+                matches = new string [] { ti.Year.ToString() };
             } else {
                 matches = new string [] {
                     ti.Artist,
                     ti.Album,
                     ti.Title,
-                    ti.Genre
+                    ti.Genre,
+                    ti.Year.ToString()
                 };
             }
             
Index: src/PlaylistView.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlaylistView.cs,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 PlaylistView.cs
--- src/PlaylistView.cs	2 Jul 2006 21:47:38 -0000	1.52
+++ src/PlaylistView.cs	12 Jul 2006 10:52:05 -0000
@@ -58,6 +58,7 @@ namespace Banshee
             Title,
             Album,
             Genre,
+            Year,
             Time,
             Rating,
             PlayCount,
@@ -105,28 +106,31 @@ namespace Banshee
             columns.Add(new PlaylistColumn(this, Catalog.GetString("Genre"), "Genre", 
                 new TreeCellDataFunc(TrackCellGenre), new CellRendererText(),
                 4, (int)ColumnId.Genre));
-            columns.Add(new PlaylistColumn(this, Catalog.GetString("Time"), "Time", 
+            columns.Add(new PlaylistColumn(this, Catalog.GetString("Year"), "Year", 
+                new TreeCellDataFunc(TrackCellYear), new CellRendererText(),
+                5, (int)ColumnId.Year));
+           	columns.Add(new PlaylistColumn(this, Catalog.GetString("Time"), "Time", 
                 new TreeCellDataFunc(TrackCellTime), new CellRendererText(),
-                5, (int)ColumnId.Time));
+                6, (int)ColumnId.Time));
             
             RatingColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Rating"), "Rating",
                 new TreeCellDataFunc(TrackCellRating), new RatingRenderer(),
-                6, (int)ColumnId.Rating);
+                7, (int)ColumnId.Rating);
             columns.Add(RatingColumn);
             
             PlaysColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Plays"), "Plays",
                 new TreeCellDataFunc(TrackCellPlayCount), 
                 new CellRendererText(),
-                7, (int)ColumnId.PlayCount);
+                8, (int)ColumnId.PlayCount);
             columns.Add(PlaysColumn);
             
             LastPlayedColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Last Played"), "Last-Played",
                 new TreeCellDataFunc(TrackCellLastPlayed), 
                 new CellRendererText(),
-                8, (int)ColumnId.LastPlayed);
+                9, (int)ColumnId.LastPlayed);
             columns.Add(LastPlayedColumn);
             
             columns.Sort(new ColumnSorter());
@@ -195,6 +199,8 @@ namespace Banshee
                 new TreeIterCompareFunc(AlbumTreeIterCompareFunc));
             model.SetSortFunc((int)ColumnId.Genre, 
                 new TreeIterCompareFunc(GenreTreeIterCompareFunc));
+            model.SetSortFunc((int)ColumnId.Year, 
+                new TreeIterCompareFunc(YearTreeIterCompareFunc));
             model.SetSortFunc((int)ColumnId.Time, 
                 new TreeIterCompareFunc(TimeTreeIterCompareFunc));
             model.SetSortFunc((int)ColumnId.Rating, 
@@ -285,6 +291,13 @@ namespace Banshee
                 model.IterTrackInfo(b).Genre);
         }
         
+        public int YearTreeIterCompareFunc(TreeModel _model, TreeIter a,
+            TreeIter b)
+        {
+            return LongFieldCompare(model.IterTrackInfo(a).Year, 
+                model.IterTrackInfo(b).Year);
+        }
+        
         public int TimeTreeIterCompareFunc(TreeModel _model, TreeIter a,
             TreeIter b)
         {
@@ -471,6 +484,18 @@ namespace Banshee
             }
             
             SetRendererAttributes((CellRendererText)cell, ti.Genre, iter);
+        }
+        
+        protected void TrackCellYear(TreeViewColumn tree_column,
+            CellRenderer cell, TreeModel tree_model, TreeIter iter)
+        {
+            TrackInfo ti = model.IterTrackInfo(iter);
+            if(ti == null) {
+                return;
+            }
+            
+            int year = ti.Year;
+            SetRendererAttributes((CellRendererText)cell, year > 0 ? Convert.ToString(year) : String.Empty, iter);
         }
         
         protected void TrackCellTime(TreeViewColumn tree_column,
