GTK+ and ATK - A Foundation for GNOME Accessibility

GTK+AppArchitecture.jpg

FIGURE 1.0 GTK+ Accessible Application Architecture

The GTK+ accessibility architecture depends on a number of libraries and interfaces for programming a GTK+ application, and for making the objects and interfaces accessible, translatable, and usable:

  1. TheGLib library provides portability and convenience functions, generic data structures, and the GLib main loop.

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

  3. 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.

    • Drag and drop interfaces support the Motif or Xdnd Drag and Drop protocols.

    • 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.

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

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

  6. 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."

  7. 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.

ATKObjectArchitecture.jpg

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:

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

  2. 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].

  3. 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.

Note: Externally refer to Creating accessible applications with Eclipse: An Introduction.

CKL: The SWT widget set and the Eclipse accessibility interface needs to be enhanced to support more of the ATK interfaces related to relationships, tables, images, hypertext, hyperlinks, etc.


Currently, the UNO Accessibility API for OpenOffice and StarOffice is wrapped by the Java Accessibility API and is exported through the GNOME Java Access Bridge to AT-SPI. Work is in progress by Novell to map the OpenOffice/StarOffice UNO Accessibility API directly to ATK, and to go through the ATK bridge to AT-SPI.

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.

  1. Fedora extras
  2. gnome-common
  3. libgail-gnome
  4. accerciser
  5. Orca or LSR screen reader
  6. Glade GUI builder (optional)

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

  1. 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".:
              gnome_program_init(
    
                             "dialog", "0.1",
    
                             libgnomeui_module_info_get(),
    
                                     argc, argv,
    
                             "app-datadir",
    
                                     "/usr/local/share",
    
                             NULL);
  2. Enable accessibility by doing one of the following:
    1. Run "gconftool-2 -s -t boolean /desktop/gnome/interface/accessibility true" (preferred method)
    2. Include "GNOME_ACCESSIBILITY=1" in the user profile file (deprecated)
    3. Select Desktop -> Preferences -> Accessibility -> Assistive Technology Support. Check the Enable assistive technology box.

After enabling accessibility, run an application from the command prompt and the following messages should be displayed:

Bonobo accessibility support initialized

GTK Accessibility Module initialized

ATK Accessibility Bridge initialized

Fedora extras and gnome-common

Install the gnome-common package, but first setup Fedora Extras:

su - root
rpm --import http://download.fedora.redhat.com/pub/fedora/linux/extras/RPM-GPG-KEY-Fedora-Extras
# missing step to create /etc/yum.repos.d/fedora-extras.repo
yum install gnome-common

libgail-gnome

Fedora does not provide the libgail-gnome.pc package configuration file required to build and run accerciser, so build and install it manually:

su - root
cd /usr/tmp
cvs -d:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome checkout libgail-gnome
cd libgail-gnome
./autogen.sh
make
install -m 444 libgail-gnome.pc /usr/lib/pkgconfig

accerciser

Build and install Accerciser:

su - root
cd /usr/local/src
git clone git://git.gnome.org/accerciser
cd accerciser
./autogen.sh
make
make install

Orca screen reader

In addition to installing Fedora extras and gnome-common, install pyorbit-devel.

yum install pyorbit-devel

Then build and install Orca:

su - root
cd /usr/local/src
git clone git://git.gnome.org/orca
cd orca
./autogen.sh
make
make install

Run orca once.

Glade GUI builder (optional)

Refer to the Glade CVS README for requirements and instructions about installing Glade on a system.

Accessibility/Documentation/GNOME2/AtkGuide/Gtk (last edited 2011-07-21 17:35:16 by JoanmarieDiggs)