1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ 2 /* eel-accessibility.h - Utility functions for accessibility 3 4 Copyright (C) 2002 Anders Carlsson 5 6 The Eel Library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Library General Public License as 8 published by the Free Software Foundation; either version 2 of the 9 License, or (at your option) any later version. 10 11 The Eel Library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Library General Public License for more details. 15 16 You should have received a copy of the GNU Library General Public 17 License along with the Eel Library; see the file COPYING.LIB. If not, 18 write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 21 Authors: Anders Carlsson <andersca@gnu.org> 22 */ 23 24 #ifndef EEL_ACCESSIBILITY_H 25 #define EEL_ACCESSIBILITY_H 26 27 #include <glib-object.h> 28 #include <atk/atkobject.h> 29 #include <atk/atkregistry.h> 30 #include <atk/atkobjectfactory.h> 31 #include <gtk/gtk.h> 32 #include <libgail-util/gailtextutil.h> 33 34 void eel_accessibility_set_up_label_widget_relation (GtkWidget *label, GtkWidget *widget); 35 36 AtkObject *eel_accessibility_for_object (gpointer object); 37 gpointer eel_accessibility_get_gobject (AtkObject *object); 38 void eel_accessibility_set_name (gpointer object, 39 const char *name); 40 void eel_accessibility_set_description (gpointer object, 41 const char *description); 42 43 char* eel_accessibility_text_get_text (AtkText *text, 44 gint start_pos, 45 gint end_pos); 46 gunichar eel_accessibility_text_get_character_at_offset 47 (AtkText *text, 48 gint offset); 49 char* eel_accessibility_text_get_text_before_offset 50 (AtkText *text, 51 gint offset, 52 AtkTextBoundary boundary_type, 53 gint *start_offset, 54 gint *end_offset); 55 char* eel_accessibility_text_get_text_at_offset 56 (AtkText *text, 57 gint offset, 58 AtkTextBoundary boundary_type, 59 gint *start_offset, 60 gint *end_offset); 61 char* eel_accessibility_text_get_text_after_offset 62 (AtkText *text, 63 gint offset, 64 AtkTextBoundary boundary_type, 65 gint *start_offset, 66 gint *end_offset); 67 gint eel_accessibility_text_get_character_count 68 (AtkText *text); 69 70 71 #define EEL_TYPE_ACCESSIBLE_TEXT (eel_accessible_text_get_type ()) 72 #define EEL_IS_ACCESSIBLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_ACCESSIBLE_TEXT) 73 #define EEL_ACCESSIBLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_ACCESSIBLE_TEXT, EelAccessibleText) 74 #define EEL_ACCESSIBLE_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EEL_TYPE_ACCESSIBLE_TEXT, EelAccessibleTextIface)) 75 76 /* Instead of implementing the AtkText interface, implement this */ 77 typedef struct _EelAccessibleText EelAccessibleText; 78 79 typedef struct 80 { 81 GTypeInterface parent; 82 83 GailTextUtil *(*get_text) (GObject *text); 84 PangoLayout *(*get_layout) (GObject *text); 85 } EelAccessibleTextIface; 86 87 GType eel_accessible_text_get_type (void); 88 89 /* From gail - should be unneccessary when AtkObjectFactory is fixed */ 90 #define EEL_ACCESSIBLE_FACTORY(type, factory_name, type_as_function, opt_create_accessible) \ 91 \ 92 static GType \ 93 type_as_function ## _factory_get_accessible_type (void) \ 94 { \ 95 return type; \ 96 } \ 97 \ 98 static AtkObject* \ 99 type_as_function ## _factory_create_accessible (GObject *obj) \ 100 { \ 101 AtkObject *accessible; \ 102 \ 103 g_assert (G_IS_OBJECT (obj)); \ 104 \ 105 accessible = opt_create_accessible (obj); \ 106 \ 107 return accessible; \ 108 } \ 109 \ 110 static void \ 111 type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass) \ 112 { \ 113 klass->create_accessible = type_as_function ## _factory_create_accessible; \ 114 klass->get_accessible_type = type_as_function ## _factory_get_accessible_type;\ 115 } \ 116 \ 117 static GType \ 118 type_as_function ## _factory_get_type (void) \ 119 { \ 120 static GType t = 0; \ 121 \ 122 if (!t) \ 123 { \ 124 static const GTypeInfo tinfo = \ 125 { \ 126 sizeof (AtkObjectFactoryClass), \ 127 NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init, \ 128 NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL \ 129 }; \ 130 \ 131 t = g_type_register_static ( \ 132 ATK_TYPE_OBJECT_FACTORY, factory_name, &tinfo, 0); \ 133 } \ 134 \ 135 return t; \ 136 } 137 138 #define EEL_OBJECT_SET_FACTORY(object_type, type_as_function) \ 139 atk_registry_set_factory_type (atk_get_default_registry (), \ 140 object_type, \ 141 type_as_function ## _factory_get_type ()) 142 143 144 #endif /* EEL_ACCESSIBILITY_H */ 145