From 50b78a502d8fe0e8ec7bf932d87151461bcecc2b Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Tue, 18 Feb 2014 12:07:33 -0600 Subject: [PATCH] Add AtspitableCell, tracking the new atk interface --- atk-adaptor/adaptors/Makefile.am | 1 + atk-adaptor/adaptors/adaptors.h | 1 + atk-adaptor/adaptors/table-cell-adaptor.c | 191 ++++++++++++++++++++++++++++++ atk-adaptor/bridge.c | 1 + atk-adaptor/introspection.c | 171 +++++++++++++++++++------- atk-adaptor/introspection.h | 4 + atk-adaptor/object.c | 6 + configure.ac | 2 +- 8 files changed, 333 insertions(+), 44 deletions(-) create mode 100644 atk-adaptor/adaptors/table-cell-adaptor.c diff --git a/atk-adaptor/adaptors/Makefile.am b/atk-adaptor/adaptors/Makefile.am index 66f7ba7..7624b57 100644 --- a/atk-adaptor/adaptors/Makefile.am +++ b/atk-adaptor/adaptors/Makefile.am @@ -29,5 +29,6 @@ libatk_bridge_adaptors_la_SOURCES =\ selection-adaptor.c \ socket-adaptor.c \ table-adaptor.c \ + table-cell-adaptor.c \ text-adaptor.c \ value-adaptor.c diff --git a/atk-adaptor/adaptors/adaptors.h b/atk-adaptor/adaptors/adaptors.h index 84d2ef4..395114b 100644 --- a/atk-adaptor/adaptors/adaptors.h +++ b/atk-adaptor/adaptors/adaptors.h @@ -42,6 +42,7 @@ void spi_initialize_image (DRoutePath * path); void spi_initialize_selection (DRoutePath * path); void spi_initialize_socket (DRoutePath * path); void spi_initialize_table (DRoutePath * path); +void spi_initialize_table_cell (DRoutePath * path); void spi_initialize_text (DRoutePath * path); void spi_initialize_value (DRoutePath * path); void spi_initialize_cache (DRoutePath * path); diff --git a/atk-adaptor/adaptors/table-cell-adaptor.c b/atk-adaptor/adaptors/table-cell-adaptor.c new file mode 100644 index 0000000..c557ed5 --- /dev/null +++ b/atk-adaptor/adaptors/table-cell-adaptor.c @@ -0,0 +1,191 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2013 SUSE LLC. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, 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. + */ + +#include +#include + +#include "spi-dbus.h" +#include "object.h" +#include "introspection.h" + +static dbus_bool_t +impl_get_ColumnSpan (DBusMessageIter * iter, void *user_data) +{ + AtkTableCell *cell = (AtkTableCell *) user_data; + g_return_val_if_fail (ATK_IS_TABLE_CELL (user_data), FALSE); + return droute_return_v_int32 (iter, atk_table_cell_get_column_span (cell)); +} + +static DBusMessage * +message_from_object_array (DBusMessage *message, GPtrArray *array) +{ + DBusMessage *reply; + DBusMessageIter iter, iter_array; + gint len; + gint i; + + reply = dbus_message_new_method_return (message); + if (!reply) + return NULL; + + dbus_message_iter_init_append (reply, &iter); + + if (!dbus_message_iter_open_container + (&iter, DBUS_TYPE_ARRAY, "(so)", &iter_array)) + return reply; /* TODO: handle out of memory */ + len = (array? array->len: 0); + for (i = 0; i < len; i++) + { + spi_object_append_reference (&iter_array, g_ptr_array_index (array, i)); + } + dbus_message_iter_close_container (&iter, &iter_array); + g_ptr_array_unref (array); + return message; +} + +static DBusMessage * +impl_GetColumnHeaderCells (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTableCell *cell = user_data; + GPtrArray *array; + + g_return_val_if_fail (ATK_IS_TABLE_CELL (user_data), + droute_not_yet_handled_error (message)); + + array = atk_table_cell_get_column_header_cells (cell); + return message_from_object_array (message, array); +} + +static dbus_bool_t +impl_get_RowSpan (DBusMessageIter * iter, void *user_data) +{ + AtkTableCell *cell = (AtkTableCell *) user_data; + g_return_val_if_fail (ATK_IS_TABLE_CELL (user_data), FALSE); + return droute_return_v_int32 (iter, atk_table_cell_get_row_span (cell)); +} + +static DBusMessage * +impl_GetRowHeaderCells (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTableCell *cell = user_data; + GPtrArray *array; + + g_return_val_if_fail (ATK_IS_TABLE_CELL (user_data), + droute_not_yet_handled_error (message)); + + array = atk_table_cell_get_row_header_cells (cell); + return message_from_object_array (message, array); +} + +static dbus_bool_t +impl_get_Position (DBusMessageIter * iter, void *user_data) +{ + AtkTableCell *cell = (AtkTableCell *) user_data; + gint row = -1, column = -1; + dbus_int32_t d_row, d_column; + DBusMessageIter iter_struct, iter_variant; + + g_return_val_if_fail (ATK_IS_TABLE_CELL (user_data), FALSE); + if (!atk_table_cell_get_position (cell, &row, &column)) + return FALSE; + + d_row = row; + d_column = column; + dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, "(ii)", &iter_variant); + dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_STRUCT, NULL, &iter_struct); + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &row); + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &column); + dbus_message_iter_close_container (&iter_variant, &iter_struct); + dbus_message_iter_close_container (iter, &iter_variant); + return TRUE; +} + +static dbus_bool_t +impl_get_Table (DBusMessageIter * iter, void *user_data) +{ + AtkTableCell *cell = (AtkTableCell *) user_data; + AtkObject *table; + + g_return_val_if_fail (ATK_IS_TABLE_CELL (user_data), FALSE); + + table = atk_table_cell_get_table (cell); + if (!table) + return FALSE; + spi_object_append_reference (iter, table); + return TRUE; +} + +static DBusMessage * +impl_GetRowColumnSpan (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTableCell *cell = (AtkTableCell *) user_data; + gint row, column, row_span, column_span; + dbus_int32_t d_row, d_column, d_row_span, d_column_span; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + atk_table_cell_get_row_column_span (cell, &row, &column, &row_span, + &column_span); + d_row = row; + d_column = column; + d_row_span = row_span; + d_column_span = column_span; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &d_row, DBUS_TYPE_INT32, + &d_column, DBUS_TYPE_INT32, &d_row_span, + DBUS_TYPE_INT32, &d_column_span, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_GetRowHeaderCells, "GetRowHeaderCells"}, + {impl_GetColumnHeaderCells, "GetColumnHeaderCells"}, + {impl_GetRowColumnSpan, "GetRowColumnSpan"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_ColumnSpan, NULL, "ColumnSpan"}, + {impl_get_Position, NULL, "Position"}, + {impl_get_RowSpan, NULL, "RowSpan"}, + {impl_get_Table, NULL, "Table"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_table_cell (DRoutePath * path) +{ + droute_path_add_interface (path, + ATSPI_DBUS_INTERFACE_TABLE_CELL, + spi_org_a11y_atspi_TableCell, + methods, properties); +}; diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index 9f5977b..e7b3bab 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -1066,6 +1066,7 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[]) spi_initialize_selection (accpath); spi_initialize_socket (accpath); spi_initialize_table (accpath); + spi_initialize_table_cell (accpath); spi_initialize_text (accpath); spi_initialize_value (accpath); diff --git a/atk-adaptor/introspection.c b/atk-adaptor/introspection.c index 7d0658d..0ce7cfa 100644 --- a/atk-adaptor/introspection.c +++ b/atk-adaptor/introspection.c @@ -13,15 +13,17 @@ const char *spi_org_a11y_atspi_Accessible = "" "" -" " +" " "" -" " +" " "" -" " +" " " " " " "" -" " +" " +"" +" " "" " " " " @@ -76,7 +78,7 @@ const char *spi_org_a11y_atspi_Accessible = const char *spi_org_a11y_atspi_Action = "" "" -" " +" " "" " " " " @@ -99,7 +101,7 @@ const char *spi_org_a11y_atspi_Action = " " "" " " -" " +" " " " " " "" @@ -114,19 +116,24 @@ const char *spi_org_a11y_atspi_Action = const char *spi_org_a11y_atspi_Application = "" "" -" " +" " "" -" " +" " "" -" " +" " +" " "" " " " " " " " " "" -" " -" " +" " +" " +" " +"" +" " +" " " " "" "" @@ -152,7 +159,7 @@ const char *spi_org_a11y_atspi_Collection = " " " " " " -" " +" " " " " " " " @@ -231,12 +238,38 @@ const char *spi_org_a11y_atspi_Component = " " " " "" +" " +" " +" " +" " +" " +" " +" " +" " +"" +" " +" " +" " +" " +" " +" " +"" +" " +" " +" " +" " +" " +"" "" ""; const char *spi_org_a11y_atspi_Document = "" "" +" " +"" +" " +"" " " " " " " @@ -278,11 +311,11 @@ const char *spi_org_a11y_atspi_Hypertext = const char *spi_org_a11y_atspi_Hyperlink = "" "" -" " +" " "" -" " +" " "" -" " +" " "" " " " " @@ -305,9 +338,9 @@ const char *spi_org_a11y_atspi_Hyperlink = const char *spi_org_a11y_atspi_Image = "" "" -" " +" " "" -" " +" " "" " " " " @@ -332,7 +365,7 @@ const char *spi_org_a11y_atspi_Image = const char *spi_org_a11y_atspi_Selection = "" "" -" " +" " "" " " " " @@ -363,7 +396,7 @@ const char *spi_org_a11y_atspi_Selection = " " " " "" -" " +" " " " " " " " @@ -374,21 +407,21 @@ const char *spi_org_a11y_atspi_Selection = const char *spi_org_a11y_atspi_Table = "" "" -" " +" " "" -" " +" " "" -" " +" " " " " " "" -" " +" " " " " " "" -" " +" " "" -" " +" " "" " " " " @@ -506,12 +539,42 @@ const char *spi_org_a11y_atspi_Table = "" ""; +const char *spi_org_a11y_atspi_TableCell = +"" +"" +" " +"" +" " +"" +" " +"" +" " +"" +" " +" " +" " +" " +" " +" " +" " +"" +"" +""; + const char *spi_org_a11y_atspi_Text = "" "" -" " +" " "" -" " +" " +"" +" " +" " +" " +" " +" " +" " +" " "" " " " " @@ -548,14 +611,6 @@ const char *spi_org_a11y_atspi_Text = " " " " "" -" " -" " -" " -" " -" " -" " -" " -"" " " " " " " @@ -659,7 +714,7 @@ const char *spi_org_a11y_atspi_Text = " " "" " " -" " +" " " " "" "" @@ -729,14 +784,44 @@ const char *spi_org_a11y_atspi_Cache = const char *spi_org_a11y_atspi_Value = "" "" -" " +" " +"" +" " +"" +" " +"" +" " +"" +"" +""; + +const char *spi_org_a11y_atspi_Registry = +"" +"" +" " +" " +" " +" " "" -" " +" " +" " +" " +" " "" -" " +" " +" " +" " +" " "" -" " +" " +" " +" " +" " "" +" " +" " +" " +" " "" ""; @@ -791,13 +876,13 @@ const char *spi_org_a11y_atspi_DeviceEventController = " " "" " " -" " +" " " " " " " " "" " " -" " +" " " " " " "" @@ -808,7 +893,7 @@ const char *spi_org_a11y_atspi_DeviceEventListener = "" "" " " -" " +" " " " " " " " diff --git a/atk-adaptor/introspection.h b/atk-adaptor/introspection.h index 5392870..2210483 100644 --- a/atk-adaptor/introspection.h +++ b/atk-adaptor/introspection.h @@ -35,6 +35,8 @@ extern const char *spi_org_a11y_atspi_Selection; extern const char *spi_org_a11y_atspi_Table; +extern const char *spi_org_a11y_atspi_TableCell; + extern const char *spi_org_a11y_atspi_Text; extern const char *spi_org_a11y_atspi_EditableText; @@ -43,6 +45,8 @@ extern const char *spi_org_a11y_atspi_Cache; extern const char *spi_org_a11y_atspi_Value; +extern const char *spi_org_a11y_atspi_Registry; + extern const char *spi_org_a11y_atspi_DeviceEventController; extern const char *spi_org_a11y_atspi_DeviceEventListener; diff --git a/atk-adaptor/object.c b/atk-adaptor/object.c index cf15cc1..404fb24 100644 --- a/atk-adaptor/object.c +++ b/atk-adaptor/object.c @@ -272,6 +272,12 @@ spi_object_append_interfaces (DBusMessageIter * iter, AtkObject * obj) dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); } + if (ATK_IS_TABLE_CELL (obj)) + { + itf = ATSPI_DBUS_INTERFACE_TABLE_CELL; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + if (ATK_IS_VALUE (obj)) { itf = ATSPI_DBUS_INTERFACE_VALUE; diff --git a/configure.ac b/configure.ac index 3e82cf9..829aef7 100644 --- a/configure.ac +++ b/configure.ac @@ -51,7 +51,7 @@ PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.0.0]) AC_SUBST(GMODULE_LIBS) AC_SUBST(GMODULE_CFLAGS) -PKG_CHECK_MODULES(ATK, [atk >= 2.11.3]) +PKG_CHECK_MODULES(ATK, [atk >= 2.11.90]) AC_SUBST(ATK_LIBS) AC_SUBST(ATK_CFLAGS) -- 2.7.4