Correctly handle column view preferences.

 PlayerInterface.cs |   15 +++++++++------
 PlaylistColumns.cs |   32 ++++++++++++++++++++++++++++----
 PlaylistView.cs    |   22 ++++++++++------------
 3 files changed, 47 insertions(+), 22 deletions(-)


Index: src/PlayerInterface.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v
retrieving revision 1.142
diff -u -p -u -p -r1.142 PlayerInterface.cs
--- src/PlayerInterface.cs	6 Feb 2006 21:30:17 -0000	1.142
+++ src/PlayerInterface.cs	7 Feb 2006 14:38:32 -0000
@@ -1232,6 +1232,7 @@ namespace Banshee
             audiocd_statusbar.Pixbuf = icon;
         }
         
+        // Called when SourceManager emits an ActiveSourceChanged event.
         private void HandleSourceChanged(object o, EventArgs args)
         {
             Source source = SourceManager.ActiveSource;
@@ -1250,22 +1251,24 @@ namespace Banshee
                 UpdateAudioCdStatus(cdSource.Disk);
             }
             
-            UpdateViewName(source);
-            SensitizeActions(source);
+            UpdateViewName(source);   // Bold label below track info
+            SensitizeActions(source); // Right-click actions, buttons above search
 
-            if(source is DapSource) {
+            if(source is DapSource) { // Show disk usage bar for DAPs
                 gxml["DapContainer"].ShowAll();
                 sync_dap_button.Pixbuf = (source as DapSource).Device.GetIcon(22);
             } else {
                 gxml["DapContainer"].Hide();
             }
             
+            // Make some choices for audio CDs, they can't be rated, nor have plays or
+            // last-played info. Only show the rip button for audio CDs
             gxml["SearchLabel"].Sensitive = !(source is AudioCdSource);
             searchEntry.Sensitive = gxml["SearchLabel"].Sensitive;
             playlistView.RipColumn.Visible = source is AudioCdSource;
-            playlistView.RatingColumn.Visible = !(source is AudioCdSource);
-            playlistView.PlaysColumn.Visible = playlistView.RatingColumn.Visible;
-            playlistView.LastPlayedColumn.Visible = playlistView.RatingColumn.Visible;
+            playlistView.RatingColumn.Hidden = (source is AudioCdSource);
+            playlistView.PlaysColumn.Hidden = (source is AudioCdSource);
+            playlistView.LastPlayedColumn.Hidden = (source is AudioCdSource);
                 
             UpdateSourceView();
                 
Index: src/PlaylistColumns.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlaylistColumns.cs,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 PlaylistColumns.cs
--- src/PlaylistColumns.cs	30 Dec 2005 06:08:42 -0000	1.10
+++ src/PlaylistColumns.cs	7 Feb 2006 14:38:32 -0000
@@ -46,6 +46,8 @@ namespace Banshee
         private PlaylistView view;
         private TreeCellDataFunc datafunc;
         private string keyName;
+        private bool preference;    // User preference
+        private bool hidden;        // Source preference
     
         public PlaylistColumn(PlaylistView view, string name, string keyName,
             TreeCellDataFunc datafunc, CellRenderer renderer, 
@@ -87,7 +89,7 @@ namespace Banshee
             }
             
             try {
-                Column.Visible = (bool)Globals.Configuration.Get(
+                preference = Column.Visible = (bool)Globals.Configuration.Get(
                     GConfKeys.ColumnPath + keyName + "/Visible");
                 this.Order = (int)Globals.Configuration.Get(
                     GConfKeys.ColumnPath + keyName + "/Order");
@@ -105,9 +107,31 @@ namespace Banshee
             Globals.Configuration.Set(GConfKeys.ColumnPath + 
                 keyName + "/Width", Column.Width);
             Globals.Configuration.Set(GConfKeys.ColumnPath + 
-                keyName + "/Visible", Column.Visible);
-            Globals.Configuration.Set(GConfKeys.ColumnPath + 
                 keyName + "/Order", order_t);    
+            Globals.Configuration.Set(GConfKeys.ColumnPath + 
+                keyName + "/Visible", preference);
+        }
+
+        // This is what the user wants (and what's stored in GConf)
+        public bool VisibilityPreference {
+            set {
+                preference = value;
+                Column.Visible = (preference && !hidden);
+            }
+            get {
+                return preference;
+            }
+        }
+
+        // This can be set by the source, to hide a specific column
+        public bool Hidden {
+            set {
+                hidden = value;
+                Column.Visible = (preference && !hidden);
+            }
+            get {
+                return hidden;
+            }
         }
     }
 
@@ -179,7 +203,7 @@ namespace Banshee
         {
             CheckButton button = (CheckButton)o;
             
-            ((PlaylistColumn)boxes[button]).Column.Visible = button.Active;
+            ((PlaylistColumn)boxes[button]).VisibilityPreference = button.Active;
         }
         
         private void OnCloseButtonClicked(object o, EventArgs args)
Index: src/PlaylistView.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlaylistView.cs,v
retrieving revision 1.37
diff -u -p -u -p -r1.37 PlaylistView.cs
--- src/PlaylistView.cs	17 Jan 2006 16:51:14 -0000	1.37
+++ src/PlaylistView.cs	7 Feb 2006 14:38:34 -0000
@@ -71,9 +71,9 @@ namespace Banshee
         Pixbuf ripColumnPixbuf;
 
         public TreeViewColumn RipColumn;
-        public TreeViewColumn RatingColumn;
-        public TreeViewColumn PlaysColumn;
-        public TreeViewColumn LastPlayedColumn;
+        public PlaylistColumn RatingColumn;
+        public PlaylistColumn PlaysColumn;
+        public PlaylistColumn LastPlayedColumn;
         
         public PlaylistView(PlaylistModel model)
         {        
@@ -96,33 +96,31 @@ namespace Banshee
                 new TreeCellDataFunc(TrackCellTime), new CellRendererText(),
                 4, (int)ColumnId.Time));
             
-            PlaylistColumn _RatingColumn = new PlaylistColumn(this, 
+            RatingColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Rating"), "Rating",
                 new TreeCellDataFunc(TrackCellRating), new RatingRenderer(),
                 5, (int)ColumnId.Rating);
-            columns.Add(_RatingColumn);
-            RatingColumn = _RatingColumn.Column;
+            columns.Add(RatingColumn);
             
-            PlaylistColumn _PlaysColumn = new PlaylistColumn(this, 
+            PlaysColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Plays"), "Plays",
                 new TreeCellDataFunc(TrackCellPlayCount), 
                 new CellRendererText(),
                 6, (int)ColumnId.PlayCount);
-            columns.Add(_PlaysColumn);
-            PlaysColumn = _PlaysColumn.Column;
+            columns.Add(PlaysColumn);
             
-            PlaylistColumn _LastPlayedColumn = new PlaylistColumn(this, 
+            LastPlayedColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Last Played"), "Last-Played",
                 new TreeCellDataFunc(TrackCellLastPlayed), 
                 new CellRendererText(),
                 7, (int)ColumnId.LastPlayed);
-            columns.Add(_LastPlayedColumn);
-            LastPlayedColumn = _LastPlayedColumn.Column;
+            columns.Add(LastPlayedColumn);
             
             foreach(PlaylistColumn plcol in columns) {
                 InsertColumn(plcol.Column, plcol.Order);
             }
 
+            // FIXME: would be nice to have these as PlaylistColumns too...
             TreeViewColumn playIndColumn = new TreeViewColumn();
             Gtk.Image playIndImg = new Gtk.Image(
                 Gdk.Pixbuf.LoadFromResource("blue-speaker.png"));
