[java-atk-wrapper] JNI: Create jaw_object_set_name



commit 54dcfc6847d0d1a32cb826085e56a2f61f1c7e1e
Author: Magdalen Berns <m berns thismagpie com>
Date:   Tue Jun 9 16:20:04 2015 +0100

    JNI: Create jaw_object_set_name
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=750647

 jni/src/jawobject.c |   41 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/jni/src/jawobject.c b/jni/src/jawobject.c
index 4dfe1ec..ba755b1 100644
--- a/jni/src/jawobject.c
+++ b/jni/src/jawobject.c
@@ -46,6 +46,7 @@ static void jaw_object_state_change (AtkObject   *atk_obj,
                                      gboolean    state_set);
 static AtkObject * jaw_object_ref_child (AtkObject *atk_obj, gint i);
 static AtkRelationSet* jaw_object_ref_relation_set(AtkObject *atk_obj);
+static void jaw_object_set_name (AtkObject *atk_obj, const gchar *name);
 
 static gpointer parent_class = NULL;
 
@@ -70,8 +71,8 @@ jaw_object_class_init (JawObjectClass *klass)
   atk_class->state_change = jaw_object_state_change;
   atk_class->ref_child = jaw_object_ref_child;
   atk_class->ref_relation_set = jaw_object_ref_relation_set;
-/*     atk_class->set_name = jaw_object_set_name;
-       atk_class->set_description = jaw_object_set_description;
+  atk_class->set_name = jaw_object_set_name;
+/*atk_class->set_description = jaw_object_set_description;
        atk_class->set_parent = jaw_object_set_parent;
        atk_class->set_role = jaw_object_set_role;
        atk_class->connect_property_change_handler = jaw_object_connect_property_change_handler;
@@ -203,6 +204,42 @@ jaw_object_get_name (AtkObject *atk_obj)
   return atk_obj->name;
 }
 
+static void jaw_object_set_name (AtkObject *atk_obj, const gchar *name)
+{
+  JawObject *jaw_obj = JAW_OBJECT(atk_obj);
+  jobject ac = jaw_obj->acc_context;
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+
+  atk_obj->name = (gchar *)ATK_OBJECT_CLASS (parent_class)->get_name (atk_obj);
+
+  jclass classAccessibleContext = (*jniEnv)->FindClass(jniEnv,
+                                                       "javax/accessibility/AccessibleContext" );
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+                                          classAccessibleContext,
+                                          "setAccessibleName",
+                                          "(Ljava/lang/String;)");
+  jstring jstr = (*jniEnv)->CallObjectMethod( jniEnv, ac, jmid );
+
+  if (atk_obj->name != NULL)
+  {
+    (*jniEnv)->ReleaseStringUTFChars(jniEnv, jaw_obj->jstrName, atk_obj->name);
+    (*jniEnv)->DeleteGlobalRef(jniEnv, jaw_obj->jstrName);
+  }
+
+  if (jstr != NULL)
+  {
+    jaw_obj->jstrName = (*jniEnv)->NewGlobalRef(jniEnv, jstr);
+    atk_obj->name = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv,
+                                                         jaw_obj->jstrName,
+                                                         NULL);
+  }
+  if (jstr == NULL)
+  {
+    name = "";
+    return;
+  }
+}
+
 static const gchar*
 jaw_object_get_description (AtkObject *atk_obj)
 {


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