Refactor events to remove unused parameters.

Track at-spi2 api.

svn path=/trunk/at-spi-sharp/; revision=150790
This commit is contained in:
Mike Gorse 2010-02-03 21:32:18 +00:00
Родитель bf9b0b81ba
Коммит da13cf4210
17 изменённых файлов: 647 добавлений и 377 удалений

Просмотреть файл

@ -32,13 +32,15 @@ namespace Atspi
{
public class Accessible : IDisposable
{
private static Dictionary<string, StateType> stateMapping;
internal string path;
IAccessible proxy;
IEventObject objectEvents;
IEventWindow windowEvents;
IEventTerminal terminalEvents;
IEventDocument documentEvents;
IEventFocus focusEvents;
internal IAccessible proxy;
EventObject objectEvents;
EventWindow windowEvents;
EventTerminal terminalEvents;
EventDocument documentEvents;
EventFocus focusEvents;
internal Application application;
protected IList<Accessible> children;
@ -46,7 +48,7 @@ namespace Atspi
private string name;
private string description;
protected Role role;
private StateSet stateSet;
internal StateSet stateSet;
private Interfaces interfaces;
private Properties properties;
@ -57,7 +59,6 @@ namespace Atspi
{
this.application = application;
this.path = path;
this.children = new List<Accessible> ();
if (application != null)
proxy = Registry.Bus.GetObject<IAccessible> (application.name, new ObjectPath (path));
if (path != null) {
@ -70,10 +71,66 @@ namespace Atspi
{
this.application = application;
this.path = e.path.ToString ();
proxy = Registry.Bus.GetObject<IAccessible> (application.name, e.path);
proxy = Registry.Bus.GetObject<IAccessible> (application.name, e.path.path);
Update (e);
}
internal void InitEvents ()
{
if (stateMapping == null)
InitStateMapping ();
if (objectEvents == null && ObjectEvents != null) {
ObjectEvents.StateChanged += OnStateChanged;
ObjectEvents.ChildrenChanged += OnChildrenChanged;
ObjectEvents.PropertyChange += OnPropertyChange;
}
}
private static void InitStateMapping ()
{
stateMapping = new Dictionary<string, StateType> ();
stateMapping ["active"] = StateType.Active;
stateMapping ["armed"] = StateType.Armed;
stateMapping ["busy"] = StateType.Busy;
stateMapping ["checked"] = StateType.Checked;
stateMapping ["collapsed"] = StateType.Collapsed;
stateMapping ["defunct"] = StateType.Defunct;
stateMapping ["editable"] = StateType.Editable;
stateMapping ["enabled"] = StateType.Enabled;
stateMapping ["expandable"] = StateType.Expandable;
stateMapping ["expanded"] = StateType.Expanded;
stateMapping ["focusable"] = StateType.Focusable;
stateMapping ["focused"] = StateType.Focused;
stateMapping ["has-tooltip"] = StateType.HasToolTip;
stateMapping ["horizontal"] = StateType.Horizontal;
stateMapping ["iconified"] = StateType.Iconified;
stateMapping ["modal"] = StateType.Modal;
stateMapping ["multi-line"] = StateType.MultiLine;
stateMapping ["multiselectable"] = StateType.Multiselectable;
stateMapping ["opaque"] = StateType.Opaque;
stateMapping ["pressed"] = StateType.Pressed;
stateMapping ["resizable"] = StateType.Resizable;
stateMapping ["selectable"] = StateType.Selectable;
stateMapping ["selected"] = StateType.Selected;
stateMapping ["sensitive"] = StateType.Sensitive;
stateMapping ["showing"] = StateType.Showing;
stateMapping ["single-line"] = StateType.SingleLine;
stateMapping ["stale"] = StateType.Stale;
stateMapping ["transient"] = StateType.Transient;
stateMapping ["vertical"] = StateType.Vertical;
stateMapping ["visible"] = StateType.Visible;
stateMapping ["manages-descendants"] = StateType.ManagesDescendants;
stateMapping ["indeterminate"] = StateType.Indeterminate;
stateMapping ["required"] = StateType.Required;
stateMapping ["truncated"] = StateType.Truncated;
stateMapping ["animated"] = StateType.Animated;
stateMapping ["invalid-entry"] = StateType.InvalidEntry;
stateMapping ["supports-autocompletion"] = StateType.SupportsAutocompletion;
stateMapping ["selectable-text"] = StateType.SelectableText;
stateMapping ["is-default"] = StateType.IsDefault;
stateMapping ["visited"] = StateType.Visited;
}
public void Dispose ()
{
Dispose (true);
@ -86,7 +143,70 @@ namespace Atspi
parent.children.Remove (this);
}
children.Clear ();
stateSet.Add (StateType.Defunct);
if (stateSet != null)
stateSet.Add (StateType.Defunct);
if (ObjectEvents != null) {
ObjectEvents.PropertyChange -= OnPropertyChange;
ObjectEvents.ChildrenChanged -= OnChildrenChanged;
ObjectEvents.StateChanged -= OnStateChanged;
}
}
private void OnStateChanged (Accessible sender, string state, bool set)
{
if (stateMapping.ContainsKey (state)) {
StateType type = stateMapping [state];
if (set)
StateSet.Add (type);
else
StateSet.Remove (type);
Desktop.RaiseStateChanged (this, type, set);
}
}
private void OnChildrenChanged (Accessible sender, string detail, int n, Accessible child)
{
bool added = (detail == "add");
if (!added && this is Desktop) {
if (child != null)
Registry.Instance.RemoveApplication (child.application.name);
}
else if (children is List<Accessible>) {
if (added) {
if (!(this is Desktop))
children.Insert (n, child);
}
else if (child != null)
children.Remove (child);
else if (n >= 0 && n < children.Count)
children.RemoveAt (n);
}
if (added)
Desktop.RaiseChildAdded (this, child);
else
Desktop.RaiseChildRemoved (this, child);
}
private void OnPropertyChange (Accessible sender, string property, object value)
{
if (property == "accessible-name") {
string oldName = name;
name = value as string;
Desktop.RaiseNameChanged (sender, oldName, name);
}
else if (property == "accessible-description") {
string oldDescription = description;
description = value as string;
Desktop.RaiseDescriptionChanged (sender, oldDescription, description);
}
else if (property == "accessible-parent" && value is Accessible) {
parent = (Accessible)value;
}
else if (property == "accessible-role" && value is uint) {
Role oldRole = role;
role = (Role) (uint) value;
Desktop.RaiseRoleChanged (sender, oldRole, role);
}
}
internal void Update (AccessibleProxy e)
@ -99,15 +219,11 @@ namespace Atspi
Desktop.RaiseNameChanged (this, oldName, e.name);
}
Accessible newParent = Registry.GetElement (e.parent, this, true);
if (newParent != parent) {
Accessible oldParent = parent;
parent = newParent;
if (!initializing) {
Desktop.RaiseChildRemoved (oldParent, this);
Desktop.RaiseChildAdded (parent, this);
}
}
parent = Registry.GetElement (e.parent, true);
// Assuming that old and new parents are also
// going to send ChildrenChanged signals, so
// not going to update their caches or send
// add/remove notifications here.
Role newRole = (Role)e.role;
if (newRole != role) {
@ -127,17 +243,24 @@ namespace Atspi
foreach (string iface in e.interfaces)
AddInterface (iface);
StateSet newStateSet = new StateSet (e.states);
if (newStateSet != stateSet) {
StateSet oldStateSet = stateSet;
stateSet = newStateSet;
if (!initializing)
foreach (StateType type in Enum.GetValues (typeof (StateType)))
if (oldStateSet.Contains (type) != newStateSet.Contains (type))
Desktop.RaiseStateChanged (this, type, newStateSet.Contains (type));
}
stateSet = new StateSet (e.states);
// Using at-spi StateChanged events to broadcast
// changes for now; needed for gail Focused handling
UpdateChildren (e.children);
}
if (stateSet.Contains (StateType.ManagesDescendants)) {
private bool PathListContains (AccessiblePath [] paths, string bus_name, string path)
{
foreach (AccessiblePath child in paths)
if (child.bus_name == bus_name && child.path.ToString () == path)
return true;
return false;
}
private void UpdateChildren (AccessiblePath [] childPaths)
{
bool initializing = (children == null);
if (StateSet.Contains (StateType.ManagesDescendants)) {
if (!(children is UncachedChildren))
children = new UncachedChildren (this);
} else {
@ -145,11 +268,11 @@ namespace Atspi
if (children is List<Accessible>) {
oldChildren = new Accessible [children.Count];
children.CopyTo (oldChildren, 0);
children = new List<Accessible> ();
}
children = new List<Accessible> ();
children.Clear ();
foreach (AccessiblePath path in e.children) {
Accessible child = Registry.GetElement (path, this, true);
foreach (AccessiblePath path in childPaths) {
Accessible child = Registry.GetElement (path, true);
if (!initializing &&
(oldChildren == null ||
Array.IndexOf (oldChildren, child) == -1))
@ -158,7 +281,7 @@ namespace Atspi
}
if (!initializing && oldChildren != null)
foreach (Accessible child in oldChildren)
if (!e.ContainsChild (child.path))
if (!PathListContains (childPaths, child.application.name, child.path))
Desktop.RaiseChildRemoved (this, child);
}
}
@ -218,13 +341,25 @@ namespace Atspi
}
public IList<Accessible> Children {
get { return children; }
get {
if (children == null) {
AccessiblePath [] childPaths;
try {
childPaths = proxy.GetChildren ();
} catch (System.Exception) {
children = new List<Accessible> ();
return children;
}
UpdateChildren (childPaths);
}
return children;
}
}
public Accessible GetChildAtIndexNoCache (int index)
{
AccessiblePath path = proxy.GetChildAtIndex (index);
return Registry.GetElement (path, this, true);
return Registry.GetElement (path, true);
}
public int IndexInParent {
@ -250,11 +385,28 @@ namespace Atspi
}
public Role Role {
get { return role; }
get {
if (role == Role.Invalid)
role = (Role) proxy.GetRole ();
return role;
}
}
public StateSet StateSet {
get { return stateSet; }
get {
if (stateSet == null) {
uint [] states;
try {
states = proxy.GetState ();
} catch (System.Exception) {
stateSet = new StateSet ();
stateSet.Add (StateType.Defunct);
return stateSet;
}
stateSet = new StateSet (states);
}
return stateSet;
}
}
public Relation [] RelationSet {
@ -292,7 +444,11 @@ namespace Atspi
private Accessible FindDescendantDepthFirst (FindPredicate d, object [] args)
{
foreach (Accessible a in children) {
if (StateSet.Contains (StateType.ManagesDescendants))
return null;
Accessible [] childrenCopy = new Accessible [Children.Count];
children.CopyTo (childrenCopy, 0);
foreach (Accessible a in childrenCopy) {
if (d (a, args))
return a;
Accessible ret = a.FindDescendantDepthFirst (d, args);
@ -304,10 +460,14 @@ namespace Atspi
private Accessible FindDescendantBreadthFirst (FindPredicate d, object [] args)
{
foreach (Accessible a in children)
if (stateSet.Contains (StateType.ManagesDescendants))
return null;
Accessible [] childrenCopy = new Accessible [children.Count];
children.CopyTo (childrenCopy, 0);
foreach (Accessible a in childrenCopy)
if (d (a, args))
return a;
foreach (Accessible a in children) {
foreach (Accessible a in childrenCopy) {
Accessible ret = a.FindDescendantBreadthFirst (d, args);
if (ret != null)
return ret;
@ -385,45 +545,49 @@ namespace Atspi
return null;
}
public IEventObject ObjectEvents {
public EventObject ObjectEvents {
get {
if (objectEvents == null)
objectEvents = Registry.Bus.GetObject<IEventObject> (application.name, new ObjectPath (path));
if (objectEvents == null && application != null)
objectEvents = new EventObject (this);
return objectEvents;
}
}
public IEventWindow WindowEvents {
public EventWindow WindowEvents {
get {
if (windowEvents == null &&
application != null &&
(Role == Role.Window ||
Role == Role.Frame ||
Role == Role.Dialog))
windowEvents = Registry.Bus.GetObject<IEventWindow> (application.name, new ObjectPath (path));
windowEvents = new EventWindow (this);
return windowEvents;
}
}
public IEventTerminal TerminalEvents {
public EventTerminal TerminalEvents {
get {
if (terminalEvents == null && Role == Role.Terminal)
terminalEvents = Registry.Bus.GetObject<IEventTerminal> (application.name, new ObjectPath (path));
if (terminalEvents == null &&
application != null &&
Role == Role.Terminal)
terminalEvents = new EventTerminal (this);
return terminalEvents;
}
}
public IEventDocument DocumentEvents {
public EventDocument DocumentEvents {
get {
if (documentEvents == null)
documentEvents = Registry.Bus.GetObject<IEventDocument> (application.name, new ObjectPath (path));
if (documentEvents == null &&
application != null)
documentEvents = new EventDocument (this);
return documentEvents;
}
}
public IEventFocus FocusEvents {
public EventFocus FocusEvents {
get {
if (focusEvents == null)
focusEvents = Registry.Bus.GetObject<IEventFocus> (application.name, new ObjectPath (path));
if (focusEvents == null && application != null)
focusEvents = new EventFocus (this);
return focusEvents;
}
}
@ -453,5 +617,8 @@ namespace Atspi
DBusRelation [] GetRelationSet ();
int GetIndexInParent ();
AccessiblePath GetChildAtIndex (int index);
AccessiblePath [] GetChildren ();
uint GetRole ();
uint [] GetState ();
}
}

Просмотреть файл

@ -30,26 +30,48 @@ using org.freedesktop.DBus;
namespace Atspi
{
public class Application : IDisposable
{
internal const string SPI_PATH_ROOT = "/org/freedesktop/atspi/accessible/root";
internal const string SPI_PATH_NULL = "/org/freedesktop/atspi/null";
internal string name;
private ITree proxy;
private ICache proxy;
private Properties properties;
private Dictionary<string, Accessible> accessibles;
protected Dictionary<string, Accessible> accessibles;
public bool Disposed {
get; private set;
}
private const string IFACE = "org.freedesktop.atspi.Application";
internal Application (string name)
{
this.name = name;
proxy = Registry.Bus.GetObject<ITree> (name, new ObjectPath ("/org/freedesktop/atspi/tree"));
accessibles = new Dictionary<string, Accessible> ();
accessibles ["/org/freedesktop/atspi/accessible/null"] = null;
proxy.UpdateAccessible += OnUpdateAccessible;
accessibles [SPI_PATH_NULL] = null;
}
internal void PostInit ()
{
proxy = Registry.Bus.GetObject<ICache> (name, new ObjectPath ("/org/at_spi/cache"));
proxy.AddAccessible += OnAddAccessible;
proxy.RemoveAccessible += OnRemoveAccessible;
properties = Registry.Bus.GetObject<Properties> (name, proxy.GetRoot ());
AccessibleProxy [] elements = proxy.GetTree ();
AddAccessibles (elements);
ObjectPath op = new ObjectPath (SPI_PATH_ROOT);
properties = Registry.Bus.GetObject<Properties> (name, op);
if (!(this is Registry)) {
AccessibleProxy [] elements;
try {
elements = proxy.GetItems ();
} catch (System.Exception) {
return;
}
AddAccessibles (elements);
}
}
public void Dispose ()
@ -59,7 +81,11 @@ namespace Atspi
protected virtual void Dispose (bool disposing)
{
proxy.UpdateAccessible -= OnUpdateAccessible;
if (!Disposed) {
proxy.RemoveAccessible -= OnRemoveAccessible;
proxy.AddAccessible -= OnAddAccessible;
Disposed = true;
}
}
void AddAccessibles (AccessibleProxy [] elements)
@ -70,12 +96,12 @@ namespace Atspi
Accessible GetElement (AccessibleProxy e)
{
Accessible obj = GetElement (e.path, true);
Accessible obj = GetElement (e.path.path, true);
obj.Update (e);
return obj;
}
void OnUpdateAccessible (AccessibleProxy nodeAdded)
void OnAddAccessible (AccessibleProxy nodeAdded)
{
GetElement (nodeAdded);
}
@ -96,6 +122,9 @@ namespace Atspi
return null;
obj = new Accessible (this, path);
accessibles [path] = obj;
// Events must be initialized after insertion into
// hash, since we need to gracefully handle reentrancy
obj.InitEvents ();
return obj;
}
@ -113,10 +142,10 @@ namespace Atspi
get { return name; }
}
internal Accessible GetRoot ()
{
ObjectPath o = proxy.GetRoot ();
return GetElement (o);
internal Accessible Root {
get {
return GetElement ("/org/freedesktop/atspi/accessible/root", true);
}
}
public string ToolkitName {
@ -126,16 +155,15 @@ namespace Atspi
}
}
[Interface ("org.freedesktop.atspi.Tree")]
interface ITree : Introspectable
[Interface ("org.freedesktop.atspi.Cache")]
interface ICache : Introspectable
{
ObjectPath GetRoot ();
AccessibleProxy [] GetTree ();
event UpdateAccessibleHandler UpdateAccessible;
AccessibleProxy [] GetItems ();
event AddAccessibleHandler AddAccessible;
event RemoveAccessibleHandler RemoveAccessible;
}
delegate void UpdateAccessibleHandler (AccessibleProxy nodeAdded);
delegate void AddAccessibleHandler (AccessibleProxy nodeAdded);
delegate void RemoveAccessibleHandler (ObjectPath nodeRemoved);
internal struct AccessiblePath
@ -146,7 +174,8 @@ namespace Atspi
struct AccessibleProxy
{
public ObjectPath path;
public AccessiblePath path;
public AccessiblePath app_root;
public AccessiblePath parent;
public AccessiblePath [] children;
public string [] interfaces;
@ -154,13 +183,5 @@ namespace Atspi
public uint role;
public string description;
public uint [] states; // 2 32-bit flags
public bool ContainsChild (string path)
{
foreach (AccessiblePath child in children)
if (child.bus_name == name && child.path.ToString () == path)
return true;
return false;
}
}
}

Просмотреть файл

@ -1,3 +1,18 @@
2010-02-03 Mike Gorse <mgorse@novell.com>
* EventBase.cs, EventDocument.cs, EventFocus.cs, EventKeyboard.cs,
EventMouse.cs, EventObject.cs, EventTerminal.cs, EventWindow.cs,
Makefile.am: Track at-spi event api, and add wrappers to remove unused
parameters.
* StateSet.cs, StateType.cs: use [System.Flags]
* Table.cs: Fix Caption and Summary.
* Component.cs, RelationSet.cs, Selection.cs, Table.cs: Internal GetElement refactoring.
* Accessible.cs, Application.cs, Hypertext.cs: Track at-spi api.
2009-12-03 Mike Gorse <mgorse@novell.com>
* Desktop.cs: Remove "On" prefix from event names.

Просмотреть файл

@ -32,12 +32,10 @@ namespace Atspi
{
public class Component
{
private Accessible accessible;
private IComponent proxy;
public Component (Accessible accessible)
{
this.accessible = accessible;
proxy = Registry.Bus.GetObject<IComponent> (accessible.application.name, new ObjectPath (accessible.path));
}
@ -49,7 +47,7 @@ namespace Atspi
public Accessible GetAccessibleAtPoint (int x, int y, CoordType coordType)
{
AccessiblePath path = proxy.GetAccessibleAtPoint (x, y, coordType);
return Registry.GetElement (path, accessible, true);
return Registry.GetElement (path, true);
}
public BoundingBox GetExtents (CoordType coordType)

Просмотреть файл

@ -51,7 +51,7 @@ namespace Atspi
get { return instance; }
}
internal Desktop (): base (null, null)
internal Desktop (Application registry) : base (registry, "/org/freedesktop/atspi/accessible/root")
{
lock (sync) {
if (instance == null)
@ -60,12 +60,28 @@ namespace Atspi
throw new Exception ("Attempt to create a second desktop");
}
role = Role.DesktopFrame;
children = new List<Accessible> ();
stateSet = new StateSet ();
stateSet.Add (StateType.Enabled);
stateSet.Add (StateType.Sensitive);
stateSet.Add (StateType.Showing);
stateSet.Add (StateType.Visible);
InitEvents ();
}
internal void PostInit ()
{
AccessiblePath [] childPaths = proxy.GetChildren ();
foreach (AccessiblePath path in childPaths)
Registry.Instance.GetApplication (path.bus_name);
}
internal void Add (Application app)
{
lock (sync) {
children.Add (app.GetRoot ());
children.Add (app.Root);
}
}
@ -90,12 +106,16 @@ namespace Atspi
internal static void RaiseChildAdded (Accessible sender, Accessible child)
{
if (sender == null)
return;
if (ChildAdded != null)
ChildAdded (sender, child);
}
internal static void RaiseChildRemoved (Accessible sender, Accessible child)
{
if (sender == null)
return;
if (ChildRemoved != null)
ChildRemoved (sender, child);
}

Просмотреть файл

@ -1,124 +0,0 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Authors:
// Mike Gorse <mgorse@novell.com>
//
using System;
using System.Collections.Generic;
using NDesk.DBus;
using org.freedesktop.DBus;
namespace Atspi
{
[Interface ("org.freedesktop.atspi.Event.Object")]
public interface IEventObject
{
event AtspiEventHandler PropertyChange;
event AtspiEventHandler BoundsChanged;
event AtspiEventHandler LinkSelected;
event AtspiEventHandler StateChanged;
event AtspiEventHandler ChildrenChanged;
event AtspiEventHandler VisibleDataChanged;
event AtspiEventHandler SelectionChanged;
event AtspiEventHandler ModelChanged;
event AtspiEventHandler ActiveDescendantChanged;
event AtspiEventHandler RowInserted;
event AtspiEventHandler RowReordered;
event AtspiEventHandler RowDeleted;
event AtspiEventHandler ColumnInserted;
event AtspiEventHandler ColumnReordered;
event AtspiEventHandler ColumnDeleted;
event AtspiEventHandler TextBoundsChanged;
event AtspiEventHandler TextSelectionChanged;
event AtspiEventHandler TextChanged;
event AtspiEventHandler TextAttributesChanged;
event AtspiEventHandler TextCaretMoved;
event AtspiEventHandler AttributesChanged;
}
[Interface ("org.freedesktop.atspi.Event.Window")]
public interface IEventWindow
{
event AtspiEventHandler PropertyChange;
event AtspiEventHandler Minimize;
event AtspiEventHandler Maximize;
event AtspiEventHandler Restore;
event AtspiEventHandler Close;
event AtspiEventHandler Create;
event AtspiEventHandler Reparent;
event AtspiEventHandler DesktopCreate;
event AtspiEventHandler DesktopDestroy;
event AtspiEventHandler Destroy;
event AtspiEventHandler Activate;
event AtspiEventHandler Deactivate;
event AtspiEventHandler Raise;
event AtspiEventHandler Lower;
event AtspiEventHandler Move;
event AtspiEventHandler Resize;
event AtspiEventHandler Shade;
event AtspiEventHandler Unshade;
event AtspiEventHandler Restyle;
}
[Interface ("org.freedesktop.atspi.Event.Mouse")]
public interface IEventMouse
{
event AtspiEventHandler Abs;
event AtspiEventHandler Rel;
event AtspiEventHandler Button;
}
[Interface ("org.freedesktop.atspi.Event.Keyboard")]
public interface IEventKeyboard
{
event AtspiEventHandler Modifiers;
}
[Interface ("org.freedesktop.atspi.Event.Terminal")]
public interface IEventTerminal
{
event AtspiEventHandler LineChanged;
event AtspiEventHandler ColumncountChanged;
event AtspiEventHandler LinecountChanged;
event AtspiEventHandler ApplicationChanged;
event AtspiEventHandler CharwidthChanged;
}
[Interface ("org.freedesktop.atspi.Event.Document")]
public interface IEventDocument
{
event AtspiEventHandler LoadComplete;
event AtspiEventHandler Reload;
event AtspiEventHandler LoadStopped;
event AtspiEventHandler ContentChanged;
event AtspiEventHandler AttributesChanged;
}
[Interface ("org.freedesktop.atspi.Event.Focus")]
public interface IEventFocus
{
event AtspiEventHandler Focus;
}
public delegate void AtspiEventHandler (string detail, int v1, int v2, object any);
}

Просмотреть файл

@ -52,10 +52,10 @@ namespace Atspi
public Hyperlink GetLink (int linkIndex)
{
string path = proxy.GetLink (linkIndex);
if (path == "/org/freedesktop/atspi/accessible/null")
AccessiblePath path = proxy.GetLink (linkIndex);
if (path.path.ToString() == Application.SPI_PATH_NULL)
return null;
return new Hyperlink (accessible, path);
return new Hyperlink (accessible, path.path.ToString ());
}
public int GetLinkIndex (int characterIndex)
@ -68,7 +68,7 @@ namespace Atspi
interface IHypertext : Introspectable
{
int GetNLinks ();
string GetLink (int linkIndex);
AccessiblePath GetLink (int linkIndex);
int GetLinkIndex (int characterIndex);
}
}

Просмотреть файл

@ -43,7 +43,14 @@ SOURCE_FILES = \
Desktop.cs \
Document.cs \
EditableText.cs \
Event.cs \
EventBase.cs \
EventDocument.cs \
EventFocus.cs \
EventKeyboard.cs \
EventMouse.cs \
EventObject.cs \
EventTerminal.cs \
EventWindow.cs \
Hyperlink.cs \
Hypertext.cs \
Image.cs \

Просмотреть файл

@ -25,13 +25,14 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using NDesk.DBus;
using org.freedesktop.DBus;
namespace Atspi
{
public class Registry
public class Registry : Application
{
public static Registry Instance {
get {
@ -41,14 +42,11 @@ namespace Atspi
private volatile static Registry instance;
private Bus bus;
private RegistryInterface proxy;
private Dictionary<string, Application> applications;
private Desktop desktop;
private static object sync = new object ();
private static Thread loopThread;
private const string PATH_DESKTOP = "/org/freedesktop/atspi/accessible/desktop";
public static void Initialize ()
{
Initialize (false);
@ -74,6 +72,7 @@ namespace Atspi
internal static Bus Bus { get { return Instance.bus; } }
internal Registry (bool startLoop)
: base ("org.freedesktop.atspi.Registry")
{
lock (sync) {
if (instance != null)
@ -81,7 +80,10 @@ namespace Atspi
instance = this;
}
bus = Bus.Session;
bus = GetAtspiBus ();
if (bus == null)
bus = Bus.Session;
if (startLoop && loopThread == null) {
loopThread = new Thread (new ThreadStart (Iterate));
loopThread.IsBackground = true;
@ -89,60 +91,97 @@ namespace Atspi
}
applications = new Dictionary<string, Application> ();
desktop = new Desktop ();
proxy = bus.GetObject<RegistryInterface> ("org.freedesktop.atspi.Registry", new ObjectPath ("/org/freedesktop/atspi/registry"));
proxy.Introspect ();
proxy.UpdateApplications += OnUpdateApplications;
applications [name] = this;
desktop = new Desktop (this);
accessibles [SPI_PATH_ROOT] = desktop;
string [] appNames = proxy.GetApplications ();
foreach (string name in appNames) {
Application application = new Application (name);
applications [name] = application;
desktop.Add (application);
PostInit ();
desktop.PostInit ();
}
[DllImport("libX11.so.6")]
static extern IntPtr XOpenDisplay (string name);
[DllImport("libX11.so.6")]
static extern IntPtr XDefaultRootWindow (IntPtr display);
[DllImport("libX11.so.6")]
static extern IntPtr XInternAtom (IntPtr display, string atom_name, int only_if_eists);
[DllImport("libX11.so.6")]
static extern int XGetWindowProperty (IntPtr display, IntPtr w, IntPtr property, IntPtr long_offset, IntPtr long_length, int delete, IntPtr req_type, out IntPtr actual_type_return, out int actual_format_return, out IntPtr nitems_return, out IntPtr bytes_after_return, out string prop_return);
public static Bus GetAtspiBus ()
{
string displayName = Environment.GetEnvironmentVariable ("AT_SPI_DISPLAY");
if (displayName == null || displayName == String.Empty)
displayName = Environment.GetEnvironmentVariable ("DISPLAY");
if (displayName == null || displayName == String.Empty)
displayName = ":0";
for (int i = displayName.Length - 1; i >= 0; i--) {
if (displayName [i] == '.') {
displayName = displayName.Substring (0, i);
break;
} else if (displayName [i] == ':')
break;
}
IntPtr display = XOpenDisplay (displayName);
if (display == IntPtr.Zero)
return null;
IntPtr atSpiBus = XInternAtom (display, "AT_SPI_BUS", 0);
IntPtr actualType, nItems, leftOver;
int actualFormat;
string data;
XGetWindowProperty (display,
XDefaultRootWindow (display),
atSpiBus, (IntPtr) 0,
(IntPtr) 2048, 0,
(IntPtr) 31, out actualType, out actualFormat,
out nItems, out leftOver, out data);
if (data == null)
return null;
return Bus.Open (data);
}
internal Application GetApplication (string name)
{
return GetApplication (name, true);
}
internal Application GetApplication (string name, bool create)
{
if (!applications.ContainsKey (name)) {
applications [name] = new Application (name);
desktop.Add (applications [name]);
applications [name].PostInit ();
}
if (applications.ContainsKey (name))
return applications [name];
return null;
}
public static Desktop Desktop {
get { return Instance.desktop; }
}
internal static Accessible GetElement (AccessiblePath ap, Accessible reference, bool create)
internal static Accessible GetElement (AccessiblePath ap, bool create)
{
Application application = (reference != null?
reference.application: null);
return GetElement (ap, application, create);
}
internal static Accessible GetElement (AccessiblePath ap, Application reference, bool create)
{
if (ap.path.ToString () == PATH_DESKTOP)
return Desktop.Instance;
Application application;
application = (Instance.applications.ContainsKey (ap.bus_name)
? Instance.applications [ap.bus_name]
: reference);
application = Instance.GetApplication (ap.bus_name, create);
if (application == null)
return null;
return application.GetElement (ap.path, create);
}
internal void TerminateInternal ()
{
proxy.UpdateApplications -= OnUpdateApplications;
foreach (string bus_name in applications.Keys)
applications [bus_name].Dispose ();
applications = null;
}
void OnUpdateApplications (int added, string name)
internal void RemoveApplication (string name)
{
// added is really a bool
if (added != 0) {
Application app = new Application (name);
applications [name] = app;
desktop.Add (app);
} else if (applications.ContainsKey (name)) {
if (applications.ContainsKey (name)) {
Application application = applications [name];
desktop.Remove (application);
Desktop.Remove (application);
applications.Remove (name);
application.Dispose ();
}
@ -161,13 +200,4 @@ namespace Atspi
}
}
}
[Interface ("org.freedesktop.atspi.Registry")]
interface RegistryInterface : Introspectable
{
string [] GetApplications ();
event UpdateApplicationsHandler UpdateApplications;
}
delegate void UpdateApplicationsHandler (int added, string name);
}

Просмотреть файл

@ -74,7 +74,7 @@ namespace Atspi
type = rel.type;
targets = new Accessible [rel.targets.Length];
for (int i = 0; i < rel.targets.Length; i++)
targets [i] = Registry.GetElement (rel.targets [i], application, false);
targets [i] = Registry.GetElement (rel.targets [i], false);
}
}

Просмотреть файл

@ -32,7 +32,6 @@ namespace Atspi
{
public class Selection
{
private Accessible accessible;
private ISelection proxy;
private Properties properties;
@ -40,7 +39,6 @@ namespace Atspi
public Selection (Accessible accessible)
{
this.accessible = accessible;
ObjectPath op = new ObjectPath (accessible.path);
proxy = Registry.Bus.GetObject<ISelection> (accessible.application.name, op);
properties = Registry.Bus.GetObject<Properties> (accessible.application.name, op);
@ -53,7 +51,7 @@ namespace Atspi
public Accessible GetSelectedChild (int selectedChildIndex)
{
AccessiblePath path = proxy.GetSelectedChild (selectedChildIndex);
return Registry.GetElement (path, accessible, true);
return Registry.GetElement (path, true);
}
public bool SelectChild (int childIndex)

Просмотреть файл

@ -48,18 +48,17 @@ namespace Atspi
public bool Contains (StateType state)
{
int n = (int)state;
if (n < 0 || n >= (int)Enum.GetValues (typeof (StateType)).Length)
throw new ArgumentOutOfRangeException ();
return (states & ((ulong)1 << n)) != 0? true: false;
return (states & (ulong)state) != 0? true: false;
}
public void Add (StateType state)
{
int n = (int)state;
if (n < 0 || n >= (int)Enum.GetValues (typeof (StateType)).Length)
throw new ArgumentOutOfRangeException ();
states |= ((ulong)1 << n);
states |= (ulong)state;
}
public void Remove (StateType state)
{
states &= ~(ulong)state;
}
public static bool operator == (StateSet left, StateSet right)

Просмотреть файл

@ -23,51 +23,54 @@
// Mike Gorse <mgorse@novell.com>
//
using System;
namespace Atspi
{
// TODO: Derive this from the at-spi xml?
public enum StateType
[Flags]
public enum StateType : ulong
{
Invalid,
Active,
Armed,
Busy,
Checked,
Collapsed,
Defunct,
Editable,
Enabled,
Expandable,
Expanded,
Focusable,
Focused,
HasToolTip,
Horizontal,
Iconified,
Modal,
MultiLine,
Multiselectable,
Opaque,
Pressed,
Resizable,
Selectable,
Selected,
Sensitive,
Showing,
SingleLine,
Stale,
Transient,
Vertical,
Visible,
ManagesDescendants,
Indeterminate,
Required,
Truncated,
Animated,
InvalidEntry,
SupportsAutocompletion,
SelectableText,
IsDefault,
Visited
Invalid = 1,
Active = 0x02,
Armed = 0x04,
Busy = 0x08,
Checked = 0x10,
Collapsed = 0x20,
Defunct = 0x40,
Editable = 0x80,
Enabled = 0x100,
Expandable = 0x0200,
Expanded = 0x0400,
Focusable = 0x0800,
Focused = 0x1000,
HasToolTip = 0x2000,
Horizontal = 0x4000,
Iconified = 0x8000,
Modal = 0x10000,
MultiLine = 0x20000,
Multiselectable = 0x40000,
Opaque = 0x80000,
Pressed = 0x100000,
Resizable = 0x200000,
Selectable = 0x400000,
Selected = 0x800000,
Sensitive = 0x1000000,
Showing = 0x2000000,
SingleLine = 0x4000000,
Stale = 0x8000000,
Transient = 0x10000000,
Vertical = 0x2000000,
Visible = 0x40000000,
ManagesDescendants = 0x80000000,
Indeterminate = 0x100000000,
Required = 0x200000000,
Truncated = 0x400000000,
Animated = 0x800000000,
InvalidEntry = 0x1000000000,
SupportsAutocompletion = 0x2000000000,
SelectableText = 0x4000000000,
IsDefault = 0x8000000000,
Visited = 0x10000000000
}
}

Просмотреть файл

@ -32,7 +32,6 @@ namespace Atspi
{
public class Table
{
private Accessible accessible;
private ITable proxy;
private Properties properties;
@ -40,7 +39,6 @@ namespace Atspi
public Table (Accessible accessible)
{
this.accessible = accessible;
proxy = Registry.Bus.GetObject<ITable> (accessible.application.name, new ObjectPath (accessible.path));
ObjectPath op = new ObjectPath (accessible.path);
@ -61,15 +59,17 @@ namespace Atspi
public Accessible Caption {
get {
AccessiblePath path = (AccessiblePath) properties.Get (IFACE, "Caption");
return Registry.GetElement (path, accessible, true);
object o = properties.Get (IFACE, "Caption");
AccessiblePath path = (AccessiblePath) Convert.ChangeType (o, typeof (AccessiblePath));
return Registry.GetElement (path, true);
}
}
public Accessible Summary {
get {
AccessiblePath path = (AccessiblePath) properties.Get (IFACE, "Summary");
return Registry.GetElement (path, accessible, true);
object o = properties.Get (IFACE, "Summary");
AccessiblePath path = (AccessiblePath) Convert.ChangeType (o, typeof (AccessiblePath));
return Registry.GetElement (path, true);
}
}
@ -88,7 +88,7 @@ namespace Atspi
public Accessible GetAccessibleAt (int row, int column)
{
AccessiblePath path = proxy.GetAccessibleAt (row, column);
return Registry.GetElement (path, accessible, true);
return Registry.GetElement (path, true);
}
public int GetIndexAt (int row, int column)
@ -129,13 +129,13 @@ namespace Atspi
public Accessible GetRowHeader (int row)
{
AccessiblePath path = proxy.GetRowHeader (row);
return Registry.GetElement (path, accessible, true);
return Registry.GetElement (path, true);
}
public Accessible GetColumnHeader (int column)
{
AccessiblePath path = proxy.GetColumnHeader (column);
return Registry.GetElement (path, accessible, true);
return Registry.GetElement (path, true);
}
public int [] GetSelectedRows ()

Просмотреть файл

@ -1,3 +1,10 @@
2010-02-03 Mike Gorse <mgorse@novell.com>
* apps/gtkradiobutton.py: Do not call pack_start until BGO#577392
is fixed.
* at-spi-sharp/EventTest.cs: Track API refactoring.
2009-12-03 Mike Gorse <mgorse@novell.com>
* at-spi-sharp/EventTest.cs: Remove "On" prefix from event names.

Просмотреть файл

@ -30,14 +30,14 @@ class RadioButton:
radio6 = gtk.RadioButton(radio4, "Foe")
radio7 = gtk.RadioButton(radio4, "Fum")
vbox.pack_start(radio1, False, False, 0)
vbox.pack_start(radio2, False, False, 0)
vbox.pack_start(radio3, False, False, 0)
vbox.add(radio1)
vbox.add(radio2)
vbox.add(radio3)
vbox.pack_start(radio4, False, False, 0)
vbox.pack_start(radio5, False, False, 0)
vbox.pack_start(radio6, False, False, 0)
vbox.pack_start(radio7, False, False, 0)
vbox.add(radio4)
vbox.add(radio5)
vbox.add(radio6)
vbox.add(radio7)
self.window.add(vbox)

Просмотреть файл

@ -58,138 +58,177 @@ namespace AtSpiTest
[Test]
public void BoundsChanged ()
{
frame.ObjectEvents.BoundsChanged += OnEvent;
frame.ObjectEvents.BoundsChanged += OnEventR;
et.SetTextContents ("BoundsChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.BoundsChanged -= OnEvent;
frame.ObjectEvents.BoundsChanged -= OnEventR;
et.SetTextContents ("BoundsChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void LinkSelected ()
{
frame.ObjectEvents.LinkSelected += OnEvent;
frame.ObjectEvents.LinkSelected += OnEventI;
et.SetTextContents ("LinkSelected");
Sync ();
AssertEvent ();
frame.ObjectEvents.LinkSelected -= OnEvent;
frame.ObjectEvents.LinkSelected -= OnEventI;
et.SetTextContents ("LinkSelected");
Sync ();
AssertNoEvent ();
}
[Test]
public void VisibleDataChanged ()
{
frame.ObjectEvents.VisibleDataChanged += OnEvent;
frame.ObjectEvents.VisibleDataChanged += OnEventSimple;
et.SetTextContents ("VisibleDataChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.VisibleDataChanged -= OnEvent;
frame.ObjectEvents.VisibleDataChanged -= OnEventSimple;
et.SetTextContents ("VisibleDataChanged");
Sync ();
AssertNoEvent ();
}
[Test]
[Ignore ("TODO: SelectionChanged")]
public void SelectionChanged ()
{
frame.ObjectEvents.SelectionChanged += OnEvent;
frame.ObjectEvents.SelectionChanged += OnEventSimple;
et.SetTextContents ("SelectionChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.SelectionChanged -= OnEvent;
frame.ObjectEvents.SelectionChanged -= OnEventSimple;
et.SetTextContents ("SelectionChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void ModelChanged ()
{
frame.ObjectEvents.ModelChanged += OnEvent;
frame.ObjectEvents.ModelChanged += OnEventSimple;
et.SetTextContents ("ModelChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.ModelChanged -= OnEvent;
frame.ObjectEvents.ModelChanged -= OnEventSimple;
et.SetTextContents ("ModelChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void ActiveDescendantChanged ()
{
frame.ObjectEvents.ActiveDescendantChanged += OnEvent;
frame.ObjectEvents.ActiveDescendantChanged += OnEventO;
et.SetTextContents ("ActiveDescendantChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.ActiveDescendantChanged -= OnEvent;
frame.ObjectEvents.ActiveDescendantChanged -= OnEventO;
et.SetTextContents ("ActiveDescendantChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void RowInserted ()
{
frame.ObjectEvents.RowInserted += OnEvent;
frame.ObjectEvents.RowInserted += OnEventII;
et.SetTextContents ("RowInserted");
Sync ();
AssertEvent ();
frame.ObjectEvents.RowInserted -= OnEvent;
frame.ObjectEvents.RowInserted -= OnEventII;
et.SetTextContents ("RowInserted");
Sync ();
AssertNoEvent ();
}
[Test]
public void RowReordered ()
{
frame.ObjectEvents.RowReordered += OnEvent;
frame.ObjectEvents.RowReordered += OnEventSimple;
et.SetTextContents ("RowReordered");
Sync ();
AssertEvent ();
frame.ObjectEvents.RowReordered -= OnEvent;
frame.ObjectEvents.RowReordered -= OnEventSimple;
et.SetTextContents ("RowReordered");
Sync ();
AssertNoEvent ();
}
[Test]
public void RowDeleted ()
{
frame.ObjectEvents.RowDeleted += OnEvent;
frame.ObjectEvents.RowDeleted += OnEventII;
et.SetTextContents ("RowDeleted");
Sync ();
AssertEvent ();
frame.ObjectEvents.RowDeleted -= OnEvent;
frame.ObjectEvents.RowDeleted -= OnEventII;
et.SetTextContents ("RowDeleted");
Sync ();
AssertNoEvent ();
}
[Test]
public void ColumnInserted ()
{
frame.ObjectEvents.ColumnInserted += OnEvent;
frame.ObjectEvents.ColumnInserted += OnEventII;
et.SetTextContents ("ColumnInserted");
Sync ();
AssertEvent ();
frame.ObjectEvents.ColumnInserted -= OnEvent;
frame.ObjectEvents.ColumnInserted -= OnEventII;
et.SetTextContents ("ColumnInserted");
Sync ();
AssertNoEvent ();
}
[Test]
public void ColumnReordered ()
{
frame.ObjectEvents.ColumnReordered += OnEvent;
frame.ObjectEvents.ColumnReordered += OnEventSimple;
et.SetTextContents ("ColumnReordered");
Sync ();
AssertEvent ();
frame.ObjectEvents.ColumnReordered -= OnEvent;
frame.ObjectEvents.ColumnReordered -= OnEventSimple;
et.SetTextContents ("ColumnReordered");
Sync ();
AssertNoEvent ();
}
[Test]
public void ColumnDeleted ()
{
frame.ObjectEvents.ColumnDeleted += OnEvent;
frame.ObjectEvents.ColumnDeleted += OnEventII;
et.SetTextContents ("ColumnDeleted");
Sync ();
AssertEvent ();
frame.ObjectEvents.ColumnDeleted -= OnEvent;
frame.ObjectEvents.ColumnDeleted -= OnEventII;
et.SetTextContents ("ColumnDeleted");
Sync ();
AssertNoEvent ();
}
[Test]
public void TextSelectionChanged ()
{
frame.ObjectEvents.TextSelectionChanged += OnEvent;
frame.ObjectEvents.TextSelectionChanged += OnEventSimple;
et.SetTextContents ("TextSelectionChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.TextSelectionChanged -= OnEvent;
frame.ObjectEvents.TextSelectionChanged -= OnEventSimple;
et.SetTextContents ("TextSelectionChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void TextChanged ()
{
frame.ObjectEvents.TextChanged += OnEvent;
frame.ObjectEvents.TextChanged += OnEventSIIS;
et.SetTextContents ("TextChanged");
Sync ();
AssertEvent ();
@ -197,68 +236,89 @@ namespace AtSpiTest
Assert.AreEqual (11, v2, "TextChanged v2");
Assert.AreEqual ("insert", detail, "TextChanged detail");
Assert.AreEqual ("TextChanged", any, "TextChanged any");
frame.ObjectEvents.TextChanged -= OnEvent;
frame.ObjectEvents.TextChanged -= OnEventSIIS;
et.SetTextContents ("TextChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void TextAttributesChanged ()
{
frame.ObjectEvents.TextAttributesChanged += OnEvent;
frame.ObjectEvents.TextAttributesChanged += OnEventSimple;
et.SetTextContents ("TextAttributesChanged");
Sync ();
AssertEvent ();
frame.ObjectEvents.TextAttributesChanged -= OnEvent;
frame.ObjectEvents.TextAttributesChanged -= OnEventSimple;
et.SetTextContents ("TextAttributesChanged");
Sync ();
AssertNoEvent ();
}
[Test]
public void TextCaretMoved ()
{
frame.ObjectEvents.TextCaretMoved += OnEvent;
frame.ObjectEvents.TextCaretMoved += OnEventI;
et.SetTextContents ("TextCaretMoved");
Sync ();
AssertEvent ();
frame.ObjectEvents.TextCaretMoved -= OnEvent;
frame.ObjectEvents.TextCaretMoved -= OnEventI;
et.SetTextContents ("TextCaretMoved");
Sync ();
AssertNoEvent ();
}
// Document event tests
[Test]
public void LoadComplete ()
{
frame.DocumentEvents.LoadComplete += OnEvent;
frame.DocumentEvents.LoadComplete += OnEventSimple;
et.SetTextContents ("LoadComplete");
Sync ();
AssertEvent ();
frame.DocumentEvents.LoadComplete -= OnEvent;
frame.DocumentEvents.LoadComplete -= OnEventSimple;
et.SetTextContents ("LoadComplete");
Sync ();
AssertNoEvent ();
}
[Test]
public void Reload ()
{
frame.DocumentEvents.Reload += OnEvent;
frame.DocumentEvents.Reload += OnEventSimple;
et.SetTextContents ("Reload");
Sync ();
AssertEvent ();
frame.DocumentEvents.Reload -= OnEvent;
frame.DocumentEvents.Reload -= OnEventSimple;
et.SetTextContents ("Reload");
Sync ();
AssertNoEvent ();
}
[Test]
public void LoadStopped ()
{
frame.DocumentEvents.LoadStopped += OnEvent;
frame.DocumentEvents.LoadStopped += OnEventSimple;
et.SetTextContents ("LoadStopped");
Sync ();
AssertEvent ();
frame.DocumentEvents.LoadStopped -= OnEvent;
frame.DocumentEvents.LoadStopped -= OnEventSimple;
et.SetTextContents ("LoadStopped");
Sync ();
AssertNoEvent ();
}
[Test]
public void Focus ()
{
frame.FocusEvents.Focus += OnEvent;
frame.FocusEvents.Focus += OnEventSimple;
et.SetTextContents ("Focus");
Sync ();
AssertEvent ();
frame.FocusEvents.Focus -= OnEvent;
frame.FocusEvents.Focus -= OnEventSimple;
et.SetTextContents ("Focus");
Sync ();
AssertNoEvent ();
}
[Test]
@ -335,15 +395,58 @@ namespace AtSpiTest
// Add a second child; ensure we don't get extra events
addEventCount = removeEventCount = 0;
et.SetTextContents ("AddChild");
Desktop.ChildAdded -= OnChildAdded;
Sync ();
Desktop.ChildAdded -= OnChildAdded;
Assert.AreEqual (1, addEventCount, "addEvents #2");
Assert.AreEqual (0, removeEventCount, "removeEvents when adding #2");
Desktop.ChildRemoved -= OnChildRemoved;
Desktop.ChildAdded -= OnChildAdded;
}
private void OnEvent (string detail, int v1, int v2, object any)
private void OnEventI (Accessible sender, int v1)
{
eventCount++;
this.v1 = v1;
}
private void OnEventII (Accessible sender, int v1, int v2)
{
eventCount++;
this.v1 = v1;
this.v2 = v2;
}
private void OnEventO (Accessible sender, Accessible obj)
{
eventCount++;
this.any = obj;
}
private void OnEventR (Accessible sender, BoundingBox rect)
{
eventCount++;
this.any = rect;
}
/*
private void OnEventSB (Accessible sender, string detail, bool val)
{
eventCount++;
this.detail = detail;
this.v1 = (val? 1: 0);
}
*/
/*
private void OnEventSII (Accessible sender, string detail, int v1, int v2)
{
eventCount++;
this.detail = detail;
this.v1 = v1;
this.v2 = v2;
}
*/
private void OnEventSIIS (Accessible sender, string detail, int v1, int v2, string any)
{
eventCount++;
this.detail = detail;
@ -352,6 +455,28 @@ namespace AtSpiTest
this.any = any;
}
/*
private void OnEventSIO (Accessible sender, string detail, int v1, Accessible obj)
{
eventCount++;
this.detail = detail;
this.v1 = v1;
this.any = obj;
}
private void OnEventSV (Accessible sender, string detail, object any)
{
eventCount++;
this.detail = detail;
this.any = any;
}
*/
private void OnEventSimple (Accessible sender)
{
eventCount++;
}
private void OnNameChanged (object sender, string oldName, string newName)
{
this.oldName = oldName;
@ -403,12 +528,16 @@ namespace AtSpiTest
AssertEvents (1);
}
private void AssertNoEvent ()
{
AssertEvents (0);
}
private void AssertEvents (int n)
{
int oldEventCount = eventCount;
eventCount = 0;
Assert.AreEqual (n, oldEventCount, "eventCount");
eventCount = 0;
}
}
}