辅助功能在 GNOME 中如何工作
辅助工具包 (ATK) 描述了一组接口,要访问它们就需要通过 GUI 组件自行实现。这些接口是工具包无关的,意思就是你可以用任意部件集来实现,比如 GTK,Motif 或者 Qt 。
The implementation for the GTK widgets is in a module called GAIL (GNOME Accessibility Implementation Library), which is dynamically loadable at runtime by a GTK application. Once loaded, those parts of your application that use standard GTK widgets will have a basic level of accessibility, without you having to modify your application at all. If GAIL is not loaded, GTK widgets will have a default accessibility implementation that essentially returns no information, though it nominally conforms to the ATK API. Applications which use Bonobo controls, particularly out-of-process ones, also load accessibility support code from module libgail-gnome. Whether or not applications on the GNOME desktop automatically load these accessibility support libraries depends on the value of a gconf key, "/desktop/gnome/interface/accessibility"; a boolean value of "true" enables support for assistive technologies and applications which call gnome_program_init will automatically load the appropriate accessibility libraries at runtime. "Pure GTK+ applications", e.g. those that use gtk+ but do not link to libgnome, rely on the value of the GTK_MODULES environment variable, which must be set to "gail:atk-bridge" in order to enable assistive technology support.
长久以来,大部分其他桌面平台所使用的辅助技术必须为桌面应用维护一个复杂的离屏模式,这种模式基于对操作系统事件的监听,使用不受支持的操作系统、应用程序特性和 API,还有一些其他高度不可移植的技术。这就使得辅助技术支持有点 "不健壮",需要特定的操作系统和指定的应用程序,甚至还要指定的应用程序版本。相反,在 GNOME 桌面,通过 GNOME 辅助功能框架,使用服务提供者接口(SPI)独立工具包,AT(辅助技术) 需要的所有信息均可由运行的应用程序提供。SPI 为基于 UNIX 的 AT 提供一些内置服务,比如屏幕阅读器和屏幕放大镜。通过一致而稳定的 API 从运行的程序中获取辅助信息,可以在大多数情况下避免使用离屏模式。对应用程序的辅助功能支持一般通过合适的 API (比如,ATK 多用于原生C程序而Java辅助 API 用于Java 应用)内置在应用程序工具包中,然后通过相应的 "bridge" 导出成通用 "AT-SPI" 接口(见下图)。
GNOME 内置辅助功能支持意味着使用 GNOME 部件创建应用程序可以 "免费" 获得辅助技术的支持,而不用额外使用与内置支持相冲突的迂回方法。
如果一个 gtk+/GNOME 部件遵循本文档中的普遍辅助指南,实现了 ATK 接口并在用户界面上扮演合适的角色,则它是具有辅助性的。 ATK 的执行由 "stock" GNOME 部件工具集提供,而且大多数情况下,由现有 GTK+/GNOME 部件派生出来的新部件同时也会继承合适的辅助功能支持。
Though GNOME's built-in accessibility support provides significant functionality without any accessibility-specific code changes on the part of the application, applications can often improve on the default descriptions provided for some of the widgets, and tailor them to that widget's specific purpose in your application, via straightforward calls to ATK methods in the application. For instance, in most cases applications should add or change the textual descriptions for these widgets with the appropriate ATK function call, so that an assistive technology can describe their purpose or state to the user. See Coding Guidelines for Supporting Accessibility for more information.
如果你的程序使用自定义部件,可能需要做些工作让它们得以使用辅助技术。参阅 让自定义组件获得辅助功能 和 使用辅助 API 的示例 获取更多信息。
此外,关于 GTK/GTK+ 更多深入内容,请参阅 GTK+ 参考手册 , ATK 指南的 GTK 章节, GNOME 网站托管的 GTK+ 2.0 教程 和官方 GTK+ FAQ。