static DBusMessage * impl_GetAttributes (DBusConnection * bus, DBusMessage * message, void *user_data) { AtkDocument *document = (AtkDocument *) user_data; DBusMessage *reply; AtkAttributeSet *attributes; DBusMessageIter iter; g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), droute_not_yet_handled_error (message)); attributes = atk_document_get_attributes (document); reply = dbus_message_new_method_return (message); if (reply) { dbus_message_iter_init_append (reply, &iter); spi_object_append_attribute_set (&iter, attributes); } if (attributes) atk_attribute_set_free (attributes); return reply; }
static VALUE rbatk_document_get_attributes(VALUE self) { AtkAttributeSet* list = atk_document_get_attributes(_SELF(self)); VALUE ary = rb_ary_new(); while (list) { AtkAttribute* attr = list->data; rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(attr->name), CSTR2RVAL(attr->value))); list = list->next; } return ary; }
static Accessibility_AttributeSet* impl_getAttributes (PortableServer_Servant servant, CORBA_Environment *ev){ AtkDocument *document = get_document_from_servant (servant); AtkAttributeSet *attributes = NULL; AtkAttribute *attr = NULL; Accessibility_AttributeSet *retval; gint n_attributes = 0; gint i; gchar *concat_str; g_return_val_if_fail (document != NULL, NULL); attributes = atk_document_get_attributes (document); /* according to atkobject.h, AtkAttributeSet is a GSList */ if (attributes) n_attributes = g_slist_length (attributes); retval = CORBA_sequence_CORBA_string__alloc (); retval->_length = retval->_maximum = n_attributes; retval->_buffer = CORBA_sequence_CORBA_string_allocbuf (n_attributes); CORBA_sequence_set_release (retval, CORBA_TRUE); for (i = 0; i < n_attributes; ++i) { attr = g_slist_nth_data (attributes, i); concat_str = g_strconcat (attr->name, ":", attr->value, NULL); retval->_buffer [i] = CORBA_string_dup (concat_str); g_free (concat_str); } atk_attribute_set_free (attributes); return retval; }