使用辅助功能 API 的示例
前文提过,如果使用标准 GTK 部件或者任何其他实现了 ATK 接口的部件库,你可以只做一点甚至不做任何事情就可以让你的应用程序获得辅助功能。这样的话,通常只需做两件事:
-
使用 atk_object_set_description() 或者 atk_image_set_description(): 为控件和图片提供文字说明
Example 1-3 为按钮设置辅助功能说明{ AtkObject *obj; obj = gtk_widget_get_accessible(button); atk_object_set_description(obj,_("Opens Preferences dialog")); }
-
使用 atk_relation_new() and atk_relation_set_add() 在任意特殊组合中的部件之间指定关系
Example 1-4 在两个控件之间指定辅助关系{ 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.
- 1.7.1. 收集一个应用程序的辅助信息
- 1.7.2. 查询一个 AtkObject 的接口
- 1.7.3. 建立一个 ATK 信号处理函数
- 1.7.4. 实现一个 ATK 对象