+2001-11-22 Padraig O'Briain <padraig.obriain@sun.com>
+
+ * atk/atk.def, atk/atkrelationtype.h, docs/atk-sections.txt,
+ docs/tmpl/atkrelation.sgml:
+ Change atk_relation_type_from_string to atk_relation_type_for_name
+ Add atk_relation_type_get_name
+
+ * atk/atkrelationtype.c:
+ Change atk_relation_type_from_string to atk_relation_type_for_name
+ Add atk_relation_type_get_name
+ Update atk_relation_type_register() to correctly register new
+ relation types
+
+ * atk/atkstate.c:
+ Changed name of static variable type to last_type
+ Changed name of paremeter if atk_state_type_get_name to type to match
+ comments
+
+ * docs/tmpl/*sgml
+ Updated files
+
+ * tests/README, tests/Makefile.am
+ Add new test file testrelation.c
+
2001-11-22 Bill Haneman <bill.haneman@sun.com>
* atk/atkutil.c (atk_add_key_event_listener):
atk_relation_set_get_type
atk_relation_set_new
atk_relation_set_remove
- atk_relation_type_from_string
+ atk_relation_type_get_name
+ atk_relation_type_for_name
atk_relation_type_register
atk_remove_focus_tracker
atk_remove_global_event_listener
#include "atkobject.h"
#include "atkrelation.h"
+static gchar *relation_names[ATK_RELATION_LAST_DEFINED] = {
+ "null",
+ "controlled_by",
+ "controller_for",
+ "label_for",
+ "labelled_by",
+ "member_of",
+ "node_child_of"
+};
+
+GPtrArray *extra_names = NULL;
+
static void atk_relation_class_init (AtkRelationClass *klass);
static void atk_relation_finalize (GObject *object);
AtkRelationType
atk_relation_type_register (const gchar *name)
{
- /* TODO: associate name with new type */
- static guint type = ATK_RELATION_LAST_DEFINED;
- return (++type);
+ g_return_val_if_fail (name, ATK_RELATION_NULL);
+
+ if (!extra_names)
+ extra_names = g_ptr_array_new ();
+
+ g_ptr_array_add (extra_names, g_strdup (name));
+ return extra_names->len + ATK_RELATION_LAST_DEFINED - 1;
}
+/**
+ * atk_relation_type_get_name:
+ * @type: The #AtkRelationType whose name is required
+ *
+ * Gets the description string describing the #AtkRelationType @type.
+ *
+ * Returns: the string describing the AtkRelationType
+ */
+G_CONST_RETURN gchar*
+atk_relation_type_get_name (AtkRelationType type)
+{
+ gint n;
+
+ n = type;
+
+ if (n >= 0)
+ {
+ if (n < ATK_RELATION_LAST_DEFINED)
+ return relation_names[n];
+ else if (extra_names)
+ {
+ n -= ATK_RELATION_LAST_DEFINED;
+
+ if (n < extra_names->len)
+ return g_ptr_array_index (extra_names, n);
+ }
+ }
+ return ATK_RELATION_NULL;
+
+}
/**
- * atk_relation_type_from_string:
+ * atk_relation_type_for_name:
* @name: a string which is the (non-localized) name of an ATK relation type.
*
* Get the #AtkRelationType type corresponding to a relation name.
* or #ATK_RELATION_NULL if no matching relation type is found.
**/
AtkRelationType
-atk_relation_type_from_string (const gchar *name)
+atk_relation_type_for_name (const gchar *name)
{
- /*
- * TODO: implement properly,
- * checking type namelist in conjunction with above function.
- */
- if ( !strcmp (name, "controlled_by") ) return ATK_RELATION_CONTROLLED_BY;
- else if (!strcmp (name, "controller_for")) return ATK_RELATION_CONTROLLER_FOR;
- else if (!strcmp (name, "label_for")) return ATK_RELATION_LABEL_FOR;
- else if (!strcmp (name, "labelled_by")) return ATK_RELATION_LABELLED_BY;
- else if (!strcmp (name, "member_of")) return ATK_RELATION_MEMBER_OF;
- else return ATK_RELATION_NULL;
+ gint i;
+
+ g_return_val_if_fail (name, ATK_RELATION_NULL);
+
+ for (i = 0; i < ATK_RELATION_LAST_DEFINED; i++)
+ {
+ if (strcmp (name, relation_names[i]) == 0)
+ return i;
+ }
+
+ if (extra_names)
+ {
+ for (i = 0; i < extra_names->len; i++)
+ {
+ gchar *extra_name = (gchar *)g_ptr_array_index (extra_names, i);
+
+ g_return_val_if_fail (extra_name, ATK_RELATION_NULL);
+
+ if (strcmp (name, extra_name) == 0)
+ return i + ATK_RELATION_LAST_DEFINED;
+ }
+ }
+ return ATK_RELATION_NULL;
}
GType atk_relation_get_type (void);
-AtkRelationType atk_relation_type_register (const gchar *name);
-
-AtkRelationType atk_relation_type_from_string (const gchar *name);
+AtkRelationType atk_relation_type_register (const gchar *name);
+G_CONST_RETURN gchar* atk_relation_type_get_name (AtkRelationType type);
+AtkRelationType atk_relation_type_for_name (const gchar *name);
/*
* Create a new relation for the specified key and the specified list
* of targets.
*/
-AtkRelation* atk_relation_new (AtkObject **targets,
+AtkRelation* atk_relation_new (AtkObject **targets,
gint n_targets,
AtkRelationType relationship);
/*
* Returns the type of a relation.
*/
-AtkRelationType atk_relation_get_relation_type (AtkRelation *relation);
+AtkRelationType atk_relation_get_relation_type (AtkRelation *relation);
/*
* Returns the target list of a relation.
*/
-GPtrArray* atk_relation_get_target (AtkRelation *relation);
+GPtrArray* atk_relation_get_target (AtkRelation *relation);
#ifdef __cplusplus
}
#include <string.h>
-static guint type = ATK_STATE_LAST_DEFINED;
+static guint last_type = ATK_STATE_LAST_DEFINED;
#define NUM_POSSIBLE_STATES (sizeof(AtkState)*8)
AtkStateType
atk_state_type_register (const gchar *name)
{
+ g_return_val_if_fail (name, ATK_STATE_INVALID);
- if (type < NUM_POSSIBLE_STATES -1)
- {
- state_names[++type] = g_strdup (name);
- return (type);
- }
+ if (last_type < NUM_POSSIBLE_STATES -1)
+ {
+ state_names[++last_type] = g_strdup (name);
+ return (last_type);
+ }
return ATK_STATE_INVALID; /* caller needs to check */
}
*
* Gets the description string describing the #AtkStateType @type.
*
- * Returns: the string describing the state
+ * Returns: the string describing the AtkStateType
*/
G_CONST_RETURN gchar*
-atk_state_type_get_name (AtkStateType state)
+atk_state_type_get_name (AtkStateType type)
{
gint n;
- if (state < type)
+ if (type < last_type)
{
- n = state;
- return state_names[n];
+ n = type;
+ if (n >= 0)
+ return state_names[n];
}
return NULL;
g_return_val_if_fail (name != NULL, 0);
g_return_val_if_fail (strlen (name) > 0, 0);
- for (i = 0; i < type; i++)
- {
- if (state_names[i] == NULL)
- continue;
- if (!strcmp(name, state_names[i]))
- return i;
- }
+ for (i = 0; i < last_type; i++)
+ {
+ if (state_names[i] == NULL)
+ continue;
+ if (!strcmp(name, state_names[i]))
+ return i;
+ }
return 0;
}
AtkRelation
AtkRelationType
atk_relation_type_register
-atk_relation_type_from_string
+atk_relation_type_get_name
+atk_relation_type_for_name
atk_relation_new
atk_relation_get_relation_type
atk_relation_get_target
-<!-- ##### SECTION ./tmpl/atk.sgml:Long_Description ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/atk.sgml:See_Also ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/atk.sgml:Short_Description ##### -->
-
-
-
-<!-- ##### SECTION ./tmpl/atk.sgml:Title ##### -->
-atk
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_BG_COLOR ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_BG_FULL_HEIGHT ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_BG_STIPPLE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_DIRECTION ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_EDITABLE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_FAMILY_NAME ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_FG_COLOR ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_FG_STIPPLE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_INDENT ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_INVISIBLE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_JUSTIFICATION ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_LANGUAGE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_LEFT_MARGIN ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_PIXELS_ABOVE_LINES ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_PIXELS_BELOW_LINES ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_PIXELS_INSIDE_WRAP ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_RIGHT_MARGIN ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_RISE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_SCALE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_SIZE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_STRETCH ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_STRIKETHROUGH ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_STYLE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_UNDERLINE ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_VARIANT ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_WEIGHT ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO ATK_ATTRIBUTE_WRAP_MODE ##### -->
-<para>
-
-</para>
-
-
AtkAction
<!-- ##### SECTION Short_Description ##### -->
-accessibility interface for objects that can perform actions
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The interface AtkAction should be supported by any object that can
-perform one or more actions. The interface provides the standard
-mechanism for an assistive technology to determine what those actions
-are as well as tell the object to perform them. Any object that can
-be manipulated should support this interface.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkComponent
<!-- ##### SECTION Short_Description ##### -->
-accessibility interface for objects that are rendered on the screen
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkComponent interface should be supported by any object that is
-rendered on the screen. The interface provides the standard mechanism
-for an assistive technology to determine and set the graphical
-representation of an object.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkEditableText
<!-- ##### SECTION Short_Description ##### -->
-accessibility interface for editable text widgets
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-AtkEditableText is used to support access in an "accessibility" context
-to editing features of editable text widgets.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkHypertext
<!-- ##### SECTION Short_Description ##### -->
-the base class for all classes that present hypertext information
-on the display
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkHypertext class is the base class for all classes that present
-hypertext information on the display. This class provides the standard
-mechanism for an assistive technology to access that text via its
-content, attributes, and spatial location. It also provides standard
-mechanisms for manipulating hyperlinks.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkImage
<!-- ##### SECTION Short_Description ##### -->
-accessibility interface for objects that have an associated image
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkImage interface should be supported by any object that has an
-associated image. This interface provides the standard mechanism for
-an assistive technology to get descriptive information about images.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkNoOpObject
<!-- ##### SECTION Short_Description ##### -->
-provides non-functioning stub #AtkObjects
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-Provides non-functioning stub #AtkObjects.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkNoOpObjectFactory
<!-- ##### SECTION Short_Description ##### -->
-an #AtkObjectFactory which creates non-functioning stub #AtkObjects
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-An #AtkObjectFactory which creates non-functioning stub #AtkObjects.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkObject
<!-- ##### SECTION Short_Description ##### -->
-represents the minimum information all accessible objects return
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-AtkObject represents the minimum information all accessible objects
-return. This information includes accessible name, accessible
-description, role and state of the object, as well information about
-its parent and children. It is also possible to obtain more specific
-accessibility information about a component if it supports one or more
-of the other ATK interfaces:
+
</para>
<!-- ##### SECTION See_Also ##### -->
@accessible:
@Returns:
-<!-- # Unused Parameters # -->
-@acessible:
<!-- ##### FUNCTION atk_object_get_role ##### -->
AtkObjectFactory
<!-- ##### SECTION Short_Description ##### -->
-factory for creating #AtkObjects
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-A factory for creating #AtkObjects.
</para>
AtkRegistry
<!-- ##### SECTION Short_Description ##### -->
-registry for registering new #AtkObject factories
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-A registry for registering new #AtkObject factories.
</para>
AtkRelation
<!-- ##### SECTION Short_Description ##### -->
-defines the functional relationship between two #AtkObjects
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-Defines the functional relationship between two #AtkObjects.
+
</para>
<!-- ##### SECTION See_Also ##### -->
@Returns:
-<!-- ##### FUNCTION atk_relation_type_from_string ##### -->
+<!-- ##### FUNCTION atk_relation_type_get_name ##### -->
+<para>
+
+</para>
+
+@type:
+@Returns:
+
+
+<!-- ##### FUNCTION atk_relation_type_for_name ##### -->
<para>
</para>
AtkRelationSet
<!-- ##### SECTION Short_Description ##### -->
-a set of #AtkRelations, which define the functional relationships
-between #AtkObjects
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-A set of #AtkRelations, which define the functional relationships
-between #AtkObjects.
</para>
AtkSelection
<!-- ##### SECTION Short_Description ##### -->
-accessibility interface for determining what the current selected
-children are, as well as modify the selection set
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkSelection interface provides the standard mechanism for an
-assistive technology to determine what the current selected children are,
-as well as modify the selection set. Any object that has children that
-can be selected should support the AtkSelection interface.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkState
<!-- ##### SECTION Short_Description ##### -->
-describes an objects particular state
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-AtkState describes an objects particular state. The actual state of the
-object is defined as an #AtkStateSet, which is a composed set of
-AtkStates.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkStateSet
<!-- ##### SECTION Short_Description ##### -->
-determines an object's state set
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-AtkStateSet determines an object's state set. The state set of an object
-is a set of AtkState objects and describes the current
-overall state of the object, such as whether it is active, has focus, etc.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkStreamableContent
<!-- ##### SECTION Short_Description ##### -->
-accessibility interface for objects that contain streamable content
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkStreamableContent interface should be supported by any object
-that contains streamable content.
+
</para>
<!-- ##### SECTION See_Also ##### -->
@table:
@row:
@Returns:
-<!-- # Unused Parameters # -->
-@r:
<!-- ##### FUNCTION atk_table_get_column_header ##### -->
@table:
@caption:
-<!-- # Unused Parameters # -->
-@accessible:
<!-- ##### FUNCTION atk_table_set_row_description ##### -->
@table:
@row:
@description:
-<!-- # Unused Parameters # -->
-@accessible:
<!-- ##### FUNCTION atk_table_set_column_description ##### -->
@table:
@column:
@description:
-<!-- # Unused Parameters # -->
-@accessible:
<!-- ##### FUNCTION atk_table_set_row_header ##### -->
@start_offset:
@end_offset:
@Returns:
-<!-- # Unused Parameters # -->
-@startOffset:
-@endOffset:
<!-- ##### FUNCTION atk_text_get_text_at_offset ##### -->
@start_offset:
@end_offset:
@Returns:
-<!-- # Unused Parameters # -->
-@startOffset:
-@endOffset:
<!-- ##### FUNCTION atk_text_get_text_before_offset ##### -->
@start_offset:
@end_offset:
@Returns:
-<!-- # Unused Parameters # -->
-@startOffset:
-@endOffset:
<!-- ##### FUNCTION atk_text_get_caret_offset ##### -->
@width:
@height:
@coords:
-<!-- # Unused Parameters # -->
-@length:
<!-- ##### FUNCTION atk_text_get_run_attributes ##### -->
AtkUtil
<!-- ##### SECTION Short_Description ##### -->
-general purpose utility class
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkUtility interface provides general purpose utility functions.
+
</para>
<!-- ##### SECTION See_Also ##### -->
AtkValue
<!-- ##### SECTION Short_Description ##### -->
-the standard mechanism for an assistive technology to
-determine and set numerical values as well as get minimum
-and maximum values
+
<!-- ##### SECTION Long_Description ##### -->
<para>
-The AtkValue interface should be supported by any object that
-supports a numerical value (e.g., a scroll bar). This interface
-provides the standard mechanism for an assistive technology to
-determine and set the numerical value as well as get the minimum
-and maximum values.
+
</para>
<!-- ##### SECTION See_Also ##### -->
-lib_LTLIBRARIES = libteststateset.la
+lib_LTLIBRARIES = \
+ libteststateset.la \
+ libtestrelation.la
libatk = $(top_builddir)/atk/libatk.la
libteststateset_la_SOURCES = teststateset.c
libteststateset_la_LDFLAGS = -avoid-version \
-module
+
+libtestrelation_la_SOURCES = testrelation.c
+libtestrelation_la_LDFLAGS = -avoid-version \
+ -module
teststateset
============
-This module tests the interfaces in atk/atkstatset.h
+This module tests the interfaces in atk/atkstateset.h
+
+testrelation
+============
+This module tests the interfaces in atk/atkrelation.h
--- /dev/null
+/* ATK - Accessibility Toolkit
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <atk/atk.h>
+
+#include <string.h>
+
+static gboolean test_relation (void);
+
+static gboolean
+test_relation (void)
+{
+ AtkRelationType type1, type2;
+ G_CONST_RETURN gchar *name;
+
+ name = atk_relation_type_get_name (ATK_RELATION_LABEL_FOR);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "label_for") != 0)
+ {
+ g_print ("Unexpected name for ATK_RELATION_LABEL_FOR %s\n", name);
+ return FALSE;
+ }
+
+ name = atk_relation_type_get_name (ATK_RELATION_NODE_CHILD_OF);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "node_child_of") != 0)
+ {
+ g_print ("Unexpected name for ATK_STATE_MODAL %s\n", name);
+ return FALSE;
+ }
+
+ type1 = atk_relation_type_for_name ("controlled_by");
+ if (type1 != ATK_RELATION_CONTROLLED_BY)
+ {
+ g_print ("Unexpected type for focused\n");
+ return FALSE;
+ }
+
+ type1 = atk_relation_type_register ("test_state");
+ name = atk_relation_type_get_name (type1);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "test_state") != 0)
+ {
+ g_print ("Unexpected name for test_state %s\n", name);
+ return FALSE;
+ }
+ type2 = atk_relation_type_for_name ("test_state");
+ if (type1 != type2)
+ {
+ g_print ("Unexpected type for test_state\n");
+ return FALSE;
+ }
+ type2 = atk_relation_type_for_name ("TEST-STATE");
+ if (type2 != 0)
+ {
+ g_print ("Unexpected type for TEST-STATE\n");
+ return FALSE;
+ }
+ /*
+ * Check that a non-existent type returns NULL
+ */
+ name = atk_relation_type_get_name (ATK_RELATION_LAST_DEFINED + 2);
+ if (name)
+ {
+ g_print ("Unexpected name for undefined type\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+int
+gtk_module_init (gint argc,
+ char* argv[])
+{
+ gboolean b_ret;
+
+ g_print("Relation test module loaded\n");
+
+ b_ret = test_relation ();
+ if (b_ret)
+ g_print ("Relation tests succeeded\n");
+ else
+ g_print ("Relation tests failed\n");
+ return 0;
+}