[banshee/a11y: 11/27] [a11y] Added ColumnHeaderCellText accessibility



commit 76f00792563f5ccda0576cd54fe3a2c3a2bd2519
Author: Eitan Isaacson <eitan ascender com>
Date:   Wed Sep 30 16:00:38 2009 -0700

    [a11y] Added ColumnHeaderCellText accessibility

 .../ColumnHeaderCellTextAccessible.cs              |   86 ++++++++++++++++++++
 .../Accessibility/ICellAccessibleParent.cs         |    2 +
 .../Accessibility/ListViewAccessible.cs            |   11 +++
 .../Hyena.Data.Gui/ColumnHeaderCellText.cs         |    9 ++-
 .../Hyena.Data.Gui/ListView/ListView_Accessible.cs |   14 +++
 src/Libraries/Hyena.Gui/Hyena.Gui.csproj           |    1 +
 src/Libraries/Hyena.Gui/Makefile.am                |    1 +
 7 files changed, 123 insertions(+), 1 deletions(-)
---
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
new file mode 100644
index 0000000..6dcc84e
--- /dev/null
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
@@ -0,0 +1,86 @@
+
+using System;
+using Mono.Unix;
+
+namespace Hyena.Data.Gui.Accessibility
+{
+    class ColumnHeaderCellTextAccessible: ColumnCellTextAccessible, Atk.ActionImplementor
+    {
+        private static string[] ActionDescriptions  = new string[] {"", Catalog.GetString("open context menu")};
+        private static string[] ActionNamesLocalized = new string[] {Catalog.GetString("click"), Catalog.GetString("menu")};
+
+        private enum Actions
+        {
+            CLICK,
+            MENU,
+            LAST
+        };
+
+        public ColumnHeaderCellTextAccessible (object bound_object, ColumnHeaderCellText cell, ICellAccessibleParent parent): base (bound_object, cell as ColumnCellText, parent)
+        {
+            Role = Atk.Role.TableColumnHeader;
+        }
+
+        protected override Atk.StateSet OnRefStateSet ()
+        {
+            Atk.StateSet states = base.OnRefStateSet ();
+            states.RemoveState (Atk.StateType.Selectable);
+            states.RemoveState (Atk.StateType.Transient);
+            return states;
+        }
+
+        public string GetLocalizedName (int action)
+        {
+            if (action >= ActionNamesLocalized.Length)
+                return "";
+
+            return ActionNamesLocalized[action];
+        }
+
+        public string GetName (int action)
+        {
+            if (action >= (int)Actions.LAST)
+                return "";
+
+            return ((Actions)action).ToString().ToLower();
+        }
+
+        public string GetDescription (int action)
+        {
+            if (action >= ActionDescriptions.Length)
+                return "";
+
+            return ActionDescriptions[action];
+        }
+
+        public string GetKeybinding (int action)
+        {
+            return "";
+        }
+
+        public int NActions
+        {
+            get {
+                return (int)Actions.LAST;
+            }
+        }
+
+        public bool DoAction (int action)
+        {
+            ICellAccessibleParent parent = (ICellAccessibleParent)Parent;
+            switch ((Actions)action)
+            {
+            case Actions.MENU: parent.InvokeColumnHeaderMenu (this); break;
+            case Actions.CLICK: parent.ClickColumnHeader (this); break;
+            }
+            if (action == (int)Actions.MENU)
+                ((ICellAccessibleParent)Parent).InvokeColumnHeaderMenu(this);
+            return true;
+        }
+
+        public bool SetDescription(int action, string description)
+        {
+            return false;
+        }
+    }
+}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ICellAccessibleParent.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ICellAccessibleParent.cs
index 132066b..8ef52aa 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ICellAccessibleParent.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ICellAccessibleParent.cs
@@ -10,5 +10,7 @@ namespace Hyena.Data.Gui.Accessibility
         bool IsCellShowing (ColumnCellAccessible cell);
         bool IsCellFocused (ColumnCellAccessible cell);
         bool IsCellSelected (ColumnCellAccessible cell);
+        void InvokeColumnHeaderMenu (ColumnCellAccessible column);
+        void ClickColumnHeader (ColumnCellAccessible column);
     }
 }
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 3264139..cf250ac 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
@@ -182,6 +182,17 @@ namespace Hyena.Data.Gui.Accessibility
             return IsChildSelected (cell_index);
         }
 
+        public void InvokeColumnHeaderMenu (ColumnCellAccessible cell)
+        {
+            list_view.InvokeColumnHeaderMenu (GetCellIndex (cell));
+        }
+
+        public void ClickColumnHeader (ColumnCellAccessible cell)
+        {
+            list_view.ClickColumnHeader (GetCellIndex (cell));
+        }
+
         # endregion ICellAccessibleParent
+
     }
 }
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs
index bb00152..f396666 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs
@@ -30,6 +30,8 @@ using System;
 using Gtk;
 using Cairo;
 
+using Hyena.Data.Gui.Accessibility;
+
 namespace Hyena.Data.Gui
 {
     public class ColumnHeaderCellText : ColumnCellText, IHeaderCell
@@ -43,7 +45,12 @@ namespace Hyena.Data.Gui
         {
             this.data_handler = data_handler;
         }
-    
+
+        public override Atk.Object GetAccessible (ICellAccessibleParent parent)
+        {
+            return new  ColumnHeaderCellTextAccessible (BoundObject, this, parent);
+        }
+
         public override void Render (CellContext context, StateType state, double cellWidth, double cellHeight)
         {
             if (data_handler == null) {
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Accessible.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Accessible.cs
index e8f93c1..778ce16 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Accessible.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Accessible.cs
@@ -127,6 +127,20 @@ namespace Hyena.Data.Gui
             row = GetRowAtY (y);
             col = cached_column.Index;
         }
+
+        public void InvokeColumnHeaderMenu (int column)
+        {
+            Gdk.Rectangle rectangle = GetColumnHeaderCellExtents (column, true, Atk.CoordType.Window);
+            Column col = ColumnController.Where (c => c.Visible).ElementAtOrDefault (column);
+            OnColumnRightClicked (col, rectangle.X + rectangle.Width/2, rectangle.Y + rectangle.Height/2);
+        }
+
+        public void ClickColumnHeader (int column)
+        {
+            Column col = ColumnController.Where (c => c.Visible).ElementAtOrDefault (column);
+            OnColumnLeftClicked (col);
+        }
+
     }
 
     internal class ListViewAccessibleFactory<T> : Atk.ObjectFactory
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui.csproj b/src/Libraries/Hyena.Gui/Hyena.Gui.csproj
index 6ea615e..ca4a22f 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui.csproj
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.csproj
@@ -157,6 +157,7 @@
     <Compile Include="Hyena.Data.Gui\Accessibility\ListViewAccessible_Table.cs" />
     <Compile Include="Hyena.Data.Gui\Accessibility\ListViewAccessible_Selection.cs" />
     <Compile Include="Hyena.Data.Gui\Accessibility\ColumnCellTextAccessible.cs" />
+    <Compile Include="Hyena.Data.Gui\Accessibility\ColumnHeaderCellTextAccessible.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
diff --git a/src/Libraries/Hyena.Gui/Makefile.am b/src/Libraries/Hyena.Gui/Makefile.am
index 1c5d43f..e8b3de6 100644
--- a/src/Libraries/Hyena.Gui/Makefile.am
+++ b/src/Libraries/Hyena.Gui/Makefile.am
@@ -5,6 +5,7 @@ LINK = $(REF_HYENA_GUI)
 SOURCES =  \
 	Hyena.Data.Gui/Accessibility/ColumnCellAccessible.cs \
 	Hyena.Data.Gui/Accessibility/ColumnCellTextAccessible.cs \
+	Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs \
 	Hyena.Data.Gui/Accessibility/ICellAccessibleParent.cs \
 	Hyena.Data.Gui/Accessibility/ListViewAccessible.cs \
 	Hyena.Data.Gui/Accessibility/ListViewAccessible_Selection.cs \



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