diff options
-rw-r--r-- | atspi/Makefile.am | 16 | ||||
-rw-r--r-- | atspi/atspi-accessible.c | 136 | ||||
-rw-r--r-- | atspi/atspi-accessible.h | 2 | ||||
-rw-r--r-- | atspi/atspi-constants.h | 4 | ||||
-rw-r--r-- | atspi/atspi-enum-types.c.template | 39 | ||||
-rw-r--r-- | atspi/atspi-enum-types.h.template | 27 | ||||
-rw-r--r-- | atspi/atspi-registry.c | 3 | ||||
-rw-r--r-- | atspi/atspi-registry.h | 3 | ||||
-rw-r--r-- | atspi/atspi-stateset.c | 70 | ||||
-rw-r--r-- | atspi/atspi-types.h | 6 | ||||
-rw-r--r-- | atspi/atspi.h | 2 | ||||
-rw-r--r-- | configure.ac | 2 |
12 files changed, 124 insertions, 186 deletions
diff --git a/atspi/Makefile.am b/atspi/Makefile.am index 8a264301..28551853 100644 --- a/atspi/Makefile.am +++ b/atspi/Makefile.am @@ -27,6 +27,7 @@ libatspiinclude_HEADERS = \ atspi-device-listener-private.h \ atspi-document.h \ atspi-editabletext.h \ + atspi-enum-types.h \ atspi-event-listener.h \ atspi-event-listener-private.h \ atspi-gmain.c \ @@ -48,6 +49,7 @@ atspi-gmain.h \ atspi-value.h libatspi_la_SOURCES = \ + $(BUILT_SOURCES) \ $(libatspiinclude_HEADERS) \ atspi.h \ atspi-accessible.c \ @@ -102,13 +104,25 @@ libatspi_la_SOURCES = \ atspi-value.c \ atspi-value.h -#BUILT_SOURCES = atspi-constants.h +BUILT_SOURCES = \ + atspi-enum-types.c \ + atspi-enum-types.h #CLEANFILES = atspi-constants.h #atspi-constants.h: $(top_srcdir)/xml/spec.xml $(top_srcdir)/tools/c-constants-gen.py # python $(top_srcdir)/tools/c-constants-gen.py Atspi $(top_srcdir)/xml/spec.xml atspi-constants +ENUM_TYPES = \ + atspi-constants.h \ + atspi-types.h + +atspi-enum-types.h: atspi-enum-types.h.template $(ENUM_TYPES) $(GLIB_MKENUMS) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template atspi-enum-types.h.template $(ENUM_TYPES)) > $@ + +atspi-enum-types.c: atspi-enum-types.c.template $(ENUM_TYPES) $(GLIB_MKENUMS) + $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template atspi-enum-types.c.template $(ENUM_TYPES)) > $@ + if HAVE_INTROSPECTION INTROSPECTION_FILES = $(libatspi_la_SOURCES) diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c index 50b58452..9461ece2 100644 --- a/atspi/atspi-accessible.c +++ b/atspi/atspi-accessible.c @@ -178,123 +178,6 @@ atspi_accessible_class_init (AtspiAccessibleClass *klass) object_class->finalize = atspi_accessible_finalize; } -/* TODO: Generate following from spec? */ -static const char *role_names [] = -{ - "invalid", - "accel-label", - "alert", - "animation", - "arrow", - "calendar", - "canvas", - "check-box", - "check-menu-item", - "color-chooser", - "column-header", - "combo-box", - "date-editor", - "desktop-icon", - "desktop-frame", - "dial", - "dialog", - "directory-pane", - "drawing-area", - "file-chooser", - "filler", - "font-chooser", - "frame", - "glass-pane", - "html-container", - "icon", - "image", - "internalframe", - "label", - "layered-pane", - "list", - "list-item", - "menu", - "menu-bar", - "menu-item", - "option-pane", - "page-tab", - "page-tab-list", - "panel", - "password-text", - "popup-menu", - "progress-bar", - "push-button", - "radio-button", - "radio-menu-item", - "root-pane", - "row-header", - "scroll-bar", - "scroll-pane", - "separator", - "slider", - "spin-button", - "split-pane", - "statusbar", - "table", - "table-cell", - "table-column-header", - "table-row-header", - "tear-off-menu-item", - "terminal", - "text", - "toggle-button", - "tool-bar", - "tool-tip", - "tree", - "tree-table", - "unknown", - "viewport", - "window", - NULL, - "header", - "fooler", - "paragraph", - "ruler", - "application", - "autocomplete", - "editbar", - "embedded", - "entry", - "chart", - "caption", - "document_frame", - "heading", - "page", - "section", - "form", - "redundant object", - "link", - "input method window" -}; - -#define MAX_ROLES (sizeof (role_names) / sizeof (char *)) - -/** - * atspi_role_get_name - * @role: an #AtspiAccessibleRole object to query. - * - * Get a localizeable string that indicates the name of an #AtspiAccessibleRole. - * <em>DEPRECATED.</em> - * - * Returns: a localizable string name for an #AtspiAccessibleRole enumerated type. - **/ -gchar * -atspi_role_get_name (AtspiRole role) -{ - if (role < MAX_ROLES && role_names [(int) role]) - { - return g_strdup (role_names [(int) role]); - } - else - { - return g_strdup (""); - } -} /** * atspi_accessible_get_name: @@ -578,7 +461,24 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error) gchar * atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error) { + AtspiRole role = atspi_accessible_get_role (obj, error); char *retval = NULL; + GTypeClass *type_class; + GEnumValue *value; + const gchar *name = NULL; + + type_class = g_type_class_ref (ATSPI_TYPE_ROLE); + g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL); + + value = g_enum_get_value (G_ENUM_CLASS (type_class), role); + + if (value) + { + retval = value->value_nick; + } + + if (retval) + return g_strdup (retval); g_return_val_if_fail (obj != NULL, NULL); @@ -1415,7 +1315,7 @@ atspi_accessible_new (AtspiApplication *app, const gchar *path) * * @accessible: The #AtspiAccessible to operate on. Must be the desktop or * the root of an application. - * @mask: (type int): An #AtspiCache specifying a bit mask of the types of data to cache. + * @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, diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h index 987f696c..bbee0cea 100644 --- a/atspi/atspi-accessible.h +++ b/atspi/atspi-accessible.h @@ -66,8 +66,6 @@ GType atspi_accessible_get_type (void); AtspiAccessible * atspi_accessible_new (AtspiApplication *app, const gchar *path); -gchar * atspi_role_get_name (AtspiRole role); - gchar * atspi_accessible_get_name (AtspiAccessible *obj, GError **error); gchar * atspi_accessible_get_description (AtspiAccessible *obj, GError **error); diff --git a/atspi/atspi-constants.h b/atspi/atspi-constants.h index 073102c6..3632854f 100644 --- a/atspi/atspi-constants.h +++ b/atspi/atspi-constants.h @@ -761,8 +761,8 @@ typedef enum { typedef enum { - ATSPI_CACHE_NONE = 0, - ATSPI_CACHE_PARENT = 1 << 0, + ATSPI_CACHE_NONE = 0, + ATSPI_CACHE_PARENT = 1 << 0, ATSPI_CACHE_CHILDREN = 1 << 1, ATSPI_CACHE_NAME = 1 << 2, ATSPI_CACHE_DESCRIPTION = 1 << 3, diff --git a/atspi/atspi-enum-types.c.template b/atspi/atspi-enum-types.c.template new file mode 100644 index 00000000..cd92f992 --- /dev/null +++ b/atspi/atspi-enum-types.c.template @@ -0,0 +1,39 @@ +/*** BEGIN file-header ***/ +#include "atspi-enum-types.h" + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +#include "@filename@" + +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static GType the_type = 0; + + if (the_type == 0) + { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, + "@VALUENAME@", + "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + the_type = g_@type@_register_static ( + g_intern_static_string ("@EnumName@"), + values); + } + return the_type; +} + +/*** END value-tail ***/ diff --git a/atspi/atspi-enum-types.h.template b/atspi/atspi-enum-types.h.template new file mode 100644 index 00000000..bd297b5c --- /dev/null +++ b/atspi/atspi-enum-types.h.template @@ -0,0 +1,27 @@ +/*** BEGIN file-header ***/ +#ifndef __ATSPI_ENUM_TYPES_H__ +#define __ATSPI_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* Enumerations from "@filename@" */ + +/*** END file-production ***/ + +/*** BEGIN enumeration-production ***/ +#define ATSPI_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) +GType @enum_name@_get_type (void) G_GNUC_CONST; + +/*** END enumeration-production ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +#endif /* __ATSPI_ENUM_TYPES_H__ */ +/*** END file-tail ***/ + diff --git a/atspi/atspi-registry.c b/atspi/atspi-registry.c index 9856be3d..51392d00 100644 --- a/atspi/atspi-registry.c +++ b/atspi/atspi-registry.c @@ -119,7 +119,8 @@ atspi_register_keystroke_listener (AtspiDeviceListener *listener, GArray *key_set, AtspiKeyMaskType modmask, AtspiKeyEventMask event_types, - gint sync_type, GError **error) + AtspiKeyListenerSyncType sync_type, + GError **error) { GArray *d_key_set; gchar *path = _atspi_device_listener_get_path (listener); diff --git a/atspi/atspi-registry.h b/atspi/atspi-registry.h index 03086dc1..f8bf42fa 100644 --- a/atspi/atspi-registry.h +++ b/atspi/atspi-registry.h @@ -42,7 +42,8 @@ atspi_register_keystroke_listener (AtspiDeviceListener *listener, GArray *key_set, AtspiKeyMaskType modmask, AtspiKeyEventMask event_types, - gint sync_type, GError **error); + AtspiKeyListenerSyncType sync_type, + GError **error); gboolean atspi_deregister_keystroke_listener (AtspiDeviceListener *listener, diff --git a/atspi/atspi-stateset.c b/atspi/atspi-stateset.c index a5bcc51c..28e272fc 100644 --- a/atspi/atspi-stateset.c +++ b/atspi/atspi-stateset.c @@ -28,52 +28,6 @@ static void atspi_state_set_class_init (AtspiStateSetClass *klass); G_DEFINE_TYPE (AtspiStateSet, atspi_state_set, G_TYPE_OBJECT) -static const char *state_names [] = -{ - "invalid", - "active", - "armed", - "busy", - "checked", - "collapsed", - "defunct", - "editable", - "enabled", - "expandable", - "expanded", - "focusable", - "focused", - "has-tool-tip", - "horizontal", - "iconified", - "modal", - "multi-line", - "multiselectable", - "opaque", - "pressed", - "resizable", - "selectable", - "selected", - "sensitive", - "showing", - "singleLine", - "stale", - "transient", - "vertical", - "visible", - "manages-descendants", - "indeterminate", - "required", - "truncated", - "animated", - "invalid-entry", - "supports-autocompletion", - "selectable-text", - "is-default", - "visited", - NULL -}; - static void atspi_state_set_init (AtspiStateSet *set) { @@ -123,25 +77,25 @@ _atspi_state_set_new_internal (AtspiAccessible *accessible, gint64 states) void atspi_state_set_set_by_name (AtspiStateSet *set, const gchar *name, gboolean enabled) { - gint i = 0; + GTypeClass *type_class; + GEnumValue *value; + + type_class = g_type_class_ref (ATSPI_TYPE_STATE_TYPE); if (set->accessible && !(set->accessible->cached_properties & ATSPI_CACHE_STATES)) return; - /* TODO: This could perhaps be optimized */ - for (i = 0; state_names [i]; i++) + value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name); + if (!value) { - if (!strcmp (state_names [i], name)) - { - if (enabled) - set->states |= ((gint64)1 << i); - else - set->states &= ~((gint64)1 << i); - return; - } + g_warning ("AT-SPI: Attempt to set unknown state '%s'", name); } - g_warning ("at-spi: Attempt to set unknown state '%s'", name); + + if (enabled) + set->states |= ((gint64)1 << value->value); + else + set->states &= ~((gint64)1 << value->value); } static void diff --git a/atspi/atspi-types.h b/atspi/atspi-types.h index e56f93f0..4e8dc1ac 100644 --- a/atspi/atspi-types.h +++ b/atspi/atspi-types.h @@ -143,8 +143,8 @@ typedef struct _AtspiKeySet **/ typedef enum { ATSPI_KEYLISTENER_NOSYNC = 0, - ATSPI_KEYLISTENER_SYNCHRONOUS = 1, - ATSPI_KEYLISTENER_CANCONSUME = 2, - ATSPI_KEYLISTENER_ALL_WINDOWS = 4 + ATSPI_KEYLISTENER_SYNCHRONOUS = 1 << 0, + ATSPI_KEYLISTENER_CANCONSUME = 1 << 1, + ATSPI_KEYLISTENER_ALL_WINDOWS = 1 << 2 } AtspiKeyListenerSyncType; #endif /* _ATSPI_TYPES_H_ */ diff --git a/atspi/atspi.h b/atspi/atspi.h index 79157601..7f66d2ac 100644 --- a/atspi/atspi.h +++ b/atspi/atspi.h @@ -50,4 +50,6 @@ #include "atspi-value.h" #include "atspi-gmain.h" + +#include "atspi-enum-types.h" #endif diff --git a/configure.ac b/configure.ac index b3374be5..fc0c93d0 100644 --- a/configure.ac +++ b/configure.ac @@ -171,6 +171,8 @@ else fi AC_SUBST(DBUS_SERVICES_DIR) +AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums) + GOBJECT_INTROSPECTION_CHECK([0.9.6]) AC_SUBST(LIBTOOL_EXPORT_OPTIONS) |