2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2007 IBM Corp.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* collection.c: implements the Collection interface */
27 #include <bonobo/bonobo-exception.h>
28 #include <libspi/collection.h>
29 #include <libspi/matchrule.h>
30 #include <libspi/spi-private.h>
32 typedef struct _MatchRulePrivate MatchRulePrivate;
34 struct _MatchRulePrivate {
36 Accessibility_StateSet states;
37 Accessibility_Collection_MatchType statematchtype;
38 Accessibility_AttributeSet *attributes;
39 Accessibility_Collection_MatchType attributematchtype;
40 Accessibility_RoleSet *roles;
41 Accessibility_Collection_MatchType rolematchtype;
42 CORBA_char *interfaces;
43 Accessibility_Collection_MatchType interfacematchtype;
48 #define MATCH_RULE_PRIVATE(o)\
49 G_TYPE_INSTANCE_GET_PRIVATE((o), SPI_MATCHRULE_TYPE, MatchRulePrivate)
53 spi_collection_interface_new ()
56 SpiCollection *new_collection = g_object_new (SPI_COLLECTION_TYPE, NULL);
58 spi_base_construct_default (SPI_BASE (new_collection));
60 return new_collection;
65 static SpiCollection *
66 get_collection_from_servant (PortableServer_Servant servant)
68 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
70 g_return_val_if_fail (object, NULL);
72 return SPI_COLLECTION (object->gobj);
77 static Accessibility_MatchRule
78 impl_createMatchRule (PortableServer_Servant servant,
79 const Accessibility_StateSet states,
80 const Accessibility_Collection_MatchType statematchtype,
81 const Accessibility_AttributeSet *attributes,
82 const Accessibility_Collection_MatchType attributematchtype,
83 const Accessibility_RoleSet *roles,
84 const Accessibility_Collection_MatchType rolematchtype,
85 const CORBA_char *interfaces,
86 const Accessibility_Collection_MatchType interfacematchtype,
87 const CORBA_boolean invert,
88 CORBA_Environment *ev){
90 Accessibility_MatchRule retval = NULL;
92 SpiMatchrule *matchrule = spi_matchrule_interface_new ();
93 MatchRulePrivate *mrp = MATCH_RULE_PRIVATE (matchrule);
97 mrp->statematchtype = statematchtype;
101 mrp->attributes = CORBA_sequence_CORBA_string__alloc ();
102 mrp->attributes->_maximum = attributes->_maximum;
103 mrp->attributes->_length = attributes->_length;
104 mrp->attributes->_buffer = CORBA_sequence_CORBA_string_allocbuf (attributes->_length);
106 for (i = 0; i < mrp->attributes->_length; i++)
107 mrp->attributes->_buffer [i]= CORBA_string_dup (attributes->_buffer [i]);
109 CORBA_sequence_set_release (mrp->attributes, TRUE);
110 mrp->attributematchtype = attributematchtype;
114 mrp->roles = Accessibility_RoleSet__alloc ();
115 mrp->roles->_maximum = roles->_maximum;
116 mrp->roles->_length = roles->_length;
117 mrp->roles->_buffer = Accessibility_RoleSet_allocbuf (roles->_length);
119 for (i = 0; i < roles->_length; i++)
120 mrp->roles->_buffer [i] = roles->_buffer [i];
122 CORBA_sequence_set_release (mrp->roles, TRUE);
123 mrp->rolematchtype = rolematchtype;
127 mrp->interfaces = CORBA_string_dup (interfaces);
128 mrp->interfacematchtype = interfacematchtype;
130 mrp->invert = invert;
132 retval = CORBA_Object_duplicate (BONOBO_OBJREF (matchrule), ev);
138 static void impl_freeMatchRule (PortableServer_Servant servant,
139 Accessibility_MatchRule matchrule,
140 CORBA_Environment *ev){
142 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
143 SpiMatchrule *spimatchrule;
145 MatchRulePrivate *mrp;
147 spimatchrule = SPI_MATCHRULE (object->gobj);
148 mrp = MATCH_RULE_PRIVATE (spimatchrule);;
150 CORBA_free (mrp->attributes);
151 CORBA_free (mrp->roles);
152 CORBA_free (mrp->interfaces);
154 g_free (spimatchrule);
158 spi_collection_class_init (SpiCollectionClass *klass)
161 POA_Accessibility_Collection__epv *epv = &klass->epv;
163 /* epv->isAncestorOf = impl_isAncestorOf; */
165 epv->createMatchRule = impl_createMatchRule;
166 epv->freeMatchRule = impl_freeMatchRule;
169 epv->getChildren = impl_getChildren;
170 epv->getPreviousChildren = impl_getPreviousChildren;
171 epv->getNextChildren = impl_getNextChildren;
172 epv->getActiveDescendant = impl_getActiveDescendant;
175 g_type_class_add_private (klass, sizeof (MatchRulePrivate));
179 spi_collection_init (SpiCollection *collection)
183 BONOBO_TYPE_FUNC_FULL (SpiCollection,
184 Accessibility_Collection,