Exemplos que usam a API de acessibilidade

Como notado anteriormente, você pode ter um pouco ou nenhum trabalho para tornar o aplicativo acessível se você usar o conjunto de widgets do GTK, ou qualquer outra biblioteca de widgets que implementa as interfaces do ATK. As duas coisas mais comuns que você pode ter que fazer neste caso são:

  • fornece descrições de alguns controles e imagem usando atk_object_set_description() ou atk_image_set_description():

    Example 1-3Configurar a descrição de acessibilidade para um botão
    {
       AtkObject *obj;
       obj = gtk_widget_get_accessible(button);
       atk_object_set_description(obj,_("Opens Preferences dialog"));
    }
    

  • Especificar relações entre quaisquer agrupamentos incomuns de widgets usando atk_relation_new() and atk_relation_set_add():

    Example 1-4Especificar relações acessíveis entre dois 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.