From: Padraig O'Briain Date: Thu, 22 Nov 2001 15:58:58 +0000 (+0000) Subject: Change atk_relation_type_from_string to atk_relation_type_for_name Add X-Git-Tag: ATK_0_7~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=904c325f06e97a4c2cf376f294b95bc23d0793d8;p=platform%2Fupstream%2Fatk.git Change atk_relation_type_from_string to atk_relation_type_for_name Add * 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 --- diff --git a/ChangeLog b/ChangeLog index 3dd92a6..1901f1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2001-11-22 Padraig O'Briain + + * 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 * atk/atkutil.c (atk_add_key_event_listener): diff --git a/atk/atk.def b/atk/atk.def index cb87a4f..81eebc2 100644 --- a/atk/atk.def +++ b/atk/atk.def @@ -99,7 +99,8 @@ EXPORTS 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 diff --git a/atk/atkrelation.c b/atk/atkrelation.c index e1d8944..9737fb1 100755 --- a/atk/atkrelation.c +++ b/atk/atkrelation.c @@ -22,6 +22,18 @@ #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); @@ -68,14 +80,48 @@ atk_relation_class_init (AtkRelationClass *klass) 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. @@ -84,18 +130,31 @@ atk_relation_type_register (const gchar *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; } diff --git a/atk/atkrelation.h b/atk/atkrelation.h index ba39ec2..ae02889 100755 --- a/atk/atkrelation.h +++ b/atk/atkrelation.h @@ -83,25 +83,25 @@ struct _AtkRelationClass 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 } diff --git a/atk/atkstate.c b/atk/atkstate.c index 673319f..d56b14e 100755 --- a/atk/atkstate.c +++ b/atk/atkstate.c @@ -21,7 +21,7 @@ #include -static guint type = ATK_STATE_LAST_DEFINED; +static guint last_type = ATK_STATE_LAST_DEFINED; #define NUM_POSSIBLE_STATES (sizeof(AtkState)*8) @@ -68,12 +68,13 @@ static gchar* state_names[NUM_POSSIBLE_STATES] = { 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 */ } @@ -83,17 +84,18 @@ atk_state_type_register (const gchar *name) * * 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; @@ -115,12 +117,12 @@ atk_state_type_for_name (const gchar *name) 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; } diff --git a/docs/atk-sections.txt b/docs/atk-sections.txt index c65deff..c2f5474 100644 --- a/docs/atk-sections.txt +++ b/docs/atk-sections.txt @@ -227,7 +227,8 @@ ATK_REGISTRY_GET_CLASS 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 diff --git a/docs/tmpl/atk-unused.sgml b/docs/tmpl/atk-unused.sgml index 4ca20da..e69de29 100644 --- a/docs/tmpl/atk-unused.sgml +++ b/docs/tmpl/atk-unused.sgml @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - -atk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/tmpl/atkaction.sgml b/docs/tmpl/atkaction.sgml index f744c7d..668cdb9 100644 --- a/docs/tmpl/atkaction.sgml +++ b/docs/tmpl/atkaction.sgml @@ -2,15 +2,11 @@ AtkAction -accessibility interface for objects that can perform actions + -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. + diff --git a/docs/tmpl/atkcomponent.sgml b/docs/tmpl/atkcomponent.sgml index bde93a5..046d8d4 100644 --- a/docs/tmpl/atkcomponent.sgml +++ b/docs/tmpl/atkcomponent.sgml @@ -2,14 +2,11 @@ AtkComponent -accessibility interface for objects that are rendered on the screen + -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. + diff --git a/docs/tmpl/atkeditabletext.sgml b/docs/tmpl/atkeditabletext.sgml index 1f9d147..c577880 100644 --- a/docs/tmpl/atkeditabletext.sgml +++ b/docs/tmpl/atkeditabletext.sgml @@ -2,12 +2,11 @@ AtkEditableText -accessibility interface for editable text widgets + -AtkEditableText is used to support access in an "accessibility" context -to editing features of editable text widgets. + diff --git a/docs/tmpl/atkhypertext.sgml b/docs/tmpl/atkhypertext.sgml index f410f78..f96dbbf 100644 --- a/docs/tmpl/atkhypertext.sgml +++ b/docs/tmpl/atkhypertext.sgml @@ -2,16 +2,11 @@ AtkHypertext -the base class for all classes that present hypertext information -on the display + -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. + diff --git a/docs/tmpl/atkimage.sgml b/docs/tmpl/atkimage.sgml index 8d0a6bc..e6558cc 100644 --- a/docs/tmpl/atkimage.sgml +++ b/docs/tmpl/atkimage.sgml @@ -2,13 +2,11 @@ AtkImage -accessibility interface for objects that have an associated image + -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. + diff --git a/docs/tmpl/atknoopobject.sgml b/docs/tmpl/atknoopobject.sgml index 2a6a21e..05f545e 100644 --- a/docs/tmpl/atknoopobject.sgml +++ b/docs/tmpl/atknoopobject.sgml @@ -2,11 +2,11 @@ AtkNoOpObject -provides non-functioning stub #AtkObjects + -Provides non-functioning stub #AtkObjects. + diff --git a/docs/tmpl/atknoopobjectfactory.sgml b/docs/tmpl/atknoopobjectfactory.sgml index 38c2c3e..ccac1bb 100644 --- a/docs/tmpl/atknoopobjectfactory.sgml +++ b/docs/tmpl/atknoopobjectfactory.sgml @@ -2,11 +2,11 @@ AtkNoOpObjectFactory -an #AtkObjectFactory which creates non-functioning stub #AtkObjects + -An #AtkObjectFactory which creates non-functioning stub #AtkObjects. + diff --git a/docs/tmpl/atkobject.sgml b/docs/tmpl/atkobject.sgml index 5c895d7..164a459 100644 --- a/docs/tmpl/atkobject.sgml +++ b/docs/tmpl/atkobject.sgml @@ -2,16 +2,11 @@ AtkObject -represents the minimum information all accessible objects return + -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: + @@ -250,8 +245,6 @@ of the other ATK interfaces: @accessible: @Returns: - -@acessible: diff --git a/docs/tmpl/atkobjectfactory.sgml b/docs/tmpl/atkobjectfactory.sgml index 77b6827..740c1a9 100644 --- a/docs/tmpl/atkobjectfactory.sgml +++ b/docs/tmpl/atkobjectfactory.sgml @@ -2,11 +2,10 @@ AtkObjectFactory -factory for creating #AtkObjects + -A factory for creating #AtkObjects. diff --git a/docs/tmpl/atkregistry.sgml b/docs/tmpl/atkregistry.sgml index 61d2dfb..b561a11 100644 --- a/docs/tmpl/atkregistry.sgml +++ b/docs/tmpl/atkregistry.sgml @@ -2,11 +2,10 @@ AtkRegistry -registry for registering new #AtkObject factories + -A registry for registering new #AtkObject factories. diff --git a/docs/tmpl/atkrelation.sgml b/docs/tmpl/atkrelation.sgml index 04d11da..f0041ae 100644 --- a/docs/tmpl/atkrelation.sgml +++ b/docs/tmpl/atkrelation.sgml @@ -2,11 +2,11 @@ AtkRelation -defines the functional relationship between two #AtkObjects + -Defines the functional relationship between two #AtkObjects. + @@ -46,7 +46,16 @@ Defines the functional relationship between two #AtkObjects. @Returns: - + + + + + +@type: +@Returns: + + + diff --git a/docs/tmpl/atkrelationset.sgml b/docs/tmpl/atkrelationset.sgml index 6a12432..b04560d 100644 --- a/docs/tmpl/atkrelationset.sgml +++ b/docs/tmpl/atkrelationset.sgml @@ -2,13 +2,10 @@ AtkRelationSet -a set of #AtkRelations, which define the functional relationships -between #AtkObjects + -A set of #AtkRelations, which define the functional relationships -between #AtkObjects. diff --git a/docs/tmpl/atkselection.sgml b/docs/tmpl/atkselection.sgml index 609b356..fdeb7b7 100644 --- a/docs/tmpl/atkselection.sgml +++ b/docs/tmpl/atkselection.sgml @@ -2,15 +2,11 @@ AtkSelection -accessibility interface for determining what the current selected -children are, as well as modify the selection set + -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. + diff --git a/docs/tmpl/atkstate.sgml b/docs/tmpl/atkstate.sgml index 28087e9..e29a4da 100644 --- a/docs/tmpl/atkstate.sgml +++ b/docs/tmpl/atkstate.sgml @@ -2,13 +2,11 @@ AtkState -describes an objects particular state + -AtkState describes an objects particular state. The actual state of the -object is defined as an #AtkStateSet, which is a composed set of -AtkStates. + diff --git a/docs/tmpl/atkstateset.sgml b/docs/tmpl/atkstateset.sgml index 972f435..08afaa7 100644 --- a/docs/tmpl/atkstateset.sgml +++ b/docs/tmpl/atkstateset.sgml @@ -2,13 +2,11 @@ AtkStateSet -determines an object's state set + -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. + diff --git a/docs/tmpl/atkstreamablecontent.sgml b/docs/tmpl/atkstreamablecontent.sgml index 8eab311..5cef56f 100644 --- a/docs/tmpl/atkstreamablecontent.sgml +++ b/docs/tmpl/atkstreamablecontent.sgml @@ -2,12 +2,11 @@ AtkStreamableContent -accessibility interface for objects that contain streamable content + -The AtkStreamableContent interface should be supported by any object -that contains streamable content. + diff --git a/docs/tmpl/atktable.sgml b/docs/tmpl/atktable.sgml index 25dc585..0ed4e6d 100644 --- a/docs/tmpl/atktable.sgml +++ b/docs/tmpl/atktable.sgml @@ -172,8 +172,6 @@ AtkTable @table: @row: @Returns: - -@r: @@ -212,8 +210,6 @@ AtkTable @table: @caption: - -@accessible: @@ -224,8 +220,6 @@ AtkTable @table: @row: @description: - -@accessible: @@ -236,8 +230,6 @@ AtkTable @table: @column: @description: - -@accessible: diff --git a/docs/tmpl/atktext.sgml b/docs/tmpl/atktext.sgml index 5e157ba..1922edb 100644 --- a/docs/tmpl/atktext.sgml +++ b/docs/tmpl/atktext.sgml @@ -139,9 +139,6 @@ AtkText @start_offset: @end_offset: @Returns: - -@startOffset: -@endOffset: @@ -155,9 +152,6 @@ AtkText @start_offset: @end_offset: @Returns: - -@startOffset: -@endOffset: @@ -171,9 +165,6 @@ AtkText @start_offset: @end_offset: @Returns: - -@startOffset: -@endOffset: @@ -197,8 +188,6 @@ AtkText @width: @height: @coords: - -@length: diff --git a/docs/tmpl/atkutil.sgml b/docs/tmpl/atkutil.sgml index bd03dde..fd370eb 100644 --- a/docs/tmpl/atkutil.sgml +++ b/docs/tmpl/atkutil.sgml @@ -2,11 +2,11 @@ AtkUtil -general purpose utility class + -The AtkUtility interface provides general purpose utility functions. + diff --git a/docs/tmpl/atkvalue.sgml b/docs/tmpl/atkvalue.sgml index 611271c..0dc4e18 100644 --- a/docs/tmpl/atkvalue.sgml +++ b/docs/tmpl/atkvalue.sgml @@ -2,17 +2,11 @@ AtkValue -the standard mechanism for an assistive technology to -determine and set numerical values as well as get minimum -and maximum values + -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. + diff --git a/tests/Makefile.am b/tests/Makefile.am index 6e6767d..33d4bb8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ -lib_LTLIBRARIES = libteststateset.la +lib_LTLIBRARIES = \ + libteststateset.la \ + libtestrelation.la libatk = $(top_builddir)/atk/libatk.la @@ -11,3 +13,7 @@ DEPS = \ libteststateset_la_SOURCES = teststateset.c libteststateset_la_LDFLAGS = -avoid-version \ -module + +libtestrelation_la_SOURCES = testrelation.c +libtestrelation_la_LDFLAGS = -avoid-version \ + -module diff --git a/tests/README b/tests/README index b3973c0..91ed76b 100644 --- a/tests/README +++ b/tests/README @@ -4,4 +4,8 @@ GTK program by specifying the GTK_MODULES environment variable. 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 diff --git a/tests/testrelation.c b/tests/testrelation.c new file mode 100644 index 0000000..9ffaec2 --- /dev/null +++ b/tests/testrelation.c @@ -0,0 +1,101 @@ +/* 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 + +#include + +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; +}