Exempel som använder tillgänglighets-API:t
Som nämnts tidigare bör det kräva liten eller ingen ansträngning för att göra ditt program tillgängligt om du använder GTK-komponentuppsättningen, eller något annat komponentbibliotek som implementerar ATK-gränssnitten. De två vanligaste sakerna som du kan behöva göra i detta fall är:
-
tillhandahålla beskrivningar av några kontroller och bilder med atk_object_set_description() eller atk_image_set_description():
Exempel 1-3 Ställa in tillgänglighetsbeskrivningen för en knapp{ AtkObject *obj; obj = gtk_widget_get_accessible(button); atk_object_set_description(obj,_("Öppnar dialogrutan Inställningar")); }
-
Ange relationer mellan ovanliga grupperingar av komponenter med atk_relation_new() och atk_relation_set_add():
Exempel 1-4 Ange en tillgänglig relation mellan två kontroller{ 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.