static void gtk_cell_accessible_object_finalize (GObject *obj) { AtkRelationSet *relation_set; AtkRelation *relation; GPtrArray *target; gpointer target_object; gint i; relation_set = atk_object_ref_relation_set (ATK_OBJECT (obj)); if (ATK_IS_RELATION_SET (relation_set)) { relation = atk_relation_set_get_relation_by_type (relation_set, ATK_RELATION_NODE_CHILD_OF); if (relation) { target = atk_relation_get_target (relation); for (i = 0; i < target->len; i++) { target_object = g_ptr_array_index (target, i); if (GTK_IS_CELL_ACCESSIBLE (target_object)) g_object_unref (target_object); } } g_object_unref (relation_set); } G_OBJECT_CLASS (_gtk_cell_accessible_parent_class)->finalize (obj); }
static G_CONST_RETURN gchar* gail_combo_box_get_keybinding (AtkAction *action, gint i) { GailComboBox *combo_box; gchar *return_value = NULL; switch (i) { case 0: { GtkWidget *widget; GtkWidget *label; AtkRelationSet *set; AtkRelation *relation; GPtrArray *target; gpointer target_object; guint key_val; combo_box = GAIL_COMBO_BOX (action); widget = GTK_ACCESSIBLE (combo_box)->widget; if (widget == NULL) return NULL; set = atk_object_ref_relation_set (ATK_OBJECT (action)); if (!set) return NULL; label = NULL; relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY); if (relation) { target = atk_relation_get_target (relation); target_object = g_ptr_array_index (target, 0); if (GTK_IS_ACCESSIBLE (target_object)) { label = GTK_ACCESSIBLE (target_object)->widget; } } g_object_unref (set); if (GTK_IS_LABEL (label)) { key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); if (key_val != GDK_VoidSymbol) return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK); } g_free (combo_box->press_keybinding); combo_box->press_keybinding = return_value; break; } default: break; } return return_value; }
static VALUE rbatkrel_get_target(VALUE self) { gint i; GPtrArray* garray = atk_relation_get_target(_SELF(self)); VALUE ary = rb_ary_new(); for (i = 0; i < garray->len; i++){ rb_ary_push(ary, GOBJ2RVAL((AtkObject*)g_ptr_array_index(garray, i))); } g_ptr_array_free(garray, TRUE); return ary; }
gboolean atk_relation_remove_target (AtkRelation *relation, AtkObject *target) { gboolean ret = FALSE; GPtrArray *array; array = atk_relation_get_target (relation); if (array && g_ptr_array_remove (array, target)) { g_object_weak_unref (G_OBJECT (target), (GWeakNotify) delete_object_while_in_relation, relation->target); ret = TRUE; } return ret; }
static const gchar * gtk_combo_box_accessible_get_keybinding (AtkAction *action, gint i) { GtkComboBoxAccessible *combo_box; GtkWidget *widget; GtkWidget *label; AtkRelationSet *set; AtkRelation *relation; GPtrArray *target; gpointer target_object; guint key_val; gchar *return_value = NULL; if (i != 0) return NULL; combo_box = GTK_COMBO_BOX_ACCESSIBLE (action); widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (combo_box)); if (widget == NULL) return NULL; set = atk_object_ref_relation_set (ATK_OBJECT (action)); if (set == NULL) return NULL; label = NULL; relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY); if (relation) { target = atk_relation_get_target (relation); target_object = g_ptr_array_index (target, 0); label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object)); } g_object_unref (set); if (GTK_IS_LABEL (label)) { key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); if (key_val != GDK_KEY_VoidSymbol) return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK); } return return_value; }
static void dump_relation (GString *string, guint depth, AtkRelation *relation) { GPtrArray *targets; const char *name; guint i; targets = atk_relation_get_target (relation); if (targets == NULL || targets->len == 0) return; name = atk_relation_type_get_name (atk_relation_get_relation_type (relation)); g_string_append_printf (string, "%*s%s: %s\n", depth, "", name, get_name (g_ptr_array_index (targets, 0))); depth += strlen (name) + 2; for (i = 1; i < targets->len; i++) { g_string_append_printf (string, "%*s%s\n", depth, "", get_name (g_ptr_array_index (targets, i))); } }
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; }
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; }
static G_CONST_RETURN gchar* gail_button_get_keybinding (AtkAction *action, gint i) { GailButton *button; gchar *return_value = NULL; button = GAIL_BUTTON (action); if (button->default_is_press) { if (i == 0) i = 1; else if (i == 1) i = 0; } switch (i) { case 0: { /* * We look for a mnemonic on the label */ GtkWidget *widget; GtkWidget *label; guint key_val; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (button)); if (widget == NULL) /* * State is defunct */ return NULL; g_return_val_if_fail (GTK_IS_BUTTON (widget), NULL); label = get_label_from_button (widget, 0, FALSE); if (GTK_IS_LABEL (label)) { key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); if (key_val != GDK_KEY_VoidSymbol) return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK); } if (return_value == NULL) { /* Find labelled-by relation */ AtkRelationSet *set; AtkRelation *relation; GPtrArray *target; gpointer target_object; set = atk_object_ref_relation_set (ATK_OBJECT (action)); if (set) { relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY); if (relation) { target = atk_relation_get_target (relation); target_object = g_ptr_array_index (target, 0); label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object)); } g_object_unref (set); } if (GTK_IS_LABEL (label)) { key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); if (key_val != GDK_KEY_VoidSymbol) return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK); } } g_free (button->click_keybinding); button->click_keybinding = return_value; break; } default: break; } return return_value; }