[java-atk-wrapper] JNI: create jaw_object_set_description



commit d24df6e71ec080bd9eec5d9b643c3434d8dda5de
Author: Magdalen Berns <m berns thismagpie com>
Date:   Tue Jun 9 16:40:27 2015 +0100

    JNI: create jaw_object_set_description
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=750649

 HACKING             |    2 --
 jni/src/jawaction.c |    1 -
 jni/src/jawobject.c |   39 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/HACKING b/HACKING
index 04b6c43..a35ce15 100644
--- a/HACKING
+++ b/HACKING
@@ -40,8 +40,6 @@ Object base class:
   AtkFunction
   implementor_ref_accessible
   peek_parent
-  set_name
-  set_description
   set_parent
   set_role
   add_relationship
diff --git a/jni/src/jawaction.c b/jni/src/jawaction.c
index 9af38d4..4edd45f 100644
--- a/jni/src/jawaction.c
+++ b/jni/src/jawaction.c
@@ -53,7 +53,6 @@ jaw_action_interface_init (AtkActionIface *iface)
   iface->get_name = jaw_action_get_name;
   iface->get_keybinding = jaw_action_get_keybinding;
   iface->get_localized_name = NULL; /*jaw_get_localized_name;*/
-  iface->set_description = NULL;
 }
 
 gpointer
diff --git a/jni/src/jawobject.c b/jni/src/jawobject.c
index ba755b1..133106e 100644
--- a/jni/src/jawobject.c
+++ b/jni/src/jawobject.c
@@ -47,6 +47,8 @@ static void jaw_object_state_change (AtkObject   *atk_obj,
 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 void jaw_object_set_description (AtkObject *atk_obj, const gchar *description);
+
 
 static gpointer parent_class = NULL;
 
@@ -72,8 +74,8 @@ jaw_object_class_init (JawObjectClass *klass)
   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_parent = jaw_object_set_parent;
+  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;
        atk_class->remove_property_change_handler = jaw_object_remove_property_change_handler;
@@ -273,6 +275,39 @@ jaw_object_get_description (AtkObject *atk_obj)
   return atk_obj->description;
 }
 
+static void jaw_object_set_description (AtkObject *atk_obj, const gchar *description)
+{
+  JawObject *jaw_obj = JAW_OBJECT(atk_obj);
+  jobject ac = jaw_obj->acc_context;
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+
+  jclass classAccessibleContext = (*jniEnv)->FindClass( jniEnv,
+                                                       "javax/accessibility/AccessibleContext" );
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+                                          classAccessibleContext,
+                                          "setAccessibleDescription",
+                                          "(Ljava/lang/String;)");
+  jstring jstr = (*jniEnv)->CallObjectMethod( jniEnv, ac, jmid );
+
+  if (description != NULL)
+  {
+    (*jniEnv)->ReleaseStringUTFChars(jniEnv, jaw_obj->jstrDescription, description);
+    (*jniEnv)->DeleteGlobalRef(jniEnv, jaw_obj->jstrDescription);
+    description = NULL;
+  }
+
+  if (jstr != NULL)
+  {
+    jaw_obj->jstrDescription = (*jniEnv)->NewGlobalRef(jniEnv, jstr);
+    description = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv,
+                                                       jaw_obj->jstrDescription,
+                                                       NULL);
+  }
+  if (jstr != NULL)
+  {
+    description = "";
+  }
+}
 static gint
 jaw_object_get_n_children (AtkObject *atk_obj)
 {


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