[java-atk-wrapper] Delegate jaw_util_get_tflag_from_jobj call to EDT
- From: Samuel Thibault <sthibaul src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] Delegate jaw_util_get_tflag_from_jobj call to EDT
- Date: Wed, 19 Jun 2019 23:06:16 +0000 (UTC)
commit f7cd6fde28d31729a5ef29e4cad7a46b19b01cae
Author: Giuseppe <giuseppecapaldo93 gmail com>
Date: Thu Jun 20 01:05:42 2019 +0200
Delegate jaw_util_get_tflag_from_jobj call to EDT
jni/src/jawutil.c | 118 +------------------------
wrapper/org/GNOME/Accessibility/AtkObject.java | 54 +++++++++++
2 files changed, 57 insertions(+), 115 deletions(-)
---
diff --git a/jni/src/jawutil.c b/jni/src/jawutil.c
index eb023ec..851b174 100644
--- a/jni/src/jawutil.c
+++ b/jni/src/jawutil.c
@@ -188,121 +188,9 @@ jaw_util_get_toolkit_version (void)
guint
jaw_util_get_tflag_from_jobj(JNIEnv *jniEnv, jobject jObj)
{
- guint tflag = 0;
- jmethodID jmid;
- jclass classAccessibleContext = (*jniEnv)->FindClass(jniEnv,
- "javax/accessibility/AccessibleContext");
- jclass classAccessible = (*jniEnv)->FindClass(jniEnv,
- "javax/accessibility/Accessible");
- jobject ac;
- jobject iface;
-
- if((*jniEnv)->IsInstanceOf(jniEnv, jObj, classAccessibleContext) )
- {
- ac = jObj;
- } else if((*jniEnv)->IsInstanceOf(jniEnv, jObj, classAccessible))
- {
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessible,
- "getAccessibleContext",
- "()Ljavax/accessibility/AccessibleContext;");
- ac = (*jniEnv)->CallObjectMethod(jniEnv, jObj, jmid);
- } else {
- return 0;
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleAction",
- "()Ljavax/accessibility/AccessibleAction;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_ACTION;
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleComponent",
- "()Ljavax/accessibility/AccessibleComponent;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_COMPONENT;
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleText",
- "()Ljavax/accessibility/AccessibleText;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_TEXT;
-
- jclass classAccessibleHypertext = (*jniEnv)->FindClass(jniEnv,
"javax/accessibility/AccessibleHypertext");
- if ( (*jniEnv)->IsInstanceOf(jniEnv, iface, classAccessibleHypertext))
- {
- tflag |= INTERFACE_HYPERTEXT;
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleEditableText",
- "()Ljavax/accessibility/AccessibleEditableText;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_EDITABLE_TEXT;
- }
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleIcon",
- "()[Ljavax/accessibility/AccessibleIcon;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_IMAGE;
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleSelection",
- "()Ljavax/accessibility/AccessibleSelection;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_SELECTION;
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleTable",
- "()Ljavax/accessibility/AccessibleTable;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_TABLE;
- jclass classAccessibleExtendedTable = (*jniEnv)->FindClass(jniEnv,
"javax/accessibility/AccessibleExtendedTable");
- if ((*jniEnv)->IsInstanceOf(jniEnv, iface, classAccessibleExtendedTable))
- {
- tflag |= INTERFACE_TABLE_CELL;
- }
- }
-
- jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAccessibleContext,
- "getAccessibleValue",
- "()Ljavax/accessibility/AccessibleValue;");
- iface = (*jniEnv)->CallObjectMethod(jniEnv, ac, jmid);
- if (iface != NULL)
- {
- tflag |= INTERFACE_VALUE;
- }
-
- return tflag;
+ jclass atkObject = (*jniEnv)->FindClass (jniEnv, "org/GNOME/Accessibility/AtkObject");
+ jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv, atkObject, "getTFlagFromObj",
"(Ljava/lang/Object;)I");
+ return (guint) (*jniEnv)->CallStaticIntMethod (jniEnv, atkObject, jmid, jObj);
}
gboolean
diff --git a/wrapper/org/GNOME/Accessibility/AtkObject.java b/wrapper/org/GNOME/Accessibility/AtkObject.java
index d27ee06..243ca23 100644
--- a/wrapper/org/GNOME/Accessibility/AtkObject.java
+++ b/wrapper/org/GNOME/Accessibility/AtkObject.java
@@ -37,6 +37,60 @@ import java.util.Locale;
*/
public class AtkObject{
+ public static final int INTERFACE_ACTION = 0x00000001;
+ public static final int INTERFACE_COMPONENT = 0x00000002;
+ public static final int INTERFACE_DOCUMENT = 0x00000004;
+ public static final int INTERFACE_EDITABLE_TEXT = 0x00000008;
+ public static final int INTERFACE_HYPERLINK = 0x00000010;
+ public static final int INTERFACE_HYPERTEXT = 0x00000020;
+ public static final int INTERFACE_IMAGE = 0x00000040;
+ public static final int INTERFACE_SELECTION = 0x00000080;
+ public static final int INTERFACE_STREAMABLE_CONTENT = 0x00000100;
+ public static final int INTERFACE_TABLE = 0x00000200;
+ public static final int INTERFACE_TABLE_CELL = 0x00000400;
+ public static final int INTERFACE_TEXT = 0x00000800;
+ public static final int INTERFACE_VALUE = 0x00001000;
+
+ public static int getTFlagFromObj(Object o){
+ return AtkUtil.invokeInSwing( () -> {
+ int flags = 0;
+ AccessibleContext ac;
+
+ if (o instanceof AccessibleContext)
+ ac = (AccessibleContext) o;
+ else if (o instanceof Accessible)
+ ac = ( (Accessible) o).getAccessibleContext();
+ else
+ return flags;
+
+ if (ac.getAccessibleAction() != null)
+ flags |= AtkObject.INTERFACE_ACTION;
+ if (ac.getAccessibleComponent() != null)
+ flags |= AtkObject.INTERFACE_COMPONENT;
+ AccessibleText text = ac.getAccessibleText();
+ if (text != null){
+ flags |= AtkObject.INTERFACE_TEXT;
+ if (text instanceof AccessibleHypertext)
+ flags |= AtkObject.INTERFACE_HYPERTEXT;
+ if (ac.getAccessibleEditableText() != null)
+ flags |= AtkObject.INTERFACE_EDITABLE_TEXT;
+ }
+ if (ac.getAccessibleIcon() != null)
+ flags |= AtkObject.INTERFACE_IMAGE;
+ if (ac.getAccessibleSelection() != null)
+ flags |= AtkObject.INTERFACE_SELECTION;
+ AccessibleTable table = ac.getAccessibleTable();
+ if (table != null){
+ flags |= AtkObject.INTERFACE_TABLE;
+ if (table instanceof AccessibleExtendedTable)
+ flags |= AtkObject.INTERFACE_TABLE_CELL;
+ }
+ if (ac.getAccessibleValue() != null)
+ flags |= AtkObject.INTERFACE_VALUE;
+ return flags;
+ }, 0);
+ }
+
public static AccessibleContext getAccessibleParent(AccessibleContext ac){
return AtkUtil.invokeInSwing( () -> {
Accessible father = ac.getAccessibleParent();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]