[at-spi2-core] Add atspi_accessible_set_cache_mask
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Add atspi_accessible_set_cache_mask
- Date: Mon, 31 Jan 2011 23:37:04 +0000 (UTC)
commit b222ea2fcda52f04e78d53b3b0b76edde0df0495
Author: Mike Gorse <mgorse novell com>
Date: Mon Jan 31 14:55:37 2011 -0600
Add atspi_accessible_set_cache_mask
atspi/Makefile.am | 2 +-
atspi/atspi-accessible.c | 55 ++++++++++++++++++++++++++++++++++++++---
atspi/atspi-accessible.h | 5 ++++
atspi/atspi-application.h | 1 +
atspi/atspi-constants.h | 12 +++++++++
atspi/atspi-event-listener.c | 6 ++--
atspi/atspi-misc-private.h | 8 ------
atspi/atspi-misc.c | 10 ++++---
8 files changed, 79 insertions(+), 20 deletions(-)
---
diff --git a/atspi/Makefile.am b/atspi/Makefile.am
index babbfe1..569c6ff 100644
--- a/atspi/Makefile.am
+++ b/atspi/Makefile.am
@@ -12,7 +12,7 @@ libatspi_la_LIBADD = $(DBUS_GLIB_LIBS) \
libatspiincludedir = $(includedir)/at-spi-2.0/atspi
-libatspiinclude_HEADERS = \
+libatspiinclude_HEADERS = \
atspi.h \
atspi-accessible.h \
atspi-action.h \
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 584c70a..1a570f7 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -311,7 +311,7 @@ atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
"s", &obj->name))
return g_strdup ("");
- obj->cached_properties |= ATSPI_CACHE_NAME;
+ _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
}
return g_strdup (obj->name);
}
@@ -336,7 +336,7 @@ atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
"Description", error, "s",
&obj->description))
return g_strdup ("");
- obj->cached_properties |= ATSPI_CACHE_DESCRIPTION;
+ _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
}
return g_strdup (obj->description);
}
@@ -383,7 +383,7 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
dbus_message_iter_recurse (&iter, &iter_variant);
obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
dbus_message_unref (reply);
- obj->cached_properties |= ATSPI_CACHE_PARENT;
+ _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
}
if (!obj->accessible_parent)
return NULL;
@@ -555,8 +555,8 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
/* TODO: Make this a property */
if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
{
- obj->cached_properties |= ATSPI_CACHE_ROLE;
obj->role = role;
+ _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
}
}
return obj->role;
@@ -648,6 +648,7 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
dbus_message_iter_init (reply, &iter);
_atspi_dbus_set_state (obj, &iter);
dbus_message_unref (reply);
+ _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
}
return g_object_ref (obj->states);
@@ -793,6 +794,7 @@ _atspi_accessible_is_a (AtspiAccessible *accessible,
dbus_message_iter_init (reply, &iter);
_atspi_dbus_set_interfaces (accessible, &iter);
dbus_message_unref (reply);
+ _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
}
n = _atspi_get_iface_num (interface_name);
@@ -1308,3 +1310,48 @@ atspi_accessible_new (AtspiApplication *app, const gchar *path)
return accessible;
}
+
+/**
+ * atspi_accessible_set_cache_mask:
+ *
+ * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
+ * the root of an application.
+ * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
+ *
+ * Sets the type of data to cache for accessibles.
+ * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
+ * then the desktop's cache flag will be used.
+ * If the desktop's cache flag is also undefined, then all possible data will
+ * be cached.
+ * This function is intended to work around bugs in toolkits where the proper
+ * events are not raised / to aid in testing for such bugs.
+ *
+ * Note: This function has no effect on data that has already been cached.
+ **/
+void
+atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
+{
+ g_return_if_fail (accessible != NULL);
+ g_return_if_fail (accessible->parent.app != NULL);
+ g_return_if_fail (accessible == accessible->parent.app->root);
+ accessible->parent.app->cache = mask;
+}
+
+void
+_atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
+{
+ AtspiCache mask = accessible->parent.app->cache;
+
+ if (mask == ATSPI_CACHE_UNDEFINED &&
+ accessible->parent.app->root->accessible_parent)
+ {
+ AtspiAccessible *desktop = atspi_get_desktop (0);
+ mask = desktop->parent.app->cache;
+ g_object_unref (desktop);
+ }
+
+ if (mask == ATSPI_CACHE_UNDEFINED)
+ mask = ATSPI_CACHE_ALL;
+
+ accessible->cached_properties |= flag & mask;
+}
diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h
index 487d0e5..db2546f 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -123,4 +123,9 @@ AtspiText * atspi_accessible_get_text (AtspiAccessible *obj);
AtspiValue * atspi_accessible_get_value (AtspiAccessible *obj);
GArray * atspi_accessible_get_interfaces (AtspiAccessible *obj);
+
+void atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask);
+
+/* private */
+void _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag);
#endif /* _ATSPI_ACCESSIBLE_H_ */
diff --git a/atspi/atspi-application.h b/atspi/atspi-application.h
index 42b48ac..1e0dd79 100644
--- a/atspi/atspi-application.h
+++ b/atspi/atspi-application.h
@@ -44,6 +44,7 @@ struct _AtspiApplication
char *bus_name;
DBusConnection *bus;
struct _AtspiAccessible *root;
+ AtspiCache cache;
};
typedef struct _AtspiApplicationClass AtspiApplicationClass;
diff --git a/atspi/atspi-constants.h b/atspi/atspi-constants.h
index 462b89b..3f64bd1 100644
--- a/atspi/atspi-constants.h
+++ b/atspi/atspi-constants.h
@@ -759,6 +759,18 @@ typedef enum {
*/
#define ATSPI_ROLE_COUNT (90+1)
+typedef enum
+{
+ ATSPI_CACHE_PARENT = 0x0001,
+ ATSPI_CACHE_CHILDREN = 0x0002,
+ ATSPI_CACHE_NAME = 0x0004,
+ ATSPI_CACHE_DESCRIPTION = 0x0008,
+ ATSPI_CACHE_STATES = 0x0010,
+ ATSPI_CACHE_ROLE = 0x0020,
+ ATSPI_CACHE_INTERFACES = 0x0040,
+ ATSPI_CACHE_ALL = 0x7fffffff,
+ ATSPI_CACHE_UNDEFINED = 0x80000000
+} AtspiCache;
#ifdef __cplusplus
}
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c
index 1d0d010..46d09f5 100644
--- a/atspi/atspi-event-listener.c
+++ b/atspi/atspi-event-listener.c
@@ -202,7 +202,7 @@ cache_process_property_change (AtspiEvent *event)
if (G_VALUE_HOLDS (&event->any_data, ATSPI_TYPE_ACCESSIBLE))
{
event->source->accessible_parent = g_value_dup_object (&event->any_data);
- event->source->cached_properties |= ATSPI_CACHE_PARENT;
+ _atspi_accessible_add_cache (event->source, ATSPI_CACHE_PARENT);
}
else
{
@@ -217,7 +217,7 @@ cache_process_property_change (AtspiEvent *event)
if (G_VALUE_HOLDS_STRING (&event->any_data))
{
event->source->name = g_value_dup_string (&event->any_data);
- event->source->cached_properties |= ATSPI_CACHE_NAME;
+ _atspi_accessible_add_cache (event->source, ATSPI_CACHE_NAME);
}
else
{
@@ -232,7 +232,7 @@ cache_process_property_change (AtspiEvent *event)
if (G_VALUE_HOLDS_STRING (&event->any_data))
{
event->source->description = g_value_dup_string (&event->any_data);
- event->source->cached_properties |= ATSPI_CACHE_DESCRIPTION;
+ _atspi_accessible_add_cache (event->source, ATSPI_CACHE_DESCRIPTION);
}
else
{
diff --git a/atspi/atspi-misc-private.h b/atspi/atspi-misc-private.h
index 87373d8..c6e6c20 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -33,14 +33,6 @@
#include "dbind/dbind.h"
-#define ATSPI_CACHE_PARENT 0x0001
-#define ATSPI_CACHE_CHILDREN 0x0002
-#define ATSPI_CACHE_NAME 0x0004
-#define ATSPI_CACHE_DESCRIPTION 0x0008
-#define ATSPI_CACHE_STATES 0x0010
-#define ATSPI_CACHE_ROLE 0x0020
-#define ATSPI_CACHE_INTERFACES 0x0040
-
typedef struct _AtspiReference AtspiReference;
struct _AtspiReference
{
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 4f974dc..65d8c09 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -194,6 +194,7 @@ get_application (const char *bus_name)
app->bus_name = bus_name_dup;
app->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
app->bus = dbus_connection_ref (_atspi_bus ());
+ app->cache = ATSPI_CACHE_UNDEFINED;
g_hash_table_insert (app_hash, bus_name_dup, app);
dbus_error_init (&error);
message = dbus_message_new_method_call (bus_name, atspi_path_root,
@@ -458,10 +459,11 @@ add_accessible_from_iter (DBusMessageIter *iter)
_atspi_dbus_set_state (accessible, &iter_struct);
dbus_message_iter_next (&iter_struct);
- accessible->cached_properties |= ATSPI_CACHE_NAME | ATSPI_CACHE_ROLE | ATSPI_CACHE_PARENT;
+ _atspi_accessible_add_cache (accessible, ATSPI_CACHE_NAME | ATSPI_CACHE_ROLE |
+ ATSPI_CACHE_PARENT | ATSPI_CACHE_DESCRIPTION);
if (!atspi_state_set_contains (accessible->states,
ATSPI_STATE_MANAGES_DESCENDANTS))
- accessible->cached_properties |= ATSPI_CACHE_CHILDREN;
+ _atspi_accessible_add_cache (accessible, ATSPI_CACHE_CHILDREN);
/* This is a bit of a hack since the cache holds a ref, so we don't need
* the one provided for us anymore */
@@ -1279,7 +1281,7 @@ _atspi_dbus_set_interfaces (AtspiAccessible *accessible, DBusMessageIter *iter)
accessible->interfaces |= (1 << n);
dbus_message_iter_next (&iter_array);
}
- accessible->cached_properties |= ATSPI_CACHE_INTERFACES;
+ _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
}
void
@@ -1306,7 +1308,7 @@ _atspi_dbus_set_state (AtspiAccessible *accessible, DBusMessageIter *iter)
else
accessible->states->states = val;
}
- accessible->cached_properties |= ATSPI_CACHE_STATES;
+ _atspi_accessible_add_cache (accessible, ATSPI_CACHE_STATES);
}
GQuark
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]