[banshee] [Hyena] Fix ListView a11y crasher



commit 864e902ce66b3a0634d13238dabc4421601eef3d
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Sun Apr 25 16:01:48 2010 -0700

    [Hyena] Fix ListView a11y crasher
    
    ListViewAccessible wasn't setup to support the fact that a ListView's
    model (and therefore its Selection) can change over time (bgo#615892).
    This patch was based on one from Sandy Armstrong.

 .../Accessibility/ListViewAccessible.cs            |    4 +-
 .../ListView/ListView_Interaction.cs               |    2 +-
 .../Hyena.Data.Gui/ListView/ListView_Model.cs      |    6 +++++
 .../Hyena/Hyena.Collections/SelectionProxy.cs      |   22 ++++++++++++++++++-
 4 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
index dc2f8c9..035b762 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
@@ -54,10 +54,10 @@ namespace Hyena.Data.Gui.Accessibility
             cell_cache = new Dictionary<int, ColumnCellAccessible> ();
 
             list_view.ModelChanged += (o, a) => OnModelChanged ();
-            list_view.Model.Reloaded += (o, a) => OnModelChanged ();
+            list_view.ModelReloaded += (o, a) => OnModelChanged ();
             OnModelChanged ();
 
-            list_view.Selection.FocusChanged += OnSelectionFocusChanged;
+            list_view.SelectionProxy.FocusChanged += OnSelectionFocusChanged;
             list_view.ActiveColumnChanged += OnSelectionFocusChanged;
 
             ListViewAccessible_Selection ();
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
index 74454c0..58c12a0 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
@@ -82,7 +82,7 @@ namespace Hyena.Data.Gui
         }
 
         public Selection Selection {
-            get { return model.Selection; }
+            get { return model == null ? null : model.Selection; }
         }
 
         private int HadjustmentValue {
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
index 47255d3..9570702 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
@@ -37,6 +37,7 @@ namespace Hyena.Data.Gui
     {
         #pragma warning disable 0067
         public event EventHandler ModelChanged;
+        public event EventHandler ModelReloaded;
         #pragma warning restore 0067
 
         public void SetModel (IListModel<T> model)
@@ -128,6 +129,11 @@ namespace Hyena.Data.Gui
         private void OnModelReloadedHandler (object o, EventArgs args)
         {
             OnModelReloaded ();
+
+            var handler = ModelReloaded;
+            if (handler != null) {
+                handler (this, EventArgs.Empty);
+            }
         }
 
         private void OnColumnControllerUpdatedHandler (object o, EventArgs args)
diff --git a/src/Libraries/Hyena/Hyena.Collections/SelectionProxy.cs b/src/Libraries/Hyena/Hyena.Collections/SelectionProxy.cs
index 6441e69..812fd54 100644
--- a/src/Libraries/Hyena/Hyena.Collections/SelectionProxy.cs
+++ b/src/Libraries/Hyena/Hyena.Collections/SelectionProxy.cs
@@ -36,6 +36,7 @@ namespace Hyena.Collections
 
         public event EventHandler Changed;
         public event EventHandler SelectionChanged;
+        public event EventHandler FocusChanged;
 
         public Selection Selection {
             get { return selection; }
@@ -43,13 +44,17 @@ namespace Hyena.Collections
                 if (selection == value)
                     return;
 
-                if (selection != null)
+                if (selection != null) {
                     selection.Changed -= HandleSelectionChanged;
+                    selection.FocusChanged -= HandleSelectionFocusChanged;
+                }
 
                 selection = value;
 
-                if (selection != null)
+                if (selection != null) {
                     selection.Changed += HandleSelectionChanged;
+                    selection.FocusChanged += HandleSelectionFocusChanged;
+                }
 
                 OnSelectionChanged ();
             }
@@ -63,6 +68,14 @@ namespace Hyena.Collections
             }
         }
 
+        protected virtual void OnFocusChanged ()
+        {
+            EventHandler handler = FocusChanged;
+            if (handler != null) {
+                handler (selection, EventArgs.Empty);
+            }
+        }
+
         protected virtual void OnSelectionChanged ()
         {
             EventHandler handler = SelectionChanged;
@@ -75,5 +88,10 @@ namespace Hyena.Collections
         {
             OnChanged ();
         }
+
+        private void HandleSelectionFocusChanged (object o, EventArgs args)
+        {
+            OnFocusChanged ();
+        }
     }
 }



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