Integrate gail into gtk+. Bug #169488.

* configure.in:
	* docs/reference/Makefile.am:
	* docs/reference/libgail-util/*:
	* gail-uninstalled.pc.in:
	* gail.pc.in:
	* modules/Makefile.am:
	* modules/other/Makefile.am:
	* modules/other/gail/*:
	* modules/other/gail/libgail-util/*:
	* po/POTFILES.skip: Integrate gail into gtk+. Bug #169488.

svn path=/trunk/; revision=19196
This commit is contained in:
Christian Persch 2007-12-18 13:51:12 +00:00
parent f8a1be3a04
commit a8e6ee33b1
153 changed files with 39655 additions and 8 deletions

View File

@ -1,3 +1,16 @@
2007-12-18 Christian Persch <chpe@gnome.org>
* configure.in:
* docs/reference/Makefile.am:
* docs/reference/libgail-util/*:
* gail-uninstalled.pc.in:
* gail.pc.in:
* modules/Makefile.am:
* modules/other/Makefile.am:
* modules/other/gail/*:
* modules/other/gail/libgail-util/*:
* po/POTFILES.skip: Integrate gail into gtk+. Bug #169488.
2007-12-17 Matthias Clasen <mclasen@redhat.com>
* gtk/gtksettings.c: Add a gtk-im-module GTK setting

View File

@ -33,7 +33,7 @@ m4_define([gtk_binary_version], [2.10.0])
# required versions of other packages
m4_define([glib_required_version], [2.15.0])
m4_define([pango_required_version], [1.17.3])
m4_define([atk_required_version], [1.9.0])
m4_define([atk_required_version], [1.13.0])
m4_define([cairo_required_version], [1.2.0])
@ -1559,6 +1559,36 @@ AC_SUBST(CAIRO_PREFIX)
AC_SUBST(GTK_DEBUG_FLAGS)
AC_SUBST(GTK_XIM_FLAGS)
########################
# Checks needed for gail
########################
old_LIBS="$LIBS"
dnl Checks for inet libraries:
AC_SEARCH_LIBS(gethostent, nsl)
AC_SEARCH_LIBS(setsockopt, socket)
AC_SEARCH_LIBS(connect, inet)
dnl check for the sockaddr_un.sun_len member
AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
[struct_sockaddr_un_sun_len=true],
[struct_sockaddr_un_suin_len=false],
[#include <sys/types.h>
#include <sys/un.h>]
)
case $struct_sockaddr_un_sun_len in
true)
AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_UN_SUN_LEN, 1, Have the sockaddr_un.sun_len member.)
;;
*)
;;
esac
GAIL_INET_LIBS="$LIBS"
AC_SUBST([GAIL_INET_LIBS])
LIBS="$old_LIBS"
################################################################
# Printing system checks
################################################################
@ -1760,9 +1790,11 @@ gdk-pixbuf-2.0.pc
gdk-2.0.pc
gtk+-2.0.pc
gtk+-unix-print-2.0.pc
gail.pc
gdk-pixbuf-2.0-uninstalled.pc
gdk-2.0-uninstalled.pc
gtk+-2.0-uninstalled.pc
gail-uninstalled.pc
m4macros/Makefile
po/Makefile.in
po-properties/Makefile.in
@ -1778,6 +1810,7 @@ docs/reference/gdk/Makefile
docs/reference/gdk/version.xml
docs/reference/gtk/Makefile
docs/reference/gtk/version.xml
docs/reference/libgail-util/Makefile
docs/faq/Makefile
docs/tools/Makefile
docs/tutorial/Makefile
@ -1800,12 +1833,15 @@ gtk/theme-bits/Makefile
gtk/tests/Makefile
gtk/xdgmime/Makefile
modules/Makefile
modules/input/Makefile
modules/other/Makefile
modules/other/gail/Makefile
modules/other/gail/libgail-util/Makefile
modules/engines/Makefile
modules/engines/pixbuf/Makefile
modules/engines/ms-windows/Makefile
modules/engines/ms-windows/Theme/Makefile
modules/engines/ms-windows/Theme/gtk-2.0/Makefile
modules/input/Makefile
modules/printbackends/Makefile
modules/printbackends/cups/Makefile
modules/printbackends/lpr/Makefile

View File

@ -1,5 +1,5 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
SUBDIRS = gdk-pixbuf gdk gtk
SUBDIRS = gdk-pixbuf gdk gtk libgail-util

View File

@ -0,0 +1,33 @@
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = 1.7
# The name of the module.
DOC_MODULE=gail-libgail-util
# The top-level SGML file.
DOC_MAIN_SGML_FILE=gail-libgail-util-docs.sgml
# The directory containing the source code (if it contains documentation).
DOC_SOURCE_DIR=../../../modules/other/gail/libgail-util
# Used for dependencies
HFILE_GLOB = $(top_srcdir)/modules/other/gail/libgail-util/*.h
CFILE_GLOB = $(top_srcdir)/modules/other/gail/libgail-util/*.c
# CFLAGS and LDFLAGS for compiling scan program. Only needed
# if $(DOC_MODULE).types is non-empty.
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(DEP_CFLAGS)
GTKDOC_LIBS = $(top_builddir)/modules/other/gail/libgail-util/libgailutil.la
# gtkdoc-mkdb related varaibles
MKDB_OPTIONS =
content_files =
HTML_IMAGES =
include $(top_srcdir)/gtk-doc.make

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY gail-libgail-util-gailtextutil SYSTEM "xml/gailtextutil.xml">
<!ENTITY gail-libgail-util-gailmisc SYSTEM "xml/gailmisc.xml">
]>
<book>
<bookinfo>
<title>GAIL Reference Manual</title>
</bookinfo>
<chapter id="libgail-util-main">
<title>GAIL libgail-util Library</title>
&gail-libgail-util-gailtextutil;
&gail-libgail-util-gailmisc;
</chapter>
</book>

View File

@ -0,0 +1,34 @@
<SECTION>
<FILE>gailtextutil</FILE>
<TITLE>GailTextUtil</TITLE>
GailTextUtil
GailOffsetType
gail_text_util_new
gail_text_util_text_setup
gail_text_util_buffer_setup
gail_text_util_get_text
gail_text_util_get_substring
<SUBSECTION Standard>
GailTextUtilClass
GAIL_TEXT_UTIL
GAIL_IS_TEXT_UTIL
GAIL_TYPE_TEXT_UTIL
GAIL_TEXT_UTIL_CLASS
GAIL_IS_TEXT_UTIL_CLASS
GAIL_TEXT_UTIL_GET_CLASS
<SUBSECTION Private>
gail_text_util_get_type
</SECTION>
<SECTION>
<FILE>gailmisc</FILE>
<TITLE>GailMisc</TITLE>
gail_misc_add_attribute
gail_misc_layout_get_run_attributes
gail_misc_get_default_attributes
gail_misc_get_extents_from_pango_rectangle
gail_misc_get_index_at_point_in_layout
gail_misc_get_origins
gail_misc_add_to_attr_set
gail_misc_buffer_get_run_attributes
</SECTION>

View File

@ -0,0 +1,122 @@
<!-- ##### SECTION Title ##### -->
GailMisc
<!-- ##### SECTION Short_Description ##### -->
GailMisc is a set of utility functions which may be useful to implementors of
Atk interfaces for custom widgets.
<!-- ##### SECTION Long_Description ##### -->
<para>
GailMisc is a set of utility function which are used in the implemementation
of Atk interfaces for Gtk widgets. They may be useful to implementors of
Atk interfaces for custom widgets.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### FUNCTION gail_misc_add_attribute ##### -->
<para>
</para>
@attrib_set:
@attr:
@value:
@Returns:
<!-- ##### FUNCTION gail_misc_layout_get_run_attributes ##### -->
<para>
</para>
@attrib_set:
@layout:
@text:
@offset:
@start_offset:
@end_offset:
@Returns:
<!-- ##### FUNCTION gail_misc_get_default_attributes ##### -->
<para>
</para>
@attrib_set:
@layout:
@widget:
@Returns:
<!-- ##### FUNCTION gail_misc_get_extents_from_pango_rectangle ##### -->
<para>
</para>
@widget:
@char_rect:
@x_layout:
@y_layout:
@x:
@y:
@width:
@height:
@coords:
<!-- ##### FUNCTION gail_misc_get_index_at_point_in_layout ##### -->
<para>
</para>
@widget:
@layout:
@x_layout:
@y_layout:
@x:
@y:
@coords:
@Returns:
<!-- ##### FUNCTION gail_misc_get_origins ##### -->
<para>
</para>
@widget:
@x_window:
@y_window:
@x_toplevel:
@y_toplevel:
<!-- ##### FUNCTION gail_misc_add_to_attr_set ##### -->
<para>
</para>
@attrib_set:
@attrs:
@attr:
@Returns:
<!-- ##### FUNCTION gail_misc_buffer_get_run_attributes ##### -->
<para>
</para>
@buffer:
@offset:
@start_offset:
@end_offset:
@Returns:

View File

@ -0,0 +1,92 @@
<!-- ##### SECTION Title ##### -->
GailTextUtil
<!-- ##### SECTION Short_Description ##### -->
GailTextUtil is a utility class which can be used to implement some of
the AtkText functions for accessible objects which implement AtkText.
<!-- ##### SECTION Long_Description ##### -->
<para>
GailTextUtil is a utility class which can be used to implement the
AtkText functions which get text for accessible objects which implement
AtkText.
In GAIL it is used by the accsesible objects for GnomeCanvasText, GtkEntry,
GtkLabel, GtkCellRendererText and GtkTextview.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GailTextUtil ##### -->
<para>
The GailTextCell structure should not be accessed directly.
</para>
@parent:
@buffer:
<!-- ##### ENUM GailOffsetType ##### -->
<para>
</para>
@GAIL_BEFORE_OFFSET:
@GAIL_AT_OFFSET:
@GAIL_AFTER_OFFSET:
<!-- ##### FUNCTION gail_text_util_new ##### -->
<para>
</para>
@Returns:
<!-- ##### FUNCTION gail_text_util_text_setup ##### -->
<para>
</para>
@textutil:
@text:
<!-- ##### FUNCTION gail_text_util_buffer_setup ##### -->
<para>
</para>
@textutil:
@buffer:
<!-- ##### FUNCTION gail_text_util_get_text ##### -->
<para>
</para>
@textutil:
@layout:
@function:
@boundary_type:
@offset:
@start_offset:
@end_offset:
@Returns:
<!-- ##### FUNCTION gail_text_util_get_substring ##### -->
<para>
</para>
@textutil:
@start_pos:
@end_pos:
@Returns:

11
gail-uninstalled.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Gail
Description: GNOME Accessibility Implementation Library
Version: @VERSION@
Requires: atk gtk+-2.0
Libs: ${pc_top_builddir}/${pcfiledir}/gail/libgail.la
Cflags: -I${pc_top_builddir}/${pcfiledir}

11
gail.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Gail
Description: GNOME Accessibility Implementation Library
Version: @VERSION@
Requires: atk gtk+-2.0
Libs: -L${libdir} -lgailutil
Cflags: -I${includedir}/gail-1.0

View File

@ -1,8 +1,7 @@
include $(top_srcdir)/Makefile.decl
if OS_UNIX
PRINTBACKENDS_SUBDIR=printbackends
endif
SUBDIRS = input engines other
SUBDIRS=input engines $(PRINTBACKENDS_SUBDIR)
DIST_SUBDIRS=input engines printbackends
if OS_UNIX
SUBDIRS += printbackends
endif

View File

@ -0,0 +1 @@
SUBDIRS = gail

View File

@ -0,0 +1,173 @@
include $(top_srcdir)/Makefile.decl
SUBDIRS = libgail-util
if OS_WIN32
no_undefined = -no-undefined
endif
moduledir = $(libdir)/gtk-2.0/$(GTK_BINARY_VERSION)/other
module_LTLIBRARIES = libgail.la
gail_c_sources = \
gail-private-macros.h \
gail.c \
gailadjustment.c \
gailarrow.c \
gailbooleancell.c \
gailbooleancellfactory.c \
gailbox.c \
gailbutton.c \
gailcalendar.c \
gailcell.c \
gailcellparent.c \
gailcheckmenuitem.c \
gailchecksubmenuitem.c \
gailclist.c \
gailclistcell.c \
gailcombo.c \
gailcombobox.c \
gailcontainer.c \
gailcontainercell.c \
gailentry.c \
gailexpander.c \
gailframe.c \
gailimage.c \
gailimagecell.c \
gailimagecellfactory.c \
gailitem.c \
gaillabel.c \
gaillist.c \
gailmenu.c \
gailmenushell.c \
gailmenuitem.c \
gailnotebook.c \
gailnotebookpage.c \
gailobject.c \
gailobjectfactory.c \
gailoptionmenu.c \
gailpaned.c \
gailpixmap.c \
gailprogressbar.c \
gailradiobutton.c \
gailradiomenuitem.c \
gailradiosubmenuitem.c \
gailrange.c \
gailrenderercell.c \
gailrenderercellfactory.c \
gailscale.c \
gailscrollbar.c \
gailscrolledwindow.c \
gailseparator.c \
gailspinbutton.c \
gailsubmenuitem.c \
gailstatusbar.c \
gailtextcell.c \
gailtextcellfactory.c \
gailtextview.c \
gailtogglebutton.c \
gailtoplevel.c \
gailtreeview.c \
gailutil.c \
gailwidget.c \
gailwindow.c
libgailincludedir=$(includedir)/gail-1.0/gail
gail_private_h_sources = \
gail.h \
gailadjustment.h \
gailarrow.h \
gailbooleancell.h \
gailbooleancellfactory.h \
gailbox.h \
gailbutton.h \
gailcalendar.h \
gailcell.h \
gailcellparent.h \
gailcheckmenuitem.h \
gailchecksubmenuitem.h \
gailclist.h \
gailclistcell.h \
gailcombo.h \
gailcombobox.h \
gailcontainercell.h \
gailcontainer.h \
gailentry.h \
gailexpander.h \
gailfactory.h \
gailframe.h \
gailimage.h \
gailimagecell.h \
gailimagecellfactory.h \
gailintl.h \
gailitem.h \
gaillabel.h \
gaillist.h \
gailmenu.h \
gailmenushell.h \
gailmenuitem.h \
gailnotebook.h \
gailnotebookpage.h \
gailobject.h \
gailobjectfactory.h \
gailoptionmenu.h \
gailpaned.h \
gailpixmap.h \
gailprogressbar.h \
gailradiobutton.h \
gailradiomenuitem.h \
gailradiosubmenuitem.h \
gailrange.h \
gailrenderercell.h \
gailrenderercellfactory.h \
gailscale.h \
gailscrollbar.h \
gailscrolledwindow.h \
gailseparator.h \
gailspinbutton.h \
gailsubmenuitem.h \
gailstatusbar.h \
gailtextcell.h \
gailtextcellfactory.h \
gailtextview.h \
gailtogglebutton.h \
gailtoplevel.h \
gailtreeview.h \
gailutil.h \
gailwindow.h
gail_public_h_sources = \
gailwidget.h
libgail_la_SOURCES = \
$(gail_c_sources) \
$(gail_public_h_sources) \
$(gail_private_h_sources)
libgailinclude_HEADERS = \
$(gail_public_h_sources)
libgail_la_CPPFLAGS = \
-I$(top_srcdir)/modules/other \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
-I$(top_srcdir)/gtk \
-I$(top_builddir)/gtk \
-DGTK_VERSION=\"$(GTK_VERSION)\" \
$(AM_CPPFLAGS)
libgail_la_CFLAGS = \
$(GTK_DEP_CFLAGS) \
$(GTK_DEBUG_FLAGS) \
$(AM_CFLAGS)
libgail_la_LIBADD = \
$(GTK_DEP_LIBS) \
$(INTLLIBS)
libgail_la_LDFLAGS = \
$(top_builddir)/modules/other/gail/libgail-util/libgailutil.la \
-rpath $(moduledir) -module -avoid-version \
$(no_undefined) \
$(LDFLAGS)

View File

@ -0,0 +1,38 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_PRIVATE_MACROS_H__
#define __GAIL_PRIVATE_MACROS_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Note: these macros are logic macros, not intended to warn on failure. */
#define gail_return_val_if_fail(a, b) if (!(a)) return (b)
#define gail_return_if_fail(a) if (!(a)) return
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_PRIVATE_MACROS_H__ */

982
modules/other/gail/gail.c Normal file
View File

@ -0,0 +1,982 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <atk/atk.h>
#include <gtk/gtk.h>
#include "gail.h"
#include "gailfactory.h"
#define GNOME_ACCESSIBILITY_ENV "GNOME_ACCESSIBILITY"
static gboolean gail_focus_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data);
static gboolean gail_select_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data);
static gboolean gail_deselect_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data);
static gboolean gail_switch_page_watcher(GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data);
static AtkObject* gail_get_accessible_for_widget (GtkWidget *widget,
gboolean *transient);
static void gail_finish_select (GtkWidget *widget);
static void gail_map_cb (GtkWidget *widget);
static void gail_map_submenu_cb (GtkWidget *widget);
static gint gail_focus_idle_handler (gpointer data);
static void gail_focus_notify (GtkWidget *widget);
static void gail_focus_notify_when_idle (GtkWidget *widget);
static void gail_focus_tracker_init (void);
static void gail_focus_object_destroyed (gpointer data);
static void gail_focus_tracker (AtkObject *object);
static void gail_set_focus_widget (GtkWidget *focus_widget,
GtkWidget *widget);
static void gail_set_focus_object (AtkObject *focus_obj,
AtkObject *obj);
GtkWidget* focus_widget = NULL;
static GtkWidget* next_focus_widget = NULL;
static gboolean was_deselect = FALSE;
static GtkWidget* subsequent_focus_widget = NULL;
static GtkWidget* focus_before_menu = NULL;
static guint focus_notify_handler = 0;
static guint focus_tracker_id = 0;
static GQuark quark_focus_object = 0;
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_WIDGET, gail_widget, gail_widget_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_CONTAINER, gail_container, gail_container_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_BUTTON, gail_button, gail_button_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_ITEM, gail_item, gail_item_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_MENU_ITEM, gail_menu_item, gail_menu_item_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_TOGGLE_BUTTON, gail_toggle_button, gail_toggle_button_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_IMAGE, gail_image, gail_image_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_TEXT_VIEW, gail_text_view, gail_text_view_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_COMBO, gail_combo, gail_combo_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_COMBO_BOX, gail_combo_box, gail_combo_box_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_ENTRY, gail_entry, gail_entry_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_MENU_SHELL, gail_menu_shell, gail_menu_shell_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_MENU, gail_menu, gail_menu_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_WINDOW, gail_window, gail_window_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_RANGE, gail_range, gail_range_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_SCALE, gail_scale, gail_scale_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_CLIST, gail_clist, gail_clist_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_LABEL, gail_label, gail_label_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_STATUSBAR, gail_statusbar, gail_statusbar_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_NOTEBOOK, gail_notebook, gail_notebook_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_CALENDAR, gail_calendar, gail_calendar_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_PROGRESS_BAR, gail_progress_bar, gail_progress_bar_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_SPIN_BUTTON, gail_spin_button, gail_spin_button_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_TREE_VIEW, gail_tree_view, gail_tree_view_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_FRAME, gail_frame, gail_frame_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_RADIO_BUTTON, gail_radio_button, gail_radio_button_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_ARROW, gail_arrow, gail_arrow_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_PIXMAP, gail_pixmap, gail_pixmap_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_SEPARATOR, gail_separator, gail_separator_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_BOX, gail_box, gail_box_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, gail_scrolled_window, gail_scrolled_window_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_LIST, gail_list, gail_list_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_PANED, gail_paned, gail_paned_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_SCROLLBAR, gail_scrollbar, gail_scrollbar_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_OPTION_MENU, gail_option_menu, gail_option_menu_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_CHECK_MENU_ITEM, gail_check_menu_item, gail_check_menu_item_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_RADIO_MENU_ITEM, gail_radio_menu_item, gail_radio_menu_item_new)
GAIL_ACCESSIBLE_FACTORY (GAIL_TYPE_EXPANDER, gail_expander, gail_expander_new)
static AtkObject*
gail_get_accessible_for_widget (GtkWidget *widget,
gboolean *transient)
{
AtkObject *obj = NULL;
GType gnome_canvas;
gnome_canvas = g_type_from_name ("GnomeCanvas");
*transient = FALSE;
if (!widget)
return NULL;
if (GTK_IS_ENTRY (widget))
{
GtkWidget *other_widget = widget->parent;
if (GTK_IS_COMBO (other_widget))
{
gail_set_focus_widget (other_widget, widget);
widget = other_widget;
}
}
else if (GTK_IS_NOTEBOOK (widget))
{
GtkNotebook *notebook;
gint page_num = -1;
notebook = GTK_NOTEBOOK (widget);
/*
* Report the currently focused tab rather than the currently selected tab
*/
if (notebook->focus_tab)
{
page_num = g_list_index (notebook->children, notebook->focus_tab->data);
}
if (page_num != -1)
{
obj = gtk_widget_get_accessible (widget);
obj = atk_object_ref_accessible_child (obj, page_num);
g_object_unref (obj);
}
}
else if (GTK_CHECK_TYPE ((widget), gnome_canvas))
{
GObject *focused_item;
GValue value = {0, };
g_value_init (&value, G_TYPE_OBJECT);
g_object_get_property (G_OBJECT (widget), "focused_item", &value);
focused_item = g_value_get_object (&value);
if (focused_item)
{
AtkObject *tmp;
obj = atk_gobject_accessible_for_object (G_OBJECT (focused_item));
tmp = g_object_get_qdata (G_OBJECT (obj), quark_focus_object);
if (tmp != NULL)
obj = tmp;
}
}
else if (GTK_IS_TOGGLE_BUTTON (widget))
{
GtkWidget *other_widget = widget->parent;
if (GTK_IS_COMBO_BOX (other_widget))
{
gail_set_focus_widget (other_widget, widget);
widget = other_widget;
}
}
if (obj == NULL)
{
AtkObject *focus_object;
obj = gtk_widget_get_accessible (widget);
focus_object = g_object_get_qdata (G_OBJECT (obj), quark_focus_object);
/*
* We check whether the object for this focus_object has been deleted.
* This can happen when navigating to an empty directory in nautilus.
* See bug #141907.
*/
if (ATK_IS_GOBJECT_ACCESSIBLE (focus_object))
{
if (!atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (focus_object)))
focus_object = NULL;
}
if (focus_object)
obj = focus_object;
}
return obj;
}
static gboolean
gail_focus_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
GtkWidget *widget;
GdkEvent *event;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
event = g_value_get_boxed (param_values + 1);
widget = GTK_WIDGET (object);
if (event->type == GDK_FOCUS_CHANGE)
{
if (event->focus_change.in)
{
if (GTK_IS_WINDOW (widget))
{
GtkWindow *window;
window = GTK_WINDOW (widget);
if (window->focus_widget)
{
/*
* If we already have a potential focus widget set this
* windows's focus widget to focus_before_menu so that
* it will be reported when menu item is unset.
*/
if (next_focus_widget)
{
if (GTK_IS_MENU_ITEM (next_focus_widget) &&
!focus_before_menu)
{
void *vp_focus_before_menu = &focus_before_menu;
focus_before_menu = window->focus_widget;
g_object_add_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu);
}
return TRUE;
}
widget = window->focus_widget;
}
else if (window->type == GTK_WINDOW_POPUP)
{
if (GTK_IS_BIN (widget))
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
if (GTK_IS_WIDGET (child) && GTK_WIDGET_HAS_GRAB (child))
{
if (GTK_IS_MENU_SHELL (child))
{
if (GTK_MENU_SHELL (child)->active_menu_item)
{
/*
* We have a menu which has a menu item selected
* so we do not report focus on the menu.
*/
return TRUE;
}
}
widget = child;
}
}
else /* popup window has no children; this edge case occurs in some custom code (OOo for instance) */
{
return TRUE;
}
}
else /* Widget is a non-popup toplevel with no focus children;
don't emit for this case either, as it's useless */
{
return TRUE;
}
}
}
else
{
if (next_focus_widget)
{
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (next_focus_widget);
if (toplevel == widget)
next_focus_widget = NULL;
}
/* focus out */
widget = NULL;
}
}
else
{
if (event->type == GDK_MOTION_NOTIFY && GTK_WIDGET_HAS_FOCUS (widget))
{
if (widget == focus_widget)
{
return TRUE;
}
}
else
{
return TRUE;
}
}
/*
* If the focus widget is a GtkSocket without a plug
* then ignore the focus notification as the embedded
* plug will report a focus notification.
*/
if (GTK_IS_SOCKET (widget) &&
GTK_SOCKET (widget)->plug_widget == NULL)
return TRUE;
/*
* The widget may not yet be visible on the screen so we wait until it is.
*/
gail_focus_notify_when_idle (widget);
return TRUE;
}
static gboolean
gail_select_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
GtkWidget *widget;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
widget = GTK_WIDGET (object);
if (!GTK_WIDGET_MAPPED (widget))
{
g_signal_connect (widget, "map",
G_CALLBACK (gail_map_cb),
NULL);
}
else
gail_finish_select (widget);
return TRUE;
}
static void
gail_finish_select (GtkWidget *widget)
{
if (GTK_IS_MENU_ITEM (widget))
{
GtkMenuItem* menu_item;
menu_item = GTK_MENU_ITEM (widget);
if (menu_item->submenu &&
!GTK_WIDGET_MAPPED (menu_item->submenu))
{
/*
* If the submenu is not visble, wait until it is before
* reporting focus on the menu item.
*/
gulong handler_id;
handler_id = g_signal_handler_find (menu_item->submenu,
G_SIGNAL_MATCH_FUNC,
g_signal_lookup ("map",
GTK_TYPE_WINDOW),
0,
NULL,
(gpointer) gail_map_submenu_cb,
NULL);
if (!handler_id)
g_signal_connect (menu_item->submenu, "map",
G_CALLBACK (gail_map_submenu_cb),
NULL);
return;
}
/*
* If we are waiting to report focus on a menubar or a menu item
* because of a previous deselect, cancel it.
*/
if (was_deselect &&
focus_notify_handler &&
next_focus_widget &&
(GTK_IS_MENU_BAR (next_focus_widget) ||
GTK_IS_MENU_ITEM (next_focus_widget)))
{
void *vp_next_focus_widget = &next_focus_widget;
g_source_remove (focus_notify_handler);
g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
next_focus_widget = NULL;
focus_notify_handler = 0;
was_deselect = FALSE;
}
}
/*
* If previously focused widget is not a GtkMenuItem or a GtkMenu,
* keep track of it so we can return to it after menubar is deactivated
*/
if (focus_widget &&
!GTK_IS_MENU_ITEM (focus_widget) &&
!GTK_IS_MENU (focus_widget))
{
void *vp_focus_before_menu = &focus_before_menu;
focus_before_menu = focus_widget;
g_object_add_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu);
}
gail_focus_notify_when_idle (widget);
return;
}
static void
gail_map_cb (GtkWidget *widget)
{
gail_finish_select (widget);
}
static void
gail_map_submenu_cb (GtkWidget *widget)
{
if (GTK_IS_MENU (widget))
{
if (GTK_MENU (widget)->parent_menu_item)
gail_finish_select (GTK_MENU (widget)->parent_menu_item);
}
}
static gboolean
gail_deselect_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
GtkWidget *widget;
GtkWidget *menu_shell;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
widget = GTK_WIDGET (object);
if (!GTK_IS_MENU_ITEM (widget))
return TRUE;
if (subsequent_focus_widget == widget)
subsequent_focus_widget = NULL;
menu_shell = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_SHELL (menu_shell))
{
GtkWidget *parent_menu_shell;
parent_menu_shell = GTK_MENU_SHELL (menu_shell)->parent_menu_shell;
if (parent_menu_shell)
{
GtkWidget *active_menu_item;
active_menu_item = GTK_MENU_SHELL (parent_menu_shell)->active_menu_item;
if (active_menu_item)
{
gail_focus_notify_when_idle (active_menu_item);
}
}
else
{
if (!GTK_IS_MENU_BAR (menu_shell))
{
gail_focus_notify_when_idle (menu_shell);
}
}
}
was_deselect = TRUE;
return TRUE;
}
static gboolean
gail_switch_page_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
GtkWidget *widget;
GtkNotebook *notebook;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
widget = GTK_WIDGET (object);
if (!GTK_IS_NOTEBOOK (widget))
return TRUE;
notebook = GTK_NOTEBOOK (widget);
if (!notebook->focus_tab)
return TRUE;
gail_focus_notify_when_idle (widget);
return TRUE;
}
static gint
gail_focus_idle_handler (gpointer data)
{
GDK_THREADS_ENTER();
focus_notify_handler = 0;
/*
* The widget which was to receive focus may have been removed
*/
if (!next_focus_widget)
{
if (next_focus_widget != data)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
}
else
{
void *vp_next_focus_widget = &next_focus_widget;
g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
next_focus_widget = NULL;
}
gail_focus_notify (data);
GDK_THREADS_LEAVE ();
return FALSE;
}
static void
gail_focus_notify (GtkWidget *widget)
{
AtkObject *atk_obj;
gboolean transient;
if (widget != focus_widget)
{
if (focus_widget)
{
void *vp_focus_widget = &focus_widget;
g_object_remove_weak_pointer (G_OBJECT (focus_widget), vp_focus_widget);
}
focus_widget = widget;
if (focus_widget)
{
void *vp_focus_widget = &focus_widget;
g_object_add_weak_pointer (G_OBJECT (focus_widget), vp_focus_widget);
/*
* The UI may not have been updated yet; e.g. in gtkhtml2
* html_view_layout() is called in a idle handler
*/
if (focus_widget == focus_before_menu)
{
void *vp_focus_before_menu = &focus_before_menu;
g_object_remove_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu);
focus_before_menu = NULL;
}
}
gail_focus_notify_when_idle (focus_widget);
}
else
{
if (focus_widget)
atk_obj = gail_get_accessible_for_widget (focus_widget, &transient);
else
atk_obj = NULL;
/*
* Do not report focus on redundant object
*/
if (atk_obj &&
(atk_object_get_role(atk_obj) != ATK_ROLE_REDUNDANT_OBJECT))
atk_focus_tracker_notify (atk_obj);
if (atk_obj && transient)
g_object_unref (atk_obj);
if (subsequent_focus_widget)
{
GtkWidget *tmp_widget = subsequent_focus_widget;
subsequent_focus_widget = NULL;
gail_focus_notify_when_idle (tmp_widget);
}
}
}
static void
gail_focus_notify_when_idle (GtkWidget *widget)
{
if (focus_notify_handler)
{
if (widget)
{
/*
* Ignore focus request when menu item is going to be focused.
* See bug #124232.
*/
if (GTK_IS_MENU_ITEM (next_focus_widget) && !GTK_IS_MENU_ITEM (widget))
return;
if (next_focus_widget)
{
if (GTK_IS_MENU_ITEM (next_focus_widget) && GTK_IS_MENU_ITEM (widget))
{
if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (next_focus_widget)) == gtk_widget_get_parent (widget))
{
if (subsequent_focus_widget)
g_assert_not_reached ();
subsequent_focus_widget = widget;
return;
}
}
}
g_source_remove (focus_notify_handler);
if (next_focus_widget)
{
void *vp_next_focus_widget = &next_focus_widget;
g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
next_focus_widget = NULL;
}
}
else
/*
* Ignore if focus is being set to NULL and we are waiting to set focus
*/
return;
}
if (widget)
{
void *vp_next_focus_widget = &next_focus_widget;
next_focus_widget = widget;
g_object_add_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
}
else
{
/*
* We are about to report focus as NULL so remove the weak pointer
* for the widget we were waiting to report focus on.
*/
if (next_focus_widget)
{
void *vp_next_focus_widget = &next_focus_widget;
g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
next_focus_widget = NULL;
}
}
focus_notify_handler = g_idle_add (gail_focus_idle_handler, widget);
}
static gboolean
gail_deactivate_watcher (GSignalInvocationHint *ihint,
guint n_param_values,
const GValue *param_values,
gpointer data)
{
GObject *object;
GtkWidget *widget;
GtkMenuShell *shell;
GtkWidget *focus = NULL;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
widget = GTK_WIDGET (object);
g_return_val_if_fail (GTK_IS_MENU_SHELL(widget), TRUE);
shell = GTK_MENU_SHELL(widget);
if (!shell->parent_menu_shell)
focus = focus_before_menu;
/*
* If we are waiting to report focus on a menubar or a menu item
* because of a previous deselect, cancel it.
*/
if (was_deselect &&
focus_notify_handler &&
next_focus_widget &&
(GTK_IS_MENU_BAR (next_focus_widget) ||
GTK_IS_MENU_ITEM (next_focus_widget)))
{
void *vp_next_focus_widget = &next_focus_widget;
g_source_remove (focus_notify_handler);
g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
next_focus_widget = NULL;
focus_notify_handler = 0;
was_deselect = FALSE;
}
gail_focus_notify_when_idle (focus);
return TRUE;
}
static void
gail_focus_tracker_init (void)
{
static gboolean emission_hooks_added = FALSE;
if (!emission_hooks_added)
{
/*
* We cannot be sure that the classes exist so we make sure that they do.
*/
gtk_type_class (GTK_TYPE_WIDGET);
gtk_type_class (GTK_TYPE_ITEM);
gtk_type_class (GTK_TYPE_MENU_SHELL);
gtk_type_class (GTK_TYPE_NOTEBOOK);
/*
* We listen for event_after signal and then check that the
* event was a focus in event so we get called after the event.
*/
g_signal_add_emission_hook (
g_signal_lookup ("event-after", GTK_TYPE_WIDGET), 0,
gail_focus_watcher, NULL, (GDestroyNotify) NULL);
/*
* A "select" signal is emitted when arrow key is used to
* move to a list item in the popup window of a GtkCombo or
* a menu item in a menu.
*/
g_signal_add_emission_hook (
g_signal_lookup ("select", GTK_TYPE_ITEM), 0,
gail_select_watcher, NULL, (GDestroyNotify) NULL);
/*
* A "deselect" signal is emitted when arrow key is used to
* move from a menu item in a menu to the parent menu.
*/
g_signal_add_emission_hook (
g_signal_lookup ("deselect", GTK_TYPE_ITEM), 0,
gail_deselect_watcher, NULL, (GDestroyNotify) NULL);
/*
* We listen for deactivate signals on menushells to determine
* when the "focus" has left the menus.
*/
g_signal_add_emission_hook (
g_signal_lookup ("deactivate", GTK_TYPE_MENU_SHELL), 0,
gail_deactivate_watcher, NULL, (GDestroyNotify) NULL);
/*
* We listen for "switch-page" signal on a GtkNotebook to notify
* when page has changed because of clicking on a notebook tab.
*/
g_signal_add_emission_hook (
g_signal_lookup ("switch-page", GTK_TYPE_NOTEBOOK), 0,
gail_switch_page_watcher, NULL, (GDestroyNotify) NULL);
emission_hooks_added = TRUE;
}
}
static void
gail_focus_object_destroyed (gpointer data)
{
GObject *obj;
obj = G_OBJECT (data);
g_object_set_qdata (obj, quark_focus_object, NULL);
g_object_unref (obj);
}
static void
gail_focus_tracker (AtkObject *focus_object)
{
/*
* Do not report focus on redundant object
*/
if (focus_object &&
(atk_object_get_role(focus_object) != ATK_ROLE_REDUNDANT_OBJECT))
{
AtkObject *old_focus_object;
if (!GTK_IS_ACCESSIBLE (focus_object))
{
AtkObject *parent;
parent = focus_object;
while (1)
{
parent = atk_object_get_parent (parent);
if (parent == NULL)
break;
if (GTK_IS_ACCESSIBLE (parent))
break;
}
if (parent)
{
gail_set_focus_object (focus_object, parent);
}
}
else
{
old_focus_object = g_object_get_qdata (G_OBJECT (focus_object), quark_focus_object);
if (old_focus_object)
{
g_object_weak_unref (G_OBJECT (old_focus_object),
(GWeakNotify) gail_focus_object_destroyed,
focus_object);
g_object_set_qdata (G_OBJECT (focus_object), quark_focus_object, NULL);
g_object_unref (G_OBJECT (focus_object));
}
}
}
}
static void
gail_set_focus_widget (GtkWidget *focus_widget,
GtkWidget *widget)
{
AtkObject *focus_obj;
AtkObject *obj;
focus_obj = gtk_widget_get_accessible (focus_widget);
obj = gtk_widget_get_accessible (widget);
gail_set_focus_object (focus_obj, obj);
}
static void
gail_set_focus_object (AtkObject *focus_obj,
AtkObject *obj)
{
AtkObject *old_focus_obj;
old_focus_obj = g_object_get_qdata (G_OBJECT (obj), quark_focus_object);
if (old_focus_obj != obj)
{
if (old_focus_obj)
g_object_weak_unref (G_OBJECT (old_focus_obj),
(GWeakNotify) gail_focus_object_destroyed,
obj);
else
/*
* We call g_object_ref as if obj is destroyed
* while the weak reference exists then destroying the
* focus_obj would cause gail_focus_object_destroyed to be
* called when obj is not a valid GObject.
*/
g_object_ref (obj);
g_object_weak_ref (G_OBJECT (focus_obj),
(GWeakNotify) gail_focus_object_destroyed,
obj);
g_object_set_qdata (G_OBJECT (obj), quark_focus_object, focus_obj);
}
}
/*
* These exported symbols are hooked by gnome-program
* to provide automatic module initialization and shutdown.
*/
extern void gnome_accessibility_module_init (void);
extern void gnome_accessibility_module_shutdown (void);
static int gail_initialized = FALSE;
static void
gail_accessibility_module_init (void)
{
const char *env_a_t_support;
gboolean a_t_support = FALSE;
if (gail_initialized)
{
return;
}
gail_initialized = TRUE;
quark_focus_object = g_quark_from_static_string ("gail-focus-object");
env_a_t_support = g_getenv (GNOME_ACCESSIBILITY_ENV);
if (env_a_t_support)
a_t_support = atoi (env_a_t_support);
if (a_t_support)
fprintf (stderr, "GTK Accessibility Module initialized\n");
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_WIDGET, gail_widget);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CONTAINER, gail_container);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BUTTON, gail_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_ITEM, gail_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_ITEM, gail_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TOGGLE_BUTTON, gail_toggle_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_IMAGE, gail_image);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TEXT_VIEW, gail_text_view);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_COMBO, gail_combo);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_COMBO_BOX, gail_combo_box);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_ENTRY, gail_entry);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_BAR, gail_menu_shell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU, gail_menu);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_WINDOW, gail_window);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RANGE, gail_range);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCALE, gail_scale);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CLIST, gail_clist);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_LABEL, gail_label);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_STATUSBAR, gail_statusbar);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_NOTEBOOK, gail_notebook);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CALENDAR, gail_calendar);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_PROGRESS_BAR, gail_progress_bar);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SPIN_BUTTON, gail_spin_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TREE_VIEW, gail_tree_view);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_FRAME, gail_frame);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TEXT, gail_text_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER, gail_renderer_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_BUTTON, gail_radio_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_ARROW, gail_arrow);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_PIXMAP, gail_pixmap);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SEPARATOR, gail_separator);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BOX, gail_box);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_LIST, gail_list);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_PANED, gail_paned);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLBAR, gail_scrollbar);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_OPTION_MENU, gail_option_menu);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CHECK_MENU_ITEM, gail_check_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_MENU_ITEM, gail_radio_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_EXPANDER, gail_expander);
/* LIBGNOMECANVAS SUPPORT */
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_OBJECT, gail_object);
atk_focus_tracker_init (gail_focus_tracker_init);
focus_tracker_id = atk_add_focus_tracker (gail_focus_tracker);
/* Initialize the GailUtility class */
g_type_class_unref (g_type_class_ref (GAIL_TYPE_UTIL));
g_type_class_unref (g_type_class_ref (GAIL_TYPE_MISC));
}
/**
* gnome_accessibility_module_init:
* @void:
*
* This method is invoked by name from libgnome's
* gnome-program.c to activate accessibility support.
**/
void
gnome_accessibility_module_init (void)
{
gail_accessibility_module_init ();
}
/**
* gnome_accessibility_module_shutdown:
* @void:
*
* This method is invoked by name from libgnome's
* gnome-program.c to de-activate accessibility support.
**/
void
gnome_accessibility_module_shutdown (void)
{
if (!gail_initialized)
{
return;
}
gail_initialized = FALSE;
atk_remove_focus_tracker (focus_tracker_id);
fprintf (stderr, "GTK Accessibility Module shutdown\n");
/* FIXME: de-register the factory types so we can unload ? */
}
int
gtk_module_init (gint *argc, char** argv[])
{
gail_accessibility_module_init ();
return 0;
}

54
modules/other/gail/gail.h Normal file
View File

@ -0,0 +1,54 @@
#include <gail/gailadjustment.h>
#include <gail/gailarrow.h>
#include <gail/gailbooleancell.h>
#include <gail/gailbooleancellfactory.h>
#include <gail/gailbox.h>
#include <gail/gailbutton.h>
#include <gail/gailcalendar.h>
#include <gail/gailcell.h>
#include <gail/gailcheckmenuitem.h>
#include <gail/gailclist.h>
#include <gail/gailclistcell.h>
#include <gail/gailcombo.h>
#include <gail/gailcombobox.h>
#include <gail/gailcontainer.h>
#include <gail/gailcontainercell.h>
#include <gail/gailentry.h>
#include <gail/gailexpander.h>
#include <gail/gailframe.h>
#include <gail/gailimage.h>
#include <gail/gailimagecell.h>
#include <gail/gailimagecellfactory.h>
#include <gail/gailitem.h>
#include <gail/gaillabel.h>
#include <gail/gaillist.h>
#include <gail/gailmenu.h>
#include <gail/gailmenushell.h>
#include <gail/gailmenuitem.h>
#include <gail/gailnotebook.h>
#include <gail/gailobject.h>
#include <gail/gailobjectfactory.h>
#include <gail/gailoptionmenu.h>
#include <gail/gailpaned.h>
#include <gail/gailpixmap.h>
#include <gail/gailprogressbar.h>
#include <gail/gailradiobutton.h>
#include <gail/gailradiomenuitem.h>
#include <gail/gailrenderercell.h>
#include <gail/gailrenderercellfactory.h>
#include <gail/gailrange.h>
#include <gail/gailscale.h>
#include <gail/gailscrollbar.h>
#include <gail/gailscrolledwindow.h>
#include <gail/gailseparator.h>
#include <gail/gailspinbutton.h>
#include <gail/gailstatusbar.h>
#include <gail/gailtextcell.h>
#include <gail/gailtextcellfactory.h>
#include <gail/gailtextview.h>
#include <gail/gailtogglebutton.h>
#include <gail/gailtoplevel.h>
#include <gail/gailtreeview.h>
#include <gail/gailutil.h>
#include <gail/gailwidget.h>
#include <gail/gailwindow.h>

View File

@ -0,0 +1,234 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailadjustment.h"
static void gail_adjustment_class_init (GailAdjustmentClass *klass);
static void gail_adjustment_real_initialize (AtkObject *obj,
gpointer data);
static void atk_value_interface_init (AtkValueIface *iface);
static void gail_adjustment_get_current_value (AtkValue *obj,
GValue *value);
static void gail_adjustment_get_maximum_value (AtkValue *obj,
GValue *value);
static void gail_adjustment_get_minimum_value (AtkValue *obj,
GValue *value);
static gboolean gail_adjustment_set_current_value (AtkValue *obj,
const GValue *value);
static void gail_adjustment_destroyed (GtkAdjustment *adjustment,
GailAdjustment *gail_adjustment);
static gpointer parent_class = NULL;
GType
gail_adjustment_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailAdjustmentClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_adjustment_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailAdjustment), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_value_info =
{
(GInterfaceInitFunc) atk_value_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"GailAdjustment", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_VALUE,
&atk_value_info);
}
return type;
}
static void
gail_adjustment_class_init (GailAdjustmentClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->initialize = gail_adjustment_real_initialize;
}
AtkObject*
gail_adjustment_new (GtkAdjustment *adjustment)
{
GObject *object;
AtkObject *atk_object;
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
object = g_object_new (GAIL_TYPE_ADJUSTMENT, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, adjustment);
return atk_object;
}
static void
gail_adjustment_real_initialize (AtkObject *obj,
gpointer data)
{
GtkAdjustment *adjustment;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
adjustment = GTK_ADJUSTMENT (data);
obj->role = ATK_ROLE_UNKNOWN;
GAIL_ADJUSTMENT (obj)->adjustment = adjustment;
g_signal_connect_object (G_OBJECT (adjustment),
"destroy",
G_CALLBACK (gail_adjustment_destroyed),
obj, 0);
}
static void
atk_value_interface_init (AtkValueIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_current_value = gail_adjustment_get_current_value;
iface->get_maximum_value = gail_adjustment_get_maximum_value;
iface->get_minimum_value = gail_adjustment_get_minimum_value;
iface->set_current_value = gail_adjustment_set_current_value;
}
static void
gail_adjustment_get_current_value (AtkValue *obj,
GValue *value)
{
GtkAdjustment* adjustment;
gdouble current_value;
adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
if (adjustment == NULL)
{
/* State is defunct */
return;
}
current_value = adjustment->value;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value,current_value);
}
static void
gail_adjustment_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkAdjustment* adjustment;
gdouble maximum_value;
adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
if (adjustment == NULL)
{
/* State is defunct */
return;
}
maximum_value = adjustment->upper;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, maximum_value);
}
static void
gail_adjustment_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkAdjustment* adjustment;
gdouble minimum_value;
adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
if (adjustment == NULL)
{
/* State is defunct */
return;
}
minimum_value = adjustment->lower;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, minimum_value);
}
static gboolean
gail_adjustment_set_current_value (AtkValue *obj,
const GValue *value)
{
if (G_VALUE_HOLDS_DOUBLE (value))
{
GtkAdjustment* adjustment;
gdouble new_value;
adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
if (adjustment == NULL)
{
/* State is defunct */
return FALSE;
}
new_value = g_value_get_double (value);
gtk_adjustment_set_value (adjustment, new_value);
return TRUE;
}
else
return FALSE;
}
static void
gail_adjustment_destroyed (GtkAdjustment *adjustment,
GailAdjustment *gail_adjustment)
{
/*
* This is the signal handler for the "destroy" signal for the
* GtkAdjustment. We set the pointer location to NULL;
*/
gail_adjustment->adjustment = NULL;
}

View File

@ -0,0 +1,61 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_ADJUSTMENT_H__
#define __GAIL_ADJUSTMENT_H__
#include <atk/atk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_ADJUSTMENT (gail_adjustment_get_type ())
#define GAIL_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_ADJUSTMENT, GailAdjustment))
#define GAIL_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_ADJUSTMENT, GailAdjustmentClass))
#define GAIL_IS_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_ADJUSTMENT))
#define GAIL_IS_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_ADJUSTMENT))
#define GAIL_ADJUSTMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_ADJUSTMENT, GailAdjustmentClass))
typedef struct _GailAdjustment GailAdjustment;
typedef struct _GailAdjustmentClass GailAdjustmentClass;
struct _GailAdjustment
{
AtkObject parent;
GtkAdjustment *adjustment;
};
GType gail_adjustment_get_type (void);
struct _GailAdjustmentClass
{
AtkObjectClass parent_class;
};
AtkObject *gail_adjustment_new (GtkAdjustment *adjustment);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_ADJUSTMENT_H__ */

View File

@ -0,0 +1,164 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailarrow.h"
static void gail_arrow_class_init (GailArrowClass *klass);
static void gail_arrow_object_init (GailArrow *arrow);
/* AtkImage */
static void atk_image_interface_init (AtkImageIface *iface);
static G_CONST_RETURN gchar* gail_arrow_get_image_description
(AtkImage *obj);
static gboolean gail_arrow_set_image_description
(AtkImage *obj,
const gchar *description);
static void gail_arrow_finalize (GObject *object);
static GailWidgetClass* parent_class = NULL;
GType
gail_arrow_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailArrowClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_arrow_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailArrow), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_arrow_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) atk_image_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailArrow", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
}
return type;
}
static void
gail_arrow_class_init (GailArrowClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gail_arrow_finalize;
parent_class = g_type_class_peek_parent (klass);
}
static void
gail_arrow_object_init (GailArrow *arrow)
{
arrow->image_description = NULL;
}
AtkObject*
gail_arrow_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_ARROW (widget), NULL);
object = g_object_new (GAIL_TYPE_ARROW, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_ICON;
return accessible;
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_image_description = gail_arrow_get_image_description;
iface->set_image_description = gail_arrow_set_image_description;
}
static G_CONST_RETURN gchar*
gail_arrow_get_image_description (AtkImage *obj)
{
GailArrow* arrow;
g_return_val_if_fail(GAIL_IS_ARROW(obj), NULL);
arrow = GAIL_ARROW (obj);
return arrow->image_description;
}
static gboolean
gail_arrow_set_image_description (AtkImage *obj,
const gchar *description)
{
GailArrow* arrow;
g_return_val_if_fail(GAIL_IS_ARROW(obj), FALSE);
arrow = GAIL_ARROW (obj);
g_free (arrow->image_description);
arrow->image_description = g_strdup (description);
return TRUE;
}
/*
* static void
* gail_arrow_get_image_size (AtkImage *obj,
* gint *height,
* gint *width)
*
* We dont implement this function for GailArrow as gtk hardcodes the size
* of the arrow to be 7x5 and it is not possible to query this.
*/
static void
gail_arrow_finalize (GObject *object)
{
GailArrow *arrow = GAIL_ARROW (object);
g_free (arrow->image_description);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,61 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_ARROW_H__
#define __GAIL_ARROW_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_ARROW (gail_arrow_get_type ())
#define GAIL_ARROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_ARROW, GailArrow))
#define GAIL_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_ARROW, GailArrowClass))
#define GAIL_IS_ARROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_ARROW))
#define GAIL_IS_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_ARROW))
#define GAIL_ARROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_ARROW, GailArrowClass))
typedef struct _GailArrow GailArrow;
typedef struct _GailArrowClass GailArrowClass;
struct _GailArrow
{
GailWidget parent;
gchar* image_description;
};
GType gail_arrow_get_type (void);
struct _GailArrowClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_arrow_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_ARROW_H__ */

View File

@ -0,0 +1,122 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailbooleancell.h"
static void gail_boolean_cell_class_init (GailBooleanCellClass *klass);
/* Misc */
static gboolean gail_boolean_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal);
gchar *gail_boolean_cell_property_list[] = {
"active",
"radio",
NULL
};
GType
gail_boolean_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailBooleanCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_boolean_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailBooleanCell), /* instance size */
0, /* nb preallocs */
NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_RENDERER_CELL,
"GailBooleanCell", &tinfo, 0);
gail_cell_type_add_action_interface (type);
}
return type;
}
static void
gail_boolean_cell_class_init (GailBooleanCellClass *klass)
{
GailRendererCellClass *renderer_cell_class = GAIL_RENDERER_CELL_CLASS (klass);
renderer_cell_class->update_cache = gail_boolean_cell_update_cache;
renderer_cell_class->property_list = gail_boolean_cell_property_list;
}
AtkObject*
gail_boolean_cell_new (void)
{
GObject *object;
AtkObject *atk_object;
GailRendererCell *cell;
GailBooleanCell *boolean_cell;
object = g_object_new (GAIL_TYPE_BOOLEAN_CELL, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
cell = GAIL_RENDERER_CELL(object);
boolean_cell = GAIL_BOOLEAN_CELL(object);
cell->renderer = gtk_cell_renderer_toggle_new ();
g_object_ref (cell->renderer);
gtk_object_sink (GTK_OBJECT (cell->renderer));
boolean_cell->cell_value = FALSE;
return atk_object;
}
static gboolean
gail_boolean_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal)
{
GailBooleanCell *boolean_cell = GAIL_BOOLEAN_CELL (cell);
gboolean rv = FALSE;
gboolean new_boolean;
g_object_get (G_OBJECT(cell->renderer), "active", &new_boolean, NULL);
if (boolean_cell->cell_value != new_boolean)
{
rv = TRUE;
boolean_cell->cell_value = !(boolean_cell->cell_value);
/* Update cell's state */
if (new_boolean)
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_CHECKED, emit_change_signal);
else
gail_cell_remove_state (GAIL_CELL (cell), ATK_STATE_CHECKED, emit_change_signal);
}
return rv;
}

View File

@ -0,0 +1,60 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_BOOLEAN_CELL_H__
#define __GAIL_BOOLEAN_CELL_H__
#include <atk/atk.h>
#include <gail/gailrenderercell.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_BOOLEAN_CELL (gail_boolean_cell_get_type ())
#define GAIL_BOOLEAN_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_BOOLEAN_CELL, GailBooleanCell))
#define GAIL_BOOLEAN_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_BOOLEAN_CELL, GailBooleanCellClass))
#define GAIL_IS_BOOLEAN_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_BOOLEAN_CELL))
#define GAIL_IS_BOOLEAN_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_BOOLEAN_CELL))
#define GAIL_BOOLEAN_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_BOOLEAN_CELL, GailBooleanCellClass))
typedef struct _GailBooleanCell GailBooleanCell;
typedef struct _GailBooleanCellClass GailBooleanCellClass;
struct _GailBooleanCell
{
GailRendererCell parent;
gboolean cell_value;
};
GType gail_boolean_cell_get_type (void);
struct _GailBooleanCellClass
{
GailRendererCellClass parent_class;
};
AtkObject *gail_boolean_cell_new (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_TREE_VIEW_BOOLEAN_CELL_H__ */

View File

@ -0,0 +1,78 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtkcellrenderertoggle.h>
#include "gailbooleancellfactory.h"
#include "gailbooleancell.h"
static void gail_boolean_cell_factory_class_init (GailBooleanCellFactoryClass *klass);
static AtkObject* gail_boolean_cell_factory_create_accessible (
GObject *obj);
static GType gail_boolean_cell_factory_get_accessible_type (void);
GType
gail_boolean_cell_factory_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailBooleanCellFactoryClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_boolean_cell_factory_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailBooleanCellFactory), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (ATK_TYPE_OBJECT_FACTORY,
"GailBooleanCellFactory" , &tinfo, 0);
}
return type;
}
static void
gail_boolean_cell_factory_class_init (GailBooleanCellFactoryClass *klass)
{
AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
class->create_accessible = gail_boolean_cell_factory_create_accessible;
class->get_accessible_type = gail_boolean_cell_factory_get_accessible_type;
}
static AtkObject*
gail_boolean_cell_factory_create_accessible (GObject *obj)
{
g_return_val_if_fail (GTK_IS_CELL_RENDERER_TOGGLE (obj), NULL);
return gail_boolean_cell_new ();
}
static GType
gail_boolean_cell_factory_get_accessible_type (void)
{
return GAIL_TYPE_BOOLEAN_CELL;
}

View File

@ -0,0 +1,56 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_BOOLEAN_CELL_FACTORY_H__
#define __GAIL_BOOLEAN_CELL_FACTORY_H__
#include <atk/atkobjectfactory.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_BOOLEAN_CELL_FACTORY (gail_boolean_cell_factory_get_type ())
#define GAIL_BOOLEAN_CELL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_BOOLEAN_CELL_FACTORY, GailBooleanCellFactory))
#define GAIL_BOOLEAN_CELL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AGTK_TYPE_BOOLEAN_CELL_FACTORY, GailBooleanCellFactoryClass))
#define GAIL_IS_BOOLEAN_CELL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_BOOLEAN_CELL_FACTORY))
#define GAIL_IS_BOOLEAN_CELL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_BOOLEAN_CELL_FACTORY))
#define GAIL_BOOLEAN_CELL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_BOOLEAN_CELL_FACTORY, GailBooleanCellFactoryClass))
typedef struct _GailBooleanCellFactory GailBooleanCellFactory;
typedef struct _GailBooleanCellFactoryClass GailBooleanCellFactoryClass;
struct _GailBooleanCellFactory
{
AtkObjectFactory parent;
};
struct _GailBooleanCellFactoryClass
{
AtkObjectFactoryClass parent_class;
};
GType gail_boolean_cell_factory_get_type(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_BOOLEAN_CELL_FACTORY_H__ */

View File

@ -0,0 +1,101 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailbox.h"
static void gail_box_class_init (GailBoxClass *klass);
static AtkStateSet* gail_box_ref_state_set (AtkObject *accessible);
static GailContainerClass *parent_class = NULL;
GType
gail_box_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailBoxClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_box_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailBox), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailBox", &tinfo, 0);
}
return type;
}
static void
gail_box_class_init (GailBoxClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->ref_state_set = gail_box_ref_state_set;
}
AtkObject*
gail_box_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_BOX (widget), NULL);
object = g_object_new (GAIL_TYPE_BOX, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_FILLER;
return accessible;
}
static AtkStateSet*
gail_box_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
return state_set;
if (GTK_IS_VBOX (widget) || GTK_IS_VBUTTON_BOX (widget))
atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
else if (GTK_IS_HBOX (widget) || GTK_IS_HBUTTON_BOX (widget))
atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
return state_set;
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_BOX_H__
#define __GAIL_BOX_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_BOX (gail_box_get_type ())
#define GAIL_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_BOX, GailBox))
#define GAIL_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_BOX, GailBoxClass))
#define GAIL_IS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_BOX))
#define GAIL_IS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_BOX))
#define GAIL_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_BOX, GailBoxClass))
typedef struct _GailBox GailBox;
typedef struct _GailBoxClass GailBoxClass;
struct _GailBox
{
GailContainer parent;
};
GType gail_box_get_type (void);
struct _GailBoxClass
{
GailContainerClass parent_class;
};
AtkObject* gail_box_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_BOX_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_BUTTON_H__
#define __GAIL_BUTTON_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#include <libgail-util/gailtextutil.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_BUTTON (gail_button_get_type ())
#define GAIL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_BUTTON, GailButton))
#define GAIL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_BUTTON, GailButtonClass))
#define GAIL_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_BUTTON))
#define GAIL_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_BUTTON))
#define GAIL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_BUTTON, GailButtonClass))
typedef struct _GailButton GailButton;
typedef struct _GailButtonClass GailButtonClass;
struct _GailButton
{
GailContainer parent;
/*
* Cache the widget state so we know the previous state when it changed
*/
gint8 state;
gchar *click_description;
gchar *press_description;
gchar *release_description;
gchar *click_keybinding;
guint action_idle_handler;
GQueue *action_queue;
GailTextUtil *textutil;
gboolean default_is_press;
};
GType gail_button_get_type (void);
struct _GailButtonClass
{
GailContainerClass parent_class;
};
AtkObject* gail_button_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_BUTTON_H__ */

View File

@ -0,0 +1,73 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailcalendar.h"
static void gail_calendar_class_init (GailCalendarClass *klass);
GType
gail_calendar_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCalendarClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_calendar_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCalendar), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailCalendar", &tinfo, 0);
}
return type;
}
static void
gail_calendar_class_init (GailCalendarClass *klass)
{
}
AtkObject*
gail_calendar_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_CALENDAR (widget), NULL);
object = g_object_new (GAIL_TYPE_CALENDAR, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_CALENDAR;
return accessible;
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CALENDAR_H__
#define __GAIL_CALENDAR_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CALENDAR (gail_calendar_get_type ())
#define GAIL_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CALENDAR, GailCalendar))
#define GAIL_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CALENDAR, GailCalendarClass))
#define GAIL_IS_CALENDAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CALENDAR))
#define GAIL_IS_CALENDAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CALENDAR))
#define GAIL_CALENDAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CALENDAR, GailCalendarClass))
typedef struct _GailCalendar GailCalendar;
typedef struct _GailCalendarClass GailCalendarClass;
struct _GailCalendar
{
GailWidget parent;
};
GType gail_calendar_get_type (void);
struct _GailCalendarClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_calendar_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CALENDAR_H__ */

View File

@ -0,0 +1,577 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <gtk/gtk.h>
#include "gailcontainercell.h"
#include "gailcell.h"
#include "gailcellparent.h"
static void gail_cell_class_init (GailCellClass *klass);
static void gail_cell_destroyed (GtkWidget *widget,
GailCell *cell);
static void gail_cell_object_init (GailCell *cell);
static void gail_cell_object_finalize (GObject *cell);
static AtkStateSet* gail_cell_ref_state_set (AtkObject *obj);
static gint gail_cell_get_index_in_parent (AtkObject *obj);
/* AtkAction */
static void gail_cell_atk_action_interface_init
(AtkActionIface *iface);
static ActionInfo * _gail_cell_get_action_info (GailCell *cell,
gint index);
static void _gail_cell_destroy_action_info
(gpointer data,
gpointer user_data);
static gint gail_cell_action_get_n_actions
(AtkAction *action);
static G_CONST_RETURN gchar*
gail_cell_action_get_name (AtkAction *action,
gint index);
static G_CONST_RETURN gchar *
gail_cell_action_get_description
(AtkAction *action,
gint index);
static gboolean gail_cell_action_set_description
(AtkAction *action,
gint index,
const gchar *desc);
static G_CONST_RETURN gchar *
gail_cell_action_get_keybinding
(AtkAction *action,
gint index);
static gboolean gail_cell_action_do_action (AtkAction *action,
gint index);
static gboolean idle_do_action (gpointer data);
static void atk_component_interface_init (AtkComponentIface *iface);
static void gail_cell_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
static gboolean gail_cell_grab_focus (AtkComponent *component);
static gpointer parent_class = NULL;
GType
gail_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_cell_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_component_info =
{
(GInterfaceInitFunc) atk_component_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"GailCell", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
&atk_component_info);
}
return type;
}
static void
gail_cell_class_init (GailCellClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
g_object_class->finalize = gail_cell_object_finalize;
class->get_index_in_parent = gail_cell_get_index_in_parent;
class->ref_state_set = gail_cell_ref_state_set;
}
void
gail_cell_init (GailCell *cell,
GtkWidget *widget,
AtkObject *parent,
gint index)
{
g_return_if_fail (GAIL_IS_CELL (cell));
g_return_if_fail (GTK_IS_WIDGET (widget));
cell->widget = widget;
atk_object_set_parent (ATK_OBJECT (cell), parent);
cell->index = index;
g_signal_connect_object (G_OBJECT (widget),
"destroy",
G_CALLBACK (gail_cell_destroyed ),
cell, 0);
}
static void
gail_cell_destroyed (GtkWidget *widget,
GailCell *cell)
{
/*
* This is the signal handler for the "destroy" signal for the
* GtkWidget. We set the pointer location to NULL;
*/
cell->widget = NULL;
}
static void
gail_cell_object_init (GailCell *cell)
{
cell->state_set = atk_state_set_new ();
cell->widget = NULL;
cell->action_list = NULL;
cell->index = 0;
atk_state_set_add_state (cell->state_set, ATK_STATE_TRANSIENT);
atk_state_set_add_state (cell->state_set, ATK_STATE_ENABLED);
atk_state_set_add_state (cell->state_set, ATK_STATE_SENSITIVE);
atk_state_set_add_state (cell->state_set, ATK_STATE_SELECTABLE);
cell->refresh_index = NULL;
}
static void
gail_cell_object_finalize (GObject *obj)
{
GailCell *cell = GAIL_CELL (obj);
AtkRelationSet *relation_set;
AtkRelation *relation;
GPtrArray *target;
gpointer target_object;
gint i;
if (cell->state_set)
g_object_unref (cell->state_set);
g_list_free (cell->action_list);
if (cell->action_idle_handler)
{
g_source_remove (cell->action_idle_handler);
cell->action_idle_handler = 0;
}
relation_set = atk_object_ref_relation_set (ATK_OBJECT (obj));
if (ATK_IS_RELATION_SET (relation_set))
{
relation = atk_relation_set_get_relation_by_type (relation_set,
ATK_RELATION_NODE_CHILD_OF);
if (relation)
{
target = atk_relation_get_target (relation);
for (i = 0; i < target->len; i++)
{
target_object = g_ptr_array_index (target, i);
if (GAIL_IS_CELL (target_object))
{
g_object_unref (target_object);
}
}
}
g_object_unref (relation_set);
}
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static AtkStateSet *
gail_cell_ref_state_set (AtkObject *obj)
{
GailCell *cell = GAIL_CELL (obj);
g_assert (cell->state_set);
g_object_ref(cell->state_set);
return cell->state_set;
}
gboolean
gail_cell_add_state (GailCell *cell,
AtkStateType state_type,
gboolean emit_signal)
{
if (!atk_state_set_contains_state (cell->state_set, state_type))
{
gboolean rc;
AtkObject *parent;
rc = atk_state_set_add_state (cell->state_set, state_type);
/*
* The signal should only be generated if the value changed,
* not when the cell is set up. So states that are set
* initially should pass FALSE as the emit_signal argument.
*/
if (emit_signal)
{
atk_object_notify_state_change (ATK_OBJECT (cell), state_type, TRUE);
/* If state_type is ATK_STATE_VISIBLE, additional notification */
if (state_type == ATK_STATE_VISIBLE)
g_signal_emit_by_name (cell, "visible_data_changed");
}
/*
* If the parent is a flyweight container cell, propagate the state
* change to it also
*/
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
gail_cell_add_state (GAIL_CELL (parent), state_type, emit_signal);
return rc;
}
else
return FALSE;
}
gboolean
gail_cell_remove_state (GailCell *cell,
AtkStateType state_type,
gboolean emit_signal)
{
if (atk_state_set_contains_state (cell->state_set, state_type))
{
gboolean rc;
AtkObject *parent;
parent = atk_object_get_parent (ATK_OBJECT (cell));
rc = atk_state_set_remove_state (cell->state_set, state_type);
/*
* The signal should only be generated if the value changed,
* not when the cell is set up. So states that are set
* initially should pass FALSE as the emit_signal argument.
*/
if (emit_signal)
{
atk_object_notify_state_change (ATK_OBJECT (cell), state_type, FALSE);
/* If state_type is ATK_STATE_VISIBLE, additional notification */
if (state_type == ATK_STATE_VISIBLE)
g_signal_emit_by_name (cell, "visible_data_changed");
}
/*
* If the parent is a flyweight container cell, propagate the state
* change to it also
*/
if (GAIL_IS_CONTAINER_CELL (parent))
gail_cell_remove_state (GAIL_CELL (parent), state_type, emit_signal);
return rc;
}
else
return FALSE;
}
static gint
gail_cell_get_index_in_parent (AtkObject *obj)
{
GailCell *cell;
g_assert (GAIL_IS_CELL (obj));
cell = GAIL_CELL (obj);
if (atk_state_set_contains_state (cell->state_set, ATK_STATE_STALE))
if (cell->refresh_index)
{
cell->refresh_index (cell);
atk_state_set_remove_state (cell->state_set, ATK_STATE_STALE);
}
return cell->index;
}
static void
gail_cell_atk_action_interface_init (AtkActionIface *iface)
{
g_assert (iface != NULL);
iface->get_n_actions = gail_cell_action_get_n_actions;
iface->do_action = gail_cell_action_do_action;
iface->get_name = gail_cell_action_get_name;
iface->get_description = gail_cell_action_get_description;
iface->set_description = gail_cell_action_set_description;
iface->get_keybinding = gail_cell_action_get_keybinding;
}
void
gail_cell_type_add_action_interface (GType type)
{
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) gail_cell_atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
}
gboolean
gail_cell_add_action (GailCell *cell,
const gchar *action_name,
const gchar *action_description,
const gchar *action_keybinding,
ACTION_FUNC action_func)
{
ActionInfo *info;
g_return_val_if_fail (GAIL_IS_CELL (cell), FALSE);
info = g_new (ActionInfo, 1);
if (action_name != NULL)
info->name = g_strdup (action_name);
else
info->name = NULL;
if (action_description != NULL)
info->description = g_strdup (action_description);
else
info->description = NULL;
if (action_keybinding != NULL)
info->keybinding = g_strdup (action_keybinding);
else
info->keybinding = NULL;
info->do_action_func = action_func;
cell->action_list = g_list_append (cell->action_list, (gpointer) info);
return TRUE;
}
gboolean
gail_cell_remove_action (GailCell *cell,
gint action_index)
{
GList *list_node;
g_return_val_if_fail (GAIL_IS_CELL (cell), FALSE);
list_node = g_list_nth (cell->action_list, action_index);
if (!list_node)
return FALSE;
_gail_cell_destroy_action_info (list_node->data, NULL);
cell->action_list = g_list_remove_link (cell->action_list, list_node);
return TRUE;
}
gboolean
gail_cell_remove_action_by_name (GailCell *cell,
const gchar *action_name)
{
GList *list_node;
gboolean action_found= FALSE;
g_return_val_if_fail (GAIL_IS_CELL (cell), FALSE);
for (list_node = cell->action_list; list_node && !action_found;
list_node = list_node->next)
{
if (!g_strcasecmp (((ActionInfo *)(list_node->data))->name, action_name))
{
action_found = TRUE;
break;
}
}
if (!action_found)
return FALSE;
_gail_cell_destroy_action_info (list_node->data, NULL);
cell->action_list = g_list_remove_link (cell->action_list, list_node);
return TRUE;
}
static ActionInfo *
_gail_cell_get_action_info (GailCell *cell,
gint index)
{
GList *list_node;
g_return_val_if_fail (GAIL_IS_CELL (cell), NULL);
if (cell->action_list == NULL)
return NULL;
list_node = g_list_nth (cell->action_list, index);
if (!list_node)
return NULL;
return (ActionInfo *) (list_node->data);
}
static void
_gail_cell_destroy_action_info (gpointer action_info,
gpointer user_data)
{
ActionInfo *info = (ActionInfo *)action_info;
g_assert (info != NULL);
g_free (info->name);
g_free (info->description);
g_free (info->keybinding);
g_free (info);
}
static gint
gail_cell_action_get_n_actions (AtkAction *action)
{
GailCell *cell = GAIL_CELL(action);
if (cell->action_list != NULL)
return g_list_length (cell->action_list);
else
return 0;
}
static G_CONST_RETURN gchar *
gail_cell_action_get_name (AtkAction *action,
gint index)
{
GailCell *cell = GAIL_CELL(action);
ActionInfo *info = _gail_cell_get_action_info (cell, index);
if (info == NULL)
return NULL;
return info->name;
}
static G_CONST_RETURN gchar *
gail_cell_action_get_description (AtkAction *action,
gint index)
{
GailCell *cell = GAIL_CELL(action);
ActionInfo *info = _gail_cell_get_action_info (cell, index);
if (info == NULL)
return NULL;
return info->description;
}
static gboolean
gail_cell_action_set_description (AtkAction *action,
gint index,
const gchar *desc)
{
GailCell *cell = GAIL_CELL(action);
ActionInfo *info = _gail_cell_get_action_info (cell, index);
if (info == NULL)
return FALSE;
g_free (info->description);
info->description = g_strdup (desc);
return TRUE;
}
static G_CONST_RETURN gchar *
gail_cell_action_get_keybinding (AtkAction *action,
gint index)
{
GailCell *cell = GAIL_CELL(action);
ActionInfo *info = _gail_cell_get_action_info (cell, index);
if (info == NULL)
return NULL;
return info->keybinding;
}
static gboolean
gail_cell_action_do_action (AtkAction *action,
gint index)
{
GailCell *cell = GAIL_CELL(action);
ActionInfo *info = _gail_cell_get_action_info (cell, index);
if (info == NULL)
return FALSE;
if (info->do_action_func == NULL)
return FALSE;
if (cell->action_idle_handler)
return FALSE;
cell->action_func = info->do_action_func;
cell->action_idle_handler = g_idle_add (idle_do_action, cell);
return TRUE;
}
static gboolean
idle_do_action (gpointer data)
{
GailCell *cell;
GDK_THREADS_ENTER ();
cell = GAIL_CELL (data);
cell->action_idle_handler = 0;
cell->action_func (cell);
GDK_THREADS_LEAVE ();
return FALSE;
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
g_assert (iface != NULL);
iface->get_extents = gail_cell_get_extents;
iface->grab_focus = gail_cell_grab_focus;
}
static void
gail_cell_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
GailCell *gailcell;
AtkObject *cell_parent;
g_assert (GAIL_IS_CELL (component));
gailcell = GAIL_CELL (component);
cell_parent = gtk_widget_get_accessible (gailcell->widget);
gail_cell_parent_get_cell_extents (GAIL_CELL_PARENT (cell_parent),
gailcell, x, y, width, height, coord_type);
}
static gboolean
gail_cell_grab_focus (AtkComponent *component)
{
GailCell *gailcell;
AtkObject *cell_parent;
g_assert (GAIL_IS_CELL (component));
gailcell = GAIL_CELL (component);
cell_parent = gtk_widget_get_accessible (gailcell->widget);
return gail_cell_parent_grab_focus (GAIL_CELL_PARENT (cell_parent),
gailcell);
}

View File

@ -0,0 +1,110 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CELL_H__
#define __GAIL_CELL_H__
#include <atk/atk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CELL (gail_cell_get_type ())
#define GAIL_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CELL, GailCell))
#define GAIL_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CELL, GailCellClass))
#define GAIL_IS_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CELL))
#define GAIL_IS_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CELL))
#define GAIL_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CELL, GailCellClass))
typedef struct _GailCell GailCell;
typedef struct _GailCellClass GailCellClass;
typedef struct _ActionInfo ActionInfo;
typedef void (*ACTION_FUNC) (GailCell *cell);
struct _GailCell
{
AtkObject parent;
GtkWidget *widget;
/*
* This cached value is used only by atk_object_get_index_in_parent()
* which updates the value when it is stale.
*/
gint index;
AtkStateSet *state_set;
GList *action_list;
void (*refresh_index) (GailCell *cell);
gint action_idle_handler;
ACTION_FUNC action_func;
};
GType gail_cell_get_type (void);
struct _GailCellClass
{
AtkObjectClass parent_class;
};
struct _ActionInfo {
gchar *name;
gchar *description;
gchar *keybinding;
ACTION_FUNC do_action_func;
};
void gail_cell_init (GailCell *cell,
GtkWidget *widget,
AtkObject *parent,
gint index);
gboolean gail_cell_add_state (GailCell *cell,
AtkStateType state_type,
gboolean emit_signal);
gboolean gail_cell_remove_state (GailCell *cell,
AtkStateType state_type,
gboolean emit_signal);
void gail_cell_type_add_action_interface
(GType type);
gboolean gail_cell_add_action (GailCell *cell,
const gchar *action_name,
const gchar *action_description,
const gchar *action_keybinding,
ACTION_FUNC action_func);
gboolean gail_cell_remove_action (GailCell *cell,
gint action_id);
gboolean gail_cell_remove_action_by_name (GailCell *cell,
const gchar *action_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CELL_H__ */

View File

@ -0,0 +1,124 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtkwidget.h>
#include "gailcellparent.h"
GType
gail_cell_parent_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCellParentIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "GailCellParent", &tinfo, 0);
}
return type;
}
/**
* gail_cell_parent_get_cell_extents:
* @parent: a #GObject instance that implements GailCellParentIface
* @cell: a #GailCell whose extents is required
* @x: address of #gint to put x coordinate
* @y: address of #gint to put y coordinate
* @width: address of #gint to put width
* @height: address of #gint to put height
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the components top level window
*
* Gets the rectangle which gives the extent of the @cell.
*
**/
void
gail_cell_parent_get_cell_extents (GailCellParent *parent,
GailCell *cell,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
GailCellParentIface *iface;
g_return_if_fail (GAIL_IS_CELL_PARENT (parent));
iface = GAIL_CELL_PARENT_GET_IFACE (parent);
if (iface->get_cell_extents)
(iface->get_cell_extents) (parent, cell, x, y, width, height, coord_type);
}
/**
* gail_cell_parent_get_cell_area:
* @parent: a #GObject instance that implements GailCellParentIface
* @cell: a #GailCell whose area is required
* @cell_rect: address of #GdkRectangle to put the cell area
*
* Gets the cell area of the @cell.
*
**/
void
gail_cell_parent_get_cell_area (GailCellParent *parent,
GailCell *cell,
GdkRectangle *cell_rect)
{
GailCellParentIface *iface;
g_return_if_fail (GAIL_IS_CELL_PARENT (parent));
g_return_if_fail (cell_rect);
iface = GAIL_CELL_PARENT_GET_IFACE (parent);
if (iface->get_cell_area)
(iface->get_cell_area) (parent, cell, cell_rect);
}
/**
* gail_cell_parent_grab_focus:
* @parent: a #GObject instance that implements GailCellParentIface
* @cell: a #GailCell whose area is required
*
* Puts focus in the specified cell.
*
**/
gboolean
gail_cell_parent_grab_focus (GailCellParent *parent,
GailCell *cell)
{
GailCellParentIface *iface;
g_return_val_if_fail (GAIL_IS_CELL_PARENT (parent), FALSE);
iface = GAIL_CELL_PARENT_GET_IFACE (parent);
if (iface->grab_focus)
return (iface->grab_focus) (parent, cell);
else
return FALSE;
}

View File

@ -0,0 +1,88 @@
/* GAIL - The GNOME Accessibility Implementation Library
*
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CELL_PARENT_H__
#define __GAIL_CELL_PARENT_H__
#include <atk/atkobject.h>
#include <atk/atkutil.h>
#include <gail/gailcell.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* The GailCellParent interface should be supported by any object which
* contains children which are flyweights, i.e. do not have corresponding
* widgets and the children need help from their parent to provide
* functionality. One example is GailTreeView where the children GailCell
* need help from the GailTreeView in order to implement
* atk_component_get_extents
*/
#define GAIL_TYPE_CELL_PARENT (gail_cell_parent_get_type ())
#define GAIL_IS_CELL_PARENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CELL_PARENT)
#define GAIL_CELL_PARENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CELL_PARENT, GailCellParent)
#define GAIL_CELL_PARENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAIL_TYPE_CELL_PARENT, GailCellParentIface))
#ifndef _TYPEDEF_GAIL_CELL_PARENT_
#define _TYPEDEF_GAIL_CELL_PARENT_
typedef struct _GailCellParent GailCellParent;
#endif
typedef struct _GailCellParentIface GailCellParentIface;
struct _GailCellParentIface
{
GTypeInterface parent;
void ( *get_cell_extents) (GailCellParent *parent,
GailCell *cell,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
void ( *get_cell_area) (GailCellParent *parent,
GailCell *cell,
GdkRectangle *cell_rect);
gboolean ( *grab_focus) (GailCellParent *parent,
GailCell *cell);
};
GType gail_cell_parent_get_type (void);
void gail_cell_parent_get_cell_extents (GailCellParent *parent,
GailCell *cell,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type
);
void gail_cell_parent_get_cell_area (GailCellParent *parent,
GailCell *cell,
GdkRectangle *cell_rect);
gboolean gail_cell_parent_grab_focus (GailCellParent *parent,
GailCell *cell);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CELL_PARENT_H__ */

View File

@ -0,0 +1,166 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailcheckmenuitem.h"
#include "gailchecksubmenuitem.h"
static void gail_check_menu_item_class_init (GailCheckMenuItemClass *klass);
static void gail_check_menu_item_toggled_gtk (GtkWidget *widget);
static void gail_check_menu_item_real_notify_gtk (GObject *obj,
GParamSpec *pspec);
static void gail_check_menu_item_real_initialize (AtkObject *obj,
gpointer data);
static AtkStateSet* gail_check_menu_item_ref_state_set (AtkObject *accessible);
static GailMenuItemClass *parent_class = NULL;
GType
gail_check_menu_item_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCheckMenuItemClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_check_menu_item_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCheckMenuItem), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_MENU_ITEM,
"GailCheckMenuItem", &tinfo, 0);
}
return type;
}
static void
gail_check_menu_item_class_init (GailCheckMenuItemClass *klass)
{
GailWidgetClass *widget_class;
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gail_check_menu_item_real_notify_gtk;
parent_class = g_type_class_peek_parent (klass);
class->ref_state_set = gail_check_menu_item_ref_state_set;
class->initialize = gail_check_menu_item_real_initialize;
}
AtkObject*
gail_check_menu_item_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (widget), NULL);
if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)))
return gail_check_sub_menu_item_new (widget);
object = g_object_new (GAIL_TYPE_CHECK_MENU_ITEM, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_check_menu_item_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
g_signal_connect (data,
"toggled",
G_CALLBACK (gail_check_menu_item_toggled_gtk),
NULL);
obj->role = ATK_ROLE_CHECK_MENU_ITEM;
}
static void
gail_check_menu_item_toggled_gtk (GtkWidget *widget)
{
AtkObject *accessible;
GtkCheckMenuItem *check_menu_item;
check_menu_item = GTK_CHECK_MENU_ITEM (widget);
accessible = gtk_widget_get_accessible (widget);
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED,
check_menu_item->active);
}
static AtkStateSet*
gail_check_menu_item_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkCheckMenuItem *check_menu_item;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
return state_set;
check_menu_item = GTK_CHECK_MENU_ITEM (widget);
if (gtk_check_menu_item_get_active (check_menu_item))
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
if (gtk_check_menu_item_get_inconsistent (check_menu_item))
atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
return state_set;
}
static void
gail_check_menu_item_real_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (obj);
AtkObject *atk_obj;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (check_menu_item));
if (strcmp (pspec->name, "inconsistent") == 0)
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED,
!gtk_check_menu_item_get_inconsistent (check_menu_item));
else
GAIL_WIDGET_CLASS (parent_class)->notify_gtk (obj, pspec);
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CHECK_MENU_ITEM_H__
#define __GAIL_CHECK_MENU_ITEM_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailmenuitem.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CHECK_MENU_ITEM (gail_check_menu_item_get_type ())
#define GAIL_CHECK_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItem))
#define GAIL_CHECK_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItemClass))
#define GAIL_IS_CHECK_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CHECK_MENU_ITEM))
#define GAIL_IS_CHECK_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CHECK_MENU_ITEM))
#define GAIL_CHECK_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItemClass))
typedef struct _GailCheckMenuItem GailCheckMenuItem;
typedef struct _GailCheckMenuItemClass GailCheckMenuItemClass;
struct _GailCheckMenuItem
{
GailMenuItem parent;
};
GType gail_check_menu_item_get_type (void);
struct _GailCheckMenuItemClass
{
GailMenuItemClass parent_class;
};
AtkObject* gail_check_menu_item_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CHECK_MENU_ITEM_H__ */

View File

@ -0,0 +1,162 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailchecksubmenuitem.h"
static void gail_check_sub_menu_item_class_init (GailCheckSubMenuItemClass *klass);
static void gail_check_sub_menu_item_toggled_gtk (GtkWidget *widget);
static void gail_check_sub_menu_item_real_notify_gtk (GObject *obj,
GParamSpec *pspec);
static void gail_check_sub_menu_item_real_initialize (AtkObject *obj,
gpointer data);
static AtkStateSet* gail_check_sub_menu_item_ref_state_set (AtkObject *accessible);
static GailSubMenuItemClass *parent_class = NULL;
GType
gail_check_sub_menu_item_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCheckSubMenuItemClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_check_sub_menu_item_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCheckSubMenuItem), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_SUB_MENU_ITEM,
"GailCheckSubMenuItem", &tinfo, 0);
}
return type;
}
static void
gail_check_sub_menu_item_class_init (GailCheckSubMenuItemClass *klass)
{
GailWidgetClass *widget_class;
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gail_check_sub_menu_item_real_notify_gtk;
parent_class = g_type_class_peek_parent (klass);
class->ref_state_set = gail_check_sub_menu_item_ref_state_set;
class->initialize = gail_check_sub_menu_item_real_initialize;
}
AtkObject*
gail_check_sub_menu_item_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (widget), NULL);
object = g_object_new (GAIL_TYPE_CHECK_SUB_MENU_ITEM, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_check_sub_menu_item_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
g_signal_connect (data,
"toggled",
G_CALLBACK (gail_check_sub_menu_item_toggled_gtk),
NULL);
obj->role = ATK_ROLE_CHECK_MENU_ITEM;
}
static void
gail_check_sub_menu_item_toggled_gtk (GtkWidget *widget)
{
AtkObject *accessible;
GtkCheckMenuItem *check_menu_item;
check_menu_item = GTK_CHECK_MENU_ITEM (widget);
accessible = gtk_widget_get_accessible (widget);
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED,
check_menu_item->active);
}
static AtkStateSet*
gail_check_sub_menu_item_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkCheckMenuItem *check_menu_item;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
return state_set;
check_menu_item = GTK_CHECK_MENU_ITEM (widget);
if (gtk_check_menu_item_get_active (check_menu_item))
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
if (gtk_check_menu_item_get_inconsistent (check_menu_item))
atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
return state_set;
}
static void
gail_check_sub_menu_item_real_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (obj);
AtkObject *atk_obj;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (check_menu_item));
if (strcmp (pspec->name, "inconsistent") == 0)
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED,
!gtk_check_menu_item_get_inconsistent (check_menu_item));
else
GAIL_WIDGET_CLASS (parent_class)->notify_gtk (obj, pspec);
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CHECK_SUB_MENU_ITEM_H__
#define __GAIL_CHECK_SUB_MENU_ITEM_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailsubmenuitem.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CHECK_SUB_MENU_ITEM (gail_check_sub_menu_item_get_type ())
#define GAIL_CHECK_SUB_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CHECK_SUB_MENU_ITEM, GailCheckSubMenuItem))
#define GAIL_CHECK_SUB_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CHECK_SUB_MENU_ITEM, GailCheckSubMenuItemClass))
#define GAIL_IS_CHECK_SUB_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CHECK_SUB_MENU_ITEM))
#define GAIL_IS_CHECK_SUB_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CHECK_SUB_MENU_ITEM))
#define GAIL_CHECK_SUB_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CHECK_SUB_MENU_ITEM, GailCheckSubMenuItemClass))
typedef struct _GailCheckSubMenuItem GailCheckSubMenuItem;
typedef struct _GailCheckSubMenuItemClass GailCheckSubMenuItemClass;
struct _GailCheckSubMenuItem
{
GailSubMenuItem parent;
};
GType gail_check_sub_menu_item_get_type (void);
struct _GailCheckSubMenuItemClass
{
GailSubMenuItemClass parent_class;
};
AtkObject* gail_check_sub_menu_item_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CHECK_SUB_MENU_ITEM_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CLIST_H__
#define __GAIL_CLIST_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CLIST (gail_clist_get_type ())
#define GAIL_CLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CLIST, GailCList))
#define GAIL_CLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CLIST, GailCListClass))
#define GAIL_IS_CLIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CLIST))
#define GAIL_IS_CLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CLIST))
#define GAIL_CLIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CLIST, GailCListClass))
typedef struct _GailCList GailCList;
typedef struct _GailCListClass GailCListClass;
typedef struct _GailCListColumn GailCListColumn;
struct _GailCList
{
GailContainer parent;
AtkObject* caption;
AtkObject* summary;
/* dynamically allocated array of column structures */
GailCListColumn *columns;
/* private */
gint n_cols;
GArray *row_data;
GList *cell_data;
AtkObject *previous_selected_cell;
};
GType gail_clist_get_type (void);
struct _GailCListClass
{
GailContainerClass parent_class;
};
AtkObject* gail_clist_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CLIST_H__ */

View File

@ -0,0 +1,121 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailclistcell.h"
static void gail_clist_cell_class_init (GailCListCellClass *klass);
static G_CONST_RETURN gchar* gail_clist_cell_get_name (AtkObject *accessible);
GType
gail_clist_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCListCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_clist_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCListCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_CELL,
"GailCListCell", &tinfo, 0);
}
return type;
}
static void
gail_clist_cell_class_init (GailCListCellClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gail_clist_cell_get_name;
}
AtkObject*
gail_clist_cell_new (void)
{
GObject *object;
AtkObject *atk_object;
object = g_object_new (GAIL_TYPE_CLIST_CELL, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
g_return_val_if_fail (!ATK_IS_TEXT (atk_object), NULL);
return atk_object;
}
static G_CONST_RETURN gchar*
gail_clist_cell_get_name (AtkObject *accessible)
{
if (accessible->name)
return accessible->name;
else
{
/*
* Get the cell's text if it exists
*/
GailCell *cell = GAIL_CELL (accessible);
GtkWidget* widget = cell->widget;
GtkCellType cell_type;
GtkCList *clist;
gchar *text = NULL;
gint row, column;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
clist = GTK_CLIST (widget);
g_return_val_if_fail (clist->columns, NULL);
row = cell->index / clist->columns;
column = cell->index % clist->columns;
cell_type = gtk_clist_get_cell_type (clist, row, column);
switch (cell_type)
{
case GTK_CELL_TEXT:
gtk_clist_get_text (clist, row, column, &text);
break;
case GTK_CELL_PIXTEXT:
gtk_clist_get_pixtext (clist, row, column, &text, NULL, NULL, NULL);
break;
default:
break;
}
return text;
}
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CLIST_CELL_H__
#define __GAIL_CLIST_CELL_H__
#include <atk/atk.h>
#include <gail/gailcell.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CLIST_CELL (gail_clist_cell_get_type ())
#define GAIL_CLIST_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CLIST_CELL, GailCListCell))
#define GAIL_CLIST_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CLIST_CELL, GailCListCellClass))
#define GAIL_IS_CLIST_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CLIST_CELL))
#define GAIL_IS_CLIST_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CLIST_CELL))
#define GAIL_CLIST_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CLIST_CELL, GailCListCellClass))
typedef struct _GailCListCell GailCListCell;
typedef struct _GailCListCellClass GailCListCellClass;
struct _GailCListCell
{
GailCell parent;
};
GType gail_clist_cell_get_type (void);
struct _GailCListCellClass
{
GailCellClass parent_class;
};
AtkObject *gail_clist_cell_new (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CLIST_CELL_H__ */

View File

@ -0,0 +1,714 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailcombo.h"
static void gail_combo_class_init (GailComboClass *klass);
static void gail_combo_object_init (GailCombo *combo);
static void gail_combo_real_initialize (AtkObject *obj,
gpointer data);
static void gail_combo_selection_changed_gtk (GtkWidget *widget,
gpointer data);
static gint gail_combo_get_n_children (AtkObject *obj);
static AtkObject* gail_combo_ref_child (AtkObject *obj,
gint i);
static void gail_combo_finalize (GObject *object);
static void atk_action_interface_init (AtkActionIface *iface);
static gboolean gail_combo_do_action (AtkAction *action,
gint i);
static gboolean idle_do_action (gpointer data);
static gint gail_combo_get_n_actions (AtkAction *action)
;
static G_CONST_RETURN gchar* gail_combo_get_description(AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_combo_get_name (AtkAction *action,
gint i);
static gboolean gail_combo_set_description(AtkAction *action,
gint i,
const gchar *desc);
static void atk_selection_interface_init (AtkSelectionIface *iface);
static gboolean gail_combo_add_selection (AtkSelection *selection,
gint i);
static gboolean gail_combo_clear_selection (AtkSelection *selection);
static AtkObject* gail_combo_ref_selection (AtkSelection *selection,
gint i);
static gint gail_combo_get_selection_count (AtkSelection *selection);
static gboolean gail_combo_is_child_selected (AtkSelection *selection,
gint i);
static gboolean gail_combo_remove_selection (AtkSelection *selection,
gint i);
static gint _gail_combo_button_release (gpointer data);
static gint _gail_combo_popup_release (gpointer data);
static gpointer parent_class = NULL;
GType
gail_combo_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailComboClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_combo_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCombo), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_combo_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_selection_info =
{
(GInterfaceInitFunc) atk_selection_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailCombo", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
g_type_add_interface_static (type, ATK_TYPE_SELECTION,
&atk_selection_info);
}
return type;
}
static void
gail_combo_class_init (GailComboClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = gail_combo_finalize;
parent_class = g_type_class_peek_parent (klass);
class->get_n_children = gail_combo_get_n_children;
class->ref_child = gail_combo_ref_child;
class->initialize = gail_combo_real_initialize;
}
static void
gail_combo_object_init (GailCombo *combo)
{
combo->press_description = NULL;
combo->old_selection = NULL;
combo->deselect_idle_handler = 0;
combo->select_idle_handler = 0;
}
AtkObject*
gail_combo_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_COMBO (widget), NULL);
object = g_object_new (GAIL_TYPE_COMBO, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_combo_real_initialize (AtkObject *obj,
gpointer data)
{
GtkCombo *combo;
GtkList *list;
GList *slist;
GailCombo *gail_combo;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
combo = GTK_COMBO (data);
list = GTK_LIST (combo->list);
slist = list->selection;
gail_combo = GAIL_COMBO (obj);
if (slist && slist->data)
{
gail_combo->old_selection = slist->data;
}
g_signal_connect (combo->list,
"selection_changed",
G_CALLBACK (gail_combo_selection_changed_gtk),
data);
atk_object_set_parent (gtk_widget_get_accessible (combo->entry), obj);
atk_object_set_parent (gtk_widget_get_accessible (combo->popup), obj);
obj->role = ATK_ROLE_COMBO_BOX;
}
static gboolean
notify_deselect (gpointer data)
{
GailCombo *combo;
GDK_THREADS_ENTER ();
combo = GAIL_COMBO (data);
combo->old_selection = NULL;
combo->deselect_idle_handler = 0;
g_signal_emit_by_name (data, "selection_changed");
GDK_THREADS_LEAVE ();
return FALSE;
}
static gboolean
notify_select (gpointer data)
{
GailCombo *combo;
GDK_THREADS_ENTER ();
combo = GAIL_COMBO (data);
combo->select_idle_handler = 0;
g_signal_emit_by_name (data, "selection_changed");
GDK_THREADS_LEAVE ();
return FALSE;
}
static void
gail_combo_selection_changed_gtk (GtkWidget *widget,
gpointer data)
{
GtkCombo *combo;
GtkList *list;
GList *slist;
AtkObject *obj;
GailCombo *gail_combo;
combo = GTK_COMBO (data);
list = GTK_LIST (combo->list);
slist = list->selection;
obj = gtk_widget_get_accessible (GTK_WIDGET (data));
gail_combo = GAIL_COMBO (obj);
if (slist && slist->data)
{
if (slist->data != gail_combo->old_selection)
{
gail_combo->old_selection = slist->data;
if (gail_combo->select_idle_handler == 0)
gail_combo->select_idle_handler = g_idle_add (notify_select, gail_combo);
}
if (gail_combo->deselect_idle_handler)
{
g_source_remove (gail_combo->deselect_idle_handler);
gail_combo->deselect_idle_handler = 0;
}
}
else
{
if (gail_combo->deselect_idle_handler == 0)
gail_combo->deselect_idle_handler = g_idle_add (notify_deselect, gail_combo);
if (gail_combo->select_idle_handler)
{
g_source_remove (gail_combo->select_idle_handler);
gail_combo->select_idle_handler = 0;
}
}
}
/*
* The children of a GailCombo are the list of items and the entry field
*/
static gint
gail_combo_get_n_children (AtkObject* obj)
{
gint n_children = 2;
GtkWidget *widget;
g_return_val_if_fail (GAIL_IS_COMBO (obj), 0);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
return n_children;
}
static AtkObject*
gail_combo_ref_child (AtkObject *obj,
gint i)
{
AtkObject *accessible;
GtkWidget *widget;
g_return_val_if_fail (GAIL_IS_COMBO (obj), NULL);
if (i < 0 || i > 1)
return NULL;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
if (i == 0)
accessible = gtk_widget_get_accessible (GTK_COMBO (widget)->popup);
else
accessible = gtk_widget_get_accessible (GTK_COMBO (widget)->entry);
g_object_ref (accessible);
return accessible;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->do_action = gail_combo_do_action;
iface->get_n_actions = gail_combo_get_n_actions;
iface->get_description = gail_combo_get_description;
iface->get_name = gail_combo_get_name;
iface->set_description = gail_combo_set_description;
}
static gboolean
gail_combo_do_action (AtkAction *action,
gint i)
{
GailCombo *combo;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (action)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
if (!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
return FALSE;
combo = GAIL_COMBO (action);
if (i == 0)
{
if (combo->action_idle_handler)
return FALSE;
combo->action_idle_handler = g_idle_add (idle_do_action, combo);
return TRUE;
}
else
return FALSE;
}
/*
* This action is the pressing of the button on the combo box.
* The behavior is different depending on whether the list is being
* displayed or removed.
*
* A button press event is simulated on the appropriate widget and
* a button release event is simulated in an idle function.
*/
static gboolean
idle_do_action (gpointer data)
{
GtkCombo *combo;
GtkWidget *action_widget;
GtkWidget *widget;
GailCombo *gail_combo;
gboolean do_popup;
GdkEvent tmp_event;
GDK_THREADS_ENTER ();
gail_combo = GAIL_COMBO (data);
gail_combo->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_combo)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
combo = GTK_COMBO (widget);
do_popup = !GTK_WIDGET_MAPPED (combo->popwin);
tmp_event.button.type = GDK_BUTTON_PRESS;
tmp_event.button.window = widget->window;
tmp_event.button.button = 1;
tmp_event.button.send_event = TRUE;
tmp_event.button.time = GDK_CURRENT_TIME;
tmp_event.button.axes = NULL;
if (do_popup)
{
/* Pop up list */
action_widget = combo->button;
gtk_widget_event (action_widget, &tmp_event);
g_idle_add (_gail_combo_button_release, combo);
}
else
{
/* Pop down list */
tmp_event.button.window = combo->list->window;
gdk_window_set_user_data (combo->list->window, combo->button);
action_widget = combo->popwin;
gtk_widget_event (action_widget, &tmp_event);
g_idle_add (_gail_combo_popup_release, combo);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
gail_combo_get_n_actions (AtkAction *action)
{
/*
* The default behavior of a combo box is to have one action -
*/
return 1;
}
static G_CONST_RETURN gchar*
gail_combo_get_description (AtkAction *action,
gint i)
{
if (i == 0)
{
GailCombo *combo;
combo = GAIL_COMBO (action);
return combo->press_description;
}
else
return NULL;
}
static G_CONST_RETURN gchar*
gail_combo_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "press";
else
return NULL;
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->add_selection = gail_combo_add_selection;
iface->clear_selection = gail_combo_clear_selection;
iface->ref_selection = gail_combo_ref_selection;
iface->get_selection_count = gail_combo_get_selection_count;
iface->is_child_selected = gail_combo_is_child_selected;
iface->remove_selection = gail_combo_remove_selection;
/*
* select_all_selection does not make sense for a combo box
* so no implementation is provided.
*/
}
static gboolean
gail_combo_add_selection (AtkSelection *selection,
gint i)
{
GtkCombo *combo;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
combo = GTK_COMBO (widget);
gtk_list_select_item (GTK_LIST (combo->list), i);
return TRUE;
}
static gboolean
gail_combo_clear_selection (AtkSelection *selection)
{
GtkCombo *combo;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
combo = GTK_COMBO (widget);
gtk_list_unselect_all (GTK_LIST (combo->list));
return TRUE;
}
static AtkObject*
gail_combo_ref_selection (AtkSelection *selection,
gint i)
{
GtkCombo *combo;
GList * list;
GtkWidget *item;
AtkObject *obj;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
combo = GTK_COMBO (widget);
/*
* A combo box can have only one selection.
*/
if (i != 0)
return NULL;
list = GTK_LIST (combo->list)->selection;
if (list == NULL)
return NULL;
item = GTK_WIDGET (list->data);
obj = gtk_widget_get_accessible (item);
g_object_ref (obj);
return obj;
}
static gint
gail_combo_get_selection_count (AtkSelection *selection)
{
GtkCombo *combo;
GList * list;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
combo = GTK_COMBO (widget);
/*
* The number of children currently selected is either 1 or 0 so we
* do not bother to count the elements of the selected list.
*/
list = GTK_LIST (combo->list)->selection;
if (list == NULL)
return 0;
else
return 1;
}
static gboolean
gail_combo_is_child_selected (AtkSelection *selection,
gint i)
{
GtkCombo *combo;
GList * list;
GtkWidget *item;
gint j;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
combo = GTK_COMBO (widget);
list = GTK_LIST (combo->list)->selection;
if (list == NULL)
return FALSE;
item = GTK_WIDGET (list->data);
j = g_list_index (GTK_LIST (combo->list)->children, item);
return (j == i);
}
static gboolean
gail_combo_remove_selection (AtkSelection *selection,
gint i)
{
if (atk_selection_is_child_selected (selection, i))
atk_selection_clear_selection (selection);
return TRUE;
}
static gint
_gail_combo_popup_release (gpointer data)
{
GtkCombo *combo;
GtkWidget *action_widget;
GdkEvent tmp_event;
GDK_THREADS_ENTER ();
combo = GTK_COMBO (data);
if (combo->current_button == 0)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
tmp_event.button.type = GDK_BUTTON_RELEASE;
tmp_event.button.button = 1;
tmp_event.button.time = GDK_CURRENT_TIME;
action_widget = combo->button;
gtk_widget_event (action_widget, &tmp_event);
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
_gail_combo_button_release (gpointer data)
{
GtkCombo *combo;
GtkWidget *action_widget;
GdkEvent tmp_event;
GDK_THREADS_ENTER ();
combo = GTK_COMBO (data);
if (combo->current_button == 0)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
tmp_event.button.type = GDK_BUTTON_RELEASE;
tmp_event.button.button = 1;
tmp_event.button.window = combo->list->window;
tmp_event.button.time = GDK_CURRENT_TIME;
gdk_window_set_user_data (combo->list->window, combo->button);
action_widget = combo->list;
gtk_widget_event (action_widget, &tmp_event);
GDK_THREADS_LEAVE ();
return FALSE;
}
static gboolean
gail_combo_set_description (AtkAction *action,
gint i,
const gchar *desc)
{
if (i == 0)
{
GailCombo *combo;
combo = GAIL_COMBO (action);
g_free (combo->press_description);
combo->press_description = g_strdup (desc);
return TRUE;
}
else
return FALSE;
}
static void
gail_combo_finalize (GObject *object)
{
GailCombo *combo = GAIL_COMBO (object);
g_free (combo->press_description);
if (combo->action_idle_handler)
{
g_source_remove (combo->action_idle_handler);
combo->action_idle_handler = 0;
}
if (combo->deselect_idle_handler)
{
g_source_remove (combo->deselect_idle_handler);
combo->deselect_idle_handler = 0;
}
if (combo->select_idle_handler)
{
g_source_remove (combo->select_idle_handler);
combo->select_idle_handler = 0;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,67 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_COMBO_H__
#define __GAIL_COMBO_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_COMBO (gail_combo_get_type ())
#define GAIL_COMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_COMBO, GailCombo))
#define GAIL_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_COMBO, GailComboClass))
#define GAIL_IS_COMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_COMBO))
#define GAIL_IS_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_COMBO))
#define GAIL_COMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_COMBO, GailComboClass))
typedef struct _GailCombo GailCombo;
typedef struct _GailComboClass GailComboClass;
struct _GailCombo
{
GailContainer parent;
gchar *press_description;
guint action_idle_handler;
gpointer old_selection;
guint select_idle_handler;
guint deselect_idle_handler;
};
GType gail_combo_get_type (void);
struct _GailComboClass
{
GailContainerClass parent_class;
};
AtkObject* gail_combo_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_COMBO_H__ */

View File

@ -0,0 +1,686 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2004 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "gailcombobox.h"
#if GTK_MINOR_VERSION > 4
#define GAIL_COMBOX_BOX_A11y_COMPLETE
#endif
static void gail_combo_box_class_init (GailComboBoxClass *klass);
static void gail_combo_box_object_init (GailComboBox *combo_box);
static void gail_combo_box_real_initialize (AtkObject *obj,
gpointer data);
static void gail_combo_box_changed_gtk (GtkWidget *widget);
static G_CONST_RETURN gchar* gail_combo_box_get_name (AtkObject *obj);
static gint gail_combo_box_get_n_children (AtkObject *obj);
static AtkObject* gail_combo_box_ref_child (AtkObject *obj,
gint i);
static void gail_combo_box_finalize (GObject *object);
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
static void atk_action_interface_init (AtkActionIface *iface);
static gboolean gail_combo_box_do_action (AtkAction *action,
gint i);
static gboolean idle_do_action (gpointer data);
static gint gail_combo_box_get_n_actions (AtkAction *action)
;
static G_CONST_RETURN gchar* gail_combo_box_get_description(AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_combo_box_get_keybinding (AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_combo_box_action_get_name(AtkAction *action,
gint i);
static gboolean gail_combo_box_set_description(AtkAction *action,
gint i,
const gchar *desc);
#endif
static void atk_selection_interface_init (AtkSelectionIface *iface);
static gboolean gail_combo_box_add_selection (AtkSelection *selection,
gint i);
static gboolean gail_combo_box_clear_selection (AtkSelection *selection);
static AtkObject* gail_combo_box_ref_selection (AtkSelection *selection,
gint i);
static gint gail_combo_box_get_selection_count (AtkSelection *selection);
static gboolean gail_combo_box_is_child_selected (AtkSelection *selection,
gint i);
static gboolean gail_combo_box_remove_selection (AtkSelection *selection,
gint i);
static gpointer parent_class = NULL;
GType
gail_combo_box_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailComboBoxClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_combo_box_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailComboBox), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_combo_box_object_init, /* instance init */
NULL /* value table */
};
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
#endif
static const GInterfaceInfo atk_selection_info =
{
(GInterfaceInitFunc) atk_selection_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailComboBox", &tinfo, 0);
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
#endif
g_type_add_interface_static (type, ATK_TYPE_SELECTION,
&atk_selection_info);
}
return type;
}
static void
gail_combo_box_class_init (GailComboBoxClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = gail_combo_box_finalize;
parent_class = g_type_class_peek_parent (klass);
class->get_name = gail_combo_box_get_name;
class->get_n_children = gail_combo_box_get_n_children;
class->ref_child = gail_combo_box_ref_child;
class->initialize = gail_combo_box_real_initialize;
}
static void
gail_combo_box_object_init (GailComboBox *combo_box)
{
combo_box->press_description = NULL;
combo_box->press_keybinding = NULL;
combo_box->old_selection = -1;
combo_box->name = NULL;
combo_box->popup_set = FALSE;
}
AtkObject*
gail_combo_box_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_COMBO_BOX (widget), NULL);
object = g_object_new (GAIL_TYPE_COMBO_BOX, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_combo_box_real_initialize (AtkObject *obj,
gpointer data)
{
GtkComboBox *combo_box;
GailComboBox *gail_combo_box;
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
AtkObject *popup;
#endif
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
combo_box = GTK_COMBO_BOX (data);
gail_combo_box = GAIL_COMBO_BOX (obj);
g_signal_connect (combo_box,
"changed",
G_CALLBACK (gail_combo_box_changed_gtk),
NULL);
gail_combo_box->old_selection = gtk_combo_box_get_active (combo_box);
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
popup = gtk_combo_box_get_popup_accessible (combo_box);
if (popup)
{
atk_object_set_parent (popup, obj);
gail_combo_box->popup_set = TRUE;
}
if (GTK_IS_COMBO_BOX_ENTRY (combo_box))
atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj);
#endif
obj->role = ATK_ROLE_COMBO_BOX;
}
static void
gail_combo_box_changed_gtk (GtkWidget *widget)
{
GtkComboBox *combo_box;
AtkObject *obj;
GailComboBox *gail_combo_box;
gint index;
combo_box = GTK_COMBO_BOX (widget);
index = gtk_combo_box_get_active (combo_box);
obj = gtk_widget_get_accessible (widget);
gail_combo_box = GAIL_COMBO_BOX (obj);
if (gail_combo_box->old_selection != index)
{
gail_combo_box->old_selection = index;
g_signal_emit_by_name (obj, "selection_changed");
}
}
static G_CONST_RETURN gchar*
gail_combo_box_get_name (AtkObject *obj)
{
GtkWidget *widget;
GtkComboBox *combo_box;
GailComboBox *gail_combo_box;
GtkTreeIter iter;
G_CONST_RETURN gchar *name;
GtkTreeModel *model;
gint n_columns;
gint i;
g_return_val_if_fail (GAIL_IS_COMBO_BOX (obj), NULL);
name = ATK_OBJECT_CLASS (parent_class)->get_name (obj);
if (name)
return name;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
combo_box = GTK_COMBO_BOX (widget);
gail_combo_box = GAIL_COMBO_BOX (obj);
if (gtk_combo_box_get_active_iter (combo_box, &iter))
{
model = gtk_combo_box_get_model (combo_box);
n_columns = gtk_tree_model_get_n_columns (model);
for (i = 0; i < n_columns; i++)
{
GValue value = { 0, };
gtk_tree_model_get_value (model, &iter, i, &value);
if (G_VALUE_HOLDS_STRING (&value))
{
if (gail_combo_box->name) g_free (gail_combo_box->name);
gail_combo_box->name = g_strdup ((gchar *)
g_value_get_string (&value));
g_value_unset (&value);
break;
}
else
g_value_unset (&value);
}
}
return gail_combo_box->name;
}
/*
* The children of a GailComboBox are the list of items and the entry field
* if it is editable.
*/
static gint
gail_combo_box_get_n_children (AtkObject* obj)
{
gint n_children = 0;
GtkWidget *widget;
g_return_val_if_fail (GAIL_IS_COMBO_BOX (obj), 0);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
n_children++;
if (GTK_IS_COMBO_BOX_ENTRY (widget))
n_children ++;
#endif
return n_children;
}
static AtkObject*
gail_combo_box_ref_child (AtkObject *obj,
gint i)
{
GtkWidget *widget;
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
AtkObject *child;
GailComboBox *box;
#endif
g_return_val_if_fail (GAIL_IS_COMBO_BOX (obj), NULL);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
if (i == 0)
{
child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget));
box = GAIL_COMBO_BOX (obj);
if (box->popup_set == FALSE)
{
atk_object_set_parent (child, obj);
box->popup_set = TRUE;
}
}
else if (i == 1 && GTK_IS_COMBO_BOX_ENTRY (widget))
{
child = gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (widget)));
}
else
{
return NULL;
}
return g_object_ref (child);
#else
return NULL;
#endif
}
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
static void
atk_action_interface_init (AtkActionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->do_action = gail_combo_box_do_action;
iface->get_n_actions = gail_combo_box_get_n_actions;
iface->get_description = gail_combo_box_get_description;
iface->get_keybinding = gail_combo_box_get_keybinding;
iface->get_name = gail_combo_box_action_get_name;
iface->set_description = gail_combo_box_set_description;
}
static gboolean
gail_combo_box_do_action (AtkAction *action,
gint i)
{
GailComboBox *combo_box;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (action)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
if (!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
return FALSE;
combo_box = GAIL_COMBO_BOX (action);
if (i == 0)
{
if (combo_box->action_idle_handler)
return FALSE;
combo_box->action_idle_handler = g_idle_add (idle_do_action, combo_box);
return TRUE;
}
else
return FALSE;
}
static gboolean
idle_do_action (gpointer data)
{
GtkComboBox *combo_box;
GtkWidget *widget;
GailComboBox *gail_combo_box;
AtkObject *popup;
gboolean do_popup;
GDK_THREADS_ENTER ();
gail_combo_box = GAIL_COMBO_BOX (data);
gail_combo_box->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_combo_box)->widget;
if (widget == NULL || /* State is defunct */
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
combo_box = GTK_COMBO_BOX (widget);
popup = gtk_combo_box_get_popup_accessible (combo_box);
do_popup = !GTK_WIDGET_MAPPED (GTK_ACCESSIBLE (popup)->widget);
if (do_popup)
gtk_combo_box_popup (combo_box);
else
gtk_combo_box_popdown (combo_box);
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
gail_combo_box_get_n_actions (AtkAction *action)
{
/*
* The default behavior of a combo_box box is to have one action -
*/
return 1;
}
static G_CONST_RETURN gchar*
gail_combo_box_get_description (AtkAction *action,
gint i)
{
if (i == 0)
{
GailComboBox *combo_box;
combo_box = GAIL_COMBO_BOX (action);
return combo_box->press_description;
}
else
return NULL;
}
static G_CONST_RETURN gchar*
gail_combo_box_get_keybinding (AtkAction *action,
gint i)
{
GailComboBox *combo_box;
gchar *return_value = NULL;
combo_box = GAIL_COMBO_BOX (action);
switch (i)
{
case 0:
{
GtkWidget *widget;
GtkWidget *label;
AtkRelationSet *set;
AtkRelation *relation;
GPtrArray *target;
gpointer target_object;
guint key_val;
combo_box = GAIL_COMBO_BOX (action);
widget = GTK_ACCESSIBLE (combo_box)->widget;
if (widget == NULL)
return NULL;
set = atk_object_ref_relation_set (ATK_OBJECT (action));
if (!set)
return NULL;
label = NULL;
relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
if (relation)
{
target = atk_relation_get_target (relation);
target_object = g_ptr_array_index (target, 0);
if (GTK_IS_ACCESSIBLE (target_object))
{
label = GTK_ACCESSIBLE (target_object)->widget;
}
}
g_object_unref (set);
if (GTK_IS_LABEL (label))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_VoidSymbol)
return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
}
g_free (combo_box->press_keybinding);
combo_box->press_keybinding = return_value;
break; }
default:
break;
}
return return_value;
}
static G_CONST_RETURN gchar*
gail_combo_box_action_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "press";
else
return NULL;
}
static gboolean
gail_combo_box_set_description (AtkAction *action,
gint i,
const gchar *desc)
{
if (i == 0)
{
GailComboBox *combo_box;
combo_box = GAIL_COMBO_BOX (action);
g_free (combo_box->press_description);
combo_box->press_description = g_strdup (desc);
return TRUE;
}
else
return FALSE;
}
#endif
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->add_selection = gail_combo_box_add_selection;
iface->clear_selection = gail_combo_box_clear_selection;
iface->ref_selection = gail_combo_box_ref_selection;
iface->get_selection_count = gail_combo_box_get_selection_count;
iface->is_child_selected = gail_combo_box_is_child_selected;
iface->remove_selection = gail_combo_box_remove_selection;
/*
* select_all_selection does not make sense for a combo_box
* so no implementation is provided.
*/
}
static gboolean
gail_combo_box_add_selection (AtkSelection *selection,
gint i)
{
GtkComboBox *combo_box;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
combo_box = GTK_COMBO_BOX (widget);
gtk_combo_box_set_active (combo_box, i);
return TRUE;
}
static gboolean
gail_combo_box_clear_selection (AtkSelection *selection)
{
GtkComboBox *combo_box;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
combo_box = GTK_COMBO_BOX (widget);
gtk_combo_box_set_active (combo_box, -1);
return TRUE;
}
static AtkObject*
gail_combo_box_ref_selection (AtkSelection *selection,
gint i)
{
GtkComboBox *combo_box;
GtkWidget *widget;
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
AtkObject *obj;
gint index;
#endif
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
combo_box = GTK_COMBO_BOX (widget);
/*
* A combo_box box can have only one selection.
*/
if (i != 0)
return NULL;
#ifdef GAIL_COMBOX_BOX_A11y_COMPLETE
obj = gtk_combo_box_get_popup_accessible (combo_box);
index = gtk_combo_box_get_active (combo_box);
return atk_object_ref_accessible_child (obj, index);
#else
return NULL;
#endif
}
static gint
gail_combo_box_get_selection_count (AtkSelection *selection)
{
GtkComboBox *combo_box;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
combo_box = GTK_COMBO_BOX (widget);
return (gtk_combo_box_get_active (combo_box) == -1) ? 0 : 1;
}
static gboolean
gail_combo_box_is_child_selected (AtkSelection *selection,
gint i)
{
GtkComboBox *combo_box;
gint j;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
combo_box = GTK_COMBO_BOX (widget);
j = gtk_combo_box_get_active (combo_box);
return (j == i);
}
static gboolean
gail_combo_box_remove_selection (AtkSelection *selection,
gint i)
{
if (atk_selection_is_child_selected (selection, i))
atk_selection_clear_selection (selection);
return TRUE;
}
static void
gail_combo_box_finalize (GObject *object)
{
GailComboBox *combo_box = GAIL_COMBO_BOX (object);
g_free (combo_box->press_description);
g_free (combo_box->press_keybinding);
g_free (combo_box->name);
if (combo_box->action_idle_handler)
{
g_source_remove (combo_box->action_idle_handler);
combo_box->action_idle_handler = 0;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,68 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2004 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_COMBO_BOX_H__
#define __GAIL_COMBO_BOX_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_COMBO_BOX (gail_combo_box_get_type ())
#define GAIL_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_COMBO_BOX, GailComboBox))
#define GAIL_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_COMBO_BOX, GailComboBoxClass))
#define GAIL_IS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_COMBO_BOX))
#define GAIL_IS_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_COMBO_BOX))
#define GAIL_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_COMBO_BOX, GailComboBoxClass))
typedef struct _GailComboBox GailComboBox;
typedef struct _GailComboBoxClass GailComboBoxClass;
struct _GailComboBox
{
GailContainer parent;
gchar *press_keybinding;
gchar *press_description;
guint action_idle_handler;
gchar *name;
gint old_selection;
gboolean popup_set;
};
GType gail_combo_box_get_type (void);
struct _GailComboBoxClass
{
GailContainerClass parent_class;
};
AtkObject* gail_combo_box_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_COMBO_BOX_H__ */

View File

@ -0,0 +1,298 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailcontainer.h"
static void gail_container_class_init (GailContainerClass *klass);
static void gail_container_object_init (GailContainer *container);
static gint gail_container_get_n_children (AtkObject *obj);
static AtkObject* gail_container_ref_child (AtkObject *obj,
gint i);
static gint gail_container_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static gint gail_container_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static gint gail_container_real_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static gint gail_container_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static void gail_container_real_initialize (AtkObject *obj,
gpointer data);
static void gail_container_finalize (GObject *object);
static GailWidgetClass *parent_class = NULL;
GType
gail_container_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailContainerClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_container_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailContainer), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_container_object_init, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailContainer", &tinfo, 0);
}
return type;
}
static void
gail_container_class_init (GailContainerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = gail_container_finalize;
class->get_n_children = gail_container_get_n_children;
class->ref_child = gail_container_ref_child;
class->initialize = gail_container_real_initialize;
klass->add_gtk = gail_container_real_add_gtk;
klass->remove_gtk = gail_container_real_remove_gtk;
}
static void
gail_container_object_init (GailContainer *container)
{
container->children = NULL;
}
AtkObject*
gail_container_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_CONTAINER (widget), NULL);
object = g_object_new (GAIL_TYPE_CONTAINER, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static gint
gail_container_get_n_children (AtkObject* obj)
{
GtkWidget *widget;
GList *children;
gint count = 0;
g_return_val_if_fail (GAIL_IS_CONTAINER (obj), count);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return 0;
children = gtk_container_get_children (GTK_CONTAINER(widget));
count = g_list_length (children);
g_list_free (children);
return count;
}
static AtkObject*
gail_container_ref_child (AtkObject *obj,
gint i)
{
GList *children, *tmp_list;
AtkObject *accessible;
GtkWidget *widget;
g_return_val_if_fail (GAIL_IS_CONTAINER (obj), NULL);
g_return_val_if_fail ((i >= 0), NULL);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return NULL;
children = gtk_container_get_children (GTK_CONTAINER (widget));
tmp_list = g_list_nth (children, i);
if (!tmp_list)
{
g_list_free (children);
return NULL;
}
accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
g_list_free (children);
g_object_ref (accessible);
return accessible;
}
static gint
gail_container_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
GailContainer *gail_container = GAIL_CONTAINER (data);
GailContainerClass *klass;
klass = GAIL_CONTAINER_GET_CLASS (gail_container);
if (klass->add_gtk)
return klass->add_gtk (container, widget, data);
else
return 1;
}
static gint
gail_container_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
GailContainer *gail_container = GAIL_CONTAINER (data);
GailContainerClass *klass;
klass = GAIL_CONTAINER_GET_CLASS (gail_container);
if (klass->remove_gtk)
return klass->remove_gtk (container, widget, data);
else
return 1;
}
static gint
gail_container_real_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
AtkObject* atk_parent = ATK_OBJECT (data);
AtkObject* atk_child = gtk_widget_get_accessible (widget);
GailContainer *gail_container = GAIL_CONTAINER (atk_parent);
gint index;
g_object_notify (G_OBJECT (atk_child), "accessible_parent");
g_list_free (gail_container->children);
gail_container->children = gtk_container_get_children (container);
index = g_list_index (gail_container->children, widget);
g_signal_emit_by_name (atk_parent, "children_changed::add",
index, atk_child, NULL);
return 1;
}
static gint
gail_container_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
AtkPropertyValues values = { NULL };
AtkObject* atk_parent;
AtkObject *atk_child;
GailContainer *gail_container;
gint index;
atk_parent = ATK_OBJECT (data);
atk_child = gtk_widget_get_accessible (widget);
if (atk_child)
{
g_value_init (&values.old_value, G_TYPE_POINTER);
g_value_set_pointer (&values.old_value, atk_parent);
values.property_name = "accessible-parent";
g_object_ref (atk_child);
g_signal_emit_by_name (atk_child,
"property_change::accessible-parent", &values, NULL);
g_object_unref (atk_child);
}
gail_container = GAIL_CONTAINER (atk_parent);
index = g_list_index (gail_container->children, widget);
g_list_free (gail_container->children);
gail_container->children = gtk_container_get_children (container);
if (index >= 0 && index <= g_list_length (gail_container->children))
g_signal_emit_by_name (atk_parent, "children_changed::remove",
index, atk_child, NULL);
return 1;
}
static void
gail_container_real_initialize (AtkObject *obj,
gpointer data)
{
GailContainer *container = GAIL_CONTAINER (obj);
guint handler_id;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
container->children = gtk_container_get_children (GTK_CONTAINER (data));
/*
* We store the handler ids for these signals in case some objects
* need to remove these handlers.
*/
handler_id = g_signal_connect (data,
"add",
G_CALLBACK (gail_container_add_gtk),
obj);
g_object_set_data (G_OBJECT (obj), "gail-add-handler-id",
GUINT_TO_POINTER (handler_id));
handler_id = g_signal_connect (data,
"remove",
G_CALLBACK (gail_container_remove_gtk),
obj);
g_object_set_data (G_OBJECT (obj), "gail-remove-handler-id",
GUINT_TO_POINTER (handler_id));
if (GTK_IS_TOOLBAR (data))
obj->role = ATK_ROLE_TOOL_BAR;
else if (GTK_IS_VIEWPORT (data))
obj->role = ATK_ROLE_VIEWPORT;
else
obj->role = ATK_ROLE_PANEL;
}
static void
gail_container_finalize (GObject *object)
{
GailContainer *container = GAIL_CONTAINER (object);
g_list_free (container->children);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,72 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CONTAINER_H__
#define __GAIL_CONTAINER_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CONTAINER (gail_container_get_type ())
#define GAIL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CONTAINER, GailContainer))
#define GAIL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CONTAINER, GailContainerClass))
#define GAIL_IS_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CONTAINER))
#define GAIL_IS_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CONTAINER))
#define GAIL_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CONTAINER, GailContainerClass))
typedef struct _GailContainer GailContainer;
typedef struct _GailContainerClass GailContainerClass;
struct _GailContainer
{
GailWidget parent;
/*
* Cached list of children
*/
GList *children;
};
GType gail_container_get_type (void);
struct _GailContainerClass
{
GailWidgetClass parent_class;
gint (*add_gtk) (GtkContainer *container,
GtkWidget *widget,
gpointer data);
gint (*remove_gtk) (GtkContainer *container,
GtkWidget *widget,
gpointer data);
};
AtkObject* gail_container_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_CONTAINER_H__ */

View File

@ -0,0 +1,202 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailcontainercell.h"
static void gail_container_cell_class_init (GailContainerCellClass *klass);
static void gail_container_cell_finalize (GObject *obj);
static void _gail_container_cell_recompute_child_indices
(GailContainerCell *container);
static void gail_container_cell_refresh_child_index (GailCell *cell);
static gint gail_container_cell_get_n_children (AtkObject *obj);
static AtkObject* gail_container_cell_ref_child (AtkObject *obj,
gint child);
static gpointer parent_class = NULL;
GType
gail_container_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailContainerCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_container_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailContainerCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_CELL,
"GailContainerCell", &tinfo, 0);
}
return type;
}
static void
gail_container_cell_class_init (GailContainerCellClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
g_object_class->finalize = gail_container_cell_finalize;
class->get_n_children = gail_container_cell_get_n_children;
class->ref_child = gail_container_cell_ref_child;
}
GailContainerCell *
gail_container_cell_new (void)
{
GObject *object;
AtkObject *atk_object;
GailContainerCell *container;
object = g_object_new (GAIL_TYPE_CONTAINER_CELL, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
container = GAIL_CONTAINER_CELL(object);
container->children = NULL;
container->NChildren = 0;
return container;
}
static void
gail_container_cell_finalize (GObject *obj)
{
GailContainerCell *container = GAIL_CONTAINER_CELL (obj);
GList *list;
list = container->children;
while (list)
{
g_object_unref (list->data);
list = list->next;
}
g_list_free (container->children);
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
void
gail_container_cell_add_child (GailContainerCell *container,
GailCell *child)
{
gint child_index;
g_return_if_fail (GAIL_IS_CONTAINER_CELL(container));
g_return_if_fail (GAIL_IS_CELL(child));
child_index = container->NChildren++;
container->children = g_list_append (container->children, (gpointer) child);
child->index = child_index;
atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
child->refresh_index = gail_container_cell_refresh_child_index;
}
void
gail_container_cell_remove_child (GailContainerCell *container,
GailCell *child)
{
g_return_if_fail (GAIL_IS_CONTAINER_CELL(container));
g_return_if_fail (GAIL_IS_CELL(child));
g_return_if_fail (container->NChildren > 0);
g_list_remove (container->children, (gpointer) child);
_gail_container_cell_recompute_child_indices (container);
container->NChildren--;
}
static void
_gail_container_cell_recompute_child_indices (GailContainerCell *container)
{
gint cur_index = 0;
GList *temp_list;
g_return_if_fail (GAIL_IS_CONTAINER_CELL(container));
for (temp_list = container->children; temp_list; temp_list = temp_list->next)
{
GAIL_CELL(temp_list->data)->index = cur_index;
cur_index++;
}
}
static void
gail_container_cell_refresh_child_index (GailCell *cell)
{
GailContainerCell *container;
g_return_if_fail (GAIL_IS_CELL(cell));
container = GAIL_CONTAINER_CELL (atk_object_get_parent (ATK_OBJECT(cell)));
g_return_if_fail (GAIL_IS_CONTAINER_CELL (container));
_gail_container_cell_recompute_child_indices (container);
}
static gint
gail_container_cell_get_n_children (AtkObject *obj)
{
GailContainerCell *cell;
g_return_val_if_fail (GAIL_IS_CONTAINER_CELL(obj), 0);
cell = GAIL_CONTAINER_CELL(obj);
return cell->NChildren;
}
static AtkObject *
gail_container_cell_ref_child (AtkObject *obj,
gint child)
{
GailContainerCell *cell;
GList *list_node;
g_return_val_if_fail (GAIL_IS_CONTAINER_CELL(obj), NULL);
cell = GAIL_CONTAINER_CELL(obj);
list_node = g_list_nth (cell->children, child);
if (!list_node)
return NULL;
return g_object_ref (ATK_OBJECT (list_node->data));
}

View File

@ -0,0 +1,71 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_CONTAINER_CELL_H__
#define __GAIL_CONTAINER_CELL_H__
#include <atk/atk.h>
#include <gail/gailcell.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_CONTAINER_CELL (gail_container_cell_get_type ())
#define GAIL_CONTAINER_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_CONTAINER_CELL, GailContainerCell))
#define GAIL_CONTAINER_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_CONTAINER_CELL, GailContainerCellClass))
#define GAIL_IS_CONTAINER_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_CONTAINER_CELL))
#define GAIL_IS_CONTAINER_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_CONTAINER_CELL))
#define GAIL_CONTAINER_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_CONTAINER_CELL, GailContainerCellClass))
typedef struct _GailContainerCell GailContainerCell;
typedef struct _GailContainerCellClass GailContainerCellClass;
struct _GailContainerCell
{
GailCell parent;
GList *children;
gint NChildren;
};
GType gail_container_cell_get_type (void);
struct _GailContainerCellClass
{
GailCellClass parent_class;
};
GailContainerCell *
gail_container_cell_new (void);
void
gail_container_cell_add_child (GailContainerCell *container,
GailCell *child);
void
gail_container_cell_remove_child (GailContainerCell *container,
GailCell *child);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_TREE_VIEW_TEXT_CELL_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_ENTRY_H__
#define __GAIL_ENTRY_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#include <libgail-util/gailtextutil.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_ENTRY (gail_entry_get_type ())
#define GAIL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_ENTRY, GailEntry))
#define GAIL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_ENTRY, GailEntryClass))
#define GAIL_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_ENTRY))
#define GAIL_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_ENTRY))
#define GAIL_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_ENTRY, GailEntryClass))
typedef struct _GailEntry GailEntry;
typedef struct _GailEntryClass GailEntryClass;
struct _GailEntry
{
GailWidget parent;
GailTextUtil *textutil;
/*
* These fields store information about text changed
*/
gchar *signal_name_insert;
gchar *signal_name_delete;
gint position_insert;
gint position_delete;
gint length_insert;
gint length_delete;
gint cursor_position;
gint selection_bound;
gchar *activate_description;
gchar *activate_keybinding;
guint action_idle_handler;
guint insert_idle_handler;
};
GType gail_entry_get_type (void);
struct _GailEntryClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_entry_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_ENTRY_H__ */

View File

@ -0,0 +1,950 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "gailexpander.h"
#include <libgail-util/gailmisc.h>
static void gail_expander_class_init (GailExpanderClass *klass);
static void gail_expander_object_init (GailExpander *expander);
static G_CONST_RETURN gchar* gail_expander_get_name (AtkObject *obj);
static gint gail_expander_get_n_children (AtkObject *obj)
;
static AtkObject* gail_expander_ref_child (AtkObject *obj,
gint i);
static AtkStateSet* gail_expander_ref_state_set (AtkObject *obj);
static void gail_expander_real_notify_gtk (GObject *obj,
GParamSpec *pspec);
static void gail_expander_map_gtk (GtkWidget *widget,
gpointer data);
static void gail_expander_real_initialize (AtkObject *obj,
gpointer data);
static void gail_expander_finalize (GObject *object);
static void gail_expander_init_textutil (GailExpander *expander,
GtkExpander *widget);
static void atk_action_interface_init (AtkActionIface *iface);
static gboolean gail_expander_do_action (AtkAction *action,
gint i);
static gboolean idle_do_action (gpointer data);
static gint gail_expander_get_n_actions(AtkAction *action);
static G_CONST_RETURN gchar* gail_expander_get_description
(AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_expander_get_keybinding
(AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_expander_action_get_name
(AtkAction *action,
gint i);
static gboolean gail_expander_set_description
(AtkAction *action,
gint i,
const gchar *desc);
/* atktext.h */
static void atk_text_interface_init (AtkTextIface *iface);
static gchar* gail_expander_get_text (AtkText *text,
gint start_pos,
gint end_pos);
static gunichar gail_expander_get_character_at_offset
(AtkText *text,
gint offset);
static gchar* gail_expander_get_text_before_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_expander_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_expander_get_text_after_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gint gail_expander_get_character_count(AtkText *text);
static void gail_expander_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
static gint gail_expander_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords);
static AtkAttributeSet* gail_expander_get_run_attributes
(AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
static AtkAttributeSet* gail_expander_get_default_attributes
(AtkText *text);
static GailContainer* parent_class = NULL;
GType
gail_expander_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailExpanderClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_expander_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailExpander), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_expander_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_text_info =
{
(GInterfaceInitFunc) atk_text_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailExpander", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
g_type_add_interface_static (type, ATK_TYPE_TEXT,
&atk_text_info);
}
return type;
}
static void
gail_expander_class_init (GailExpanderClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailWidgetClass *widget_class;
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gail_expander_real_notify_gtk;
gobject_class->finalize = gail_expander_finalize;
parent_class = g_type_class_peek_parent (klass);
class->get_name = gail_expander_get_name;
class->get_n_children = gail_expander_get_n_children;
class->ref_child = gail_expander_ref_child;
class->ref_state_set = gail_expander_ref_state_set;
class->initialize = gail_expander_real_initialize;
}
static void
gail_expander_object_init (GailExpander *expander)
{
expander->activate_description = NULL;
expander->activate_keybinding = NULL;
expander->action_idle_handler = 0;
expander->textutil = NULL;
}
AtkObject*
gail_expander_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL);
object = g_object_new (GAIL_TYPE_EXPANDER, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static G_CONST_RETURN gchar*
gail_expander_get_name (AtkObject *obj)
{
G_CONST_RETURN gchar *name;
g_return_val_if_fail (GAIL_IS_EXPANDER (obj), NULL);
name = ATK_OBJECT_CLASS (parent_class)->get_name (obj);
if (name != NULL)
return name;
else
{
/*
* Get the text on the label
*/
GtkWidget *widget;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL);
return gtk_expander_get_label (GTK_EXPANDER (widget));
}
}
static gint
gail_expander_get_n_children (AtkObject* obj)
{
GtkWidget *widget;
GList *children;
gint count = 0;
g_return_val_if_fail (GAIL_IS_CONTAINER (obj), count);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return 0;
children = gtk_container_get_children (GTK_CONTAINER(widget));
count = g_list_length (children);
g_list_free (children);
/* See if there is a label - if there is, reduce our count by 1
* since we don't want the label included with the children.
*/
if (gtk_expander_get_label_widget (widget))
count -= 1;
return count;
}
static AtkObject*
gail_expander_ref_child (AtkObject *obj,
gint i)
{
GList *children, *tmp_list;
AtkObject *accessible;
GtkWidget *widget;
GtkWidget *label;
gint index;
gint count;
g_return_val_if_fail (GAIL_IS_CONTAINER (obj), NULL);
g_return_val_if_fail ((i >= 0), NULL);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return NULL;
children = gtk_container_get_children (GTK_CONTAINER (widget));
/* See if there is a label - if there is, we need to skip it
* since we don't want the label included with the children.
*/
label = gtk_expander_get_label_widget (widget);
if (label) {
count = g_list_length (children);
for (index = 0; index <= i; index++) {
tmp_list = g_list_nth (children, index);
if (label == GTK_WIDGET (tmp_list->data)) {
i += 1;
break;
}
}
}
tmp_list = g_list_nth (children, i);
if (!tmp_list)
{
g_list_free (children);
return NULL;
}
accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
g_list_free (children);
g_object_ref (accessible);
return accessible;
}
static void
gail_expander_real_initialize (AtkObject *obj,
gpointer data)
{
GailExpander *gail_expander = GAIL_EXPANDER (obj);
GtkWidget *expander;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
expander = GTK_WIDGET (data);
if (GTK_WIDGET_MAPPED (expander))
gail_expander_init_textutil (gail_expander, GTK_EXPANDER (expander));
else
g_signal_connect (expander,
"map",
G_CALLBACK (gail_expander_map_gtk),
gail_expander);
obj->role = ATK_ROLE_TOGGLE_BUTTON;
}
static void
gail_expander_map_gtk (GtkWidget *widget,
gpointer data)
{
GailExpander *expander;
expander = GAIL_EXPANDER (data);
gail_expander_init_textutil (expander, GTK_EXPANDER (widget));
}
static void
gail_expander_real_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
AtkObject* atk_obj;
GtkExpander *expander;
GailExpander *gail_expander;
expander = GTK_EXPANDER (obj);
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (expander));
;
if (strcmp (pspec->name, "label") == 0)
{
const gchar* label_text;
label_text = gtk_expander_get_label (expander);
gail_expander = GAIL_EXPANDER (atk_obj);
if (gail_expander->textutil)
gail_text_util_text_setup (gail_expander->textutil, label_text);
if (atk_obj->name == NULL)
{
/*
* The label has changed so notify a change in accessible-name
*/
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
}
/*
* The label is the only property which can be changed
*/
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
else if (strcmp (pspec->name, "expanded") == 0)
{
atk_object_notify_state_change (atk_obj, ATK_STATE_CHECKED,
gtk_expander_get_expanded (expander));
atk_object_notify_state_change (atk_obj, ATK_STATE_EXPANDED,
gtk_expander_get_expanded (expander));
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
else
GAIL_WIDGET_CLASS (parent_class)->notify_gtk (obj, pspec);
}
static void
gail_expander_init_textutil (GailExpander *expander,
GtkExpander *widget)
{
const gchar *label_text;
expander->textutil = gail_text_util_new ();
label_text = gtk_expander_get_label (widget);
gail_text_util_text_setup (expander->textutil, label_text);
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->do_action = gail_expander_do_action;
iface->get_n_actions = gail_expander_get_n_actions;
iface->get_description = gail_expander_get_description;
iface->get_keybinding = gail_expander_get_keybinding;
iface->get_name = gail_expander_action_get_name;
iface->set_description = gail_expander_set_description;
}
static gboolean
gail_expander_do_action (AtkAction *action,
gint i)
{
GtkWidget *widget;
GailExpander *expander;
gboolean return_value = TRUE;
widget = GTK_ACCESSIBLE (action)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
return FALSE;
expander = GAIL_EXPANDER (action);
switch (i)
{
case 0:
if (expander->action_idle_handler)
return_value = FALSE;
else
expander->action_idle_handler = g_idle_add (idle_do_action, expander);
break;
default:
return_value = FALSE;
break;
}
return return_value;
}
static gboolean
idle_do_action (gpointer data)
{
GtkWidget *widget;
GailExpander *gail_expander;
GDK_THREADS_ENTER ();
gail_expander = GAIL_EXPANDER (data);
gail_expander->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_expander)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
gtk_widget_activate (widget);
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
gail_expander_get_n_actions (AtkAction *action)
{
return 1;
}
static G_CONST_RETURN gchar*
gail_expander_get_description (AtkAction *action,
gint i)
{
GailExpander *expander;
G_CONST_RETURN gchar *return_value;
expander = GAIL_EXPANDER (action);
switch (i)
{
case 0:
return_value = expander->activate_description;
break;
default:
return_value = NULL;
break;
}
return return_value;
}
static G_CONST_RETURN gchar*
gail_expander_get_keybinding (AtkAction *action,
gint i)
{
GailExpander *expander;
gchar *return_value = NULL;
switch (i)
{
case 0:
{
/*
* We look for a mnemonic on the label
*/
GtkWidget *widget;
GtkWidget *label;
expander = GAIL_EXPANDER (action);
widget = GTK_ACCESSIBLE (expander)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL);
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (GTK_IS_LABEL (label))
{
guint key_val;
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_VoidSymbol)
return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
g_free (expander->activate_keybinding);
expander->activate_keybinding = return_value;
}
break;
}
default:
break;
}
return return_value;
}
static G_CONST_RETURN gchar*
gail_expander_action_get_name (AtkAction *action,
gint i)
{
G_CONST_RETURN gchar *return_value;
switch (i)
{
case 0:
return_value = "activate";
break;
default:
return_value = NULL;
break;
}
return return_value;
}
static gboolean
gail_expander_set_description (AtkAction *action,
gint i,
const gchar *desc)
{
GailExpander *expander;
gchar **value;
expander = GAIL_EXPANDER (action);
switch (i)
{
case 0:
value = &expander->activate_description;
break;
default:
value = NULL;
break;
}
if (value)
{
g_free (*value);
*value = g_strdup (desc);
return TRUE;
}
else
return FALSE;
}
static AtkStateSet*
gail_expander_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
GtkExpander *expander;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return state_set;
expander = GTK_EXPANDER (widget);
atk_state_set_add_state (state_set, ATK_STATE_EXPANDABLE);
if (gtk_expander_get_expanded (expander)) {
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
atk_state_set_add_state (state_set, ATK_STATE_EXPANDED);
}
return state_set;
}
/* atktext.h */
static void
atk_text_interface_init (AtkTextIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_text = gail_expander_get_text;
iface->get_character_at_offset = gail_expander_get_character_at_offset;
iface->get_text_before_offset = gail_expander_get_text_before_offset;
iface->get_text_at_offset = gail_expander_get_text_at_offset;
iface->get_text_after_offset = gail_expander_get_text_after_offset;
iface->get_character_count = gail_expander_get_character_count;
iface->get_character_extents = gail_expander_get_character_extents;
iface->get_offset_at_point = gail_expander_get_offset_at_point;
iface->get_run_attributes = gail_expander_get_run_attributes;
iface->get_default_attributes = gail_expander_get_default_attributes;
}
static gchar*
gail_expander_get_text (AtkText *text,
gint start_pos,
gint end_pos)
{
GtkWidget *widget;
GailExpander *expander;
const gchar *label_text;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
expander = GAIL_EXPANDER (text);
if (!expander->textutil)
gail_expander_init_textutil (expander, GTK_EXPANDER (widget));
label_text = gtk_expander_get_label (GTK_EXPANDER (widget));
if (label_text == NULL)
return NULL;
else
return gail_text_util_get_substring (expander->textutil,
start_pos, end_pos);
}
static gchar*
gail_expander_get_text_before_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GailExpander *expander;
GtkWidget *label;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
expander = GAIL_EXPANDER (text);
if (!expander->textutil)
gail_expander_init_textutil (expander, GTK_EXPANDER (widget));
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return NULL;
return gail_text_util_get_text (expander->textutil,
gtk_label_get_layout (GTK_LABEL (label)),
GAIL_BEFORE_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_expander_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GailExpander *expander;
GtkWidget *label;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
expander = GAIL_EXPANDER (text);
if (!expander->textutil)
gail_expander_init_textutil (expander, GTK_EXPANDER (widget));
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return NULL;
return gail_text_util_get_text (expander->textutil,
gtk_label_get_layout (GTK_LABEL (label)),
GAIL_AT_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_expander_get_text_after_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GailExpander *expander;
GtkWidget *label;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
expander = GAIL_EXPANDER (text);
if (!expander->textutil)
gail_expander_init_textutil (expander, GTK_EXPANDER (widget));
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return NULL;
return gail_text_util_get_text (expander->textutil,
gtk_label_get_layout (GTK_LABEL (label)),
GAIL_AFTER_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gint
gail_expander_get_character_count (AtkText *text)
{
GtkWidget *widget;
GtkWidget *label;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return 0;
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return 0;
return g_utf8_strlen (gtk_label_get_text (GTK_LABEL (label)), -1);
}
static void
gail_expander_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords)
{
GtkWidget *widget;
GtkWidget *label;
PangoRectangle char_rect;
gint index, x_layout, y_layout;
const gchar *label_text;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return;
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
label_text = gtk_label_get_text (GTK_LABEL (label));
index = g_utf8_offset_to_pointer (label_text, offset) - label_text;
pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect);
gail_misc_get_extents_from_pango_rectangle (label, &char_rect,
x_layout, y_layout, x, y, width, height, coords);
}
static gint
gail_expander_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords)
{
GtkWidget *widget;
GtkWidget *label;
gint index, x_layout, y_layout;
const gchar *label_text;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return -1;
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return -1;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
index = gail_misc_get_index_at_point_in_layout (label,
gtk_label_get_layout (GTK_LABEL (label)),
x_layout, y_layout, x, y, coords);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (index == -1)
{
if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
return g_utf8_strlen (label_text, -1);
return index;
}
else
return g_utf8_pointer_to_offset (label_text, label_text + index);
}
static AtkAttributeSet*
gail_expander_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
AtkAttributeSet *at_set = NULL;
GtkJustification justify;
GtkTextDirection dir;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return NULL;
/* Get values set for entire label, if any */
justify = gtk_label_get_justify (GTK_LABEL (label));
if (justify != GTK_JUSTIFY_CENTER)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_JUSTIFICATION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justify)));
}
dir = gtk_widget_get_direction (label);
if (dir == GTK_TEXT_DIR_RTL)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_DIRECTION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, dir)));
}
at_set = gail_misc_layout_get_run_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
(gchar *) gtk_label_get_text (GTK_LABEL (label)),
offset,
start_offset,
end_offset);
return at_set;
}
static AtkAttributeSet*
gail_expander_get_default_attributes (AtkText *text)
{
GtkWidget *widget;
GtkWidget *label;
AtkAttributeSet *at_set = NULL;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return NULL;
at_set = gail_misc_get_default_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
widget);
return at_set;
}
static gunichar
gail_expander_get_character_at_offset (AtkText *text,
gint offset)
{
GtkWidget *widget;
GtkWidget *label;
const gchar *string;
gchar *index;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return '\0';
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (!GTK_IS_LABEL(label))
return '\0';
string = gtk_label_get_text (GTK_LABEL (label));
if (offset >= g_utf8_strlen (string, -1))
return '\0';
index = g_utf8_offset_to_pointer (string, offset);
return g_utf8_get_char (index);
}
static void
gail_expander_finalize (GObject *object)
{
GailExpander *expander = GAIL_EXPANDER (object);
g_free (expander->activate_description);
g_free (expander->activate_keybinding);
if (expander->action_idle_handler)
{
g_source_remove (expander->action_idle_handler);
expander->action_idle_handler = 0;
}
if (expander->textutil)
g_object_unref (expander->textutil);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,66 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_EXPANDER_H__
#define __GAIL_EXPANDER_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#include <libgail-util/gailtextutil.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_EXPANDER (gail_expander_get_type ())
#define GAIL_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_EXPANDER, GailExpander))
#define GAIL_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_EXPANDER, GailExpanderClass))
#define GAIL_IS_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_EXPANDER))
#define GAIL_IS_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_EXPANDER))
#define GAIL_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_EXPANDER, GailExpanderClass))
typedef struct _GailExpander GailExpander;
typedef struct _GailExpanderClass GailExpanderClass;
struct _GailExpander
{
GailContainer parent;
gchar *activate_description;
gchar *activate_keybinding;
guint action_idle_handler;
GailTextUtil *textutil;
};
GType gail_expander_get_type (void);
struct _GailExpanderClass
{
GailContainerClass parent_class;
};
AtkObject* gail_expander_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_EXPANDER_H__ */

View File

@ -0,0 +1,85 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _GAIL_FACTORY_H__
#define _GAIL_FACTORY_H__
#include <glib-object.h>
#include <atk/atkobject.h>
#define GAIL_ACCESSIBLE_FACTORY(type, type_as_function, opt_create_accessible) \
\
static GType \
type_as_function ## _factory_get_accessible_type (void) \
{ \
return type; \
} \
\
static AtkObject* \
type_as_function ## _factory_create_accessible (GObject *obj) \
{ \
GtkWidget *widget; \
AtkObject *accessible; \
\
g_return_val_if_fail (GTK_IS_WIDGET (obj), NULL); \
\
widget = GTK_WIDGET (obj); \
\
accessible = opt_create_accessible (widget); \
\
return accessible; \
} \
\
static void \
type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass) \
{ \
klass->create_accessible = type_as_function ## _factory_create_accessible; \
klass->get_accessible_type = type_as_function ## _factory_get_accessible_type;\
} \
\
static GType \
type_as_function ## _factory_get_type (void) \
{ \
static GType t = 0; \
\
if (!t) \
{ \
char *name; \
static const GTypeInfo tinfo = \
{ \
sizeof (AtkObjectFactoryClass), \
NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init, \
NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL \
}; \
\
name = g_strconcat (g_type_name (type), "Factory", NULL); \
t = g_type_register_static ( \
ATK_TYPE_OBJECT_FACTORY, name, &tinfo, 0); \
g_free (name); \
} \
\
return t; \
}
#define GAIL_WIDGET_SET_FACTORY(widget_type, type_as_function) \
atk_registry_set_factory_type (atk_get_default_registry (), \
widget_type, \
type_as_function ## _factory_get_type ())
#endif /* _GAIL_FACTORY_H__ */

View File

@ -0,0 +1,113 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailframe.h"
static void gail_frame_class_init (GailFrameClass *klass);
static G_CONST_RETURN gchar* gail_frame_get_name (AtkObject *obj);
static gpointer parent_class = NULL;
GType
gail_frame_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailFrameClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_frame_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailFrame), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailFrame", &tinfo, 0);
}
return type;
}
static void
gail_frame_class_init (GailFrameClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gail_frame_get_name;
parent_class = g_type_class_peek_parent (klass);
}
AtkObject*
gail_frame_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_FRAME (widget), NULL);
object = g_object_new (GAIL_TYPE_FRAME, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_PANEL;
return accessible;
}
static G_CONST_RETURN gchar*
gail_frame_get_name (AtkObject *obj)
{
G_CONST_RETURN gchar *name;
g_return_val_if_fail (GAIL_IS_FRAME (obj), NULL);
name = ATK_OBJECT_CLASS (parent_class)->get_name (obj);
if (name != NULL)
{
return name;
}
else
{
/*
* Get the text on the label
*/
GtkWidget *widget;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
{
/*
* State is defunct
*/
return NULL;
}
return gtk_frame_get_label (GTK_FRAME (widget));
}
}

View File

@ -0,0 +1,60 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_FRAME_H__
#define __GAIL_FRAME_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_FRAME (gail_frame_get_type ())
#define GAIL_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_FRAME, GailFrame))
#define GAIL_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_FRAME, GailFrameClass))
#define GAIL_IS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_FRAME))
#define GAIL_IS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_FRAME))
#define GAIL_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_FRAME, GailFrameClass))
typedef struct _GailFrame GailFrame;
typedef struct _GailFrameClass GailFrameClass;
struct _GailFrame
{
GailContainer parent;
};
GType gail_frame_get_type (void);
struct _GailFrameClass
{
GailContainerClass parent_class;
};
AtkObject* gail_frame_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_FRAME_H__ */

View File

@ -0,0 +1,289 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailhtmlbox.h"
#include "gailhtmlview.h"
#include <libgtkhtml/layout/htmlbox.h>
static void gail_html_box_class_init (GailHtmlBoxClass *klass);
static void gail_html_box_initialize (AtkObject *obj,
gpointer data);
static gint gail_html_box_get_index_in_parent (AtkObject *obj);
static AtkStateSet* gail_html_box_ref_state_set (AtkObject *obj);
static void gail_html_box_component_interface_init (AtkComponentIface *iface);
static guint gail_html_box_add_focus_handler (AtkComponent *component,
AtkFocusHandler handler);
static void gail_html_box_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
static gboolean gail_html_box_grab_focus (AtkComponent *component);
static void gail_html_box_remove_focus_handler (AtkComponent *component,
guint handler_id);
static AtkGObjectClass *parent_class = NULL;
GType
gail_html_box_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailHtmlBoxClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_html_box_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailHtmlBox), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_component_info =
{
(GInterfaceInitFunc) gail_html_box_component_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_GOBJECT,
"GailHtmlBox", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
&atk_component_info);
}
return type;
}
static void
gail_html_box_class_init (GailHtmlBoxClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_ref (ATK_TYPE_GOBJECT);
class->get_index_in_parent = gail_html_box_get_index_in_parent;
class->ref_state_set = gail_html_box_ref_state_set;
class->initialize = gail_html_box_initialize;
}
AtkObject*
gail_html_box_new (GObject *obj)
{
GObject *object;
AtkObject *atk_object;
g_return_val_if_fail (HTML_IS_BOX (obj), NULL);
object = g_object_new (GAIL_TYPE_HTML_BOX, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, obj);
atk_object->role = ATK_ROLE_UNKNOWN;
return atk_object;
}
static void
gail_html_box_initialize (AtkObject *obj,
gpointer data)
{
HtmlBox *box;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
box = HTML_BOX (data);
/*
* We do not set the parent here for the root node of a HtmlView
*/
if (box->parent)
{
atk_object_set_parent (obj,
atk_gobject_get_accessible (G_OBJECT (box->parent)));
}
}
static gint
gail_html_box_get_index_in_parent (AtkObject *obj)
{
AtkObject *parent;
AtkGObject *atk_gobj;
HtmlBox *box;
HtmlBox *parent_box;
gint n_children = 0;
GObject *g_obj;
g_return_val_if_fail (GAIL_IS_HTML_BOX (obj), -1);
atk_gobj = ATK_GOBJECT (obj);
g_obj = atk_gobject_get_object (atk_gobj);
if (g_obj == NULL)
return -1;
g_return_val_if_fail (HTML_IS_BOX (g_obj), -1);
box = HTML_BOX (g_obj);
parent = atk_object_get_parent (obj);
if (GAIL_IS_HTML_VIEW (parent))
{
return 0;
}
else if (ATK_IS_GOBJECT (parent))
{
parent_box = HTML_BOX (atk_gobject_get_object (ATK_GOBJECT (parent)));
}
else
{
g_assert_not_reached ();
return -1;
}
if (parent_box)
{
HtmlBox *child;
child = parent_box->children;
while (child)
{
if (child == box)
return n_children;
n_children++;
child = child->next;
}
}
return -1;
}
static AtkStateSet*
gail_html_box_ref_state_set (AtkObject *obj)
{
AtkGObject *atk_gobj;
GObject *g_obj;
AtkStateSet *state_set;
g_return_val_if_fail (GAIL_IS_HTML_BOX (obj), NULL);
atk_gobj = ATK_GOBJECT (obj);
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
g_obj = atk_gobject_get_object (atk_gobj);
if (g_obj == NULL)
{
/* Object is defunct */
atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
}
else
{
HtmlBox *box;
box = HTML_BOX (g_obj);
if (HTML_BOX_GET_STYLE (box)->display != HTML_DISPLAY_NONE)
{
atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
}
}
return state_set;
}
static void
gail_html_box_component_interface_init (AtkComponentIface *iface)
{
g_return_if_fail (iface != NULL);
/*
* Use default implementation for contains and get_position
*/
iface->contains = NULL;
iface->get_position = NULL;
iface->add_focus_handler = gail_html_box_add_focus_handler;
iface->get_extents = gail_html_box_get_extents;
iface->get_size = NULL;
iface->grab_focus = gail_html_box_grab_focus;
iface->remove_focus_handler = gail_html_box_remove_focus_handler;
iface->set_extents = NULL;
iface->set_position = NULL;
iface->set_size = NULL;
}
static guint
gail_html_box_add_focus_handler (AtkComponent *component,
AtkFocusHandler handler)
{
return g_signal_connect_closure (component,
"focus-event",
g_cclosure_new (
G_CALLBACK (handler), NULL,
(GClosureNotify) NULL),
FALSE);
}
static void
gail_html_box_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
AtkGObject *atk_gobj;
HtmlBox *box;
GObject *g_obj;
g_return_if_fail (GAIL_IS_HTML_BOX (component));
atk_gobj = ATK_GOBJECT (component);
g_obj = atk_gobject_get_object (atk_gobj);
if (g_obj == NULL)
return;
g_return_if_fail (HTML_IS_BOX (g_obj));
box = HTML_BOX (g_obj);
*x = html_box_get_absolute_x (box);
*y = html_box_get_absolute_y (box);
*width = box->width;
*height = box->height;
g_print ("%d %d %d %d\n",
html_box_get_absolute_x (box),
html_box_get_absolute_y (box),
html_box_get_containing_block_width (box),
html_box_get_containing_block_height (box));
}
static gboolean
gail_html_box_grab_focus (AtkComponent *component)
{
return TRUE;
}
static void
gail_html_box_remove_focus_handler (AtkComponent *component,
guint handler_id)
{
g_signal_handler_disconnect (ATK_OBJECT (component), handler_id);
}

View File

@ -0,0 +1,58 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_HTML_BOX_H__
#define __GAIL_HTML_BOX_H__
#include <atk/atk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_HTML_BOX (gail_html_box_get_type ())
#define GAIL_HTML_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_HTML_BOX, GailHtmlBox))
#define GAIL_HTML_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_HTML_BOX, GailHtmlBoxClass))
#define GAIL_IS_HTML_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_HTML_BOX))
#define GAIL_IS_HTML_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_HTML_BOX))
#define GAIL_HTML_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_HTML_BOX, GailHtmlBoxClass))
typedef struct _GailHtmlBox GailHtmlBox;
typedef struct _GailHtmlBoxClass GailHtmlBoxClass;
struct _GailHtmlBox
{
AtkGObject parent;
};
struct _GailHtmlBoxClass
{
AtkGObjectClass parent_class;
};
GType gail_html_box_get_type (void);
AtkObject* gail_html_box_new (GObject *obj);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_HTML_BOX_H__ */

View File

@ -0,0 +1,153 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libgtkhtml/gtkhtml.h>
#include "gailhtmlboxblock.h"
static void gail_html_box_block_class_init (GailHtmlBoxBlockClass *klass);
static gint gail_html_box_block_get_n_children (AtkObject *obj);
static AtkObject* gail_html_box_block_ref_child (AtkObject *obj,
gint i);
static GailHtmlBoxClass *parent_class = NULL;
GType
gail_html_box_block_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailHtmlBoxBlockClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_html_box_block_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailHtmlBoxBlock), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_HTML_BOX,
"GailHtmlBoxBlock", &tinfo, 0);
}
return type;
}
AtkObject*
gail_html_box_block_new (GObject *obj)
{
GObject *object;
AtkObject *atk_object;
g_return_val_if_fail (HTML_IS_BOX_BLOCK (obj), NULL);
object = g_object_new (GAIL_TYPE_HTML_BOX_BLOCK, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, obj);
atk_object->role = ATK_ROLE_PANEL;
return atk_object;
}
static void
gail_html_box_block_class_init (GailHtmlBoxBlockClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_ref (GAIL_TYPE_HTML_BOX);
class->get_n_children = gail_html_box_block_get_n_children;
class->ref_child = gail_html_box_block_ref_child;
}
static gint
gail_html_box_block_get_n_children (AtkObject *obj)
{
AtkGObject *atk_gobject;
HtmlBox *box;
gint n_children = 0;
GObject *g_obj;
g_return_val_if_fail (GAIL_IS_HTML_BOX_BLOCK (obj), 0);
atk_gobject = ATK_GOBJECT (obj);
g_obj = atk_gobject_get_object (atk_gobject);
if (g_obj == NULL)
return 0;
g_return_val_if_fail (HTML_IS_BOX (g_obj), 0);
box = HTML_BOX (g_obj);
if (box)
{
HtmlBox *child;
child = box->children;
while (child)
{
n_children++;
child = child->next;
}
}
return n_children;
}
static AtkObject *
gail_html_box_block_ref_child (AtkObject *obj,
gint i)
{
AtkGObject *atk_gobject;
GObject *g_obj;
HtmlBox *box;
AtkObject *atk_child = NULL;
gint n_children = 0;
g_return_val_if_fail (GAIL_IS_HTML_BOX_BLOCK (obj), NULL);
atk_gobject = ATK_GOBJECT (obj);
g_obj = atk_gobject_get_object (atk_gobject);
if (g_obj == NULL)
return NULL;
g_return_val_if_fail (HTML_IS_BOX (g_obj), NULL);
box = HTML_BOX (g_obj);
if (box)
{
HtmlBox *child;
child = box->children;
while (child)
{
if (n_children == i)
{
atk_child = atk_gobject_get_accessible (G_OBJECT (child));
g_object_ref (atk_child);
break;
}
n_children++;
child = child->next;
}
}
return atk_child;
}

View File

@ -0,0 +1,133 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libgtkhtml/gtkhtml.h>
#include "gailhtmlboxembedded.h"
static void gail_html_box_embedded_class_init (GailHtmlBoxEmbeddedClass *klass);
static gint gail_html_box_embedded_get_n_children (AtkObject *obj);
static AtkObject* gail_html_box_embedded_ref_child (AtkObject *obj,
gint i);
static GailHtmlBoxClass *parent_class = NULL;
GType
gail_html_box_embedded_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailHtmlBoxEmbeddedClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_html_box_embedded_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailHtmlBoxEmbedded), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_HTML_BOX,
"GailHtmlBoxEmbedded", &tinfo, 0);
}
return type;
}
AtkObject*
gail_html_box_embedded_new (GObject *obj)
{
gpointer object;
AtkObject *atk_object;
g_return_val_if_fail (HTML_IS_BOX_EMBEDDED (obj), NULL);
object = g_object_new (GAIL_TYPE_HTML_BOX_EMBEDDED, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, obj);
atk_object->role = ATK_ROLE_PANEL;
return atk_object;
}
static void
gail_html_box_embedded_class_init (GailHtmlBoxEmbeddedClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_ref (GAIL_TYPE_HTML_BOX);
class->get_n_children = gail_html_box_embedded_get_n_children;
class->ref_child = gail_html_box_embedded_ref_child;
}
static gint
gail_html_box_embedded_get_n_children (AtkObject *obj)
{
AtkGObject *atk_gobject;
HtmlBoxEmbedded *box_embedded;
GObject *g_obj;
g_return_val_if_fail (GAIL_IS_HTML_BOX_EMBEDDED (obj), 0);
atk_gobject = ATK_GOBJECT (obj);
g_obj = atk_gobject_get_object (atk_gobject);
if (g_obj == NULL)
/* State is defunct */
return 0;
g_return_val_if_fail (HTML_IS_BOX_EMBEDDED (g_obj), 0);
box_embedded = HTML_BOX_EMBEDDED (g_obj);
g_return_val_if_fail (box_embedded->widget, 0);
return 1;
}
static AtkObject*
gail_html_box_embedded_ref_child (AtkObject *obj,
gint i)
{
AtkGObject *atk_gobject;
HtmlBoxEmbedded *box_embedded;
GObject *g_obj;
AtkObject *atk_child;
g_return_val_if_fail (GAIL_IS_HTML_BOX_EMBEDDED (obj), NULL);
if (i != 0)
return NULL;
atk_gobject = ATK_GOBJECT (obj);
g_obj = atk_gobject_get_object (atk_gobject);
if (g_obj == NULL)
/* State is defunct */
return NULL;
g_return_val_if_fail (HTML_IS_BOX_EMBEDDED (g_obj), NULL);
box_embedded = HTML_BOX_EMBEDDED (g_obj);
g_return_val_if_fail (box_embedded->widget, NULL);
atk_child = gtk_widget_get_accessible (box_embedded->widget);
g_object_ref (atk_child);
atk_object_set_parent (atk_child, obj);
return atk_child;
}

View File

@ -0,0 +1,506 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gailhtmlboxtext.h"
static void gail_html_box_text_class_init (GailHtmlBoxTextClass *klass);
static void gail_html_box_text_text_interface_init (AtkTextIface *iface);
static gchar* gail_html_box_text_get_text (AtkText *text,
gint start_offset,
gint end_offset);
static gchar* gail_html_box_text_get_text_after_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_html_box_text_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_html_box_text_get_text_before_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gunichar gail_html_box_text_get_character_at_offset
(AtkText *text,
gint offset);
static gint gail_html_box_text_get_character_count (AtkText *text);
static gint gail_html_box_text_get_caret_offset (AtkText *text);
static gboolean gail_html_box_text_set_caret_offset (AtkText *text,
gint offset);
static gint gail_html_box_text_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords);
static void gail_html_box_text_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
static AtkAttributeSet*
gail_html_box_text_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
static AtkAttributeSet*
gail_html_box_text_get_default_attributes (AtkText *text);
static gint gail_html_box_text_get_n_selections (AtkText *text);
static gchar* gail_html_box_text_get_selection (AtkText *text,
gint selection_num,
gint *start_pos,
gint *end_pos);
static gboolean gail_html_box_text_add_selection (AtkText *text,
gint start_pos,
gint end_pos);
static gboolean gail_html_box_text_remove_selection (AtkText *text,
gint selection_num);
static gboolean gail_html_box_text_set_selection (AtkText *text,
gint selection_num,
gint start_pos,
gint end_pos);
static AtkAttributeSet*
add_to_attr_set (AtkAttributeSet *attrib_set,
GtkTextAttributes *attrs,
AtkTextAttribute attr);
static gchar* get_text_near_offset (AtkText *text,
GailOffsetType function,
AtkTextBoundary boundary_type,
gint offset,
gint *start_offset,
gint *end_offset);
static AtkObjectClass *parent_class = NULL;
GType
gail_html_box_text_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailHtmlBoxTextClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_html_box_text_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailHtmlBoxText), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_text_info =
{
(GInterfaceInitFunc) gail_html_box_text_text_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_HTML_BOX,
"GailHtmlBoxText", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_TEXT,
&atk_text_info);
}
return type;
}
AtkObject*
gail_html_box_text_new (GObject *obj)
{
gpointer object;
AtkObject *atk_object;
GailHtmlBoxText *gail_text;
g_return_val_if_fail (HTML_IS_BOX_TEXT (obj), NULL);
object = g_object_new (GAIL_TYPE_HTML_BOX_TEXT, NULL);
atk_object = ATK_OBJECT (object);
gail_text = GAIL_HTML_BOX_TEXT (object);
atk_object_initialize (atk_object, obj);
gail_text->texthelper = gail_text_helper_new ();
#if 0
gail_text_helper_text_setup (gail_text->texthelper,
HTML_BOX_TEXT (obj)->master->text);
#endif
atk_object->role = ATK_ROLE_TEXT;
return atk_object;
}
static void
gail_html_box_text_class_init (GailHtmlBoxTextClass *klass)
{
parent_class = g_type_class_ref (ATK_TYPE_OBJECT);
}
static void
gail_html_box_text_text_interface_init (AtkTextIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_text = gail_html_box_text_get_text;
iface->get_text_after_offset = gail_html_box_text_get_text_after_offset;
iface->get_text_at_offset = gail_html_box_text_get_text_at_offset;
iface->get_text_before_offset = gail_html_box_text_get_text_before_offset;
iface->get_character_at_offset = gail_html_box_text_get_character_at_offset;
iface->get_character_count = gail_html_box_text_get_character_count;
iface->get_caret_offset = gail_html_box_text_get_caret_offset;
iface->set_caret_offset = gail_html_box_text_set_caret_offset;
iface->get_offset_at_point = gail_html_box_text_get_offset_at_point;
iface->get_character_extents = gail_html_box_text_get_character_extents;
iface->get_n_selections = gail_html_box_text_get_n_selections;
iface->get_selection = gail_html_box_text_get_selection;
iface->add_selection = gail_html_box_text_add_selection;
iface->remove_selection = gail_html_box_text_remove_selection;
iface->set_selection = gail_html_box_text_set_selection;
iface->get_run_attributes = gail_html_box_text_get_run_attributes;
iface->get_default_attributes = gail_html_box_text_get_default_attributes;
}
static gchar*
gail_html_box_text_get_text (AtkText *text,
gint start_offset,
gint end_offset)
{
GailHtmlBoxText *gail_text;
GtkTextBuffer *buffer;
GtkTextIter start, end;
g_return_val_if_fail (GAIL_IS_HTML_BOX_TEXT (text), NULL);
gail_text = GAIL_HTML_BOX_TEXT (text);
g_return_val_if_fail (gail_text->texthelper, NULL);
buffer = gail_text->texthelper->buffer;
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_offset);
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_offset);
return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
}
static gchar*
gail_html_box_text_get_text_after_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
return get_text_near_offset (text, GAIL_AFTER_OFFSET,
boundary_type, offset,
start_offset, end_offset);
}
static gchar*
gail_html_box_text_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
return get_text_near_offset (text, GAIL_AT_OFFSET,
boundary_type, offset,
start_offset, end_offset);
}
static gchar*
gail_html_box_text_get_text_before_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
return get_text_near_offset (text, GAIL_BEFORE_OFFSET,
boundary_type, offset,
start_offset, end_offset);
}
static gunichar
gail_html_box_text_get_character_at_offset (AtkText *text,
gint offset)
{
GailHtmlBoxText *gail_item;
GtkTextIter start, end;
GtkTextBuffer *buffer;
gchar *string;
gchar *index;
g_return_val_if_fail (GAIL_IS_HTML_BOX_TEXT (text), 0);
gail_item = GAIL_HTML_BOX_TEXT (text);
buffer = gail_item->texthelper->buffer;
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
string = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
index = g_utf8_offset_to_pointer (string, offset);
g_free (string);
return g_utf8_get_char (index);
}
static gint
gail_html_box_text_get_character_count (AtkText *text)
{
GtkTextBuffer *buffer;
GailHtmlBoxText *gail_text;
g_return_val_if_fail (GAIL_IS_HTML_BOX_TEXT (text), 0);
gail_text = GAIL_HTML_BOX_TEXT (text);
g_return_val_if_fail (gail_text->texthelper, 0);
buffer = gail_text->texthelper->buffer;
return gtk_text_buffer_get_char_count (buffer);
}
static gint
gail_html_box_text_get_caret_offset (AtkText *text)
{
GailHtmlBoxText *gail_text;
GtkTextBuffer *buffer;
GtkTextMark *cursor_mark;
GtkTextIter cursor_itr;
g_return_val_if_fail (GAIL_IS_HTML_BOX_TEXT (text), 0);
gail_text = GAIL_HTML_BOX_TEXT (text);
g_return_val_if_fail (gail_text->texthelper, 0);
buffer = gail_text->texthelper->buffer;
cursor_mark = gtk_text_buffer_get_insert (buffer);
gtk_text_buffer_get_iter_at_mark (buffer, &cursor_itr, cursor_mark);
return gtk_text_iter_get_offset (&cursor_itr);
}
static gboolean
gail_html_box_text_set_caret_offset (AtkText *text,
gint offset)
{
GailHtmlBoxText *gail_text;
GtkTextBuffer *buffer;
GtkTextIter pos_itr;
g_return_val_if_fail (GAIL_IS_HTML_BOX_TEXT (text), FALSE);
gail_text = GAIL_HTML_BOX_TEXT (text);
g_return_val_if_fail (gail_text->texthelper, FALSE);
buffer = gail_text->texthelper->buffer;
gtk_text_buffer_get_iter_at_offset (buffer, &pos_itr, offset);
gtk_text_buffer_move_mark_by_name (buffer, "insert", &pos_itr);
return TRUE;
}
static gint
gail_html_box_text_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords)
{
return -1;
}
static void
gail_html_box_text_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords)
{
return;
}
static AtkAttributeSet*
gail_html_box_text_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset)
{
return NULL;
}
static AtkAttributeSet*
gail_html_box_text_get_default_attributes (AtkText *text)
{
return NULL;
}
static gint
gail_html_box_text_get_n_selections (AtkText *text)
{
return 0;
}
static gchar*
gail_html_box_text_get_selection (AtkText *text,
gint selection_num,
gint *start_pos,
gint *end_pos)
{
return NULL;
}
static gboolean
gail_html_box_text_add_selection (AtkText *text,
gint start_pos,
gint end_pos)
{
return FALSE;
}
static gboolean
gail_html_box_text_remove_selection (AtkText *text,
gint selection_num)
{
return FALSE;
}
static gboolean
gail_html_box_text_set_selection (AtkText *text,
gint selection_num,
gint start_pos,
gint end_pos)
{
return FALSE;
}
static AtkAttributeSet*
add_to_attr_set (AtkAttributeSet *attrib_set,
GtkTextAttributes *attrs,
AtkTextAttribute attr)
{
gchar *value;
switch (attr)
{
case ATK_TEXT_ATTR_LEFT_MARGIN:
value = g_strdup_printf ("%i", attrs->left_margin);
break;
case ATK_TEXT_ATTR_RIGHT_MARGIN:
value = g_strdup_printf ("%i", attrs->right_margin);
break;
case ATK_TEXT_ATTR_INDENT:
value = g_strdup_printf ("%i", attrs->indent);
break;
case ATK_TEXT_ATTR_INVISIBLE:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->invisible));
break;
case ATK_TEXT_ATTR_EDITABLE:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->editable));
break;
case ATK_TEXT_ATTR_PIXELS_ABOVE_LINES:
value = g_strdup_printf ("%i", attrs->pixels_above_lines);
break;
case ATK_TEXT_ATTR_PIXELS_BELOW_LINES:
value = g_strdup_printf ("%i", attrs->pixels_below_lines);
break;
case ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP:
value = g_strdup_printf ("%i", attrs->pixels_inside_wrap);
break;
case ATK_TEXT_ATTR_BG_FULL_HEIGHT:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->bg_full_height));
break;
case ATK_TEXT_ATTR_RISE:
value = g_strdup_printf ("%i", attrs->appearance.rise);
break;
case ATK_TEXT_ATTR_UNDERLINE:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.underline));
break;
case ATK_TEXT_ATTR_STRIKETHROUGH:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.strikethrough));
break;
case ATK_TEXT_ATTR_SIZE:
value = g_strdup_printf ("%i",
pango_font_description_get_size (attrs->font));
break;
case ATK_TEXT_ATTR_SCALE:
value = g_strdup_printf ("%g", attrs->font_scale);
break;
case ATK_TEXT_ATTR_WEIGHT:
value = g_strdup_printf ("%d",
pango_font_description_get_weight (attrs->font));
break;
case ATK_TEXT_ATTR_LANGUAGE:
value = g_strdup ((gchar *)(attrs->language));
break;
case ATK_TEXT_ATTR_FAMILY_NAME:
value = g_strdup (pango_font_description_get_family (attrs->font));
break;
case ATK_TEXT_ATTR_BG_COLOR:
value = g_strdup_printf ("%u,%u,%u",
attrs->appearance.bg_color.red,
attrs->appearance.bg_color.green,
attrs->appearance.bg_color.blue);
break;
case ATK_TEXT_ATTR_FG_COLOR:
value = g_strdup_printf ("%u,%u,%u",
attrs->appearance.fg_color.red,
attrs->appearance.fg_color.green,
attrs->appearance.fg_color.blue);
break;
case ATK_TEXT_ATTR_BG_STIPPLE:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.bg_stipple ? 1 : 0));
break;
case ATK_TEXT_ATTR_FG_STIPPLE:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->appearance.fg_stipple ? 1 : 0));
break;
case ATK_TEXT_ATTR_WRAP_MODE:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->wrap_mode));
break;
case ATK_TEXT_ATTR_DIRECTION:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->direction));
break;
case ATK_TEXT_ATTR_JUSTIFICATION:
value = g_strdup (atk_text_attribute_get_value (attr, attrs->justification));
break;
case ATK_TEXT_ATTR_STRETCH:
value = g_strdup (atk_text_attribute_get_value (attr,
pango_font_description_get_stretch (attrs->font)));
break;
case ATK_TEXT_ATTR_VARIANT:
value = g_strdup (atk_text_attribute_get_value (attr,
pango_font_description_get_variant (attrs->font)));
break;
case ATK_TEXT_ATTR_STYLE:
value = g_strdup (atk_text_attribute_get_value (attr,
pango_font_description_get_style (attrs->font)));
break;
default:
value = NULL;
break;
}
return gail_text_helper_add_attribute (attrib_set,
attr,
value);
}
static gchar*
get_text_near_offset (AtkText *text,
GailOffsetType function,
AtkTextBoundary boundary_type,
gint offset,
gint *start_offset,
gint *end_offset)
{
return gail_text_helper_get_text (GAIL_HTML_BOX_TEXT (text)->texthelper, NULL,
function, boundary_type, offset,
start_offset, end_offset);
}

View File

@ -0,0 +1,430 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailimage.h"
#include "gailintl.h"
static void gail_image_class_init (GailImageClass *klass);
static void gail_image_object_init (GailImage *image);
static G_CONST_RETURN gchar* gail_image_get_name (AtkObject *accessible);
static void atk_image_interface_init (AtkImageIface *iface);
static G_CONST_RETURN gchar *
gail_image_get_image_description (AtkImage *image);
static void gail_image_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type);
static void gail_image_get_image_size (AtkImage *image,
gint *width,
gint *height);
static gboolean gail_image_set_image_description (AtkImage *image,
const gchar *description);
static void gail_image_finalize (GObject *object);
typedef struct _GailImageItem GailImageItem;
struct _GailImageItem
{
GQuark id;
gchar *name;
gchar *stock_id;
};
static GailImageItem stock_items [] =
{
{ 0, N_("dialog authentication"), "gtk-dialog-authentication"},
{ 0, N_("dialog information"), "gtk-dialog-info"},
{ 0, N_("dialog warning"), "gtk-dialog-warning"},
{ 0, N_("dialog error"), "gtk-dialog-error"},
{ 0, N_("dialog question"), "gtk-dialog-question"},
{ 0, N_("drag and drop"), "gtk-dnd"},
{ 0, N_("multiple drag and drop"), "gtk-dnd-multiple"},
{ 0, N_("add"), "gtk-add"},
{ 0, N_("apply"), "gtk-apply"},
{ 0, N_("bold"), "gtk-bold"},
{ 0, N_("cancel"), "gtk_cancel"},
{ 0, N_("cdrom"), "gtk-cdrom"},
{ 0, N_("clear"), "gtk-clear"},
{ 0, N_("close"), "gtk-close"},
{ 0, N_("color picker"), "gtk-color-picker"},
{ 0, N_("convert"), "gtk-convert"},
{ 0, N_("copy"), "gtk-copy"},
{ 0, N_("cut"), "gtk-cut"},
{ 0, N_("delete"), "gtk-delete"},
{ 0, N_("execute"), "gtk-execute"},
{ 0, N_("find"), "gtk-find"},
{ 0, N_("find and replace"), "gtk-find-and-replace"},
{ 0, N_("floppy"), "gtk-floppy"},
{ 0, N_("go to bottom"), "gtk-goto-bottom"},
{ 0, N_("go to first"), "gtk-goto-first"},
{ 0, N_("go to last"), "gtk-goto-last"},
{ 0, N_("go to top"), "gtk-goto-top"},
{ 0, N_("go back"), "gtk-go-back"},
{ 0, N_("go down"), "gtk-go-down"},
{ 0, N_("go forward"), "gtk-go-forward"},
{ 0, N_("go up"), "gtk-go-up"},
{ 0, N_("help"), "gtk-help"},
{ 0, N_("home"), "gtk-home"},
{ 0, N_("index"), "gtk-index"},
{ 0, N_("italic"), "gtk-italic"},
{ 0, N_("jump to"), "gtk-jump-to"},
{ 0, N_("justify center"), "gtk-justify-center"},
{ 0, N_("justify fill"), "gtk-justify-fill"},
{ 0, N_("justify left"), "gtk-justify-left"},
{ 0, N_("justify right"), "gtk-justify-right"},
{ 0, N_("missing image"), "gtk-missing-image"},
{ 0, N_("new"), "gtk-new"},
{ 0, N_("no"), "gtk-no"},
{ 0, N_("ok"), "gtk-ok"},
{ 0, N_("open"), "gtk-open"},
{ 0, N_("paste"), "gtk-paste"},
{ 0, N_("preferences"), "gtk-preferences"},
{ 0, N_("print"), "gtk-print"},
{ 0, N_("print preview"), "gtk-print-preview"},
{ 0, N_("properties"), "gtk-properties"},
{ 0, N_("quit"), "gtk-quit"},
{ 0, N_("redo"), "gtk-redo"},
{ 0, N_("refresh"), "gtk-refresh"},
{ 0, N_("remove"), "gtk-remove"},
{ 0, N_("revert to saved"), "gtk-revert-to-saved"},
{ 0, N_("save"), "gtk-save"},
{ 0, N_("save as"), "gtk-save-as"},
{ 0, N_("select color"), "gtk-select-color"},
{ 0, N_("select font"), "gtk-select-font"},
{ 0, N_("sort ascending"), "gtk-sort-ascending"},
{ 0, N_("sort descending"), "gtk-sort-descending"},
{ 0, N_("spell check"), "gtk-spell-check"},
{ 0, N_("stop"), "gtk-stop"},
{ 0, N_("strikethrough"), "gtk-strikethrough"},
{ 0, N_("undelete"), "gtk-undelete"},
{ 0, N_("underline"), "gtk-underline"},
{ 0, N_("yes"), "gtk-yes"},
{ 0, N_("zoom 100 percent"), "gtk-zoom-100"},
{ 0, N_("zoom fit"), "gtk-zoom-fit"},
{ 0, N_("zoom in"), "gtk-zoom-in"},
{ 0, N_("zoom out"), "gtk-zoom-out"},
{ 0, N_("timer"), "gnome-stock-timer"},
{ 0, N_("timer stop"), "gnome-stock-timer-stop"},
{ 0, N_("trash"), "gnome-stock-trash"},
{ 0, N_("trash full"), "gnome-stock-trash-full"},
{ 0, N_("scores"), "gnome-stock-scores"},
{ 0, N_("about"), "gnome-stock-about"},
{ 0, N_("blank"), "gnome-stock-blank"},
{ 0, N_("volume"), "gnome-stock-volume"},
{ 0, N_("midi"), "gnome-stock-midi"},
{ 0, N_("microphone"), "gnome-stock-mic"},
{ 0, N_("line in"), "gnome-stock-line-in"},
{ 0, N_("mail"), "gnome-stock-mail"},
{ 0, N_("mail receive"), "gnome-stock-mail-rcv"},
{ 0, N_("mail send"), "gnome-stock-mail-snd"},
{ 0, N_("mail reply"), "gnome-stock-mail-rpl"},
{ 0, N_("mail forward"), "gnome-stock-mail-fwd"},
{ 0, N_("mail new"), "gnome-stock-mail-new"},
{ 0, N_("attach"), "gnome-stock-attach"},
{ 0, N_("book red"), "gnome-stock-book-red"},
{ 0, N_("book green"), "gnome-stock-book-green"},
{ 0, N_("book blue"), "gnome-stock-book-blue"},
{ 0, N_("book yellow"), "gnome-stock-book-yellow"},
{ 0, N_("book open"), "gnome-stock-book-open"},
{ 0, N_("multiple file"), "gnome-stock-multiple-file"},
{ 0, N_("not"), "gnome-stock-not"},
{ 0, N_("table borders"), "gnome-stock-table-borders"},
{ 0, N_("table fill"), "gnome-stock-table-fill"},
{ 0, N_("text indent"), "gnome-stock-text-indent"},
{ 0, N_("text unindent"), "gnome-stock-text-unindent"},
{ 0, N_("text bulleted list"), "gnome-stock-text-bulleted-list"},
{ 0, N_("text numbered list"), "gnome-stock-text-numbered-list"},
{ 0, N_("authentication"), "gnome-stock-authentication"}
};
static gpointer parent_class = NULL;
GType
gail_image_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailImageClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_image_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailImage), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_image_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) atk_image_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailImage", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
}
return type;
}
static void
gail_image_class_init (GailImageClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = gail_image_finalize;
class->get_name = gail_image_get_name;
}
static void
gail_image_object_init (GailImage *image)
{
image->image_description = NULL;
}
AtkObject*
gail_image_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_IMAGE (widget), NULL);
object = g_object_new (GAIL_TYPE_IMAGE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_ICON;
return accessible;
}
static void
init_strings (void)
{
gint i;
for (i = 0; i < G_N_ELEMENTS (stock_items); i++)
stock_items[i].id = g_quark_from_static_string (stock_items[i].stock_id);
}
static G_CONST_RETURN gchar*
get_localized_name (const gchar *str)
{
GQuark str_q;
gint i;
#if 0
static gboolean gettext_initialized = FALSE;
if (!gettext_initialized)
{
init_strings ();
gettext_initialized = TRUE;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, GAIL_LOCALEDIR);
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
#endif
}
#endif
str_q = g_quark_try_string (str);
for (i = 0; i < G_N_ELEMENTS (stock_items); i++)
{
if (str_q == stock_items[i].id)
return dgettext (GETTEXT_PACKAGE, stock_items[i].name);
}
return str;
}
static G_CONST_RETURN gchar*
gail_image_get_name (AtkObject *accessible)
{
G_CONST_RETURN gchar *name;
name = ATK_OBJECT_CLASS (parent_class)->get_name (accessible);
if (name)
return name;
else
{
GtkWidget* widget = GTK_ACCESSIBLE (accessible)->widget;
GtkImage *image;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
g_return_val_if_fail (GTK_IS_IMAGE (widget), NULL);
image = GTK_IMAGE (widget);
if (image->storage_type == GTK_IMAGE_STOCK &&
image->data.stock.stock_id)
return get_localized_name (image->data.stock.stock_id);
else return NULL;
}
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_image_description = gail_image_get_image_description;
iface->get_image_position = gail_image_get_image_position;
iface->get_image_size = gail_image_get_image_size;
iface->set_image_description = gail_image_set_image_description;
}
static G_CONST_RETURN gchar *
gail_image_get_image_description (AtkImage *image)
{
GailImage* aimage = GAIL_IMAGE (image);
return aimage->image_description;
}
static void
gail_image_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
atk_component_get_position (ATK_COMPONENT (image), x, y, coord_type);
}
static void
gail_image_get_image_size (AtkImage *image,
gint *width,
gint *height)
{
GtkWidget* widget;
GtkImage *gtk_image;
GtkImageType image_type;
widget = GTK_ACCESSIBLE (image)->widget;
if (widget == 0)
{
/* State is defunct */
*height = -1;
*width = -1;
return;
}
gtk_image = GTK_IMAGE(widget);
image_type = gtk_image_get_storage_type(gtk_image);
switch(image_type) {
case GTK_IMAGE_PIXMAP:
{
GdkPixmap *pixmap;
gtk_image_get_pixmap(gtk_image, &pixmap, NULL);
gdk_window_get_size (pixmap, width, height);
break;
}
case GTK_IMAGE_PIXBUF:
{
GdkPixbuf *pixbuf;
pixbuf = gtk_image_get_pixbuf(gtk_image);
*height = gdk_pixbuf_get_height(pixbuf);
*width = gdk_pixbuf_get_width(pixbuf);
break;
}
case GTK_IMAGE_IMAGE:
{
GdkImage *gdk_image;
gtk_image_get_image(gtk_image, &gdk_image, NULL);
*height = gdk_image->height;
*width = gdk_image->width;
break;
}
case GTK_IMAGE_STOCK:
{
GtkIconSize size;
gtk_image_get_stock(gtk_image, NULL, &size);
gtk_icon_size_lookup(size, width, height);
break;
}
case GTK_IMAGE_ICON_SET:
{
GtkIconSize size;
gtk_image_get_icon_set(gtk_image, NULL, &size);
gtk_icon_size_lookup(size, width, height);
break;
}
case GTK_IMAGE_ANIMATION:
{
GdkPixbufAnimation *animation;
animation = gtk_image_get_animation(gtk_image);
*height = gdk_pixbuf_animation_get_height(animation);
*width = gdk_pixbuf_animation_get_width(animation);
break;
}
default:
{
*height = -1;
*width = -1;
break;
}
}
}
static gboolean
gail_image_set_image_description (AtkImage *image,
const gchar *description)
{
GailImage* aimage = GAIL_IMAGE (image);
g_free (aimage->image_description);
aimage->image_description = g_strdup (description);
return TRUE;
}
static void
gail_image_finalize (GObject *object)
{
GailImage *aimage = GAIL_IMAGE (object);
g_free (aimage->image_description);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,61 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_IMAGE_H__
#define __GAIL_IMAGE_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_IMAGE (gail_image_get_type ())
#define GAIL_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_IMAGE, GailImage))
#define GAIL_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_IMAGE, GailImageClass))
#define GAIL_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_IMAGE))
#define GAIL_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_IMAGE))
#define GAIL_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_IMAGE, GailImageClass))
typedef struct _GailImage GailImage;
typedef struct _GailImageClass GailImageClass;
struct _GailImage
{
GailWidget parent;
gchar* image_description;
};
GType gail_image_get_type (void);
struct _GailImageClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_image_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_IMAGE_H__ */

View File

@ -0,0 +1,207 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailimagecell.h"
static void gail_image_cell_class_init (GailImageCellClass *klass);
static void gail_image_cell_object_init (GailImageCell *image_cell);
static void gail_image_cell_finalize (GObject *object);
/* AtkImage */
static void atk_image_interface_init (AtkImageIface *iface);
static G_CONST_RETURN gchar *
gail_image_cell_get_image_description (AtkImage *image);
static gboolean gail_image_cell_set_image_description (AtkImage *image,
const gchar *description);
static void gail_image_cell_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type);
static void gail_image_cell_get_image_size (AtkImage *image,
gint *width,
gint *height);
/* Misc */
static gboolean gail_image_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal);
gchar *gail_image_cell_property_list[] = {
"pixbuf",
NULL
};
static gpointer parent_class = NULL;
GType
gail_image_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailImageCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_image_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailImageCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_image_cell_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) atk_image_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_RENDERER_CELL,
"GailImageCell", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
}
return type;
}
static void
gail_image_cell_class_init (GailImageCellClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GailRendererCellClass *renderer_cell_class = GAIL_RENDERER_CELL_CLASS(klass);
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = gail_image_cell_finalize;
renderer_cell_class->update_cache = gail_image_cell_update_cache;
renderer_cell_class->property_list = gail_image_cell_property_list;
}
AtkObject*
gail_image_cell_new (void)
{
GObject *object;
AtkObject *atk_object;
GailRendererCell *cell;
object = g_object_new (GAIL_TYPE_IMAGE_CELL, NULL);
g_return_val_if_fail (object != NULL, NULL);
atk_object = ATK_OBJECT (object);
atk_object->role = ATK_ROLE_TABLE_CELL;
cell = GAIL_RENDERER_CELL(object);
cell->renderer = gtk_cell_renderer_pixbuf_new ();
g_object_ref (cell->renderer);
gtk_object_sink (GTK_OBJECT (cell->renderer));
return atk_object;
}
static void
gail_image_cell_object_init (GailImageCell *image_cell)
{
image_cell->image_description = NULL;
}
static void
gail_image_cell_finalize (GObject *object)
{
GailImageCell *image_cell = GAIL_IMAGE_CELL (object);
g_free (image_cell->image_description);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
gail_image_cell_update_cache (GailRendererCell *cell,
gboolean emit_change_signal)
{
return FALSE;
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
iface->get_image_description = gail_image_cell_get_image_description;
iface->set_image_description = gail_image_cell_set_image_description;
iface->get_image_position = gail_image_cell_get_image_position;
iface->get_image_size = gail_image_cell_get_image_size;
}
static G_CONST_RETURN gchar *
gail_image_cell_get_image_description (AtkImage *image)
{
GailImageCell *image_cell;
image_cell = GAIL_IMAGE_CELL (image);
return image_cell->image_description;
}
static gboolean
gail_image_cell_set_image_description (AtkImage *image,
const gchar *description)
{
GailImageCell *image_cell;
image_cell = GAIL_IMAGE_CELL (image);
g_free (image_cell->image_description);
image_cell->image_description = g_strdup (description);
if (image_cell->image_description)
return TRUE;
else
return FALSE;
}
static void
gail_image_cell_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
atk_component_get_position (ATK_COMPONENT (image), x, y, coord_type);
}
static void
gail_image_cell_get_image_size (AtkImage *image,
gint *width,
gint *height)
{
GailImageCell *cell = GAIL_IMAGE_CELL (image);
GtkCellRenderer *cell_renderer;
GdkPixbuf *pixbuf;
cell_renderer = GAIL_RENDERER_CELL (cell)->renderer;
pixbuf = GTK_CELL_RENDERER_PIXBUF (cell_renderer)->pixbuf;
*width = gdk_pixbuf_get_width (pixbuf);
*height = gdk_pixbuf_get_height (pixbuf);
}

View File

@ -0,0 +1,62 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_IMAGE_CELL_H__
#define __GAIL_IMAGE_CELL_H__
#include <atk/atk.h>
#include <gail/gailrenderercell.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_IMAGE_CELL (gail_image_cell_get_type ())
#define GAIL_IMAGE_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_IMAGE_CELL, GailImageCell))
#define GAIL_IMAGE_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_IMAGE_CELL, GailImageCellClass))
#define GAIL_IS_IMAGE_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_IMAGE_CELL))
#define GAIL_IS_IMAGE_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_IMAGE_CELL))78
#define GAIL_IMAGE_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_IMAGE_CELL, GailImageCellClass))
typedef struct _GailImageCell GailImageCell;
typedef struct _GailImageCellClass GailImageCellClass;
struct _GailImageCell
{
GailRendererCell parent;
gchar *image_description;
gint x, y;
};
GType gail_image_cell_get_type (void);
struct _GailImageCellClass
{
GailRendererCellClass parent_class;
};
AtkObject *gail_image_cell_new (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_TREE_VIEW_IMAGE_CELL_H__ */

View File

@ -0,0 +1,79 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtkcellrendererpixbuf.h>
#include "gailimagecellfactory.h"
#include "gailimagecell.h"
static void gail_image_cell_factory_class_init (GailImageCellFactoryClass *klass);
static AtkObject* gail_image_cell_factory_create_accessible (
GObject *obj);
static GType gail_image_cell_factory_get_accessible_type (void);
GType
gail_image_cell_factory_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailImageCellFactoryClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_image_cell_factory_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailImageCellFactory), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (ATK_TYPE_OBJECT_FACTORY,
"GailImageCellFactory" , &tinfo, 0);
}
return type;
}
static void
gail_image_cell_factory_class_init (GailImageCellFactoryClass *klass)
{
AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
class->create_accessible = gail_image_cell_factory_create_accessible;
class->get_accessible_type = gail_image_cell_factory_get_accessible_type;
}
static AtkObject*
gail_image_cell_factory_create_accessible (GObject *obj)
{
g_return_val_if_fail (GTK_IS_CELL_RENDERER_PIXBUF (obj), NULL);
return gail_image_cell_new ();
}
static GType
gail_image_cell_factory_get_accessible_type (void)
{
return GAIL_TYPE_IMAGE_CELL;
}

View File

@ -0,0 +1,56 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_IMAGE_CELL_FACTORY_H__
#define __GAIL_IMAGE_CELL_FACTORY_H__
#include <atk/atkobjectfactory.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_IMAGE_CELL_FACTORY (gail_image_cell_factory_get_type ())
#define GAIL_IMAGE_CELL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_IMAGE_CELL_FACTORY, GailImageCellFactory))
#define GAIL_IMAGE_CELL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AGTK_TYPE_IMAGE_CELL_FACTORY, GailImageCellFactoryClass))
#define GAIL_IS_IMAGE_CELL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_IMAGE_CELL_FACTORY))
#define GAIL_IS_IMAGE_CELL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_IMAGE_CELL_FACTORY))
#define GAIL_IMAGE_CELL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_IMAGE_CELL_FACTORY, GailImageCellFactoryClass))
typedef struct _GailImageCellFactory GailImageCellFactory;
typedef struct _GailImageCellFactoryClass GailImageCellFactoryClass;
struct _GailImageCellFactory
{
AtkObjectFactory parent;
};
struct _GailImageCellFactoryClass
{
AtkObjectFactoryClass parent_class;
};
GType gail_image_cell_factory_get_type(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_IMAGE_CELL_FACTORY_H__ */

View File

@ -0,0 +1,24 @@
#ifndef __GAILINTL_H__
#define __GAILINTL_H__
#include "config.h"
#ifdef ENABLE_NLS
#include<libintl.h>
#define _(String) dgettext(GETTEXT_PACKAGE,String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#define N_(String) (String)
#endif
#else /* NLS is disabled */
#define _(String) (String)
#define N_(String) (String)
#define textdomain(String) (String)
#define gettext(String) (String)
#define dgettext(Domain,String) (String)
#define dcgettext(Domain,String,Type) (String)
#define bindtextdomain(Domain,Directory) (Domain)
#endif
#endif

View File

@ -0,0 +1,760 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailitem.h"
#include <libgail-util/gailmisc.h>
static void gail_item_class_init (GailItemClass *klass);
static G_CONST_RETURN gchar* gail_item_get_name (AtkObject *obj);
static gint gail_item_get_n_children (AtkObject *obj);
static AtkObject* gail_item_ref_child (AtkObject *obj,
gint i);
static void gail_item_real_initialize (AtkObject *obj,
gpointer data);
static void gail_item_label_map_gtk (GtkWidget *widget,
gpointer data);
static void gail_item_finalize (GObject *object);
static void gail_item_init_textutil (GailItem *item,
GtkWidget *label);
static void gail_item_notify_label_gtk(GObject *obj,
GParamSpec *pspec,
gpointer data);
/* atktext.h */
static void atk_text_interface_init (AtkTextIface *iface);
static gchar* gail_item_get_text (AtkText *text,
gint start_pos,
gint end_pos);
static gunichar gail_item_get_character_at_offset(AtkText *text,
gint offset);
static gchar* gail_item_get_text_before_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_item_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_item_get_text_after_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gint gail_item_get_character_count (AtkText *text);
static void gail_item_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
static gint gail_item_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords);
static AtkAttributeSet* gail_item_get_run_attributes
(AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
static AtkAttributeSet* gail_item_get_default_attributes
(AtkText *text);
static GtkWidget* get_label_from_container (GtkWidget *container);
static GailContainerClass* parent_class = NULL;
GType
gail_item_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailItemClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_item_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailItem), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_text_info =
{
(GInterfaceInitFunc) atk_text_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailItem", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_TEXT,
&atk_text_info);
}
return type;
}
static void
gail_item_class_init (GailItemClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailContainerClass *container_class;
parent_class = g_type_class_peek_parent (klass);
container_class = (GailContainerClass *)klass;
gobject_class->finalize = gail_item_finalize;
class->get_name = gail_item_get_name;
class->get_n_children = gail_item_get_n_children;
class->ref_child = gail_item_ref_child;
class->initialize = gail_item_real_initialize;
/*
* As we report the item as having no children we are not interested
* in add and remove signals
*/
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
}
AtkObject*
gail_item_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_ITEM (widget), NULL);
object = g_object_new (GAIL_TYPE_ITEM, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_item_real_initialize (AtkObject *obj,
gpointer data)
{
GailItem *item = GAIL_ITEM (obj);
GtkWidget *label;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
item->textutil = NULL;
item->text = NULL;
label = get_label_from_container (GTK_WIDGET (data));
if (GTK_IS_LABEL (label))
{
if (GTK_WIDGET_MAPPED (label))
gail_item_init_textutil (item, label);
else
g_signal_connect (label,
"map",
G_CALLBACK (gail_item_label_map_gtk),
item);
}
obj->role = ATK_ROLE_LIST_ITEM;
}
static void
gail_item_label_map_gtk (GtkWidget *widget,
gpointer data)
{
GailItem *item;
item = GAIL_ITEM (data);
gail_item_init_textutil (item, widget);
}
static void
gail_item_init_textutil (GailItem *item,
GtkWidget *label)
{
const gchar *label_text;
if (item->textutil == NULL)
{
item->textutil = gail_text_util_new ();
g_signal_connect (label,
"notify",
(GCallback) gail_item_notify_label_gtk,
item);
}
label_text = gtk_label_get_text (GTK_LABEL (label));
gail_text_util_text_setup (item->textutil, label_text);
}
static void
gail_item_finalize (GObject *object)
{
GailItem *item = GAIL_ITEM (object);
if (item->textutil)
{
g_object_unref (item->textutil);
}
if (item->text)
{
g_free (item->text);
item->text = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static G_CONST_RETURN gchar*
gail_item_get_name (AtkObject *obj)
{
G_CONST_RETURN gchar* name;
g_return_val_if_fail (GAIL_IS_ITEM (obj), NULL);
name = ATK_OBJECT_CLASS (parent_class)->get_name (obj);
if (name == NULL)
{
/*
* Get the label child
*/
GtkWidget *widget;
GtkWidget *label;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
label = get_label_from_container (widget);
if (GTK_IS_LABEL (label))
return gtk_label_get_text (GTK_LABEL(label));
/*
* If we have a menu item in a menu attached to a GtkOptionMenu
* the label of the selected item is detached from the menu item
*/
else if (GTK_IS_MENU_ITEM (widget))
{
GtkWidget *parent;
GtkWidget *attach;
GList *list;
AtkObject *parent_obj;
gint index;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU (parent))
{
attach = gtk_menu_get_attach_widget (GTK_MENU (parent));
if (GTK_IS_OPTION_MENU (attach))
{
label = get_label_from_container (attach);
if (GTK_IS_LABEL (label))
return gtk_label_get_text (GTK_LABEL(label));
}
list = gtk_container_get_children (GTK_CONTAINER (parent));
index = g_list_index (list, widget);
if (index < 0 || index > g_list_length (list))
{
g_list_free (list);
return NULL;
}
g_list_free (list);
parent_obj = atk_object_get_parent (gtk_widget_get_accessible (parent));
if (GTK_IS_ACCESSIBLE (parent_obj))
{
parent = GTK_ACCESSIBLE (parent_obj)->widget;
if (GTK_IS_COMBO_BOX (parent))
{
GtkTreeModel *model;
GtkTreeIter iter;
GailItem *item;
gint n_columns, i;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (parent));
item = GAIL_ITEM (obj);
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, index))
{
n_columns = gtk_tree_model_get_n_columns (model);
for (i = 0; i < n_columns; i++)
{
GValue value = { 0, };
gtk_tree_model_get_value (model, &iter, i, &value);
if (G_VALUE_HOLDS_STRING (&value))
{
g_free (item->text);
item->text = (gchar *) g_value_dup_string (&value);
g_value_unset (&value);
break;
}
}
}
name = item->text;
}
}
}
}
}
return name;
}
/*
* We report that this object has no children
*/
static gint
gail_item_get_n_children (AtkObject* obj)
{
return 0;
}
static AtkObject*
gail_item_ref_child (AtkObject *obj,
gint i)
{
return NULL;
}
static void
gail_item_notify_label_gtk (GObject *obj,
GParamSpec *pspec,
gpointer data)
{
AtkObject* atk_obj = ATK_OBJECT (data);
GtkLabel *label;
GailItem *gail_item;
if (strcmp (pspec->name, "label") == 0)
{
const gchar* label_text;
label = GTK_LABEL (obj);
label_text = gtk_label_get_text (label);
gail_item = GAIL_ITEM (atk_obj);
gail_text_util_text_setup (gail_item->textutil, label_text);
if (atk_obj->name == NULL)
{
/*
* The label has changed so notify a change in accessible-name
*/
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
}
/*
* The label is the only property which can be changed
*/
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
}
/* atktext.h */
static void
atk_text_interface_init (AtkTextIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_text = gail_item_get_text;
iface->get_character_at_offset = gail_item_get_character_at_offset;
iface->get_text_before_offset = gail_item_get_text_before_offset;
iface->get_text_at_offset = gail_item_get_text_at_offset;
iface->get_text_after_offset = gail_item_get_text_after_offset;
iface->get_character_count = gail_item_get_character_count;
iface->get_character_extents = gail_item_get_character_extents;
iface->get_offset_at_point = gail_item_get_offset_at_point;
iface->get_run_attributes = gail_item_get_run_attributes;
iface->get_default_attributes = gail_item_get_default_attributes;
}
static gchar*
gail_item_get_text (AtkText *text,
gint start_pos,
gint end_pos)
{
GtkWidget *widget;
GtkWidget *label;
GailItem *item;
const gchar *label_text;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
label = get_label_from_container (widget);
if (!GTK_IS_LABEL (label))
return NULL;
item = GAIL_ITEM (text);
if (!item->textutil)
gail_item_init_textutil (item, label);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (label_text == NULL)
return NULL;
else
{
return gail_text_util_get_substring (item->textutil,
start_pos, end_pos);
}
}
static gchar*
gail_item_get_text_before_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
GailItem *item;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
/* Get label */
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return NULL;
item = GAIL_ITEM (text);
if (!item->textutil)
gail_item_init_textutil (item, label);
return gail_text_util_get_text (item->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_BEFORE_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_item_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
GailItem *item;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
/* Get label */
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return NULL;
item = GAIL_ITEM (text);
if (!item->textutil)
gail_item_init_textutil (item, label);
return gail_text_util_get_text (item->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_AT_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_item_get_text_after_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
GailItem *item;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
{
/* State is defunct */
return NULL;
}
/* Get label */
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return NULL;
item = GAIL_ITEM (text);
if (!item->textutil)
gail_item_init_textutil (item, label);
return gail_text_util_get_text (item->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gint
gail_item_get_character_count (AtkText *text)
{
GtkWidget *widget;
GtkWidget *label;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return 0;
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return 0;
return g_utf8_strlen (gtk_label_get_text (GTK_LABEL (label)), -1);
}
static void
gail_item_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords)
{
GtkWidget *widget;
GtkWidget *label;
PangoRectangle char_rect;
gint index, x_layout, y_layout;
const gchar *label_text;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return;
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
label_text = gtk_label_get_text (GTK_LABEL (label));
index = g_utf8_offset_to_pointer (label_text, offset) - label_text;
pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect);
gail_misc_get_extents_from_pango_rectangle (label, &char_rect,
x_layout, y_layout, x, y, width, height, coords);
}
static gint
gail_item_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords)
{
GtkWidget *widget;
GtkWidget *label;
gint index, x_layout, y_layout;
const gchar *label_text;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return -1;
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return -1;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
index = gail_misc_get_index_at_point_in_layout (label,
gtk_label_get_layout (GTK_LABEL (label)),
x_layout, y_layout, x, y, coords);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (index == -1)
{
if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
return g_utf8_strlen (label_text, -1);
return index;
}
else
return g_utf8_pointer_to_offset (label_text, label_text + index);
}
static AtkAttributeSet*
gail_item_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset)
{
GtkWidget *widget;
GtkWidget *label;
AtkAttributeSet *at_set = NULL;
GtkJustification justify;
GtkTextDirection dir;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return NULL;
/* Get values set for entire label, if any */
justify = gtk_label_get_justify (GTK_LABEL (label));
if (justify != GTK_JUSTIFY_CENTER)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_JUSTIFICATION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justify)));
}
dir = gtk_widget_get_direction (label);
if (dir == GTK_TEXT_DIR_RTL)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_DIRECTION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, dir)));
}
at_set = gail_misc_layout_get_run_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
(gchar *) gtk_label_get_text (GTK_LABEL (label)),
offset,
start_offset,
end_offset);
return at_set;
}
static AtkAttributeSet*
gail_item_get_default_attributes (AtkText *text)
{
GtkWidget *widget;
GtkWidget *label;
AtkAttributeSet *at_set = NULL;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return NULL;
at_set = gail_misc_get_default_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
widget);
return at_set;
}
static gunichar
gail_item_get_character_at_offset (AtkText *text,
gint offset)
{
GtkWidget *widget;
GtkWidget *label;
const gchar *string;
gchar *index;
widget = GTK_ACCESSIBLE (text)->widget;
if (widget == NULL)
/* State is defunct */
return '\0';
label = get_label_from_container (widget);
if (!GTK_IS_LABEL(label))
return '\0';
string = gtk_label_get_text (GTK_LABEL (label));
if (offset >= g_utf8_strlen (string, -1))
return '\0';
index = g_utf8_offset_to_pointer (string, offset);
return g_utf8_get_char (index);
}
static GtkWidget*
get_label_from_container (GtkWidget *container)
{
GtkWidget *label;
GList *children, *tmp_list;
if (!GTK_IS_CONTAINER (container))
return NULL;
children = gtk_container_get_children (GTK_CONTAINER (container));
label = NULL;
for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next)
{
if (GTK_IS_LABEL (tmp_list->data))
{
label = tmp_list->data;
break;
}
/*
* Get label from menu item in desktop background preferences
* option menu. See bug #144084.
*/
else if (GTK_IS_BOX (tmp_list->data))
{
label = get_label_from_container (GTK_WIDGET (tmp_list->data));
if (label)
break;
}
}
g_list_free (children);
return label;
}

View File

@ -0,0 +1,64 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_ITEM_H__
#define __GAIL_ITEM_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#include <libgail-util/gailtextutil.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_ITEM (gail_item_get_type ())
#define GAIL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_ITEM, GailItem))
#define GAIL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_ITEM, GailItemClass))
#define GAIL_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_ITEM))
#define GAIL_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_ITEM))
#define GAIL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_ITEM, GailItemClass))
typedef struct _GailItem GailItem;
typedef struct _GailItemClass GailItemClass;
struct _GailItem
{
GailContainer parent;
GailTextUtil *textutil;
gchar *text;
};
GType gail_item_get_type (void);
struct _GailItemClass
{
GailContainerClass parent_class;
};
AtkObject* gail_item_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_ITEM_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_LABEL_H__
#define __GAIL_LABEL_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#include <libgail-util/gailtextutil.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_LABEL (gail_label_get_type ())
#define GAIL_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_LABEL, GailLabel))
#define GAIL_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_LABEL, GailLabelClass))
#define GAIL_IS_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_LABEL))
#define GAIL_IS_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_LABEL))
#define GAIL_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_LABEL, GailLabelClass))
typedef struct _GailLabel GailLabel;
typedef struct _GailLabelClass GailLabelClass;
struct _GailLabel
{
GailWidget parent;
GailTextUtil *textutil;
gint cursor_position;
gint selection_bound;
gint label_length;
guint window_create_handler;
gboolean has_top_level;
};
GType gail_label_get_type (void);
struct _GailLabelClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_label_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_LABEL_H__ */

View File

@ -0,0 +1,277 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gaillist.h"
#include "gailcombo.h"
static void gail_list_class_init (GailListClass *klass);
static gint gail_list_get_index_in_parent (AtkObject *accessible);
static void atk_selection_interface_init (AtkSelectionIface *iface);
static gboolean gail_list_add_selection (AtkSelection *selection,
gint i);
static gboolean gail_list_clear_selection (AtkSelection *selection);
static AtkObject* gail_list_ref_selection (AtkSelection *selection,
gint i);
static gint gail_list_get_selection_count (AtkSelection *selection);
static gboolean gail_list_is_child_selected (AtkSelection *selection,
gint i);
static gboolean gail_list_remove_selection (AtkSelection *selection,
gint i);
static GailContainerClass *parent_class = NULL;
GType
gail_list_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailListClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_list_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailList), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_selection_info =
{
(GInterfaceInitFunc) atk_selection_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailList", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_SELECTION,
&atk_selection_info);
}
return type;
}
static void
gail_list_class_init (GailListClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->get_index_in_parent = gail_list_get_index_in_parent;
}
AtkObject*
gail_list_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_LIST (widget), NULL);
object = g_object_new (GAIL_TYPE_LIST, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_LIST;
return accessible;
}
static gint
gail_list_get_index_in_parent (AtkObject *accessible)
{
/*
* If the parent widget is a combo box then the index is 0
* otherwise do the normal thing.
*/
if (accessible->accessible_parent)
{
if (GAIL_IS_COMBO (accessible->accessible_parent))
return 0;
}
return ATK_OBJECT_CLASS (parent_class)->get_index_in_parent (accessible);
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->add_selection = gail_list_add_selection;
iface->clear_selection = gail_list_clear_selection;
iface->ref_selection = gail_list_ref_selection;
iface->get_selection_count = gail_list_get_selection_count;
iface->is_child_selected = gail_list_is_child_selected;
iface->remove_selection = gail_list_remove_selection;
/*
* select_all_selection does not make sense for a combo box
* so no implementation is provided.
*/
}
static gboolean
gail_list_add_selection (AtkSelection *selection,
gint i)
{
GtkList *list;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
list = GTK_LIST (widget);
gtk_list_select_item (list, i);
return TRUE;
}
static gboolean
gail_list_clear_selection (AtkSelection *selection)
{
GtkList *list;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
list = GTK_LIST (widget);
gtk_list_unselect_all (list);
return TRUE;
}
static AtkObject*
gail_list_ref_selection (AtkSelection *selection,
gint i)
{
GtkList *list;
GList *g_list;
GtkWidget *item;
AtkObject *obj;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
list = GTK_LIST (widget);
/*
* A combo box can have only one selection.
*/
if (i != 0)
return NULL;
g_list = list->selection;
if (g_list == NULL)
return NULL;
item = GTK_WIDGET (g_list->data);
obj = gtk_widget_get_accessible (item);
g_object_ref (obj);
return obj;
}
static gint
gail_list_get_selection_count (AtkSelection *selection)
{
GtkList *list;
GList *g_list;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
list = GTK_LIST (widget);
g_list = list->selection;
return g_list_length (g_list);;
}
static gboolean
gail_list_is_child_selected (AtkSelection *selection,
gint i)
{
GtkList *list;
GList *g_list;
GtkWidget *item;
gint j;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
list = GTK_LIST (widget);
g_list = list->selection;
if (g_list == NULL)
return FALSE;
item = GTK_WIDGET (g_list->data);
j = g_list_index (list->children, item);
return (j == i);
}
static gboolean
gail_list_remove_selection (AtkSelection *selection,
gint i)
{
if (atk_selection_is_child_selected (selection, i))
atk_selection_clear_selection (selection);
return TRUE;
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_LIST_H__
#define __GAIL_LIST_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_LIST (gail_list_get_type ())
#define GAIL_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_LIST, GailList))
#define GAIL_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_LIST, GailListClass))
#define GAIL_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_LIST))
#define GAIL_IS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_LIST))
#define GAIL_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_LIST, GailListClass))
typedef struct _GailList GailList;
typedef struct _GailListClass GailListClass;
struct _GailList
{
GailContainer parent;
};
GType gail_list_get_type (void);
struct _GailListClass
{
GailContainerClass parent_class;
};
AtkObject* gail_list_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_LIST_H__ */

View File

@ -0,0 +1,167 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkoptionmenu.h>
#include <gtk/gtkcombobox.h>
#include "gailmenu.h"
static void gail_menu_class_init (GailMenuClass *klass);
static void gail_menu_real_initialize (AtkObject *obj,
gpointer data);
static AtkObject* gail_menu_get_parent (AtkObject *accessible);
static gint gail_menu_get_index_in_parent (AtkObject *accessible);
static GailMenuShell *parent_class = NULL;
GType
gail_menu_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailMenuClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_menu_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailMenu), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_MENU_SHELL,
"GailMenu", &tinfo, 0);
}
return type;
}
static void
gail_menu_class_init (GailMenuClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_parent = gail_menu_get_parent;
class->get_index_in_parent = gail_menu_get_index_in_parent;
class->initialize = gail_menu_real_initialize;
parent_class = g_type_class_peek_parent (klass);
}
AtkObject*
gail_menu_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_MENU (widget), NULL);
object = g_object_new (GAIL_TYPE_MENU, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
g_object_set_data (G_OBJECT (accessible), "atk-component-layer",
GINT_TO_POINTER (ATK_LAYER_POPUP));
return accessible;
}
static void
gail_menu_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_MENU;
}
static AtkObject*
gail_menu_get_parent (AtkObject *accessible)
{
AtkObject *parent;
parent = accessible->accessible_parent;
if (parent != NULL)
{
g_return_val_if_fail (ATK_IS_OBJECT (parent), NULL);
}
else
{
GtkWidget *widget, *parent_widget;
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
{
/*
* State is defunct
*/
return NULL;
}
g_return_val_if_fail (GTK_IS_MENU (widget), NULL);
/*
* If the menu is attached to a menu item or a button (Gnome Menu)
* report the menu item as parent.
*/
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
if (!GTK_IS_MENU_ITEM (parent_widget) && !GTK_IS_BUTTON (parent_widget) && !GTK_IS_COMBO_BOX (parent_widget) && !GTK_IS_OPTION_MENU (parent_widget))
parent_widget = widget->parent;
if (parent_widget == NULL)
return NULL;
parent = gtk_widget_get_accessible (parent_widget);
atk_object_set_parent (accessible, parent);
}
return parent;
}
static gint
gail_menu_get_index_in_parent (AtkObject *accessible)
{
GtkWidget *widget;
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
{
/*
* State is defunct
*/
return -1;
}
g_return_val_if_fail (GTK_IS_MENU (widget), -1);
if (gtk_menu_get_attach_widget (GTK_MENU (widget)))
{
return 0;
}
return ATK_OBJECT_CLASS (parent_class)->get_index_in_parent (accessible);
}

View File

@ -0,0 +1,60 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_MENU_H__
#define __GAIL_MENU_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailmenushell.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_MENU (gail_menu_get_type ())
#define GAIL_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_MENU_SHELL, GailMenu))
#define GAIL_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_MENU, GailMenuClass))
#define GAIL_IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_MENU))
#define GAIL_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_MENU))
#define GAIL_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_MENU, GailMenuClass))
typedef struct _GailMenu GailMenu;
typedef struct _GailMenuClass GailMenuClass;
struct _GailMenu
{
GailMenuShell parent;
};
GType gail_menu_get_type (void);
struct _GailMenuClass
{
GailMenuShellClass parent_class;
};
AtkObject* gail_menu_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_MENU_H__ */

View File

@ -0,0 +1,682 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "gailmenuitem.h"
#include "gailsubmenuitem.h"
#define KEYBINDING_SEPARATOR ";"
static void gail_menu_item_class_init (GailMenuItemClass *klass);
static void gail_menu_item_object_init (GailMenuItem *menu_item);
static void gail_menu_item_real_initialize
(AtkObject *obj,
gpointer data);
static gint gail_menu_item_get_n_children (AtkObject *obj);
static AtkObject* gail_menu_item_ref_child (AtkObject *obj,
gint i);
static void gail_menu_item_finalize (GObject *object);
static void atk_action_interface_init (AtkActionIface *iface);
static gboolean gail_menu_item_do_action (AtkAction *action,
gint i);
static gboolean idle_do_action (gpointer data);
static gint gail_menu_item_get_n_actions (AtkAction *action);
static G_CONST_RETURN gchar* gail_menu_item_get_description(AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_menu_item_get_name (AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_menu_item_get_keybinding (AtkAction *action,
gint i);
static gboolean gail_menu_item_set_description(AtkAction *action,
gint i,
const gchar *desc);
static void menu_item_select (GtkItem *item);
static void menu_item_deselect (GtkItem *item);
static void menu_item_selection (GtkItem *item,
gboolean selected);
static gboolean find_accel (GtkAccelKey *key,
GClosure *closure,
gpointer data);
static gboolean find_accel_new (GtkAccelKey *key,
GClosure *closure,
gpointer data);
static gpointer parent_class = NULL;
GType
gail_menu_item_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailMenuItemClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_menu_item_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailMenuItem), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_menu_item_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_ITEM,
"GailMenuItem", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
}
return type;
}
static void
gail_menu_item_class_init (GailMenuItemClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = gail_menu_item_finalize;
class->get_n_children = gail_menu_item_get_n_children;
class->ref_child = gail_menu_item_ref_child;
class->initialize = gail_menu_item_real_initialize;
parent_class = g_type_class_peek_parent (klass);
}
static void
gail_menu_item_real_initialize (AtkObject *obj,
gpointer data)
{
GtkWidget *widget;
GtkWidget *parent;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
g_signal_connect (data,
"select",
G_CALLBACK (menu_item_select),
NULL);
g_signal_connect (data,
"deselect",
G_CALLBACK (menu_item_deselect),
NULL);
widget = GTK_WIDGET (data);
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU (parent))
{
GtkWidget *parent_widget;
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (parent));
if (!GTK_IS_MENU_ITEM (parent_widget))
parent_widget = gtk_widget_get_parent (widget);
if (parent_widget)
{
atk_object_set_parent (obj, gtk_widget_get_accessible (parent_widget));
}
}
g_object_set_data (G_OBJECT (obj), "atk-component-layer",
GINT_TO_POINTER (ATK_LAYER_POPUP));
if (GTK_IS_TEAROFF_MENU_ITEM (data))
obj->role = ATK_ROLE_TEAR_OFF_MENU_ITEM;
else if (GTK_IS_SEPARATOR_MENU_ITEM (data))
obj->role = ATK_ROLE_SEPARATOR;
else
obj->role = ATK_ROLE_MENU_ITEM;
}
static void
gail_menu_item_object_init (GailMenuItem *menu_item)
{
menu_item->click_keybinding = NULL;
menu_item->click_description = NULL;
}
AtkObject*
gail_menu_item_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_MENU_ITEM (widget), NULL);
if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)))
return gail_sub_menu_item_new (widget);
object = g_object_new (GAIL_TYPE_MENU_ITEM, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
GList *
get_children (GtkWidget *submenu)
{
GList *children;
children = gtk_container_get_children (GTK_CONTAINER (submenu));
if (g_list_length (children) == 0)
{
/*
* If menu is empty it may be because the menu items are created only
* on demand. For example, in gnome-panel the menu items are created
* only when "show" signal is emitted on the menu.
*
* The following hack forces the menu items to be created.
*/
if (!GTK_WIDGET_VISIBLE (submenu))
{
GTK_WIDGET_SET_FLAGS (submenu, GTK_VISIBLE);
g_signal_emit_by_name (submenu, "show");
GTK_WIDGET_UNSET_FLAGS (submenu, GTK_VISIBLE);
}
g_list_free (children);
children = gtk_container_get_children (GTK_CONTAINER (submenu));
}
return children;
}
/*
* If a menu item has a submenu return the items of the submenu as the
* accessible children; otherwise expose no accessible children.
*/
static gint
gail_menu_item_get_n_children (AtkObject* obj)
{
GtkWidget *widget;
GtkWidget *submenu;
gint count = 0;
g_return_val_if_fail (GAIL_IS_MENU_ITEM (obj), count);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return count;
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
if (submenu)
{
GList *children;
children = get_children (submenu);
count = g_list_length (children);
g_list_free (children);
}
return count;
}
static AtkObject*
gail_menu_item_ref_child (AtkObject *obj,
gint i)
{
AtkObject *accessible;
GtkWidget *widget;
GtkWidget *submenu;
g_return_val_if_fail (GAIL_IS_MENU_ITEM (obj), NULL);
g_return_val_if_fail ((i >= 0), NULL);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
return NULL;
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
if (submenu)
{
GList *children;
GList *tmp_list;
children = get_children (submenu);
tmp_list = g_list_nth (children, i);
if (!tmp_list)
{
g_list_free (children);
return NULL;
}
accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
g_list_free (children);
g_object_ref (accessible);
}
else
accessible = NULL;
return accessible;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->do_action = gail_menu_item_do_action;
iface->get_n_actions = gail_menu_item_get_n_actions;
iface->get_description = gail_menu_item_get_description;
iface->get_name = gail_menu_item_get_name;
iface->get_keybinding = gail_menu_item_get_keybinding;
iface->set_description = gail_menu_item_set_description;
}
static gboolean
gail_menu_item_do_action (AtkAction *action,
gint i)
{
if (i == 0)
{
GtkWidget *item;
GailMenuItem *gail_menu_item;
item = GTK_ACCESSIBLE (action)->widget;
if (item == NULL)
/* State is defunct */
return FALSE;
if (!GTK_WIDGET_SENSITIVE (item) || !GTK_WIDGET_VISIBLE (item))
return FALSE;
gail_menu_item = GAIL_MENU_ITEM (action);
if (gail_menu_item->action_idle_handler)
return FALSE;
else
{
g_object_ref (gail_menu_item);
gail_menu_item->action_idle_handler = g_idle_add (idle_do_action, gail_menu_item);
}
return TRUE;
}
else
return FALSE;
}
static void
ensure_menus_unposted (GailMenuItem *menu_item)
{
AtkObject *parent;
GtkWidget *widget;
parent = atk_object_get_parent (ATK_OBJECT (menu_item));
while (parent)
{
if (GTK_IS_ACCESSIBLE (parent))
{
widget = GTK_ACCESSIBLE (parent)->widget;
if (GTK_IS_MENU (widget))
{
if (GTK_WIDGET_MAPPED (widget))
gtk_menu_shell_cancel (GTK_MENU_SHELL (widget));
return;
}
}
parent = atk_object_get_parent (parent);
}
}
static gboolean
idle_do_action (gpointer data)
{
GtkWidget *item;
GtkWidget *item_parent;
GailMenuItem *menu_item;
gboolean item_mapped;
GDK_THREADS_ENTER ();
menu_item = GAIL_MENU_ITEM (data);
menu_item->action_idle_handler = 0;
item = GTK_ACCESSIBLE (menu_item)->widget;
if (item == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (item) || !GTK_WIDGET_VISIBLE (item))
{
g_object_unref (menu_item);
GDK_THREADS_LEAVE ();
return FALSE;
}
item_parent = gtk_widget_get_parent (item);
gtk_menu_shell_select_item (GTK_MENU_SHELL (item_parent), item);
item_mapped = GTK_WIDGET_MAPPED (item);
/*
* This is what is called when <Return> is pressed for a menu item
*/
g_signal_emit_by_name (item_parent, "activate_current",
/*force_hide*/ 1);
if (!item_mapped)
ensure_menus_unposted (menu_item);
g_object_unref (menu_item);
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
gail_menu_item_get_n_actions (AtkAction *action)
{
/*
* Menu item has 1 action
*/
return 1;
}
static G_CONST_RETURN gchar*
gail_menu_item_get_description (AtkAction *action,
gint i)
{
if (i == 0)
{
GailMenuItem *item;
item = GAIL_MENU_ITEM (action);
return item->click_description;
}
else
return NULL;
}
static G_CONST_RETURN gchar*
gail_menu_item_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "click";
else
return NULL;
}
static G_CONST_RETURN gchar*
gail_menu_item_get_keybinding (AtkAction *action,
gint i)
{
/*
* This function returns a string of the form A;B;C where
* A is the keybinding for the widget; B is the keybinding to traverse
* from the menubar and C is the accelerator.
* The items in the keybinding to traverse from the menubar are separated
* by ":".
*/
GailMenuItem *gail_menu_item;
gchar *keybinding = NULL;
gchar *item_keybinding = NULL;
gchar *full_keybinding = NULL;
gchar *accelerator = NULL;
gail_menu_item = GAIL_MENU_ITEM (action);
if (i == 0)
{
GtkWidget *item;
GtkWidget *temp_item;
GtkWidget *child;
GtkWidget *parent;
item = GTK_ACCESSIBLE (action)->widget;
if (item == NULL)
/* State is defunct */
return NULL;
temp_item = item;
while (TRUE)
{
GdkModifierType mnemonic_modifier = 0;
guint key_val;
gchar *key, *temp_keybinding;
child = gtk_bin_get_child (GTK_BIN (temp_item));
if (child == NULL)
{
/* Possibly a tear off menu item; it could also be a menu
* separator generated by gtk_item_factory_create_items()
*/
return NULL;
}
parent = gtk_widget_get_parent (temp_item);
if (!parent)
{
/*
* parent can be NULL when activating a window from the panel
*/
return NULL;
}
g_return_val_if_fail (GTK_IS_MENU_SHELL (parent), NULL);
if (GTK_IS_MENU_BAR (parent))
{
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (parent);
if (toplevel && GTK_IS_WINDOW (toplevel))
mnemonic_modifier = gtk_window_get_mnemonic_modifier (
GTK_WINDOW (toplevel));
}
if (GTK_IS_LABEL (child))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (child));
if (key_val != GDK_VoidSymbol)
{
key = gtk_accelerator_name (key_val, mnemonic_modifier);
if (full_keybinding)
temp_keybinding = g_strconcat (key, ":", full_keybinding, NULL);
else
temp_keybinding = g_strconcat (key, NULL);
if (temp_item == item)
{
item_keybinding = g_strdup (key);
}
g_free (key);
g_free (full_keybinding);
full_keybinding = temp_keybinding;
}
else
{
/* No keybinding */
g_free (full_keybinding);
full_keybinding = NULL;
break;
}
}
if (GTK_IS_MENU_BAR (parent))
/* We have reached the menu bar so we are finished */
break;
g_return_val_if_fail (GTK_IS_MENU (parent), NULL);
temp_item = gtk_menu_get_attach_widget (GTK_MENU (parent));
if (!GTK_IS_MENU_ITEM (temp_item))
{
/*
* Menu is attached to something other than a menu item;
* probably an option menu
*/
g_free (full_keybinding);
full_keybinding = NULL;
break;
}
}
parent = gtk_widget_get_parent (item);
if (GTK_IS_MENU (parent))
{
GtkAccelGroup *group;
GtkAccelKey *key;
group = gtk_menu_get_accel_group (GTK_MENU (parent));
if (group)
{
key = gtk_accel_group_find (group, find_accel, item);
}
else
{
/*
* If the menu item is created using GtkAction and GtkUIManager
* we get here.
*/
key = NULL;
child = GTK_BIN (item)->child;
if (GTK_IS_ACCEL_LABEL (child))
{
GtkAccelLabel *accel_label;
accel_label = GTK_ACCEL_LABEL (child);
if (accel_label->accel_closure)
{
key = gtk_accel_group_find (accel_label->accel_group,
find_accel_new,
accel_label->accel_closure);
}
}
}
if (key)
{
accelerator = gtk_accelerator_name (key->accel_key,
key->accel_mods);
}
}
}
/*
* Concatenate the bindings
*/
if (item_keybinding || full_keybinding || accelerator)
{
gchar *temp;
if (item_keybinding)
{
keybinding = g_strconcat (item_keybinding, KEYBINDING_SEPARATOR, NULL);
g_free (item_keybinding);
}
else
keybinding = g_strconcat (KEYBINDING_SEPARATOR, NULL);
if (full_keybinding)
{
temp = g_strconcat (keybinding, full_keybinding,
KEYBINDING_SEPARATOR, NULL);
g_free (full_keybinding);
}
else
temp = g_strconcat (keybinding, KEYBINDING_SEPARATOR, NULL);
g_free (keybinding);
keybinding = temp;
if (accelerator)
{
temp = g_strconcat (keybinding, accelerator, NULL);
g_free (accelerator);
g_free (keybinding);
keybinding = temp;
}
}
g_free (gail_menu_item->click_keybinding);
gail_menu_item->click_keybinding = keybinding;
return keybinding;
}
static gboolean
gail_menu_item_set_description (AtkAction *action,
gint i,
const gchar *desc)
{
if (i == 0)
{
GailMenuItem *item;
item = GAIL_MENU_ITEM (action);
g_free (item->click_description);
item->click_description = g_strdup (desc);
return TRUE;
}
else
return FALSE;
}
static void
gail_menu_item_finalize (GObject *object)
{
GailMenuItem *menu_item = GAIL_MENU_ITEM (object);
g_free (menu_item->click_keybinding);
g_free (menu_item->click_description);
if (menu_item->action_idle_handler)
{
g_source_remove (menu_item->action_idle_handler);
menu_item->action_idle_handler = 0;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
menu_item_select (GtkItem *item)
{
menu_item_selection (item, TRUE);
}
static void
menu_item_deselect (GtkItem *item)
{
menu_item_selection (item, FALSE);
}
static void
menu_item_selection (GtkItem *item,
gboolean selected)
{
AtkObject *obj, *parent;
obj = gtk_widget_get_accessible (GTK_WIDGET (item));
atk_object_notify_state_change (obj, ATK_STATE_SELECTED, selected);
parent = atk_object_get_parent (obj);
g_signal_emit_by_name (parent, "selection_changed");
}
static gboolean
find_accel (GtkAccelKey *key,
GClosure *closure,
gpointer data)
{
/*
* We assume that closure->data points to the widget
* pending gtk_widget_get_accel_closures being made public
*/
return data == (gpointer) closure->data;
}
static gboolean
find_accel_new (GtkAccelKey *key,
GClosure *closure,
gpointer data)
{
return data == (gpointer) closure;
}

View File

@ -0,0 +1,64 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_MENU_ITEM_H__
#define __GAIL_MENU_ITEM_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailitem.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_MENU_ITEM (gail_menu_item_get_type ())
#define GAIL_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_MENU_ITEM, GailMenuItem))
#define GAIL_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_MENU_ITEM, GailMenuItemClass))
#define GAIL_IS_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_MENU_ITEM))
#define GAIL_IS_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_MENU_ITEM))
#define GAIL_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_MENU_ITEM, GailMenuItemClass))
typedef struct _GailMenuItem GailMenuItem;
typedef struct _GailMenuItemClass GailMenuItemClass;
struct _GailMenuItem
{
GailItem parent;
gchar *click_keybinding;
gchar *click_description;
guint action_idle_handler;
};
GType gail_menu_item_get_type (void);
struct _GailMenuItemClass
{
GailItemClass parent_class;
};
AtkObject* gail_menu_item_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_MENU_ITEM_H__ */

View File

@ -0,0 +1,281 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailmenushell.h"
static void gail_menu_shell_class_init (GailMenuShellClass *klass);
static void atk_selection_interface_init (AtkSelectionIface *iface);
static gboolean gail_menu_shell_add_selection (AtkSelection *selection,
gint i);
static gboolean gail_menu_shell_clear_selection (AtkSelection *selection);
static AtkObject* gail_menu_shell_ref_selection (AtkSelection *selection,
gint i);
static gint gail_menu_shell_get_selection_count (AtkSelection *selection);
static gboolean gail_menu_shell_is_child_selected (AtkSelection *selection,
gint i);
static gboolean gail_menu_shell_remove_selection (AtkSelection *selection,
gint i);
GType
gail_menu_shell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailMenuShellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_menu_shell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailMenuShell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_selection_info =
{
(GInterfaceInitFunc) atk_selection_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailMenuShell", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_SELECTION,
&atk_selection_info);
}
return type;
}
static void
gail_menu_shell_class_init (GailMenuShellClass *klass)
{
}
AtkObject*
gail_menu_shell_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_MENU_SHELL (widget), NULL);
object = g_object_new (GAIL_TYPE_MENU_SHELL, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
if (GTK_IS_MENU_BAR (widget))
accessible->role = ATK_ROLE_MENU_BAR;
else
/*
* Accessible object for Menu is created in gailmenu.c
*/
accessible->role = ATK_ROLE_UNKNOWN;
return accessible;
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->add_selection = gail_menu_shell_add_selection;
iface->clear_selection = gail_menu_shell_clear_selection;
iface->ref_selection = gail_menu_shell_ref_selection;
iface->get_selection_count = gail_menu_shell_get_selection_count;
iface->is_child_selected = gail_menu_shell_is_child_selected;
iface->remove_selection = gail_menu_shell_remove_selection;
/*
* select_all_selection does not make sense for a menu_shell
* so no implementation is provided.
*/
}
static gboolean
gail_menu_shell_add_selection (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
GList *item;
guint length;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
shell = GTK_MENU_SHELL (widget);
length = g_list_length (shell->children);
if (i < 0 || i > length)
return FALSE;
item = g_list_nth (shell->children, i);
g_return_val_if_fail (item != NULL, FALSE);
g_return_val_if_fail (GTK_IS_MENU_ITEM(item->data), FALSE);
gtk_menu_shell_select_item (shell, GTK_WIDGET (item->data));
return TRUE;
}
static gboolean
gail_menu_shell_clear_selection (AtkSelection *selection)
{
GtkMenuShell *shell;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
shell = GTK_MENU_SHELL (widget);
gtk_menu_shell_deselect (shell);
return TRUE;
}
static AtkObject*
gail_menu_shell_ref_selection (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
AtkObject *obj;
GtkWidget *widget;
if (i != 0)
return NULL;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
{
/* State is defunct */
return NULL;
}
shell = GTK_MENU_SHELL (widget);
if (shell->active_menu_item != NULL)
{
obj = gtk_widget_get_accessible (shell->active_menu_item);
g_object_ref (obj);
return obj;
}
else
{
return NULL;
}
}
static gint
gail_menu_shell_get_selection_count (AtkSelection *selection)
{
GtkMenuShell *shell;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
{
/* State is defunct */
return 0;
}
shell = GTK_MENU_SHELL (widget);
/*
* Identifies the currently selected menu item
*/
if (shell->active_menu_item == NULL)
{
return 0;
}
else
{
return 1;
}
}
static gboolean
gail_menu_shell_is_child_selected (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
gint j;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
shell = GTK_MENU_SHELL (widget);
if (shell->active_menu_item == NULL)
return FALSE;
j = g_list_index (shell->children, shell->active_menu_item);
return (j==i);
}
static gboolean
gail_menu_shell_remove_selection (AtkSelection *selection,
gint i)
{
GtkMenuShell *shell;
GtkWidget *widget;
if (i != 0)
return FALSE;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
{
/* State is defunct */
return FALSE;
}
shell = GTK_MENU_SHELL (widget);
if (shell->active_menu_item &&
GTK_MENU_ITEM (shell->active_menu_item)->submenu)
{
/*
* Menu item contains a menu and it is the selected menu item
* so deselect it.
*/
gtk_menu_shell_deselect (shell);
}
return TRUE;
}

View File

@ -0,0 +1,60 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_MENU_SHELL_H__
#define __GAIL_MENU_SHELL_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_MENU_SHELL (gail_menu_shell_get_type ())
#define GAIL_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_MENU_SHELL, GailMenuShell))
#define GAIL_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_MENU_SHELL, GailMenuShellClass))
#define GAIL_IS_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_MENU_SHELL))
#define GAIL_IS_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_MENU_SHELL))
#define GAIL_MENU_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_MENU_SHELL, GailMenuShellClass))
typedef struct _GailMenuShell GailMenuShell;
typedef struct _GailMenuShellClass GailMenuShellClass;
struct _GailMenuShell
{
GailContainer parent;
};
GType gail_menu_shell_get_type (void);
struct _GailMenuShellClass
{
GailContainerClass parent_class;
};
AtkObject* gail_menu_shell_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_MENU_SHELL_H__ */

View File

@ -0,0 +1,655 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailnotebook.h"
#include "gailnotebookpage.h"
#include "gail-private-macros.h"
static void gail_notebook_class_init (GailNotebookClass *klass);
static void gail_notebook_object_init (GailNotebook *notebook);
static void gail_notebook_finalize (GObject *object);
static void gail_notebook_real_initialize (AtkObject *obj,
gpointer data);
static void gail_notebook_real_notify_gtk (GObject *obj,
GParamSpec *pspec);
static AtkObject* gail_notebook_ref_child (AtkObject *obj,
gint i);
static gint gail_notebook_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static void atk_selection_interface_init (AtkSelectionIface *iface);
static gboolean gail_notebook_add_selection (AtkSelection *selection,
gint i);
static AtkObject* gail_notebook_ref_selection (AtkSelection *selection,
gint i);
static gint gail_notebook_get_selection_count (AtkSelection *selection);
static gboolean gail_notebook_is_child_selected (AtkSelection *selection,
gint i);
static AtkObject* find_child_in_list (GList *list,
gint index);
static void check_cache (GailNotebook *gail_notebook,
GtkNotebook *notebook);
static void reset_cache (GailNotebook *gail_notebook,
gint index);
static void create_notebook_page_accessible (GailNotebook *gail_notebook,
GtkNotebook *notebook,
gint index,
gboolean insert_before,
GList *list);
static void gail_notebook_child_parent_set (GtkWidget *widget,
GtkWidget *old_parent,
gpointer data);
static gboolean gail_notebook_focus_cb (GtkWidget *widget,
GtkDirectionType type);
static gboolean gail_notebook_check_focus_tab (gpointer data);
static void gail_notebook_destroyed (gpointer data);
static gpointer parent_class = NULL;
GType
gail_notebook_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailNotebookClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_notebook_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailNotebook), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_notebook_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_selection_info =
{
(GInterfaceInitFunc) atk_selection_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailNotebook", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_SELECTION,
&atk_selection_info);
}
return type;
}
static void
gail_notebook_class_init (GailNotebookClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailWidgetClass *widget_class;
GailContainerClass *container_class;
widget_class = (GailWidgetClass*)klass;
container_class = (GailContainerClass*)klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = gail_notebook_finalize;
widget_class->notify_gtk = gail_notebook_real_notify_gtk;
class->ref_child = gail_notebook_ref_child;
class->initialize = gail_notebook_real_initialize;
/*
* We do not provide an implementation of get_n_children
* as the implementation in GailContainer returns the correct
* number of children.
*/
container_class->remove_gtk = gail_notebook_real_remove_gtk;
}
static void
gail_notebook_object_init (GailNotebook *notebook)
{
notebook->page_cache = NULL;
notebook->selected_page = -1;
notebook->focus_tab_page = -1;
notebook->remove_index = -1;
notebook->idle_focus_id = 0;
}
AtkObject*
gail_notebook_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), NULL);
object = g_object_new (GAIL_TYPE_NOTEBOOK, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static AtkObject*
gail_notebook_ref_child (AtkObject *obj,
gint i)
{
AtkObject *accessible = NULL;
GailNotebook *gail_notebook;
GtkNotebook *gtk_notebook;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
gail_notebook = GAIL_NOTEBOOK (obj);
gtk_notebook = GTK_NOTEBOOK (widget);
if (gail_notebook->page_count < g_list_length (gtk_notebook->children))
check_cache (gail_notebook, gtk_notebook);
accessible = find_child_in_list (gail_notebook->page_cache, i);
if (accessible != NULL)
g_object_ref (accessible);
return accessible;
}
static void
gail_notebook_page_added (GtkNotebook *gtk_notebook,
GtkWidget *child,
guint page_num,
gpointer data)
{
AtkObject *atk_obj;
GailNotebook *notebook;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (gtk_notebook));
notebook = GAIL_NOTEBOOK (atk_obj);
create_notebook_page_accessible (notebook, gtk_notebook, page_num, FALSE, NULL);
}
static void
gail_notebook_real_initialize (AtkObject *obj,
gpointer data)
{
GailNotebook *notebook;
GtkNotebook *gtk_notebook;
gint i;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
notebook = GAIL_NOTEBOOK (obj);
gtk_notebook = GTK_NOTEBOOK (data);
for (i = 0; i < g_list_length (gtk_notebook->children); i++)
{
create_notebook_page_accessible (notebook, gtk_notebook, i, FALSE, NULL);
}
notebook->page_count = i;
notebook->selected_page = gtk_notebook_get_current_page (gtk_notebook);
if (gtk_notebook->focus_tab && gtk_notebook->focus_tab->data)
{
notebook->focus_tab_page = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
}
g_signal_connect (gtk_notebook,
"focus",
G_CALLBACK (gail_notebook_focus_cb),
NULL);
g_signal_connect (gtk_notebook,
"page-added",
G_CALLBACK (gail_notebook_page_added),
NULL);
g_object_weak_ref (G_OBJECT(gtk_notebook),
(GWeakNotify) gail_notebook_destroyed,
obj);
obj->role = ATK_ROLE_PAGE_TAB_LIST;
}
static void
gail_notebook_real_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkWidget *widget;
AtkObject* atk_obj;
widget = GTK_WIDGET (obj);
atk_obj = gtk_widget_get_accessible (widget);
if (strcmp (pspec->name, "page") == 0)
{
gint page_num, old_page_num;
gint focus_page_num = 0;
gint old_focus_page_num;
GailNotebook *gail_notebook;
GtkNotebook *gtk_notebook;
gail_notebook = GAIL_NOTEBOOK (atk_obj);
gtk_notebook = GTK_NOTEBOOK (widget);
if (gail_notebook->page_count < g_list_length (gtk_notebook->children))
check_cache (gail_notebook, gtk_notebook);
/*
* Notify SELECTED state change for old and new page
*/
old_page_num = gail_notebook->selected_page;
page_num = gtk_notebook_get_current_page (gtk_notebook);
gail_notebook->selected_page = page_num;
old_focus_page_num = gail_notebook->focus_tab_page;
if (gtk_notebook->focus_tab && gtk_notebook->focus_tab->data)
{
focus_page_num = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
gail_notebook->focus_tab_page = focus_page_num;
}
if (page_num != old_page_num)
{
AtkObject *obj;
if (old_page_num != -1)
{
obj = gail_notebook_ref_child (atk_obj, old_page_num);
if (obj)
{
atk_object_notify_state_change (obj,
ATK_STATE_SELECTED,
FALSE);
g_object_unref (obj);
}
}
obj = gail_notebook_ref_child (atk_obj, page_num);
if (obj)
{
atk_object_notify_state_change (obj,
ATK_STATE_SELECTED,
TRUE);
g_object_unref (obj);
/*
* The page which is being displayed has changed but there is
* no need to tell the focus tracker as the focus page will also
* change or a widget in the page will receive focus if the
* Notebook does not have tabs.
*/
}
g_signal_emit_by_name (atk_obj, "selection_changed");
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
if (gtk_notebook_get_show_tabs (gtk_notebook) &&
(focus_page_num != old_focus_page_num))
{
if (gail_notebook->idle_focus_id)
g_source_remove (gail_notebook->idle_focus_id);
gail_notebook->idle_focus_id = g_idle_add (gail_notebook_check_focus_tab, atk_obj);
}
}
else
GAIL_WIDGET_CLASS (parent_class)->notify_gtk (obj, pspec);
}
static void
gail_notebook_finalize (GObject *object)
{
GailNotebook *notebook = GAIL_NOTEBOOK (object);
GList *list;
/*
* Get rid of the GailNotebookPage objects which we have cached.
*/
list = notebook->page_cache;
if (list != NULL)
{
while (list)
{
g_object_unref (list->data);
list = list->next;
}
}
g_list_free (notebook->page_cache);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->add_selection = gail_notebook_add_selection;
iface->ref_selection = gail_notebook_ref_selection;
iface->get_selection_count = gail_notebook_get_selection_count;
iface->is_child_selected = gail_notebook_is_child_selected;
/*
* The following don't make any sense for GtkNotebook widgets.
* Unsupported AtkSelection interfaces:
* clear_selection();
* remove_selection();
* select_all_selection();
*/
}
/*
* GtkNotebook only supports the selection of one page at a time.
* Selecting a page unselects any previous selection, so this
* changes the current selection instead of adding to it.
*/
static gboolean
gail_notebook_add_selection (AtkSelection *selection,
gint i)
{
GtkNotebook *notebook;
GtkWidget *widget;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
notebook = GTK_NOTEBOOK (widget);
gtk_notebook_set_current_page (notebook, i);
return TRUE;
}
static AtkObject*
gail_notebook_ref_selection (AtkSelection *selection,
gint i)
{
AtkObject *accessible;
GtkWidget *widget;
GtkNotebook *notebook;
gint pagenum;
/*
* A note book can have only one selection.
*/
gail_return_val_if_fail (i == 0, NULL);
g_return_val_if_fail (GAIL_IS_NOTEBOOK (selection), NULL);
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/* State is defunct */
return NULL;
notebook = GTK_NOTEBOOK (widget);
pagenum = gtk_notebook_get_current_page (notebook);
gail_return_val_if_fail (pagenum != -1, NULL);
accessible = gail_notebook_ref_child (ATK_OBJECT (selection), pagenum);
return accessible;
}
/*
* Always return 1 because there can only be one page
* selected at any time
*/
static gint
gail_notebook_get_selection_count (AtkSelection *selection)
{
GtkWidget *widget;
GtkNotebook *notebook;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
notebook = GTK_NOTEBOOK (widget);
if (notebook == NULL)
return 0;
else
return 1;
}
static gboolean
gail_notebook_is_child_selected (AtkSelection *selection,
gint i)
{
GtkWidget *widget;
GtkNotebook *notebook;
gint pagenumber;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
notebook = GTK_NOTEBOOK (widget);
pagenumber = gtk_notebook_get_current_page(notebook);
if (pagenumber == i)
return TRUE;
else
return FALSE;
}
static AtkObject*
find_child_in_list (GList *list,
gint index)
{
AtkObject *obj = NULL;
while (list)
{
if (GAIL_NOTEBOOK_PAGE (list->data)->index == index)
{
obj = ATK_OBJECT (list->data);
break;
}
list = list->next;
}
return obj;
}
static void
check_cache (GailNotebook *gail_notebook,
GtkNotebook *notebook)
{
GList *gtk_list;
GList *gail_list;
gint i;
gtk_list = notebook->children;
gail_list = gail_notebook->page_cache;
i = 0;
while (gtk_list)
{
if (!gail_list)
{
create_notebook_page_accessible (gail_notebook, notebook, i, FALSE, NULL);
}
else if (GAIL_NOTEBOOK_PAGE (gail_list->data)->page != gtk_list->data)
{
create_notebook_page_accessible (gail_notebook, notebook, i, TRUE, gail_list);
}
else
{
gail_list = gail_list->next;
}
i++;
gtk_list = gtk_list->next;
}
gail_notebook->page_count = i;
}
static void
reset_cache (GailNotebook *gail_notebook,
gint index)
{
GList *l;
for (l = gail_notebook->page_cache; l; l = l->next)
{
if (GAIL_NOTEBOOK_PAGE (l->data)->index > index)
GAIL_NOTEBOOK_PAGE (l->data)->index -= 1;
}
}
static void
create_notebook_page_accessible (GailNotebook *gail_notebook,
GtkNotebook *notebook,
gint index,
gboolean insert_before,
GList *list)
{
AtkObject *obj;
obj = gail_notebook_page_new (notebook, index);
g_object_ref (obj);
if (insert_before)
gail_notebook->page_cache = g_list_insert_before (gail_notebook->page_cache, list, obj);
else
gail_notebook->page_cache = g_list_append (gail_notebook->page_cache, obj);
g_signal_connect (gtk_notebook_get_nth_page (notebook, index),
"parent_set",
G_CALLBACK (gail_notebook_child_parent_set),
obj);
}
static void
gail_notebook_child_parent_set (GtkWidget *widget,
GtkWidget *old_parent,
gpointer data)
{
GailNotebook *gail_notebook;
gail_return_if_fail (old_parent != NULL);
gail_notebook = GAIL_NOTEBOOK (gtk_widget_get_accessible (old_parent));
gail_notebook->remove_index = GAIL_NOTEBOOK_PAGE (data)->index;
}
static gint
gail_notebook_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
GailNotebook *gail_notebook;
AtkObject *obj;
gint index;
g_return_val_if_fail (container != NULL, 1);
gail_notebook = GAIL_NOTEBOOK (gtk_widget_get_accessible (GTK_WIDGET (container)));
index = gail_notebook->remove_index;
gail_notebook->remove_index = -1;
obj = find_child_in_list (gail_notebook->page_cache, index);
g_return_val_if_fail (obj, 1);
gail_notebook->page_cache = g_list_remove (gail_notebook->page_cache, obj);
gail_notebook->page_count -= 1;
reset_cache (gail_notebook, index);
g_signal_emit_by_name (gail_notebook,
"children_changed::remove",
GAIL_NOTEBOOK_PAGE (obj)->index,
obj, NULL);
g_object_unref (obj);
return 1;
}
static gboolean
gail_notebook_focus_cb (GtkWidget *widget,
GtkDirectionType type)
{
AtkObject *atk_obj = gtk_widget_get_accessible (widget);
GailNotebook *gail_notebook = GAIL_NOTEBOOK (atk_obj);
switch (type)
{
case GTK_DIR_LEFT:
case GTK_DIR_RIGHT:
if (gail_notebook->idle_focus_id)
g_source_remove (gail_notebook->idle_focus_id);
gail_notebook->idle_focus_id = g_idle_add (gail_notebook_check_focus_tab, atk_obj);
break;
default:
break;
}
return FALSE;
}
static gboolean
gail_notebook_check_focus_tab (gpointer data)
{
GtkWidget *widget;
AtkObject *atk_obj;
gint focus_page_num, old_focus_page_num;
GailNotebook *gail_notebook;
GtkNotebook *gtk_notebook;
GDK_THREADS_ENTER ();
atk_obj = ATK_OBJECT (data);
gail_notebook = GAIL_NOTEBOOK (atk_obj);
widget = GTK_ACCESSIBLE (atk_obj)->widget;
gtk_notebook = GTK_NOTEBOOK (widget);
gail_notebook->idle_focus_id = 0;
if (!gtk_notebook->focus_tab)
{
GDK_THREADS_LEAVE ();
return FALSE;
}
old_focus_page_num = gail_notebook->focus_tab_page;
focus_page_num = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
gail_notebook->focus_tab_page = focus_page_num;
if (old_focus_page_num != focus_page_num)
{
AtkObject *obj;
obj = atk_object_ref_accessible_child (atk_obj, focus_page_num);
atk_focus_tracker_notify (obj);
g_object_unref (obj);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
static void
gail_notebook_destroyed (gpointer data)
{
GailNotebook *gail_notebook = GAIL_NOTEBOOK (data);
if (gail_notebook->idle_focus_id)
g_source_remove (gail_notebook->idle_focus_id);
}

View File

@ -0,0 +1,73 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_NOTEBOOK_H__
#define __GAIL_NOTEBOOK_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_NOTEBOOK (gail_notebook_get_type ())
#define GAIL_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_NOTEBOOK, GailNotebook))
#define GAIL_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_NOTEBOOK, GailNotebookClass))
#define GAIL_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_NOTEBOOK))
#define GAIL_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_NOTEBOOK))
#define GAIL_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_NOTEBOOK, GailNotebookClass))
typedef struct _GailNotebook GailNotebook;
typedef struct _GailNotebookClass GailNotebookClass;
struct _GailNotebook
{
GailContainer parent;
/*
* page_cache maintains a list of pre-ref'd Notebook Pages.
* This cache is queried by gail_notebook_ref_child().
* If the page is found in the list then a new page does not
* need to be created
*/
GList* page_cache;
gint selected_page;
gint focus_tab_page;
gint page_count;
guint idle_focus_id;
gint remove_index;
};
GType gail_notebook_get_type (void);
struct _GailNotebookClass
{
GailContainerClass parent_class;
};
AtkObject* gail_notebook_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_NOTEBOOK_H__ */

View File

@ -0,0 +1,868 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailnotebookpage.h"
#include <libgail-util/gailmisc.h>
#include "gail-private-macros.h"
static void gail_notebook_page_class_init (GailNotebookPageClass *klass);
static void gail_notebook_page_finalize (GObject *object);
static void gail_notebook_page_label_map_gtk (GtkWidget *widget,
gpointer data);
static G_CONST_RETURN gchar* gail_notebook_page_get_name (AtkObject *accessible);
static AtkObject* gail_notebook_page_get_parent (AtkObject *accessible);
static gint gail_notebook_page_get_n_children (AtkObject *accessible);
static AtkObject* gail_notebook_page_ref_child (AtkObject *accessible,
gint i);
static gint gail_notebook_page_get_index_in_parent
(AtkObject *accessible);
static AtkStateSet* gail_notebook_page_ref_state_set (AtkObject *accessible);
static gint gail_notebook_page_notify (GObject *obj,
GParamSpec *pspec,
gpointer user_data);
static void gail_notebook_page_init_textutil (GailNotebookPage *notebook_page,
GtkWidget *label);
static void atk_component_interface_init (AtkComponentIface *iface);
static AtkObject* gail_notebook_page_ref_accessible_at_point
(AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
static void gail_notebook_page_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
static AtkObject* _gail_notebook_page_get_tab_label (GailNotebookPage *page);
/* atktext.h */
static void atk_text_interface_init (AtkTextIface *iface);
static gchar* gail_notebook_page_get_text (AtkText *text,
gint start_pos,
gint end_pos);
static gunichar gail_notebook_page_get_character_at_offset
(AtkText *text,
gint offset);
static gchar* gail_notebook_page_get_text_before_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_notebook_page_get_text_at_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gchar* gail_notebook_page_get_text_after_offset
(AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
static gint gail_notebook_page_get_character_count (AtkText *text);
static void gail_notebook_page_get_character_extents
(AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
static gint gail_notebook_page_get_offset_at_point
(AtkText *text,
gint x,
gint y,
AtkCoordType coords);
static AtkAttributeSet* gail_notebook_page_get_run_attributes
(AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
static AtkAttributeSet* gail_notebook_page_get_default_attributes
(AtkText *text);
static GtkWidget* get_label_from_notebook_page (GailNotebookPage *page);
static GtkWidget* find_label_child (GtkContainer *container);
static gpointer parent_class = NULL;
GType
gail_notebook_page_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailNotebookPageClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_notebook_page_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailNotebookPage), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_component_info =
{
(GInterfaceInitFunc) atk_component_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_text_info =
{
(GInterfaceInitFunc) atk_text_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"GailNotebookPage", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
&atk_component_info);
g_type_add_interface_static (type, ATK_TYPE_TEXT,
&atk_text_info);
}
return type;
}
static void
gail_notebook_page_class_init (GailNotebookPageClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->get_name = gail_notebook_page_get_name;
class->get_parent = gail_notebook_page_get_parent;
class->get_n_children = gail_notebook_page_get_n_children;
class->ref_child = gail_notebook_page_ref_child;
class->ref_state_set = gail_notebook_page_ref_state_set;
class->get_index_in_parent = gail_notebook_page_get_index_in_parent;
gobject_class->finalize = gail_notebook_page_finalize;
}
static gint
notify_child_added (gpointer data)
{
GailNotebookPage *page;
AtkObject *atk_object, *atk_parent;
GDK_THREADS_ENTER ();
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (data), FALSE);
page = GAIL_NOTEBOOK_PAGE (data);
atk_object = ATK_OBJECT (data);
/* The widget page->notebook may be deleted before this handler is called */
if (page->notebook != NULL)
{
atk_parent = gtk_widget_get_accessible (GTK_WIDGET (page->notebook));
atk_object_set_parent (atk_object, atk_parent);
g_signal_emit_by_name (atk_parent, "children_changed::add", page->index, atk_object, NULL);
}
GDK_THREADS_LEAVE ();
return FALSE;
}
AtkObject*
gail_notebook_page_new (GtkNotebook *notebook,
gint pagenum)
{
GObject *object;
AtkObject *atk_object;
GailNotebookPage *page;
GtkWidget *child;
GtkWidget *label;
GList *list;
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
child = gtk_notebook_get_nth_page (notebook, pagenum);
if (!child)
return NULL;
object = g_object_new (GAIL_TYPE_NOTEBOOK_PAGE, NULL);
g_return_val_if_fail (object != NULL, NULL);
page = GAIL_NOTEBOOK_PAGE (object);
page->notebook = notebook;
g_object_add_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook);
page->index = pagenum;
list = g_list_nth (notebook->children, pagenum);
page->page = list->data;
page->textutil = NULL;
atk_object = ATK_OBJECT (page);
atk_object->role = ATK_ROLE_PAGE_TAB;
atk_object->layer = ATK_LAYER_WIDGET;
g_idle_add (notify_child_added, atk_object);
/*
* We get notified of changes to the label
*/
label = get_label_from_notebook_page (page);
if (GTK_IS_LABEL (label))
{
if (GTK_WIDGET_MAPPED (label))
gail_notebook_page_init_textutil (page, label);
else
g_signal_connect (label,
"map",
G_CALLBACK (gail_notebook_page_label_map_gtk),
page);
}
return atk_object;
}
static void
gail_notebook_page_label_map_gtk (GtkWidget *widget,
gpointer data)
{
GailNotebookPage *page;
page = GAIL_NOTEBOOK_PAGE (data);
gail_notebook_page_init_textutil (page, widget);
}
static void
gail_notebook_page_init_textutil (GailNotebookPage *page,
GtkWidget *label)
{
const gchar *label_text;
if (page->textutil == NULL)
{
page->textutil = gail_text_util_new ();
g_signal_connect (label,
"notify",
(GCallback) gail_notebook_page_notify,
page);
}
label_text = gtk_label_get_text (GTK_LABEL (label));
gail_text_util_text_setup (page->textutil, label_text);
}
static gint
gail_notebook_page_notify (GObject *obj,
GParamSpec *pspec,
gpointer user_data)
{
AtkObject *atk_obj = ATK_OBJECT (user_data);
GtkLabel *label;
GailNotebookPage *page;
if (strcmp (pspec->name, "label") == 0)
{
const gchar* label_text;
label = GTK_LABEL (obj);
label_text = gtk_label_get_text (label);
page = GAIL_NOTEBOOK_PAGE (atk_obj);
gail_text_util_text_setup (page->textutil, label_text);
if (atk_obj->name == NULL)
{
/*
* The label has changed so notify a change in accessible-name
*/
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
}
/*
* The label is the only property which can be changed
*/
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
return 1;
}
static void
gail_notebook_page_finalize (GObject *object)
{
GailNotebookPage *page = GAIL_NOTEBOOK_PAGE (object);
if (page->notebook)
g_object_remove_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook);
if (page->textutil)
g_object_unref (page->textutil);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static G_CONST_RETURN gchar*
gail_notebook_page_get_name (AtkObject *accessible)
{
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (accessible), NULL);
if (accessible->name != NULL)
return accessible->name;
else
{
GtkWidget *label;
label = get_label_from_notebook_page (GAIL_NOTEBOOK_PAGE (accessible));
if (GTK_IS_LABEL (label))
return gtk_label_get_text (GTK_LABEL (label));
else
return NULL;
}
}
static AtkObject*
gail_notebook_page_get_parent (AtkObject *accessible)
{
GailNotebookPage *page;
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (accessible), NULL);
page = GAIL_NOTEBOOK_PAGE (accessible);
if (!page->notebook)
return NULL;
return gtk_widget_get_accessible (GTK_WIDGET (page->notebook));
}
static gint
gail_notebook_page_get_n_children (AtkObject *accessible)
{
/* Notebook page has only one child */
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (accessible), 0);
return 1;
}
static AtkObject*
gail_notebook_page_ref_child (AtkObject *accessible,
gint i)
{
GtkWidget *child;
AtkObject *child_obj;
GailNotebookPage *page = NULL;
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (accessible), NULL);
if (i != 0)
return NULL;
page = GAIL_NOTEBOOK_PAGE (accessible);
if (!page->notebook)
return NULL;
child = gtk_notebook_get_nth_page (page->notebook, page->index);
gail_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
child_obj = gtk_widget_get_accessible (child);
g_object_ref (child_obj);
return child_obj;
}
static gint
gail_notebook_page_get_index_in_parent (AtkObject *accessible)
{
GailNotebookPage *page;
g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (accessible), -1);
page = GAIL_NOTEBOOK_PAGE (accessible);
return page->index;
}
static AtkStateSet*
gail_notebook_page_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set, *label_state_set, *merged_state_set;
AtkObject *atk_label;
g_return_val_if_fail (GAIL_NOTEBOOK_PAGE (accessible), NULL);
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
atk_label = _gail_notebook_page_get_tab_label (GAIL_NOTEBOOK_PAGE (accessible));
if (atk_label)
{
label_state_set = atk_object_ref_state_set (atk_label);
merged_state_set = atk_state_set_or_sets (state_set, label_state_set);
g_object_unref (label_state_set);
g_object_unref (state_set);
}
else
{
AtkObject *child;
child = atk_object_ref_accessible_child (accessible, 0);
gail_return_val_if_fail (child, state_set);
merged_state_set = state_set;
state_set = atk_object_ref_state_set (child);
if (atk_state_set_contains_state (state_set, ATK_STATE_VISIBLE))
{
atk_state_set_add_state (merged_state_set, ATK_STATE_VISIBLE);
if (atk_state_set_contains_state (state_set, ATK_STATE_ENABLED))
atk_state_set_add_state (merged_state_set, ATK_STATE_ENABLED);
if (atk_state_set_contains_state (state_set, ATK_STATE_SHOWING))
atk_state_set_add_state (merged_state_set, ATK_STATE_SHOWING);
}
g_object_unref (state_set);
g_object_unref (child);
}
return merged_state_set;
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
g_return_if_fail (iface != NULL);
/*
* We use the default implementations for contains, get_position, get_size
*/
iface->ref_accessible_at_point = gail_notebook_page_ref_accessible_at_point;
iface->get_extents = gail_notebook_page_get_extents;
}
static AtkObject*
gail_notebook_page_ref_accessible_at_point (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
/*
* There is only one child so we return it.
*/
AtkObject* child;
g_return_val_if_fail (ATK_IS_OBJECT (component), NULL);
child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0);
return child;
}
static void
gail_notebook_page_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
AtkObject *atk_label;
g_return_if_fail (GAIL_IS_NOTEBOOK_PAGE (component));
atk_label = _gail_notebook_page_get_tab_label (GAIL_NOTEBOOK_PAGE (component));
if (!atk_label)
{
AtkObject *child;
*width = 0;
*height = 0;
child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0);
gail_return_if_fail (child);
atk_component_get_position (ATK_COMPONENT (child), x, y, coord_type);
g_object_unref (child);
}
else
{
atk_component_get_extents (ATK_COMPONENT (atk_label),
x, y, width, height, coord_type);
}
return;
}
static AtkObject*
_gail_notebook_page_get_tab_label (GailNotebookPage *page)
{
GtkWidget *label;
label = get_label_from_notebook_page (page);
if (label)
return gtk_widget_get_accessible (label);
else
return NULL;
}
/* atktext.h */
static void
atk_text_interface_init (AtkTextIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_text = gail_notebook_page_get_text;
iface->get_character_at_offset = gail_notebook_page_get_character_at_offset;
iface->get_text_before_offset = gail_notebook_page_get_text_before_offset;
iface->get_text_at_offset = gail_notebook_page_get_text_at_offset;
iface->get_text_after_offset = gail_notebook_page_get_text_after_offset;
iface->get_character_count = gail_notebook_page_get_character_count;
iface->get_character_extents = gail_notebook_page_get_character_extents;
iface->get_offset_at_point = gail_notebook_page_get_offset_at_point;
iface->get_run_attributes = gail_notebook_page_get_run_attributes;
iface->get_default_attributes = gail_notebook_page_get_default_attributes;
}
static gchar*
gail_notebook_page_get_text (AtkText *text,
gint start_pos,
gint end_pos)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
const gchar *label_text;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL (label))
return NULL;
if (!notebook_page->textutil)
gail_notebook_page_init_textutil (notebook_page, label);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (label_text == NULL)
return NULL;
else
{
return gail_text_util_get_substring (notebook_page->textutil,
start_pos, end_pos);
}
}
static gchar*
gail_notebook_page_get_text_before_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return NULL;
if (!notebook_page->textutil)
gail_notebook_page_init_textutil (notebook_page, label);
return gail_text_util_get_text (notebook_page->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_BEFORE_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_notebook_page_get_text_at_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return NULL;
if (!notebook_page->textutil)
gail_notebook_page_init_textutil (notebook_page, label);
return gail_text_util_get_text (notebook_page->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_AT_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gchar*
gail_notebook_page_get_text_after_offset (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return NULL;
if (!notebook_page->textutil)
gail_notebook_page_init_textutil (notebook_page, label);
return gail_text_util_get_text (notebook_page->textutil,
gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET,
boundary_type, offset, start_offset, end_offset);
}
static gint
gail_notebook_page_get_character_count (AtkText *text)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return 0;
return g_utf8_strlen (gtk_label_get_text (GTK_LABEL (label)), -1);
}
static void
gail_notebook_page_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
PangoRectangle char_rect;
gint index, x_layout, y_layout;
const gchar *label_text;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
label_text = gtk_label_get_text (GTK_LABEL (label));
index = g_utf8_offset_to_pointer (label_text, offset) - label_text;
pango_layout_index_to_pos (gtk_label_get_layout (GTK_LABEL (label)), index, &char_rect);
gail_misc_get_extents_from_pango_rectangle (label, &char_rect,
x_layout, y_layout, x, y, width, height, coords);
}
static gint
gail_notebook_page_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
gint index, x_layout, y_layout;
const gchar *label_text;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return -1;
gtk_label_get_layout_offsets (GTK_LABEL (label), &x_layout, &y_layout);
index = gail_misc_get_index_at_point_in_layout (label,
gtk_label_get_layout (GTK_LABEL (label)),
x_layout, y_layout, x, y, coords);
label_text = gtk_label_get_text (GTK_LABEL (label));
if (index == -1)
{
if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN)
return g_utf8_strlen (label_text, -1);
return index;
}
else
return g_utf8_pointer_to_offset (label_text, label_text + index);
}
static AtkAttributeSet*
gail_notebook_page_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
AtkAttributeSet *at_set = NULL;
GtkJustification justify;
GtkTextDirection dir;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return NULL;
/* Get values set for entire label, if any */
justify = gtk_label_get_justify (GTK_LABEL (label));
if (justify != GTK_JUSTIFY_CENTER)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_JUSTIFICATION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, justify)));
}
dir = gtk_widget_get_direction (label);
if (dir == GTK_TEXT_DIR_RTL)
{
at_set = gail_misc_add_attribute (at_set,
ATK_TEXT_ATTR_DIRECTION,
g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, dir)));
}
at_set = gail_misc_layout_get_run_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
(gchar *) gtk_label_get_text (GTK_LABEL (label)),
offset,
start_offset,
end_offset);
return at_set;
}
static AtkAttributeSet*
gail_notebook_page_get_default_attributes (AtkText *text)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
AtkAttributeSet *at_set = NULL;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return NULL;
at_set = gail_misc_get_default_attributes (at_set,
gtk_label_get_layout (GTK_LABEL (label)),
label);
return at_set;
}
static gunichar
gail_notebook_page_get_character_at_offset (AtkText *text,
gint offset)
{
GtkWidget *label;
GailNotebookPage *notebook_page;
const gchar *string;
gchar *index;
notebook_page = GAIL_NOTEBOOK_PAGE (text);
label = get_label_from_notebook_page (notebook_page);
if (!GTK_IS_LABEL(label))
return '\0';
string = gtk_label_get_text (GTK_LABEL (label));
if (offset >= g_utf8_strlen (string, -1))
return '\0';
index = g_utf8_offset_to_pointer (string, offset);
return g_utf8_get_char (index);
}
static GtkWidget*
get_label_from_notebook_page (GailNotebookPage *page)
{
GtkWidget *child;
GtkNotebook *notebook;
notebook = page->notebook;
if (!notebook)
return NULL;
if (!gtk_notebook_get_show_tabs (notebook))
return NULL;
child = gtk_notebook_get_nth_page (notebook, page->index);
if (child == NULL) return NULL;
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
child = gtk_notebook_get_tab_label (notebook, child);
if (GTK_IS_LABEL (child))
return child;
if (GTK_IS_CONTAINER (child))
child = find_label_child (GTK_CONTAINER (child));
return child;
}
static GtkWidget*
find_label_child (GtkContainer *container)
{
GList *children, *tmp_list;
GtkWidget *child;
children = gtk_container_get_children (container);
child = NULL;
for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next)
{
if (GTK_IS_LABEL (tmp_list->data))
{
child = GTK_WIDGET (tmp_list->data);
break;
}
else if (GTK_IS_CONTAINER (tmp_list->data))
{
child = find_label_child (GTK_CONTAINER (tmp_list->data));
if (child)
break;
}
}
g_list_free (children);
return child;
}

View File

@ -0,0 +1,69 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_NOTEBOOK_PAGE_H__
#define __GAIL_NOTEBOOK_PAGE_H__
#include <atk/atk.h>
#include <gtk/gtknotebook.h>
#include <gail/gailnotebook.h>
#include <libgail-util/gailtextutil.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_NOTEBOOK_PAGE (gail_notebook_page_get_type ())
#define GAIL_NOTEBOOK_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),GAIL_TYPE_NOTEBOOK_PAGE, GailNotebookPage))
#define GAIL_NOTEBOOK_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_NOTEBOOK_PAGE, GailNotebookPageClass))
#define GAIL_IS_NOTEBOOK_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_NOTEBOOK_PAGE))
#define GAIL_IS_NOTEBOOK_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_NOTEBOOK_PAGE))
#define GAIL_NOTEBOOK_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_NOTEBOOK_PAGE, GailNotebookPageClass))
typedef struct _GailNotebookPage GailNotebookPage;
typedef struct _GailNotebookPageClass GailNotebookPageClass;
struct _GailNotebookPage
{
AtkObject parent;
GtkNotebook *notebook;
GtkNotebookPage *page;
gint index;
GailTextUtil *textutil;
};
GType gail_notebook_page_get_type (void);
struct _GailNotebookPageClass
{
AtkObjectClass parent_class;
};
AtkObject *gail_notebook_page_new(GtkNotebook *notebook, gint pagenum);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_NOTEBOOK_PAGE_H__ */

View File

@ -0,0 +1,88 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailobject.h"
static void gail_object_class_init (GailObjectClass *klass);
static void gail_object_real_initialize (AtkObject *obj,
gpointer data);
static AtkGObjectAccessibleClass *parent_class = NULL;
GType
gail_object_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailObjectClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_object_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailObject), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE,
"GailObject", &tinfo, 0);
}
return type;
}
AtkObject*
gail_object_new (GObject *obj)
{
gpointer object;
AtkObject *atk_object;
g_return_val_if_fail (GTK_IS_OBJECT (obj), NULL);
object = g_object_new (GAIL_TYPE_OBJECT, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, obj);
return atk_object;
}
static void
gail_object_class_init (GailObjectClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->initialize = gail_object_real_initialize;
}
static void
gail_object_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_UNKNOWN;
}

View File

@ -0,0 +1,58 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_OBJECT_H__
#define __GAIL_OBJECT_H__
#include <atk/atk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_OBJECT (gail_object_get_type ())
#define GAIL_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_OBJECT, GailObject)
#define GAIL_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_OBJECT, GailObjectlass))
#define GAIL_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_OBJECT))
#define GAIL_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_OBJECT))
#define GAIL_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_OBJECT, GailObjectlass))
typedef struct _GailObject GailObject;
typedef struct _GailObjectClass GailObjectClass;
struct _GailObject
{
AtkGObjectAccessible parent;
};
GType gail_object_get_type (void);
struct _GailObjectClass
{
AtkGObjectAccessibleClass parent_class;
};
AtkObject* gail_object_new (GObject *obj);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_OBJECT_H__ */

View File

@ -0,0 +1,77 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailobjectfactory.h"
#include "gailobject.h"
static void gail_object_factory_class_init (GailObjectFactoryClass *klass);
static AtkObject* gail_object_factory_create_accessible (GObject *obj);
static GType gail_object_factory_get_accessible_type (void);
GType
gail_object_factory_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailObjectFactoryClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_object_factory_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailObjectFactory), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (
ATK_TYPE_OBJECT_FACTORY,
"GailObjectFactory" , &tinfo, 0);
}
return type;
}
static void
gail_object_factory_class_init (GailObjectFactoryClass *klass)
{
AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
class->create_accessible = gail_object_factory_create_accessible;
class->get_accessible_type = gail_object_factory_get_accessible_type;
}
static AtkObject*
gail_object_factory_create_accessible (GObject *obj)
{
return gail_object_new (obj);
}
static GType
gail_object_factory_get_accessible_type (void)
{
return GAIL_TYPE_OBJECT;
}

View File

@ -0,0 +1,58 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_OBJECT_FACTORY_H__
#define __GAIL_OBJECT_FACTORY_H__
#include <atk/atkobjectfactory.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_OBJECT_FACTORY (gail_object_factory_get_type ())
#define GAIL_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_OBJECT_FACTORY, GailObjectFactory))
#define GAIL_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_OBJECT_FACTORY, GailObjectFactoryClass))
#define GAIL_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_OBJECT_FACTORY))
#define GAIL_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_OBJECT_FACTORY))
#define GAIL_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_OBJECT_FACTORY, GailObjectFactoryClass))
typedef struct _GailObjectFactory GailObjectFactory;
typedef struct _GailObjectFactoryClass GailObjectFactoryClass;
struct _GailObjectFactory
{
AtkObjectFactory parent;
};
struct _GailObjectFactoryClass
{
AtkObjectFactoryClass parent_class;
};
GType gail_object_factory_get_type(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_OBJECT_FACTORY_H__ */

View File

@ -0,0 +1,388 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "gailoptionmenu.h"
static void gail_option_menu_class_init (GailOptionMenuClass *klass);
static void gail_option_menu_real_initialize (AtkObject *obj,
gpointer data);
static gint gail_option_menu_get_n_children (AtkObject *obj);
static AtkObject* gail_option_menu_ref_child (AtkObject *obj,
gint i);
static gint gail_option_menu_real_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static gint gail_option_menu_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data);
static void atk_action_interface_init (AtkActionIface *iface);
static gboolean gail_option_menu_do_action (AtkAction *action,
gint i);
static gboolean idle_do_action (gpointer data);
static gint gail_option_menu_get_n_actions (AtkAction *action);
static G_CONST_RETURN gchar* gail_option_menu_get_description (AtkAction *action,
gint i);
static G_CONST_RETURN gchar* gail_option_menu_action_get_name (AtkAction *action,
gint i);
static gboolean gail_option_menu_set_description (AtkAction *action,
gint i,
const gchar *desc);
static GailButtonClass* parent_class = NULL;
GType
gail_option_menu_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailOptionMenuClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_option_menu_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailOptionMenu), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_BUTTON,
"GailOptionMenu", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
}
return type;
}
static void
gail_option_menu_class_init (GailOptionMenuClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailContainerClass *container_class;
container_class = (GailContainerClass *) klass;
class->get_n_children = gail_option_menu_get_n_children;
class->ref_child = gail_option_menu_ref_child;
class->initialize = gail_option_menu_real_initialize;
container_class->add_gtk = gail_option_menu_real_add_gtk;
container_class->remove_gtk = gail_option_menu_real_remove_gtk;
parent_class = g_type_class_peek_parent (klass);
}
AtkObject*
gail_option_menu_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), NULL);
object = g_object_new (GAIL_TYPE_OPTION_MENU, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_option_menu_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_COMBO_BOX;
}
static gint
gail_option_menu_get_n_children (AtkObject *obj)
{
GtkWidget *widget;
GtkOptionMenu *option_menu;
gint n_children = 0;
g_return_val_if_fail (GAIL_IS_OPTION_MENU (obj), 0);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return 0;
option_menu = GTK_OPTION_MENU (widget);
if (gtk_option_menu_get_menu (option_menu))
n_children++;
return n_children;;
}
static AtkObject*
gail_option_menu_ref_child (AtkObject *obj,
gint i)
{
GtkWidget *widget;
AtkObject *accessible;
g_return_val_if_fail (GAIL_IS_OPTION_MENU (obj), NULL);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return NULL;
if (i == 0)
accessible = g_object_ref (gtk_widget_get_accessible (gtk_option_menu_get_menu (GTK_OPTION_MENU (widget))));
else
accessible = NULL;
return accessible;
}
static gint
gail_option_menu_real_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
AtkObject* atk_parent = ATK_OBJECT (data);
AtkObject* atk_child = gtk_widget_get_accessible (widget);
GAIL_CONTAINER_CLASS (parent_class)->add_gtk (container, widget, data);
g_object_notify (G_OBJECT (atk_child), "accessible_parent");
g_signal_emit_by_name (atk_parent, "children_changed::add",
1, atk_child, NULL);
return 1;
}
static gint
gail_option_menu_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
{
AtkPropertyValues values = { NULL };
AtkObject* atk_parent = ATK_OBJECT (data);
AtkObject *atk_child = gtk_widget_get_accessible (widget);
g_value_init (&values.old_value, G_TYPE_POINTER);
g_value_set_pointer (&values.old_value, atk_parent);
values.property_name = "accessible-parent";
g_signal_emit_by_name (atk_child,
"property_change::accessible-parent", &values, NULL);
g_signal_emit_by_name (atk_parent, "children_changed::remove",
1, atk_child, NULL);
return 1;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->do_action = gail_option_menu_do_action;
iface->get_n_actions = gail_option_menu_get_n_actions;
iface->get_description = gail_option_menu_get_description;
iface->get_name = gail_option_menu_action_get_name;
iface->set_description = gail_option_menu_set_description;
}
static gboolean
gail_option_menu_do_action (AtkAction *action,
gint i)
{
GtkWidget *widget;
GailButton *button;
gboolean return_value = TRUE;
button = GAIL_BUTTON (action);
widget = GTK_ACCESSIBLE (action)->widget;
if (widget == NULL)
/*
* State is defunct
*/
return FALSE;
if (!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
return FALSE;
switch (i)
{
case 0:
if (button->action_idle_handler)
return_value = FALSE;
else
button->action_idle_handler = g_idle_add (idle_do_action, button);
break;
default:
return_value = FALSE;
break;
}
return return_value;
}
static gboolean
idle_do_action (gpointer data)
{
GtkButton *button;
GtkWidget *widget;
GdkEvent tmp_event;
GailButton *gail_button;
GDK_THREADS_ENTER ();
gail_button = GAIL_BUTTON (data);
gail_button->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_button)->widget;
if (widget == NULL /* State is defunct */ ||
!GTK_WIDGET_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
{
GDK_THREADS_LEAVE ();
return FALSE;
}
button = GTK_BUTTON (widget);
button->in_button = TRUE;
gtk_button_enter (button);
/*
* Simulate a button press event. calling gtk_button_pressed() does
* not get the job done for a GtkOptionMenu.
*/
tmp_event.button.type = GDK_BUTTON_PRESS;
tmp_event.button.window = widget->window;
tmp_event.button.button = 1;
tmp_event.button.send_event = TRUE;
tmp_event.button.time = GDK_CURRENT_TIME;
tmp_event.button.axes = NULL;
gtk_widget_event (widget, &tmp_event);
GDK_THREADS_LEAVE ();
return FALSE;
}
static gint
gail_option_menu_get_n_actions (AtkAction *action)
{
return 1;
}
static G_CONST_RETURN gchar*
gail_option_menu_get_description (AtkAction *action,
gint i)
{
GailButton *button;
G_CONST_RETURN gchar *return_value;
button = GAIL_BUTTON (action);
switch (i)
{
case 0:
return_value = button->press_description;
break;
default:
return_value = NULL;
break;
}
return return_value;
}
static G_CONST_RETURN gchar*
gail_option_menu_action_get_name (AtkAction *action,
gint i)
{
G_CONST_RETURN gchar *return_value;
switch (i)
{
case 0:
/*
* This action simulates a button press by simulating moving the
* mouse into the button followed by pressing the left mouse button.
*/
return_value = "press";
break;
default:
return_value = NULL;
break;
}
return return_value;
}
static gboolean
gail_option_menu_set_description (AtkAction *action,
gint i,
const gchar *desc)
{
GailButton *button;
gchar **value;
button = GAIL_BUTTON (action);
switch (i)
{
case 0:
value = &button->press_description;
break;
default:
value = NULL;
break;
}
if (value)
{
g_free (*value);
*value = g_strdup (desc);
return TRUE;
}
else
return FALSE;
}

View File

@ -0,0 +1,60 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_OPTION_MENU_H__
#define __GAIL_OPTION_MENU_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailbutton.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_OPTION_MENU (gail_option_menu_get_type ())
#define GAIL_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_OPTION_MENU, GailOptionMenu))
#define GAIL_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_OPTION_MENU, GailOptionMenuClass))
#define GAIL_IS_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_OPTION_MENU))
#define GAIL_IS_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_OPTION_MENU))
#define GAIL_OPTION_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_OPTION_MENU, GailOptionMenuClass))
typedef struct _GailOptionMenu GailOptionMenu;
typedef struct _GailOptionMenuClass GailOptionMenuClass;
struct _GailOptionMenu
{
GailButton parent;
};
GType gail_option_menu_get_type (void);
struct _GailOptionMenuClass
{
GailButtonClass parent_class;
};
AtkObject* gail_option_menu_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_OPTION_MENU_H__ */

View File

@ -0,0 +1,247 @@
/* GAIL - The GNOME Accessibility Enabling Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailpaned.h"
static void gail_paned_class_init (GailPanedClass *klass);
static void gail_paned_real_initialize (AtkObject *obj,
gpointer data);
static void gail_paned_size_allocate_gtk (GtkWidget *widget,
GtkAllocation *allocation);
static AtkStateSet* gail_paned_ref_state_set (AtkObject *accessible);
static void atk_value_interface_init (AtkValueIface *iface);
static void gail_paned_get_current_value (AtkValue *obj,
GValue *value);
static void gail_paned_get_maximum_value (AtkValue *obj,
GValue *value);
static void gail_paned_get_minimum_value (AtkValue *obj,
GValue *value);
static gboolean gail_paned_set_current_value (AtkValue *obj,
const GValue *value);
static GailContainerClass *parent_class = NULL;
GType
gail_paned_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailPanedClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_paned_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailPaned), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_value_info =
{
(GInterfaceInitFunc) atk_value_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailPaned", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_VALUE,
&atk_value_info);
}
return type;
}
static void
gail_paned_class_init (GailPanedClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->ref_state_set = gail_paned_ref_state_set;
class->initialize = gail_paned_real_initialize;
}
AtkObject*
gail_paned_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_PANED (widget), NULL);
object = g_object_new (GAIL_TYPE_PANED, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static AtkStateSet*
gail_paned_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
return state_set;
if (GTK_IS_VPANED (widget))
atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
else if (GTK_IS_HPANED (widget))
atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
return state_set;
}
static void
gail_paned_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
g_signal_connect (data,
"size_allocate",
G_CALLBACK (gail_paned_size_allocate_gtk),
NULL);
obj->role = ATK_ROLE_SPLIT_PANE;
}
static void
gail_paned_size_allocate_gtk (GtkWidget *widget,
GtkAllocation *allocation)
{
AtkObject *obj = gtk_widget_get_accessible (widget);
g_object_notify (G_OBJECT (obj), "accessible-value");
}
static void
atk_value_interface_init (AtkValueIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_current_value = gail_paned_get_current_value;
iface->get_maximum_value = gail_paned_get_maximum_value;
iface->get_minimum_value = gail_paned_get_minimum_value;
iface->set_current_value = gail_paned_set_current_value;
}
static void
gail_paned_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint current_value;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/* State is defunct */
return;
current_value = gtk_paned_get_position (GTK_PANED (widget));
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value,current_value);
}
static void
gail_paned_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint maximum_value;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/* State is defunct */
return;
maximum_value = GTK_PANED (widget)->max_position;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, maximum_value);
}
static void
gail_paned_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint minimum_value;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/* State is defunct */
return;
minimum_value = GTK_PANED (widget)->min_position;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, minimum_value);
}
/*
* Calling atk_value_set_current_value() is no guarantee that the value is
* acceptable; it is necessary to listen for accessible-value signals
* and check whether the current value has been changed or check what the
* maximum and minimum values are.
*/
static gboolean
gail_paned_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget* widget;
gint new_value;
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
/* State is defunct */
return FALSE;
if (G_VALUE_HOLDS_INT (value))
{
new_value = g_value_get_int (value);
gtk_paned_set_position (GTK_PANED (widget), new_value);
return TRUE;
}
else
return FALSE;
}

View File

@ -0,0 +1,59 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_PANED_H__
#define __GAIL_PANED_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailcontainer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_PANED (gail_paned_get_type ())
#define GAIL_PANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_PANED, GailPaned))
#define GAIL_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_PANED, GailPanedClass))
#define GAIL_IS_PANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_PANED))
#define GAIL_IS_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_PANED))
#define GAIL_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_PANED, GailPanedClass))
typedef struct _GailPaned GailPaned;
typedef struct _GailPanedClass GailPanedClass;
struct _GailPaned
{
GailContainer parent;
};
GType gail_paned_get_type (void);
struct _GailPanedClass
{
GailContainerClass parent_class;
};
AtkObject* gail_paned_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_PANED_H__ */

View File

@ -0,0 +1,198 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include "gailpixmap.h"
static void gail_pixmap_class_init (GailPixmapClass *klass);
static void gail_pixmap_object_init (GailPixmap *pixmap);
/* AtkImage */
static void atk_image_interface_init (AtkImageIface *iface);
static G_CONST_RETURN gchar* gail_pixmap_get_image_description
(AtkImage *obj);
static void gail_pixmap_get_image_position
(AtkImage *obj,
gint *x,
gint *y,
AtkCoordType coord_type);
static void gail_pixmap_get_image_size (AtkImage *obj,
gint *width,
gint *height);
static gboolean gail_pixmap_set_image_description
(AtkImage *obj,
const gchar *description);
static void gail_pixmap_finalize (GObject *object);
static GailWidgetClass* parent_class = NULL;
GType
gail_pixmap_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailPixmapClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_pixmap_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailPixmap), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_pixmap_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) atk_image_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailPixmap", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
}
return type;
}
static void
gail_pixmap_class_init (GailPixmapClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gail_pixmap_finalize;
parent_class = g_type_class_peek_parent (klass);
}
static void
gail_pixmap_object_init (GailPixmap *pixmap)
{
pixmap->image_description = NULL;
}
AtkObject*
gail_pixmap_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_assert (GTK_IS_PIXMAP (widget));
g_return_val_if_fail (GTK_IS_PIXMAP (widget), NULL);
object = g_object_new (GAIL_TYPE_PIXMAP, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
accessible->role = ATK_ROLE_ICON;
return accessible;
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_image_description = gail_pixmap_get_image_description;
iface->get_image_position = gail_pixmap_get_image_position;
iface->get_image_size = gail_pixmap_get_image_size;
iface->set_image_description = gail_pixmap_set_image_description;
}
static G_CONST_RETURN gchar*
gail_pixmap_get_image_description (AtkImage *obj)
{
GailPixmap* pixmap;
g_return_val_if_fail (GAIL_IS_PIXMAP (obj), NULL);
pixmap = GAIL_PIXMAP (obj);
return pixmap->image_description;
}
static void
gail_pixmap_get_image_position (AtkImage *obj,
gint *x,
gint *y,
AtkCoordType coord_type)
{
atk_component_get_position (ATK_COMPONENT (obj), x, y, coord_type);
}
static void
gail_pixmap_get_image_size (AtkImage *obj,
gint *width,
gint *height)
{
GtkWidget *widget;
GtkPixmap *pixmap;
*width = -1;
*height = -1;
g_return_if_fail (GAIL_IS_PIXMAP (obj));
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == 0)
/* State is defunct */
return;
g_return_if_fail (GTK_IS_PIXMAP (widget));
pixmap = GTK_PIXMAP (widget);
if (pixmap->pixmap)
gdk_window_get_size (pixmap->pixmap, width, height);
}
static gboolean
gail_pixmap_set_image_description (AtkImage *obj,
const gchar *description)
{
GailPixmap* pixmap;
g_return_val_if_fail (GAIL_IS_PIXMAP (obj), FALSE);
pixmap = GAIL_PIXMAP (obj);
g_free (pixmap->image_description);
pixmap->image_description = g_strdup (description);
return TRUE;
}
static void
gail_pixmap_finalize (GObject *object)
{
GailPixmap *pixmap = GAIL_PIXMAP (object);
g_free (pixmap->image_description);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -0,0 +1,63 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_PIXMAP_H__
#define __GAIL_PIXMAP_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_PIXMAP (gail_pixmap_get_type ())
#define GAIL_PIXMAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_PIXMAP, GailPixmap))
#define GAIL_PIXMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_PIXMAP, GailPixmapClass))
#define GAIL_IS_PIXMAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_PIXMAP))
#define GAIL_IS_PIXMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_PIXMAP))
#define GAIL_PIXMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_PIXMAP, GailPixmapClass))
typedef struct _GailPixmap GailPixmap;
typedef struct _GailPixmapClass GailPixmapClass;
struct _GailPixmap
{
GailWidget parent;
gchar* image_description;
};
GType gail_pixmap_get_type (void);
struct _GailPixmapClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_pixmap_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_PIXMAP_H__ */

View File

@ -0,0 +1,271 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <gtk/gtk.h>
#include "gailprogressbar.h"
#include "gailadjustment.h"
static void gail_progress_bar_class_init (GailProgressBarClass *klass);
static void gail_progress_bar_real_initialize (AtkObject *obj,
gpointer data);
static void gail_progress_bar_finalize (GObject *object);
static void atk_value_interface_init (AtkValueIface *iface);
static void gail_progress_bar_real_notify_gtk (GObject *obj,
GParamSpec *pspec);
static void gail_progress_bar_get_current_value (AtkValue *obj,
GValue *value);
static void gail_progress_bar_get_maximum_value (AtkValue *obj,
GValue *value);
static void gail_progress_bar_get_minimum_value (AtkValue *obj,
GValue *value);
static void gail_progress_bar_value_changed (GtkAdjustment *adjustment,
gpointer data);
static GailWidgetClass *parent_class = NULL;
GType
gail_progress_bar_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailProgressBarClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_progress_bar_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailProgressBar), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_value_info =
{
(GInterfaceInitFunc) atk_value_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailProgressBar", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_VALUE,
&atk_value_info);
}
return type;
}
static void
gail_progress_bar_class_init (GailProgressBarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailWidgetClass *widget_class;
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gail_progress_bar_real_notify_gtk;
class->initialize = gail_progress_bar_real_initialize;
gobject_class->finalize = gail_progress_bar_finalize;
parent_class = g_type_class_peek_parent (klass);
}
AtkObject*
gail_progress_bar_new (GtkWidget *widget)
{
GObject *object;
AtkObject *accessible;
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (widget), NULL);
object = g_object_new (GAIL_TYPE_PROGRESS_BAR, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, widget);
return accessible;
}
static void
gail_progress_bar_real_initialize (AtkObject *obj,
gpointer data)
{
GailProgressBar *progress_bar = GAIL_PROGRESS_BAR (obj);
GtkProgress *gtk_progress;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
gtk_progress = GTK_PROGRESS (data);
/*
* If a GtkAdjustment already exists for the spin_button,
* create the GailAdjustment
*/
if (gtk_progress->adjustment)
{
progress_bar->adjustment = gail_adjustment_new (gtk_progress->adjustment);
g_signal_connect (gtk_progress->adjustment,
"value-changed",
G_CALLBACK (gail_progress_bar_value_changed),
obj);
}
else
progress_bar->adjustment = NULL;
obj->role = ATK_ROLE_PROGRESS_BAR;
}
static void
atk_value_interface_init (AtkValueIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_current_value = gail_progress_bar_get_current_value;
iface->get_maximum_value = gail_progress_bar_get_maximum_value;
iface->get_minimum_value = gail_progress_bar_get_minimum_value;
}
static void
gail_progress_bar_get_current_value (AtkValue *obj,
GValue *value)
{
GailProgressBar *progress_bar;
g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
progress_bar = GAIL_PROGRESS_BAR (obj);
if (progress_bar->adjustment == NULL)
/*
* Adjustment has not been specified
*/
return;
atk_value_get_current_value (ATK_VALUE (progress_bar->adjustment), value);
}
static void
gail_progress_bar_get_maximum_value (AtkValue *obj,
GValue *value)
{
GailProgressBar *progress_bar;
g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
progress_bar = GAIL_PROGRESS_BAR (obj);
if (progress_bar->adjustment == NULL)
/*
* Adjustment has not been specified
*/
return;
atk_value_get_maximum_value (ATK_VALUE (progress_bar->adjustment), value);
}
static void
gail_progress_bar_get_minimum_value (AtkValue *obj,
GValue *value)
{
GailProgressBar *progress_bar;
g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
progress_bar = GAIL_PROGRESS_BAR (obj);
if (progress_bar->adjustment == NULL)
/*
* Adjustment has not been specified
*/
return;
atk_value_get_minimum_value (ATK_VALUE (progress_bar->adjustment), value);
}
static void
gail_progress_bar_finalize (GObject *object)
{
GailProgressBar *progress_bar = GAIL_PROGRESS_BAR (object);
if (progress_bar->adjustment)
{
g_object_unref (progress_bar->adjustment);
progress_bar->adjustment = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gail_progress_bar_real_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkWidget *widget = GTK_WIDGET (obj);
GailProgressBar *progress_bar = GAIL_PROGRESS_BAR (gtk_widget_get_accessible (widget));
if (strcmp (pspec->name, "adjustment") == 0)
{
/*
* Get rid of the GailAdjustment for the GtkAdjustment
* which was associated with the progress_bar.
*/
if (progress_bar->adjustment)
{
g_object_unref (progress_bar->adjustment);
progress_bar->adjustment = NULL;
}
/*
* Create the GailAdjustment when notify for "adjustment" property
* is received
*/
progress_bar->adjustment = gail_adjustment_new (GTK_PROGRESS (widget)->adjustment);
g_signal_connect (GTK_PROGRESS (widget)->adjustment,
"value-changed",
G_CALLBACK (gail_progress_bar_value_changed),
progress_bar);
}
else
parent_class->notify_gtk (obj, pspec);
}
static void
gail_progress_bar_value_changed (GtkAdjustment *adjustment,
gpointer data)
{
GailProgressBar *progress_bar;
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
progress_bar = GAIL_PROGRESS_BAR (data);
g_object_notify (G_OBJECT (progress_bar), "accessible-value");
}

View File

@ -0,0 +1,64 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_PROGRESS_BAR_H__
#define __GAIL_PROGRESS_BAR_H__
#include <gtk/gtkaccessible.h>
#include <gail/gailwidget.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GAIL_TYPE_PROGRESS_BAR (gail_progress_bar_get_type ())
#define GAIL_PROGRESS_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_PROGRESS_BAR, GailProgressBar))
#define GAIL_PROGRESS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_PROGRESS_BAR, GailProgressBarClass))
#define GAIL_IS_PROGRESS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_PROGRESS_BAR))
#define GAIL_IS_PROGRESS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_PROGRESS_BAR))
#define GAIL_PROGRESS_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_PROGRESS_BAR, GailProgressBarClass))
typedef struct _GailProgressBar GailProgressBar;
typedef struct _GailProgressBarClass GailProgressBarClass;
struct _GailProgressBar
{
GailWidget parent;
AtkObject *adjustment;
};
GType gail_progress_bar_get_type (void);
struct _GailProgressBarClass
{
GailWidgetClass parent_class;
};
AtkObject* gail_progress_bar_new (GtkWidget *widget);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GAIL_PROGRESS_BAR_H__ */

Some files were not shown because too many files have changed in this diff Show More