[banshee] [EqualizerPresetComboBox] Fix row separator bug



commit 7d4534515be6fd73e3c67a0ac52cfad8b2c7e3e5
Author: Aaron Bockover <abockover novell com>
Date:   Thu Feb 11 13:39:26 2010 -0500

    [EqualizerPresetComboBox] Fix row separator bug
    
    Worked around what is very likely a GTK+ or Gtk# bug regarding sorting,
    the row separator function, and storing null values across a row. Thanks
    to Sandy Armstrong for thinking outside of his box and trying a fix
    that works around the issue (causing the row separator to show up last
    in the list when a new insertion is performed on the model, even though
    it shows up sorted properly when the model is first constructed).
    
    Also changed the sort function to be the default model sort, and reduced
    some logic to its most simple form.

 .../EqualizerPresetComboBox.cs                     |   25 ++++++++++++--------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs b/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs
index b4d25ed..c2c248c 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Equalizer.Gui/EqualizerPresetComboBox.cs
@@ -60,16 +60,13 @@ namespace Banshee.Equalizer.Gui
             Model = store;
             TextColumn = 0;
 
-            store.SetSortColumnId (1, SortType.Ascending);
-            store.SetSortFunc (1, (model, ia, ib) => {
+            store.DefaultSortFunc = (model, ia, ib) => {
                 var a = GetEqualizerSettingForIter (ia);
                 var b = GetEqualizerSettingForIter (ib);
                 if (a != null && b != null) {
-                    if ((!a.IsReadOnly && !b.IsReadOnly) ||
-                        (a.IsReadOnly && b.IsReadOnly)) {
-                        return a.Name.CompareTo (b.Name);
-                    }
-                    return a.IsReadOnly.CompareTo (b.IsReadOnly);
+                    return a.IsReadOnly == b.IsReadOnly
+                        ? a.Name.CompareTo (b.Name)
+                        : a.IsReadOnly.CompareTo (b.IsReadOnly);
                 } else if (a == null && b == null) {
                     return 0;
                 } else if ((a == null && b.IsReadOnly) || (b == null && !a.IsReadOnly)) {
@@ -78,10 +75,13 @@ namespace Banshee.Equalizer.Gui
                     return 1;
                 }
                 return 0;
-            });
+            };
+
+
+            store.SetSortColumnId (-1, SortType.Ascending);
 
             RowSeparatorFunc = (model, iter) =>
-                store.GetValue (iter, 0) == null &&
+                store.GetValue (iter, 0) as String == String.Empty &&
                 store.GetValue (iter, 1) == null;
 
             foreach (EqualizerSetting eq in manager) {
@@ -138,7 +138,12 @@ namespace Banshee.Equalizer.Gui
             if (!eq.IsReadOnly) {
                 user_count++;
                 if (separator_iter.Equals (TreeIter.Zero)) {
-                    separator_iter = store.AppendValues (null, null);
+                    // FIXME: Very strange bug if (null, null) is stored
+                    // here regarding RowSeparatorFunc - not sure where the
+                    // bug might be, but I'm 99% sure this is a bug in GTK+
+                    // or Gtk#. I demand answers! Thanks to Sandy Armstrong
+                    // for thinking outside of his box.
+                    separator_iter = store.AppendValues (String.Empty, null);
                 }
             }
 



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