[at-spi2-core] Revert "Remove redundant tables of state and role names"



commit 65caa813eda92711d4d6f37f9f2d0709fab35e92
Author: Mike Gorse <mgorse novell com>
Date:   Sun May 29 17:24:38 2011 -0500

    Revert "Remove redundant tables of state and role names"
    
    This reverts commit 73b811b78954dfb0f8b407354c146d9fbd47dea3.

 atspi/atspi-accessible.c |  117 ++++++++++++++++++++++++++++++++++++++++++++++
 atspi/atspi-accessible.h |    2 +
 atspi/atspi-stateset.c   |   70 +++++++++++++++++++++++-----
 3 files changed, 177 insertions(+), 12 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 9461ece..82d37c4 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -178,6 +178,123 @@ 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:
diff --git a/atspi/atspi-accessible.h b/atspi/atspi-accessible.h
index bbee0ce..987f696 100644
--- a/atspi/atspi-accessible.h
+++ b/atspi/atspi-accessible.h
@@ -66,6 +66,8 @@ 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-stateset.c b/atspi/atspi-stateset.c
index 28e272f..a5bcc51 100644
--- a/atspi/atspi-stateset.c
+++ b/atspi/atspi-stateset.c
@@ -28,6 +28,52 @@ 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)
 {
@@ -77,25 +123,25 @@ _atspi_state_set_new_internal (AtspiAccessible *accessible, gint64 states)
 void
 atspi_state_set_set_by_name (AtspiStateSet *set, const gchar *name, gboolean enabled)
 {
-  GTypeClass *type_class;
-  GEnumValue *value;
-
-  type_class = g_type_class_ref (ATSPI_TYPE_STATE_TYPE);
+  gint i = 0;
 
   if (set->accessible &&
       !(set->accessible->cached_properties & ATSPI_CACHE_STATES))
     return;
 
-  value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);
-  if (!value)
+  /* TODO: This could perhaps be optimized */
+  for (i = 0; state_names [i]; i++)
   {
-    g_warning ("AT-SPI: Attempt to set unknown state '%s'", name);
+    if (!strcmp (state_names [i], name))
+    {
+      if (enabled)
+        set->states |= ((gint64)1 << i);
+      else
+        set->states &= ~((gint64)1 << i);
+      return;
+    }
   }
-
-  if (enabled)
-    set->states |= ((gint64)1 << value->value);
-  else
-    set->states &= ~((gint64)1 << value->value);
+  g_warning ("at-spi: Attempt to set unknown state '%s'", name);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]