Ejemplos que usan la API de accesibilidad

Como se indicó anteriormente, podría tener poco o nada de trabajo para hacer su aplicación accesible si usa el conjunto de widgets de GTK, o cualquier otra biblioteca de widgets que implemente las interfaces de ATK. Las dos cosas más comunes que debe hacer en este caso son:

  • proporcione descripciones de algunos controles e imágenes usando atk_object_set_description() o atk_image_set_description():

    Ejemplo 1-3Establecer la descripción accesible para un botón
    {
       AtkObject *obj;
       obj = gtk_widget_get_accessible(button);
       atk_object_set_description(obj,_("Abre el diálogo de preferencias"));
    }
    

  • Especifique la relación entre cualquier agrupación inusual de widgets usando atk_relation_new() y atk_relation_set_add():

    Ejemplo 1-4Especificar la relación accesible entre dos controles
    {
      GtkWidget *widget;
      GtkLabel *label;
    
      AtkObject *atk_widget, *atk_label;
      AtkRelationSet *relation_set;
      AtkRelation *relation;
      AtkObject *targets[1];
    
      atk_widget = gtk_widget_get_accessible (widget);
      atk_label = gtk_widget_get_accessible (GTK_WIDGET(label));
    
      relation_set = atk_object_ref_relation_set (atk_label);
      targets[0] = atk_widget;
    
      relation = atk_relation_new(targets,1, ATK_RELATION_LABEL_FOR);
      atk_relation_set_add(relation_set,relation);
      g_object_unref(G_OBJECT(relation));
    }
    

The examples in the rest of this section are mostly to give you a flavor of the scope of the ATK. They cover techniques that you may never need to use as an application developer, although they may be of interest if you are writing your own custom widgets (see Making Custom Components Accessible) or if you want to write an assistive technology application.