[banshee/1.5.1-fixes: 1/56] Culturally format integer columns except year



commit ee9b0fd847995ee919fd9e789d067425b4d71903
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Oct 7 15:40:18 2009 -0700

    Culturally format integer columns except year
    
    So a play count of 1000 will now appear as 1,000 in US locale.

 .../ColumnCellPositiveInt.cs                       |   11 ++++++++++-
 .../DefaultColumnController.cs                     |    2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellPositiveInt.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellPositiveInt.cs
index de455c4..f9fc15c 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellPositiveInt.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellPositiveInt.cs
@@ -34,10 +34,13 @@ namespace Banshee.Collection.Gui
 {
     public class ColumnCellPositiveInt : ColumnCellText
     {
+        public bool CultureFormatted { get; set; }
+
         public ColumnCellPositiveInt (string property, bool expand, int min_digits, int max_digits) : base (property, expand)
         {
             SetMinMaxStrings ((int)Math.Pow (10, min_digits) - 1, (int)Math.Pow (10, max_digits) - 1);
             Alignment = Pango.Alignment.Right;
+            CultureFormatted = true;
         }
         
         protected override string GetText (object obj)
@@ -47,7 +50,13 @@ namespace Banshee.Collection.Gui
             }
 
             int val = (int) obj;
-            return val > 0 ? val.ToString () : String.Empty;
+
+            if (val <= 0)
+                return "";
+            else if (CultureFormatted)
+                return val.ToString ("N0");
+            else
+                return val.ToString ();
         }
     }
 }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
index 5c475db..b6ad97a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
@@ -113,7 +113,7 @@ namespace Banshee.Collection.Gui
             album_artist_column = CreateText (BansheeQuery.AlbumArtistField, 0.225);
             genre_column        = CreateText (BansheeQuery.GenreField, 0.25);
             duration_column     = Create (BansheeQuery.DurationField, 0.10, true, new ColumnCellDuration (null, true));
-            year_column         = Create (BansheeQuery.YearField, 0.15, false, new ColumnCellPositiveInt (null, true, 4, 4));
+            year_column         = Create (BansheeQuery.YearField, 0.15, false, new ColumnCellPositiveInt (null, true, 4, 4) { CultureFormatted = false });
             file_size_column    = Create (BansheeQuery.FileSizeField, 0.15, false, new ColumnCellFileSize (null, true));
             bpm_column          = Create (BansheeQuery.BpmField, 0.10, false, new ColumnCellPositiveInt (null, true, 3, 3));
 



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