[banshee/a11y: 13/27] [a11y] Added ColumnCellStatusIndicator accessibility.



commit d3a5db28b616e4951b6de0b9acd74d62db81c3a5
Author: Eitan Isaacson <eitan ascender com>
Date:   Wed Sep 30 16:04:47 2009 -0700

    [a11y] Added ColumnCellStatusIndicator accessibility.

 .../ColumnCellStatusIndicator.cs                   |  101 ++++++++++++++++---
 1 files changed, 85 insertions(+), 16 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellStatusIndicator.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellStatusIndicator.cs
index 134c1f1..110a1d2 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellStatusIndicator.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellStatusIndicator.cs
@@ -29,9 +29,11 @@
 using System;
 using Gtk;
 using Cairo;
+using Mono.Unix;
 
 using Hyena.Gui;
 using Hyena.Data.Gui;
+using Hyena.Data.Gui.Accessibility;
 using Banshee.Gui;
 
 using Banshee.Streaming;
@@ -40,6 +42,49 @@ using Banshee.ServiceStack;
 
 namespace Banshee.Collection.Gui
 {
+    class ColumnCellStatusIndicatorAccessible : ColumnCellAccessible, Atk.ImageImplementor
+    {
+        public ColumnCellStatusIndicatorAccessible (object bound_object, ColumnCellStatusIndicator cell, ICellAccessibleParent parent) : base (bound_object, cell as ColumnCell, parent)
+        {
+        }
+
+        public string ImageLocale {
+            get {
+                return null;
+            }
+        }
+
+        public bool SetImageDescription (string description)
+        {
+            return false;
+        }
+
+        public void GetImageSize (out int width, out int height)
+        {
+            if (cell.GetTextAlternative (bound_object) != string.Empty)
+                width = height = 16;
+            else
+                width = height = int.MinValue;
+        }
+
+        public string ImageDescription {
+            get {
+                return cell.GetTextAlternative (bound_object);
+            }
+        }
+
+        public void GetImagePosition(out int x, out int y, Atk.CoordType coordType)
+        {
+            if (cell.GetTextAlternative (bound_object) != string.Empty)
+            {
+                GetPosition (out x, out y, coordType);
+                x += 4;
+                y += 4;
+            } else
+                x = y = int.MinValue;
+        }
+    }
+
     public class ColumnCellStatusIndicator : ColumnCell
     {
         protected enum Icon : int {
@@ -48,6 +93,10 @@ namespace Banshee.Collection.Gui
             Error,
             Protected
         }
+
+        private string[] icon_names = new string[] {
+            Catalog.GetString ("Playing"), Catalog.GetString ("Paused"),
+            Catalog.GetString ("Error"), Catalog.GetString ("Protected"), string.Empty};
         
         private int pixbuf_size = 16;
         protected virtual int PixbufSize {
@@ -74,14 +123,46 @@ namespace Banshee.Collection.Gui
         {
             LoadPixbufs ();
         }
-        
+
+        public override Atk.Object GetAccessible (ICellAccessibleParent parent)
+        {
+            return new ColumnCellStatusIndicatorAccessible (BoundObject, this, parent);
+        }
+
+        public override string GetTextAlternative (object obj)
+        {
+            if (!(obj is TrackInfo))
+                return string.Empty;
+
+            int icon_index = GetIconIndex ((TrackInfo)obj);
+
+            if (icon_index < 0)
+                return string.Empty;
+            else
+                return icon_names[GetIconIndex ((TrackInfo)obj)];
+        }
+
         protected virtual int PixbufCount {
             get { return 4; }
         }
         
         protected virtual int GetIconIndex (TrackInfo track)
         {
-            return -1;
+            int icon_index = -1;
+
+            if (track.PlaybackError != StreamPlaybackError.None) {
+                icon_index = (int)(track.PlaybackError == StreamPlaybackError.Drm
+                    ? Icon.Protected
+                    : Icon.Error);
+            } else if (track.IsPlaying) {
+                icon_index = (int)(ServiceManager.PlayerEngine.CurrentState == PlayerState.Paused
+                    ? Icon.Paused
+                    : Icon.Playing);
+            } else {
+                icon_index = -1;
+            }
+
+            return icon_index;
         }
         
         protected virtual void LoadPixbufs ()
@@ -117,19 +198,7 @@ namespace Banshee.Collection.Gui
                 return;
             }
             
-            int icon_index = -1;
-
-            if (track.PlaybackError != StreamPlaybackError.None) {
-                icon_index = (int)(track.PlaybackError == StreamPlaybackError.Drm
-                    ? Icon.Protected
-                    : Icon.Error);
-            } else if (track.IsPlaying) {
-                icon_index = (int)(ServiceManager.PlayerEngine.CurrentState == PlayerState.Paused
-                    ? Icon.Paused
-                    : Icon.Playing);
-            } else {
-                icon_index = GetIconIndex (track);
-            }
+            int icon_index = GetIconIndex (track);
             
             if (icon_index < 0 || pixbufs == null || pixbufs[icon_index] == null) {
                 return;
@@ -157,7 +226,7 @@ namespace Banshee.Collection.Gui
                 context.Context.Fill ();
             }
         }
-        
+
         protected TrackInfo BoundTrack {
             get { return BoundObject as TrackInfo; }
         }



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