[banshee] [TrackEditor] Fix bug with losing SpinButton edits



commit 3fdaeb29806670abb0ffd2b49988e1bc82f85ea3
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Dec 18 13:40:10 2009 -0800

    [TrackEditor] Fix bug with losing SpinButton edits
    
    Bug presented itself if you edited any spin entry (eg year) and then
    pressed alt-f to move the next track: if you went back, your edit was
    gone.  Solved by forcing a value update on every text change in the
    entry (except when it's empty, to avoid inserting zero).

 .../Banshee.Gui.TrackEditor/RangeEntry.cs          |    4 ++--
 .../Banshee.Gui.TrackEditor/SpinButtonEntry.cs     |   11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs
index b7a348a..c2e5071 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs
@@ -56,9 +56,9 @@ namespace Banshee.Gui.TrackEditor
         {
             AutoOrderButton auto_order_button;
 
-            PackStart (from_entry = new SpinButton (0, 999, 1), true, true, 0);
+            PackStart (from_entry = new SpinButtonEntry (0, 999, 1), true, true, 0);
             PackStart (new Label (rangeLabel), false, false, 6);
-            PackStart (to_entry = new SpinButton (0, 999, 1), true, true, 0);
+            PackStart (to_entry = new SpinButtonEntry (0, 999, 1), true, true, 0);
             if (orderClosure != null) {
                 PackStart (auto_order_button = new AutoOrderButton (), false, false, 1);
                 auto_order_button.Clicked += delegate { orderClosure (this); };
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs
index d3916bb..4b3a7ae 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs
@@ -41,5 +41,16 @@ namespace Banshee.Gui.TrackEditor
         public SpinButtonEntry (double min, double max, double step) : base (min, max, step)
         {
         }
+
+        // Make sure the value is updated every time the text is changed, not just when the focus leaves
+        // this SpinButton, since that may be too late
+        protected override void OnChanged ()
+        {
+            // Don't update when empty, since it will be treated as a 0 which will get inserted.
+            // Particularly messes up selecting all text and typing over it.
+            if (Text.Trim () != "") {
+                Update ();
+            }
+        }
     }
 }



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