The GDK library provides an abstraction layer between the GTK+ widgets in an application and the underlying X window system.

The GTK+ Object System provides a library and class hierarchy of objects (including widgets, containers, windows) with features that include inheritance, polymorphism and reference counting, signal notification, and attributes.

User-interface customization is accomplished using themes. Without recompiling either GTK+ or the application, users can choose a new look for their applications by installing a new theme. A theme can either be simply a set of colors and pixmaps used by the existing drawing code or it can be a complete replacement of the functions used to draw widgets. Themes are useful for low vision users.

The Pango engine and library provides functions for text layout and rendering, with internationalization considerations.

The ATK library provides all the accessible object classes (based on GObject) and the interfaces the accessible objects implement (based on GInterface).

ATK is an in-process accessibility API, written to by applications and implemented for GTK+ widgets by GAIL (GNOME Accessbility Implementation Library), which a GTK application dynamically loads at runtime if the value of the accessibility gconf key (/desktop/gnome/interface/accessibility) is "true."

AT-SPI is an out-of-process CORBA API implementation used by assistive technologies. The ATK bridge exports ATK to AT-SPI for GTK+ applications.

Why use GTK+ widgets?

When using the GTK+ widget set, most accessibility information is built into the widgets by GAIL except for doing the following:

Provide names and descriptions of some controls and images using atk_object_set_name and atk_object_set_description() or atk_image_set_description().

Specify relationships between labels and controls and between groups of controls using atk_relation_new() and atk_relation_set_add(). Note that GAIL does automatically create RELATION_LABELLED_BY/RELATION_LABEL_FOR labels and widgets which are attached next to one another in table layouts.

Define access key mnemonics for controls using GTK methods such as gtk_radio_button_new_with_mnemonic. For controls which have separate labels (like text boxes, combo boxes, sliders, sping buttons, etc), use GTK methods to set the mnemonic on the label (gtk_label_new_with_mnemonic) and to associate the mnemonic access key with its control (gtk_label_set_mnemonic_widget).

For commonly used functions in menus, define accelerators, or shortcut keys, using the GtkAccelLabel and GtkAccelGroup interfaces plus the methods gtk_window_add_accel_group and gtk_widget_add_accelerator.

Figure 1.1 Accessible Component Architecture for GTK+ Object

Creating accessible custom widgets

While many applications for Linux may not use GTK+ widgets, the discussion of how to make GTK+ widgets accessible using ATK interfaces and Atk#ATKIFORGTK how GAIL implements ATK for GTK+ widgets] provides us with a model for implementing ATK interfaces (methods, attributes, signals, etc) to make custom widgets in Linux GNOME applications accessible.

Since ATK uses the standard GObject and GType model, take advantage of inheritance by creating custom widgets. Implement ATK objects and interfaces for widgets either directly in a custom ATK implementation library, in the application itself, or in an external implementation library, like the GAIL library. For example, create an AtkObject subclass which can inherit from the "default" GAIL ATK implementation, override selected ATK methods, support selected ATK interfaces, and use GAIL utilities such as AtkText helpers for Pango classes. Custom widgets should fire appropriate ATK events, such as focus and property changes. To associate a widget's ATKObject subtype, override get_accessible for the GtkWidgetClass OR associate an AtkObjectFactory with the AtkRegistry. All the application ATK interface, object, and event information is exported through the ATK bridge to the AT-SPI interface for use by assistive technologies like the Orca and Gnopernicus screen readers.

To build an accessible application with the least amount of effort do the following:

Wherever possible, use GTK+ widgets to build an application, as described in Atk section 4.0 Using GTK+ and ATK to Build Accessible Applications].

If the rich class library in GTK+ does not have a desired widget, create a custom widget by subclassing the AtkObject class. Implement the Accessibility API for a widget as described in Custom section 5.0 Building Custom Accessible Widgets].

If steps 1 and 2 are not sufficient, implement the Accessibility API for a class library or widget as described in AtkApi section 6.0 The Accessibility API]

Making GNOME Applications Accessible by Marc Mulcahy and Bill Haneman from Sun provides a good overview of using ATK, GTK+, and Glade to make both standard and custom widgets accessible in an application.

A custom ATK implementation is the Mozilla ATK Implementation (MAI), which exposes its nsIAccessible and nsIAcc extensions through ATK objects and interfaces. When accessible events that need to be reported are generated in Mozilla, MAI creates the proper ATK objects and sends ATK signals for those events. When Mozilla receives accessible commands from AT-SPI through the ATK interface, MAI sends the commands to Mozilla though nsIAccessible and nsIAcc extensions.

Eclipse developers use SWT widget accessibility interfaces (org.eclipse.swt.accessibility) to enable custom SWT widgets. Eclipse then exposes both standard and custom accessible SWT widgets as accessible GTK+ widgets by implementing ATK objects and interfaces for the SWT widgets. Especially look at chapters 4, 9, and 13 to understand SWT accessibility interfaces, how they relate to ATK objects, and how to enable accessibility for custom SWT widgets.

Setting up the accessible application development and test environment

To set up an environment for developing and testing accessible GTK+ applications on Fedora Core 6, download and install the following packages.

Fedora extras

gnome-common

libgail-gnome

accerciser

Orca or LSR screen reader

Glade GUI builder (optional)

Accessibility in GNOME is disabled by default. Before running any accessibility tools or accessible applications:

Set the value of the GTK_MODULES environment variable to "gail:atk-bridge". GTK_MODULES cause libgail.so and libatk-bridge.so to be loaded. (Note: For GNOME applications, this step is not necessary but for GTK+ applications, it is. Add the following code to the beginning of applications to setup the accessibility environment. Also, add the following to the compile linker line "-lgnome-2 -lgnomeui-2".: