[banshee: 19/61] Change StatisticsPage to be usable with non-Tracks



commit d310f972126e0581168b19fe88f9cedee97d1b30
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Oct 8 21:22:30 2009 -0700

    Change StatisticsPage to be usable with non-Tracks

 .../Banshee.Gui.TrackEditor/StatisticsPage.cs      |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
index cd884f0..f6cd664 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
@@ -61,6 +61,7 @@ namespace Banshee.Gui.TrackEditor
             ShadowType = ShadowType.In;
             VscrollbarPolicy = PolicyType.Automatic;
             HscrollbarPolicy = PolicyType.Never;
+            BorderWidth = 2;
             
             view = new FixedTreeView (model);
             view.HeadersVisible = false;
@@ -145,9 +146,8 @@ namespace Banshee.Gui.TrackEditor
         
         public void LoadTrack (EditorTrackInfo track)
         {
-            BorderWidth = 2;
-            model = new ListStore (typeof (string), typeof (string), typeof (bool));
-            view.Model = model;
+            model = null;
+            CreateModel ();
             
             TagLib.File file = track.TaglibFile;
             
@@ -213,16 +213,26 @@ namespace Banshee.Gui.TrackEditor
             AddItem (Catalog.GetString ("File Size:"), String.Format ("{0} ({1} {2})", 
                 value.ToUserQuery (), bytes, Catalog.GetString ("bytes")));
         }
+
+        private void CreateModel ()
+        {
+            if (model == null) {
+                model = new ListStore (typeof (string), typeof (string), typeof (bool));
+                view.Model = model;
+            }
+        }
         
         public void AddItem (string name, object value)
         {
+            CreateModel ();
             if (name != null && value != null) {
                 model.AppendValues (name, value.ToString (), false);
             }
         }
-        
+
         public void AddSeparator ()
         {
+            CreateModel ();
             model.AppendValues (String.Empty, String.Empty, true);
         }
         



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