summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Sanchez Prada <mario.prada@samsung.com>2013-08-06 13:06:36 +0200
committerMike Gorse <mgorse@suse.com>2013-08-19 11:26:45 -0500
commit2fc87b5a17e28fb4b786dfa758cc8e09ea959aed (patch)
tree5864a9e0f708796b6cdbde6f6582390641d76dc5
parentc60babbd8746b81ea8a6b9b3702a4a36cdfc27bf (diff)
downloadat-spi2-atk-2fc87b5a17e28fb4b786dfa758cc8e09ea959aed.tar.gz
Implemented GetStringAtOffset in the text adaptor in the ATK bridge
Also, raised the version of the ATK dependency up to 2.9.4. https://bugzilla.gnome.org/show_bug.cgi?id=705581
-rw-r--r--atk-adaptor/adaptors/text-adaptor.c95
-rw-r--r--atk-adaptor/introspection.c8
-rw-r--r--configure.ac2
3 files changed, 104 insertions, 1 deletions
diff --git a/atk-adaptor/adaptors/text-adaptor.c b/atk-adaptor/adaptors/text-adaptor.c
index f039d2e..bd9a4c6 100644
--- a/atk-adaptor/adaptors/text-adaptor.c
+++ b/atk-adaptor/adaptors/text-adaptor.c
@@ -254,6 +254,100 @@ impl_GetCharacterAtOffset (DBusConnection * bus, DBusMessage * message,
return reply;
}
+static gchar *
+get_text_for_legacy_implementations(AtkText *text,
+ gint offset,
+ AtkTextGranularity granularity,
+ gint *start_offset,
+ gint *end_offset)
+{
+ gchar *txt = 0;
+ AtkTextBoundary boundary = 0;
+ switch (granularity) {
+ case ATK_TEXT_GRANULARITY_CHAR:
+ boundary = ATK_TEXT_BOUNDARY_CHAR;
+ break;
+
+ case ATK_TEXT_GRANULARITY_WORD:
+ boundary = ATK_TEXT_BOUNDARY_WORD_START;
+ break;
+
+ case ATK_TEXT_GRANULARITY_SENTENCE:
+ boundary = ATK_TEXT_BOUNDARY_SENTENCE_START;
+ break;
+
+ case ATK_TEXT_GRANULARITY_LINE:
+ boundary = ATK_TEXT_BOUNDARY_LINE_START;
+ break;
+
+ case ATK_TEXT_GRANULARITY_PARAGRAPH:
+ /* This is not implemented in previous versions of ATK */
+ txt = g_strdup("");
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
+ if (!txt)
+ {
+ txt =
+ atk_text_get_text_at_offset (text, offset, boundary,
+ start_offset, end_offset);
+ }
+
+ return txt;
+}
+
+static DBusMessage *
+impl_GetStringAtOffset (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
+{
+ AtkText *text = (AtkText *) user_data;
+ dbus_int32_t offset;
+ dbus_uint32_t granularity;
+ gchar *txt = 0;
+ dbus_int32_t startOffset, endOffset;
+ gint intstart_offset = 0, intend_offset = 0;
+ DBusMessage *reply;
+
+ g_return_val_if_fail (ATK_IS_TEXT (user_data),
+ droute_not_yet_handled_error (message));
+ if (!dbus_message_get_args
+ (message, NULL, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &granularity,
+ DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+
+ txt =
+ atk_text_get_string_at_offset (text, offset, (AtkTextGranularity) granularity,
+ &intstart_offset, &intend_offset);
+
+ /* Accessibility layers implementing an older version of ATK (even if
+ * a new enough version of libatk is installed) might return NULL due
+ * not to provide an implementation for get_string_at_offset(), so we
+ * try with the legacy implementation if that's the case. */
+ if (!txt)
+ txt = get_text_for_legacy_implementations(text, offset,
+ (AtkTextGranularity) granularity,
+ &intstart_offset, &intend_offset);
+
+ startOffset = intstart_offset;
+ endOffset = intend_offset;
+ txt = validate_allocated_string (txt);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_STRING, &txt,
+ DBUS_TYPE_INT32, &startOffset,
+ DBUS_TYPE_INT32, &endOffset,
+ DBUS_TYPE_INVALID);
+ }
+ g_free (txt);
+ return reply;
+}
+
static DBusMessage *
impl_GetAttributeValue (DBusConnection * bus, DBusMessage * message,
void *user_data)
@@ -757,6 +851,7 @@ static DRouteMethod methods[] = {
{impl_GetTextBeforeOffset, "GetTextBeforeOffset"},
{impl_GetTextAtOffset, "GetTextAtOffset"},
{impl_GetTextAfterOffset, "GetTextAfterOffset"},
+ {impl_GetStringAtOffset, "GetStringAtOffset"},
{impl_GetCharacterAtOffset, "GetCharacterAtOffset"},
{impl_GetAttributeValue, "GetAttributeValue"},
{impl_GetAttributes, "GetAttributes"},
diff --git a/atk-adaptor/introspection.c b/atk-adaptor/introspection.c
index 838d933..7d0658d 100644
--- a/atk-adaptor/introspection.c
+++ b/atk-adaptor/introspection.c
@@ -548,6 +548,14 @@ const char *spi_org_a11y_atspi_Text =
" <arg direction=\"out\" name=\"endOffset\" type=\"i\" />"
" </method>"
""
+" <method name=\"GetStringAtOffset\">"
+" <arg direction=\"in\" name=\"offset\" type=\"i\" />"
+" <arg direction=\"in\" name=\"granularity\" type=\"u\" />"
+" <arg direction=\"out\" type=\"s\" />"
+" <arg direction=\"out\" name=\"startOffset\" type=\"i\" />"
+" <arg direction=\"out\" name=\"endOffset\" type=\"i\" />"
+" </method>"
+""
" <method name=\"GetCharacterAtOffset\">"
" <arg direction=\"in\" name=\"offset\" type=\"i\" />"
" <arg direction=\"out\" type=\"i\" />"
diff --git a/configure.ac b/configure.ac
index 0b3604e..7409a89 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.7.90])
+PKG_CHECK_MODULES(ATK, [atk >= 2.9.4])
AC_SUBST(ATK_LIBS)
AC_SUBST(ATK_CFLAGS)