[banshee] [Banshee.Widgets] Add Default to DictionaryComboBox



commit 7c40ad51f05c8f3a56ad57433193fa2f744d5aa2
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Feb 17 16:49:46 2010 -0800

    [Banshee.Widgets] Add Default to DictionaryComboBox
    
    If the active item is removed, the Default will become the active.

 .../Banshee.Widgets/DictionaryComboBox.cs          |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
index 8f13772..faa5052 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
@@ -47,6 +47,8 @@ namespace Banshee.Widgets
             AddAttribute (text_renderer, "text", 0);
         }
 
+        public T Default { get; set; }
+
         public TreeIter Add (string str, T value)
         {
             return store.AppendValues (str, value, row++);
@@ -60,11 +62,23 @@ namespace Banshee.Widgets
         public bool Remove (T value)
         {
             var iter = IterFor (value);
-            return store.Remove (ref iter);
+            return Remove (ref iter);
         }
 
         public bool Remove (ref TreeIter iter)
         {
+            // Try to change the active value to the default
+            TreeIter active_iter;
+            if (GetActiveIter (out active_iter)) {
+                if (active_iter.Equals (iter)) {
+                    if (Default != null) {
+                        ActiveValue = Default;
+                    } else if (store.IterNChildren () > 0) {
+                        Active = 0;
+                    }
+                }
+            }
+
             return store.Remove (ref iter);
         }
 



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