summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gorse <mgorse@suse.com>2013-05-10 18:56:32 -0500
committerMike Gorse <mgorse@suse.com>2013-05-10 18:56:32 -0500
commite74c40ea4b7616930557ca2e9eda73f5b344a4b5 (patch)
tree85d65785426bede318aa66e7804f4a6fcb24d30d
parenta29788df335d9ffc2fd471463ba996ba1aca4665 (diff)
parent7afb51e5093fef46c699d92ee8eee94f5b6886fb (diff)
downloadat-spi2-core-e74c40ea4b7616930557ca2e9eda73f5b344a4b5.tar.gz
Merge branch 'enum-types'
Conflicts: atspi/Makefile.am atspi/atspi-accessible.c
-rw-r--r--atspi/Makefile.am17
-rw-r--r--atspi/atspi-accessible.c155
-rw-r--r--atspi/atspi-accessible.h2
-rw-r--r--atspi/atspi-constants.h4
-rw-r--r--atspi/atspi-enum-types.c.template39
-rw-r--r--atspi/atspi-enum-types.h.template27
-rw-r--r--atspi/atspi-misc-private.h2
-rw-r--r--atspi/atspi-misc.c14
-rw-r--r--atspi/atspi-registry.c3
-rw-r--r--atspi/atspi-registry.h3
-rw-r--r--atspi/atspi-stateset.c71
-rw-r--r--atspi/atspi-types.h6
-rw-r--r--atspi/atspi.h2
-rw-r--r--configure.ac2
14 files changed, 138 insertions, 209 deletions
diff --git a/atspi/Makefile.am b/atspi/Makefile.am
index f89d13af..4d345408 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,20 +104,31 @@ 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)) > $@
+
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
if HAVE_INTROSPECTION
-
Atspi-2.0.gir: libatspi.la
Atspi_2_0_gir_INCLUDES = GLib-2.0 GObject-2.0
Atspi_2_0_gir_PACKAGES = dbus-1
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 03bceca7..fc2b48f0 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -201,139 +201,6 @@ atspi_accessible_class_init (AtspiAccessibleClass *klass)
quark_locale = g_quark_from_string ("accessible-locale");
}
-/* TODO: Generate following from spec? */
-static const char *role_names [] =
-{
- "invalid",
- "accelerator label",
- "alert",
- "animation",
- "arrow",
- "calendar",
- "canvas",
- "check box",
- "check menu item",
- "color chooser",
- "column header",
- "combo box",
- "dateeditor",
- "desktop icon",
- "desktop frame",
- "dial",
- "dialog",
- "directory pane",
- "drawing area",
- "file chooser",
- "filler",
- "focus traversable",
- "fontchooser",
- "frame",
- "glass pane",
- "html container",
- "icon",
- "image",
- "internal frame",
- "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",
- "footer",
- "paragraph",
- "ruler",
- "application",
- "autocomplete",
- "editbar",
- "embedded component",
- "entry",
- "chart",
- "caption",
- "document frame",
- "heading",
- "page",
- "section",
- "redundant object",
- "form",
- "link",
- "input method window",
- "table row",
- "tree item",
- "document spreadsheet",
- "document presentation",
- "document text",
- "document web",
- "document email",
- "comment",
- "list box",
- "grouping",
- "image map",
- "notification",
- "info bar",
- "level bar"
-};
-
-#define MAX_ROLES (sizeof (role_names) / sizeof (char *))
-
-/**
- * atspi_role_get_name:
- * @role: an #AtspiRole object to query.
- *
- * Gets a localizable string that indicates the name of an #AtspiRole.
- * <em>DEPRECATED.</em>
- *
- * Returns: a localizable string name for an #AtspiRole 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:
* @obj: a pointer to the #AtspiAccessible object on which to operate.
@@ -621,14 +488,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;
- AtspiRole role;
+ GTypeClass *type_class;
+ GEnumValue *value;
+ const gchar *name = NULL;
- g_return_val_if_fail (obj != NULL, 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;
+ }
- role = atspi_accessible_get_role (obj, error);
- if (role >= 0 && role < MAX_ROLES && role != ATSPI_ROLE_EXTENDED)
- return g_strdup (role_names [role]);
+ if (retval)
+ return _atspi_name_compat (g_strdup (retval));
_atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
@@ -1480,7 +1357,7 @@ _atspi_accessible_new (AtspiApplication *app, const gchar *path)
* atspi_accessible_set_cache_mask:
* @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 7047016c..f4e2ed39 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -68,8 +68,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 98564e0c..fe734382 100644
--- a/atspi/atspi-constants.h
+++ b/atspi/atspi-constants.h
@@ -1192,8 +1192,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-misc-private.h b/atspi/atspi-misc-private.h
index c7de37b9..26fb793e 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -156,6 +156,8 @@ extern GMainLoop *atspi_main_loop;
extern gboolean atspi_no_cache;
GHashTable *_atspi_get_live_refs ();
+
+gchar *_atspi_name_compat (gchar *in);
G_END_DECLS
#endif /* _ATSPI_MISC_PRIVATE_H_ */
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 67b92dfc..efd2ba65 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -1626,3 +1626,17 @@ debug_disposed ()
g_hash_table_foreach (live_refs, print_disposed, NULL);
}
#endif
+
+gchar *
+_atspi_name_compat (gchar *name)
+{
+ gchar *p = name;
+
+ while (*p)
+ {
+ if (*p == '-')
+ *p = ' ';
+ p++;
+ }
+ return name;
+}
diff --git a/atspi/atspi-registry.c b/atspi/atspi-registry.c
index 116da196..fa876600 100644
--- a/atspi/atspi-registry.c
+++ b/atspi/atspi-registry.c
@@ -197,7 +197,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)
{
DeviceListenerEntry *e;
diff --git a/atspi/atspi-registry.h b/atspi/atspi-registry.h
index 3716f611..18e32a66 100644
--- a/atspi/atspi-registry.h
+++ b/atspi/atspi-registry.h
@@ -44,7 +44,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 fd6fc0cd..33c28a7f 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)
{
@@ -133,25 +87,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
@@ -319,4 +273,3 @@ atspi_state_set_remove (AtspiStateSet *set, AtspiStateType state)
g_return_if_fail (set != NULL);
set->states &= ~((gint64)1 << state);
}
-
diff --git a/atspi/atspi-types.h b/atspi/atspi-types.h
index 99bb8f5c..0d2a6e2a 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 b2b38682..3f3cb00c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,6 +172,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)