[java-atk-wrapper] Delegate setAccessibleName call to EDT



commit 647b30281ec53b06a6397546b35445c44b0c640d
Author: Giuseppe <giuseppecapaldo93 gmail com>
Date:   Mon Jun 17 23:54:08 2019 +0200

    Delegate setAccessibleName call to EDT

 jni/src/jawobject.c                            | 27 ++++----------------------
 wrapper/org/GNOME/Accessibility/AtkObject.java |  4 ++++
 2 files changed, 8 insertions(+), 23 deletions(-)
---
diff --git a/jni/src/jawobject.c b/jni/src/jawobject.c
index 18a828d..5c3f7ff 100644
--- a/jni/src/jawobject.c
+++ b/jni/src/jawobject.c
@@ -323,30 +323,11 @@ static void jaw_object_set_name (AtkObject *atk_obj, const gchar *name)
     jstr = (*jniEnv)->NewStringUTF(jniEnv, name);
   }
 
-  jclass classAccessibleContext = (*jniEnv)->FindClass(jniEnv,
-                                                       "javax/accessibility/AccessibleContext" );
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
-                                          classAccessibleContext,
-                                          "setAccessibleName",
-                                          "(Ljava/lang/String;)");
-  (*jniEnv)->CallVoidMethod( jniEnv, ac, jmid, jstr );
-  (*jniEnv)->DeleteGlobalRef(jniEnv, ac);
-
-  if (atk_obj->name != NULL)
-  {
-    (*jniEnv)->ReleaseStringUTFChars(jniEnv, jaw_obj->jstrName, atk_obj->name);
-    (*jniEnv)->DeleteGlobalRef(jniEnv, jaw_obj->jstrName);
-    jaw_obj->jstrName = NULL;
-    atk_obj->name = NULL;
-  }
+  jclass atkObject = (*jniEnv)->FindClass (jniEnv, "org/GNOME/Accessibility/AtkObject");
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID (jniEnv, atkObject, "setAccessibleName", 
"(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)V");
+  (*jniEnv)->CallStaticVoidMethod (jniEnv, atkObject, jmid, ac, jstr);
 
-  if (jstr != NULL)
-  {
-    jaw_obj->jstrName = (*jniEnv)->NewGlobalRef(jniEnv, jstr);
-    atk_obj->name = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv,
-                                                         jaw_obj->jstrName,
-                                                         NULL);
-  }
+  (*jniEnv)->DeleteGlobalRef(jniEnv, ac);
 }
 
 static const gchar*
diff --git a/wrapper/org/GNOME/Accessibility/AtkObject.java b/wrapper/org/GNOME/Accessibility/AtkObject.java
index cdc2603..0bc8415 100644
--- a/wrapper/org/GNOME/Accessibility/AtkObject.java
+++ b/wrapper/org/GNOME/Accessibility/AtkObject.java
@@ -51,6 +51,10 @@ public class AtkObject{
         return AtkUtil.invokeInSwing( () -> { return ac.getAccessibleName(); }, "");
     }
 
+    public static void setAccessibleName(AccessibleContext ac, String name){
+        AtkUtil.invokeInSwing( () -> { ac.setAccessibleName(name); } );
+    }
+
     public static int hashCode(AccessibleContext ac){
         return AtkUtil.invokeInSwing( () -> { return ac.hashCode(); }, 0);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]