Exemple #1
0
/*
 * CORBA Accessibility::Accessible::getRelationSet method implementation
 */
static Accessibility_RelationSet *
impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
						CORBA_Environment     *ev)
{
  Accessibility_RelationSet *retval;
  gint n_relations = 0;
  gint i;
  AtkRelationSet *relation_set;
  AtkObject      *object = get_atkobject_from_servant (servant);

  bonobo_return_val_if_fail (object != NULL, NULL, ev);

  relation_set = atk_object_ref_relation_set (object);

  if (relation_set)
    n_relations = atk_relation_set_get_n_relations (relation_set);

  retval = CORBA_sequence_Accessibility_Relation__alloc ();
  retval->_length = retval->_maximum = n_relations;
  retval->_buffer = CORBA_sequence_Accessibility_Relation_allocbuf (n_relations);
  CORBA_sequence_set_release (retval, CORBA_TRUE);
	  
  for (i = 0; i < n_relations; ++i)
    {
      retval->_buffer[i] =
        CORBA_Object_duplicate (
          BONOBO_OBJREF (
            spi_relation_new (atk_relation_set_get_relation (relation_set, i))),
	  NULL);
    }
  
  return retval;
}
Exemple #2
0
JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1relation_1set_1get_1relation)
	(JNIEnv *env, jclass that, jint arg0, jint arg1)
{
	jint rc = 0;
	ATK_NATIVE_ENTER(env, that, _1atk_1relation_1set_1get_1relation_FUNC);
	rc = (jint)atk_relation_set_get_relation((AtkRelationSet *)arg0, arg1);
	ATK_NATIVE_EXIT(env, that, _1atk_1relation_1set_1get_1relation_FUNC);
	return rc;
}
Exemple #3
0
static void
dump_relation_set (GString        *string,
                   guint           depth,
                   AtkRelationSet *set)
{
  guint i;

  if (set == NULL)
    return;

  for (i = 0; i < atk_relation_set_get_n_relations (set); i++)
    {
      AtkRelation *relation;
      
      relation = atk_relation_set_get_relation (set, i);

      dump_relation (string, depth, relation);
    }

  g_object_unref (set);
}
AccessibilityUIElement AccessibilityUIElement::titleUIElement()
{
    if (!m_element)
        return 0;

    AtkRelationSet* set = atk_object_ref_relation_set(ATK_OBJECT(m_element));
    if (!set)
        return 0;

    AtkObject* target = 0;
    int count = atk_relation_set_get_n_relations(set);
    for (int i = 0; i < count; i++) {
        AtkRelation* relation = atk_relation_set_get_relation(set, i);
        if (atk_relation_get_relation_type(relation) == ATK_RELATION_LABELLED_BY) {
            GPtrArray* targetList = atk_relation_get_target(relation);
            if (targetList->len)
                target = static_cast<AtkObject*>(g_ptr_array_index(targetList, 0));
        }
    }

    g_object_unref(set);
    return target ? AccessibilityUIElement(target) : 0;
}
Exemple #5
0
static gboolean
test_relation (void)
{
    AtkRelationType type1, type2;
    G_CONST_RETURN gchar *name;
    AtkObject *obj;
    gboolean ret_value;
    AtkRelationSet *set;
    AtkRelation *relation;
    gint n_relations;
    GPtrArray *array;

    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_RELATION_NODE_CHILD_OF %s\n", name);
        return FALSE;
    }

    name = atk_relation_type_get_name (ATK_RELATION_EMBEDS);
    g_return_val_if_fail (name, FALSE);
    if (strcmp (name, "embeds") != 0)
    {
        g_print ("Unexpected name for ATK_RELATION_EMBEDS %s\n", name);
        return FALSE;
    }

    type1 = atk_relation_type_for_name ("embedded-by");
    if (type1 != ATK_RELATION_EMBEDDED_BY)
    {
        g_print ("Unexpected role for ATK_RELATION_EMBEDDED_BY\n");
        return FALSE;
    }

    type1 = atk_relation_type_for_name ("controlled-by");
    if (type1 != ATK_RELATION_CONTROLLED_BY)
    {
        g_print ("Unexpected name for ATK_RELATION_CONTROLLED_BY\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 %s\n", name);
        return FALSE;
    }

    obj = g_object_new (ATK_TYPE_OBJECT, NULL);
    ret_value = atk_object_add_relationship (obj, ATK_RELATION_LABEL_FOR, obj);
    if (!ret_value)
    {
        g_print ("Unexpected return value for atk_object_add_relationship\n");
        return FALSE;
    }
    set = atk_object_ref_relation_set (obj);
    if (!set)
    {
        g_print ("Unexpected return value for atk_object_ref_relation_set\n");
        return FALSE;
    }
    n_relations = atk_relation_set_get_n_relations (set);
    if (n_relations != 1)
    {
        g_print ("Unexpected return value (%d) for atk_relation_set_get_n_relations expected value: %d\n", n_relations, 1);
        return FALSE;
    }
    relation = atk_relation_set_get_relation (set, 0);
    if (!relation)
    {
        g_print ("Unexpected return value for atk_object_relation_set_get_relation\n");
        return FALSE;
    }
    type1 = atk_relation_get_relation_type (relation);
    if (type1 != ATK_RELATION_LABEL_FOR)
    {
        g_print ("Unexpected return value for atk_relation_get_relation_type\n");
        return FALSE;
    }
    array = atk_relation_get_target (relation);
    if (obj != g_ptr_array_index (array, 0))
    {
        g_print ("Unexpected return value for atk_relation_get_target\n");
        return FALSE;
    }
    g_object_unref (set);
    ret_value = atk_object_remove_relationship (obj, ATK_RELATION_LABEL_FOR, obj);
    if (!ret_value)
    {
        g_print ("Unexpected return value for atk_object_remove_relationship\n");
        return FALSE;
    }
    set = atk_object_ref_relation_set (obj);
    if (!set)
    {
        g_print ("Unexpected return value for atk_object_ref_relation_set\n");
        return FALSE;
    }
    n_relations = atk_relation_set_get_n_relations (set);
    if (n_relations != 0)
    {
        g_print ("Unexpected return value (%d) for atk_relation_set_get_n_relations expected value: %d\n", n_relations, 0);
        return FALSE;
    }
    g_object_unref (set);
    g_object_unref (obj);
    return TRUE;
}
static DBusMessage *
impl_GetRelationSet (DBusConnection * bus,
                     DBusMessage * message, void *user_data)
{
  AtkObject *object = (AtkObject *) user_data;
  DBusMessage *reply;
  AtkRelationSet *set;
  DBusMessageIter iter, iter_array, iter_struct, iter_targets;
  gint count;
  gint i, j;

  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
                        droute_not_yet_handled_error (message));
  reply = dbus_message_new_method_return (message);
  if (!reply)
    return NULL;
  set = atk_object_ref_relation_set (object);
  dbus_message_iter_init_append (reply, &iter);
  if (!dbus_message_iter_open_container
      (&iter, DBUS_TYPE_ARRAY, "(ua(so))", &iter_array))
    {
      goto oom;
    }
  count = 0;
  if (set)
    count = atk_relation_set_get_n_relations (set);
  for (i = 0; i < count; i++)
    {
      AtkRelation *r = atk_relation_set_get_relation (set, i);
      AtkRelationType rt;
      GPtrArray *target;
      dbus_uint32_t type;
      if (!r)
        continue;
      rt = atk_relation_get_relation_type (r);
      type = spi_relation_type_from_atk_relation_type (rt);
      target = atk_relation_get_target (r);
      if (!dbus_message_iter_open_container
          (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct))
        {
          goto oom;
        }
      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &type);
      if (!dbus_message_iter_open_container
          (&iter_struct, DBUS_TYPE_ARRAY, "(so)", &iter_targets))
        {
          goto oom;
        }
      for (j = 0; j < target->len; j++)
        {
          AtkObject *obj = target->pdata[j];
          if (!obj)
            continue;
          spi_object_append_reference (&iter_targets, obj);
        }
      dbus_message_iter_close_container (&iter_struct, &iter_targets);
      dbus_message_iter_close_container (&iter_array, &iter_struct);
    }
  dbus_message_iter_close_container (&iter, &iter_array);
oom:
  if (set)
    g_object_unref (set);
  // TODO: handle out of memory */
  return reply;
}