[banshee/a11y: 23/27] [a11y] More style cleanup and cast avoiding
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee/a11y: 23/27] [a11y] More style cleanup and cast avoiding
- Date: Tue, 6 Oct 2009 00:22:40 +0000 (UTC)
commit 704d865f1d10ec66975198716b5183a73fde2723
Author: Gabriel Burt <gabriel burt gmail com>
Date: Mon Oct 5 17:05:31 2009 -0700
[a11y] More style cleanup and cast avoiding
.../Accessibility/ColumnCellAccessible.cs | 16 ++++---
.../ColumnHeaderCellTextAccessible.cs | 39 +++++++--------
.../Accessibility/ListViewAccessible.cs | 49 +++++++++----------
.../Accessibility/ListViewAccessible_Selection.cs | 6 +-
.../Accessibility/ListViewAccessible_Table.cs | 25 ++--------
5 files changed, 57 insertions(+), 78 deletions(-)
---
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnCellAccessible.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnCellAccessible.cs
index 333ce65..1aa319f 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnCellAccessible.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnCellAccessible.cs
@@ -7,12 +7,14 @@ namespace Hyena.Data.Gui.Accessibility
{
protected ColumnCell cell;
protected object bound_object;
+ private ICellAccessibleParent cell_parent;
public ColumnCellAccessible (object bound_object, ColumnCell cell, ICellAccessibleParent parent)
{
Role = Atk.Role.TableCell;
this.bound_object = bound_object;
this.cell = cell;
+ cell_parent = parent;
Parent = (Atk.Object) parent;
}
@@ -25,13 +27,13 @@ namespace Hyena.Data.Gui.Accessibility
states.AddState (Atk.StateType.Sensitive);
states.AddState (Atk.StateType.Visible);
- if (((ICellAccessibleParent)Parent).IsCellShowing (this))
+ if (cell_parent.IsCellShowing (this))
states.AddState (Atk.StateType.Showing);
- if (((ICellAccessibleParent)Parent).IsCellFocused (this))
+ if (cell_parent.IsCellFocused (this))
states.AddState (Atk.StateType.Focused);
- if (((ICellAccessibleParent)Parent).IsCellSelected (this))
+ if (cell_parent.IsCellSelected (this))
states.AddState (Atk.StateType.Selected);
return states;
@@ -39,7 +41,7 @@ namespace Hyena.Data.Gui.Accessibility
protected override int OnGetIndexInParent ()
{
- return ((ICellAccessibleParent)Parent).GetCellIndex (this);
+ return cell_parent.GetCellIndex (this);
}
public double Alpha {
@@ -72,14 +74,14 @@ namespace Hyena.Data.Gui.Accessibility
public void GetSize (out int w, out int h)
{
- Gdk.Rectangle rectangle = ((ICellAccessibleParent)Parent).GetCellExtents(this, Atk.CoordType.Screen);
+ Gdk.Rectangle rectangle = cell_parent.GetCellExtents(this, Atk.CoordType.Screen);
w = rectangle.Width;
h = rectangle.Height;
}
public void GetPosition (out int x, out int y, Atk.CoordType coordType)
{
- Gdk.Rectangle rectangle = ((ICellAccessibleParent)Parent).GetCellExtents(this, coordType);
+ Gdk.Rectangle rectangle = cell_parent.GetCellExtents(this, coordType);
x = rectangle.X;
y = rectangle.Y;
@@ -87,7 +89,7 @@ namespace Hyena.Data.Gui.Accessibility
public void GetExtents (out int x, out int y, out int w, out int h, Atk.CoordType coordType)
{
- Gdk.Rectangle rectangle = ((ICellAccessibleParent)Parent).GetCellExtents(this, coordType);
+ Gdk.Rectangle rectangle = cell_parent.GetCellExtents(this, coordType);
x = rectangle.X;
y = rectangle.Y;
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
index 8b4d064..c137723 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ColumnHeaderCellTextAccessible.cs
@@ -6,17 +6,17 @@ 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 static string [] action_descriptions = new string[] {"", Catalog.GetString ("open context menu")};
+ private static string [] action_names_localized = new string[] {Catalog.GetString ("click"), Catalog.GetString ("menu")};
- private enum Actions
- {
- CLICK,
- MENU,
- LAST
+ private enum Actions {
+ Click,
+ Menu,
+ Last
};
- public ColumnHeaderCellTextAccessible (object bound_object, ColumnHeaderCellText cell, ICellAccessibleParent parent): base (bound_object, cell as ColumnCellText, parent)
+ public ColumnHeaderCellTextAccessible (object bound_object, ColumnHeaderCellText cell, ICellAccessibleParent parent)
+ : base (bound_object, cell as ColumnCellText, parent)
{
Role = Atk.Role.TableColumnHeader;
}
@@ -31,15 +31,15 @@ namespace Hyena.Data.Gui.Accessibility
public string GetLocalizedName (int action)
{
- if (action >= ActionNamesLocalized.Length)
+ if (action >= action_names_localized.Length)
return "";
- return ActionNamesLocalized[action];
+ return action_names_localized[action];
}
public string GetName (int action)
{
- if (action >= (int)Actions.LAST)
+ if (action >= (int)Actions.Last)
return "";
return ((Actions)action).ToString ().ToLower ();
@@ -47,10 +47,10 @@ namespace Hyena.Data.Gui.Accessibility
public string GetDescription (int action)
{
- if (action >= ActionDescriptions.Length)
+ if (action >= action_descriptions.Length)
return "";
- return ActionDescriptions[action];
+ return action_descriptions[action];
}
public string GetKeybinding (int action)
@@ -58,22 +58,19 @@ namespace Hyena.Data.Gui.Accessibility
return "";
}
- public int NActions
- {
- get {
- return (int)Actions.LAST;
- }
+ 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;
+ case Actions.Menu: parent.InvokeColumnHeaderMenu (this); break;
+ case Actions.Click: parent.ClickColumnHeader (this); break;
}
- if (action == (int)Actions.MENU) {
+ if (action == (int)Actions.Menu) {
((ICellAccessibleParent)Parent).InvokeColumnHeaderMenu (this);
}
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 32ebc73..2e124c6 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible.cs
@@ -7,13 +7,12 @@ using Hyena.Data.Gui;
namespace Hyena.Data.Gui.Accessibility
{
- public partial class ListViewAccessible<T> : Hyena.Gui.BaseWidgetAccessible,
- ICellAccessibleParent
+ public partial class ListViewAccessible<T> : Hyena.Gui.BaseWidgetAccessible, ICellAccessibleParent
{
private ListView<T> list_view;
private Dictionary<int, ColumnCellAccessible> cell_cache;
- public ListViewAccessible (GLib.Object widget): base (widget as Gtk.Widget)
+ public ListViewAccessible (GLib.Object widget) : base (widget as Gtk.Widget)
{
list_view = widget as ListView<T>;
// TODO replace with list_view.Name?
@@ -43,12 +42,13 @@ namespace Hyena.Data.Gui.Accessibility
return states;
}
-
protected override int OnGetIndexInParent ()
{
- for (int i=0; i < Parent.NAccessibleChildren; i++)
- if (Parent.RefAccessibleChild (i) == this)
+ for (int i=0; i < Parent.NAccessibleChildren; i++) {
+ if (Parent.RefAccessibleChild (i) == this) {
return i;
+ }
+ }
return -1;
}
@@ -62,19 +62,20 @@ namespace Hyena.Data.Gui.Accessibility
{
ColumnCellAccessible child;
- if (cell_cache.ContainsKey (index))
- {
+ if (cell_cache.ContainsKey (index)) {
return cell_cache[index];
}
- if (0 > index - n_columns)
- {
- child = (ColumnCellAccessible) list_view.ColumnController.Where (c => c.Visible).ElementAtOrDefault (index).HeaderCell.GetAccessible (this);
- }
- else
- {
- int column = (index - n_columns)%n_columns;
- int row = (index - n_columns)/n_columns;
- var cell = list_view.ColumnController.Where (c => c.Visible).ElementAtOrDefault (column).GetCell (0);
+
+ var columns = list_view.ColumnController.Where (c => c.Visible);
+
+ if (index - n_columns < 0) {
+ child = columns.ElementAtOrDefault (index)
+ .HeaderCell
+ .GetAccessible (this) as ColumnCellAccessible;
+ } else {
+ int column = (index - n_columns) % n_columns;
+ int row = (index - n_columns) / n_columns;
+ var cell = columns.ElementAtOrDefault (column).GetCell (0);
cell.BindListItem (list_view.Model[row]);
child = (ColumnCellAccessible) cell.GetAccessible (this);
}
@@ -115,15 +116,13 @@ namespace Hyena.Data.Gui.Accessibility
private int n_columns {
get { return list_view.ColumnController.Count (c => c.Visible); }
- set {}
}
private int n_rows {
get { return list_view.Model.Count; }
- set {}
}
- # region ICellAccessibleParent
+ #region ICellAccessibleParent
public int GetCellIndex (ColumnCellAccessible cell)
{
@@ -167,18 +166,17 @@ namespace Hyena.Data.Gui.Accessibility
public bool IsCellFocused (ColumnCellAccessible cell)
{
int cell_index = GetCellIndex (cell);
- if (cell_index%NColumns != 0)
+ if (cell_index % NColumns != 0)
return false; // Only 0 column cells get focus now.
- int row = cell_index/NColumns;
+ int row = cell_index / NColumns;
return row == list_view.Selection.FocusedIndex;
}
public bool IsCellSelected (ColumnCellAccessible cell)
{
- int cell_index = GetCellIndex (cell);
- return IsChildSelected (cell_index);
+ return IsChildSelected (GetCellIndex (cell));
}
public void InvokeColumnHeaderMenu (ColumnCellAccessible cell)
@@ -191,7 +189,6 @@ namespace Hyena.Data.Gui.Accessibility
list_view.ClickColumnHeader (GetCellIndex (cell));
}
- # endregion ICellAccessibleParent
-
+ #endregion
}
}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Selection.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Selection.cs
index 392155a..1d519c0 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Selection.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Selection.cs
@@ -31,14 +31,14 @@ namespace Hyena.Data.Gui.Accessibility
public bool RemoveSelection (int index)
{
- int row = list_view.Selection.RangeCollection [index/n_columns];
+ int row = list_view.Selection.RangeCollection [index / n_columns];
return RemoveRowSelection (row);
}
public Atk.Object RefSelection (int index)
{
- int row = list_view.Selection.RangeCollection [index/n_columns];
- int column = index%n_columns;
+ int row = list_view.Selection.RangeCollection [index / n_columns];
+ int column = index % n_columns;
return RefAt (row, column);
}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Table.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Table.cs
index 129c721..c92a21c 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Table.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Accessibility/ListViewAccessible_Table.cs
@@ -45,9 +45,7 @@ namespace Hyena.Data.Gui.Accessibility
public int GetColumnAtIndex (int index)
{
- if (NColumns == 0)
- return -1;
- return (index-NColumns)%NColumns;
+ return NColumns == 0 ? -1 : (index - NColumns) % NColumns;
}
public string GetColumnDescription (int column)
@@ -78,7 +76,7 @@ namespace Hyena.Data.Gui.Accessibility
{
if (NColumns == 0)
return -1;
- return (index-NColumns)/NColumns;
+ return (index - NColumns) / NColumns;
}
public string GetRowDescription (int row)
@@ -122,7 +120,7 @@ namespace Hyena.Data.Gui.Accessibility
public Atk.Object RefAt (int row, int column)
{
- int index = NColumns*row + column + NColumns;
+ int index = NColumns * row + column + NColumns;
return OnRefChild (index);
}
@@ -152,20 +150,5 @@ namespace Hyena.Data.Gui.Accessibility
public void SetRowHeader (int row, Atk.Object header)
{
}
-
- #pragma warning disable 0067
-
- /*
- public event Atk.ColumnDeletedHandler ColumnDeleted;
- public event Atk.ColumnInsertedHandler ColumnInserted;
- public event EventHandler ColumnReordered;
- public event EventHandler ModelChanged;
- public event Atk.RowDeletedHandler RowDeleted;
- public event Atk.RowInsertedHandler RowInserted;
- public event EventHandler RowReordered;
- */
-
- #pragma warning restore 0067
-
}
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]