diff options
-rw-r--r-- | src/Core/Banshee.ThickClient/Banshee.Collection.Gui/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 134c1f12e..110a1d24c 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; } } |