diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-05-03 20:11:14 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-05-03 20:11:14 +0000 |
commit | 42cc312df65ba892bfc21e638f109c77be3cd00e (patch) | |
tree | 9ca5fd5b82443cebf1a96fd6ffaecefe6a8e1f59 /gtk | |
parent | 3125dc0cf28a399bcc92d9c5350f996a1a23cc76 (diff) | |
download | gtk+-42cc312df65ba892bfc21e638f109c77be3cd00e.tar.gz |
Add dependency on Atk for accessibility support.
Thu May 3 14:13:49 2001 Owen Taylor <otaylor@redhat.com>
* INSTALL.in HACKING gtk/gtkaccessible.[ch] gtk/gtk.c: Add
dependency on Atk for accessibility support.
* configure.in **/Makefile.am: Major reworking of substituted
variables for CFLAGS/LIBS to make a lot more sane and
keep the the compile/link lines a bit shorter.
* gdk/x11/gdkkeys-x11.c: Fix #endif with trailing stuff.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/Makefile.am | 21 | ||||
-rw-r--r-- | gtk/gtk.h | 1 | ||||
-rw-r--r-- | gtk/gtkaccessible.c | 93 | ||||
-rw-r--r-- | gtk/gtkaccessible.h | 73 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 88 | ||||
-rw-r--r-- | gtk/gtkwidget.h | 13 |
6 files changed, 268 insertions, 21 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 1822458844..2f3c3e40c9 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -16,11 +16,7 @@ INCLUDES = @STRIP_BEGIN@ \ -I$(top_srcdir) -I../gdk \ -I$(top_srcdir)/gdk \ -I$(top_srcdir)/gdk-pixbuf -I../gdk-pixbuf \ - @GTK_DEBUG_FLAGS@ \ - @GTK_XIM_FLAGS@ \ - @PANGO_CFLAGS@ \ - @GLIB_CFLAGS@ \ - @more_cflags@ \ + @GTK_DEP_CFLAGS@ \ @STRIP_END@ gtarget=@gdktarget@ @@ -34,11 +30,7 @@ LDFLAGS = @STRIP_BEGIN@ \ -export-dynamic \ -rpath @prefix@/lib \ @LIBTOOL_EXPORT_OPTIONS@ \ - @PANGO_LIBS@ \ - @GLIB_DEPLIBS@ \ - @more_ldflags@ \ - @more_libs@ \ - -lm \ + @GTK_DEP_LIBS@ \ @STRIP_END@ # @@ -51,6 +43,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \ gtk.h \ gtkaccelgroup.h \ gtkaccellabel.h \ + gtkaccessible.h \ gtkadjustment.h \ gtkalignment.h \ gtkarg.h \ @@ -209,6 +202,7 @@ gtk_private_h_sources = @STRIP_BEGIN@ \ gtk_c_sources = @STRIP_BEGIN@ \ gtkaccelgroup.c \ gtkaccellabel.c \ + gtkaccessible.c \ gtkadjustment.c \ gtkalignment.c \ gtkarg.c \ @@ -516,13 +510,6 @@ LDADDS = @STRIP_BEGIN@ \ @gtktargetlib@ \ $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \ $(top_builddir)/gdk/@gdktargetlib@ \ - @more_ldflags@ \ - @more_libs@ \ - @GDK_WLIBS@ \ - @PANGO_LIBS@ \ - @GLIB_LIBS@ \ - @GTK_LIBS_EXTRA@ \ - -lm \ @STRIP_END@ # @@ -31,6 +31,7 @@ #include <gdk/gdk.h> #include <gtk/gtkaccelgroup.h> #include <gtk/gtkaccellabel.h> +#include <gtk/gtkaccessible.h> #include <gtk/gtkadjustment.h> #include <gtk/gtkalignment.h> #include <gtk/gtkarg.h> diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c new file mode 100644 index 0000000000..d5a96b2367 --- /dev/null +++ b/gtk/gtkaccessible.c @@ -0,0 +1,93 @@ +/* GTK - The GIMP Toolkit + * 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/gtkwidget.h> +#include <gtk/gtksignal.h> +#include <gtk/gtkaccessible.h> + +static void gtk_accessible_class_init (GtkAccessibleClass *klass); + +static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible); + +GtkType +gtk_accessible_get_type (void) +{ + static GtkType accessible_type = 0; + + if (!accessible_type) + { + static const GTypeInfo accessible_info = + { + sizeof (GtkAccessibleClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_accessible_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkAccessible), + 16, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + accessible_type = g_type_register_static (ATK_TYPE_OBJECT, "GtkAccessible", &accessible_info, 0); + } + + return accessible_type; +} + +static void +gtk_accessible_class_init (GtkAccessibleClass *klass) +{ + klass->connect_widget_destroyed = gtk_accessible_real_connect_widget_destroyed; + +} + +/** + * gtk_accessible_connect_widget_destroyed + * @accessible: a #GtkAccessible + * + * This function specifies the callback function to be called when the widget + * corresponding to a GtkAccessible is destroyed. + */ +void +gtk_accessible_connect_widget_destroyed (GtkAccessible *accessible) +{ + GtkAccessibleClass *class; + + g_return_if_fail (accessible != NULL); + g_return_if_fail (GTK_IS_ACCESSIBLE (accessible)); + + class = GTK_ACCESSIBLE_GET_CLASS (accessible); + + if (class->connect_widget_destroyed) + class->connect_widget_destroyed (accessible); +} + +static void +gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible) +{ + if (accessible->widget) + { + gtk_signal_connect (GTK_OBJECT (accessible->widget), + "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &accessible->widget); + } +} diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h new file mode 100644 index 0000000000..a09832e3fb --- /dev/null +++ b/gtk/gtkaccessible.h @@ -0,0 +1,73 @@ +/* GTK - The GIMP Toolkit + * 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 __GTK_ACCESSIBLE_H__ +#define __GTK_ACCESSIBLE_H__ + +#include <atk/atk.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define GTK_TYPE_ACCESSIBLE (gtk_accessible_get_type ()) +#define GTK_ACCESSIBLE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessible)) +#define GTK_ACCESSIBLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass)) +#define GTK_IS_ACCESSIBLE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_ACCESSIBLE)) +#define GTK_IS_ACCESSIBLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCESSIBLE)) +#define GTK_ACCESSIBLE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass)) + +typedef struct _GtkAccessible GtkAccessible; +typedef struct _GtkAccessibleClass GtkAccessibleClass; + + /** + * This object is a thin wrapper, in the GTK+ namespace, for AtkObject + */ + +struct _GtkAccessible +{ + AtkObject parent; + + /* + * The GtkWidget whose properties and features are exported via this + * accessible instance. + */ + GtkWidget *widget; + +}; + +GtkType gtk_accessible_get_type (void); + +struct _GtkAccessibleClass +{ + AtkObjectClass parent_class; + + void (*connect_widget_destroyed) (GtkAccessible *accessible); +}; + +void gtk_accessible_connect_widget_destroyed (GtkAccessible *accessible); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GTK_ACCESSIBLE_H__ */ + + diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index e5a2738a81..8079611f84 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -44,7 +44,7 @@ #include "gobject/gvaluecollector.h" #include "gdk/gdkkeysyms.h" #include "gtkintl.h" - +#include "gtkaccessible.h" #define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w) #define INIT_PATH_SIZE (512) @@ -203,7 +203,11 @@ static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget, static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info); static void gtk_widget_do_uposition (GtkWidget *widget); - + +static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget); +static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface); +static AtkObject * gtk_widget_ref_accessible (AtkImplementor *implementor); + static gpointer parent_class = NULL; static guint widget_signals[LAST_SIGNAL] = { 0 }; @@ -226,6 +230,7 @@ static GQuark quark_shape_info = 0; static GQuark quark_colormap = 0; static GQuark quark_pango_context = 0; static GQuark quark_rc_style = 0; +static GQuark quark_accessible_object = 0; /***************************************** @@ -255,7 +260,19 @@ gtk_widget_get_type (void) (GtkClassInitFunc) NULL, }; + static const GInterfaceInfo accessibility_info = + { + (GInterfaceInitFunc) gtk_widget_accessible_interface_init, + (GInterfaceFinalizeFunc) NULL, + NULL /* interface data */ + }; + + widget_type = gtk_type_unique (GTK_TYPE_OBJECT, &widget_info); + + g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR, + &accessibility_info) ; + } return widget_type; @@ -337,6 +354,9 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->drag_drop = NULL; klass->drag_data_received = NULL; + /* Accessibility support */ + klass->get_accessible = gtk_widget_real_get_accessible; + klass->no_expose_event = NULL; quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser"); @@ -349,6 +369,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_colormap = g_quark_from_static_string ("gtk-colormap"); quark_pango_context = g_quark_from_static_string ("gtk-pango-context"); quark_rc_style = g_quark_from_static_string ("gtk-rc-style"); + quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object"); style_property_spec_pool = g_param_spec_pool_new (FALSE); @@ -4954,6 +4975,7 @@ gtk_widget_finalize (GObject *object) gint *events; GdkExtensionMode *mode; GtkStyle *saved_style; + GtkAccessible *accessible; gtk_grab_remove (widget); gtk_selection_remove_all (widget); @@ -4983,6 +5005,10 @@ gtk_widget_finalize (GObject *object) if (mode) g_free (mode); + accessible = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_accessible_object); + if (accessible) + g_object_unref (G_OBJECT (accessible)); + G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -5684,3 +5710,61 @@ gtk_requisition_free (GtkRequisition *requisition) g_free (requisition); } +AtkObject* gtk_widget_get_accessible (GtkWidget *widget) +{ + GtkWidgetClass *klass; + + g_return_val_if_fail (widget != NULL, NULL); + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + klass = GTK_WIDGET_GET_CLASS (widget); + + g_return_val_if_fail (klass->get_accessible != NULL, NULL); + + return klass->get_accessible(widget); +} + +AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget) +{ + AtkObject* accessible; + + accessible = g_object_get_qdata (G_OBJECT (widget), + quark_accessible_object); + if (!accessible) + { + AtkObjectFactory *factory; + AtkRegistry *default_registry; + + default_registry = atk_get_default_registry (); + factory = atk_registry_get_factory (default_registry, + GTK_OBJECT_TYPE (widget)); + accessible = + atk_object_factory_create_accessible (factory, + G_OBJECT(widget)); + g_object_set_qdata (G_OBJECT (widget), + quark_accessible_object, + accessible); + } + return accessible; +} + +/* + * Initialize a AtkImplementorIface instance's virtual pointers as + * appropriate to this implementor's class (GtkWidget). + */ +static void +gtk_widget_accessible_interface_init (AtkImplementorIface *iface) +{ + iface->ref_accessible = gtk_widget_ref_accessible; +} + +static AtkObject* +gtk_widget_ref_accessible(AtkImplementor *implementor) +{ + AtkObject *accessible; + + accessible = gtk_widget_get_accessible (GTK_WIDGET (implementor)); + if (accessible) + g_object_ref (G_OBJECT (accessible)); + return accessible; +} diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 64ba08553a..8bdc5d17be 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -32,7 +32,7 @@ #include <gtk/gtkobject.h> #include <gtk/gtkadjustment.h> #include <gtk/gtkstyle.h> - +#include <atk/atkobject.h> #ifdef __cplusplus extern "C" { @@ -235,7 +235,7 @@ struct _GtkWidgetClass * Implementation of this signal is optional. */ guint set_scroll_adjustments_signal; - + /* basics */ void (* show) (GtkWidget *widget); void (* show_all) (GtkWidget *widget); @@ -381,6 +381,11 @@ struct _GtkWidgetClass /* Signals used only for keybindings */ void (* popup_menu) (GtkWidget *widget); + + /* accessibility support + */ + AtkObject* (* get_accessible) (GtkWidget *widget); + /* Padding for future expansion */ GtkFunction pad1; GtkFunction pad2; @@ -536,6 +541,10 @@ GtkWidget* gtk_widget_get_ancestor (GtkWidget *widget, GdkColormap* gtk_widget_get_colormap (GtkWidget *widget); GdkVisual* gtk_widget_get_visual (GtkWidget *widget); + +/* Accessibility support */ +AtkObject* gtk_widget_get_accessible (GtkWidget *widget); + /* The following functions must not be called on an already * realized widget. Because it is possible that somebody * can call get_colormap() or get_visual() and save the |