[java-atk-wrapper] Create jaw_action_get_localized_name & getLocalizedName
- From: Magdalen Berns <mberns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] Create jaw_action_get_localized_name & getLocalizedName
- Date: Mon, 13 Jul 2015 19:20:47 +0000 (UTC)
commit 4cd782cb88dff50a6b5e3c43a0e1b70037ee216f
Author: Magdalen Berns <m berns thismagpie com>
Date: Mon Jul 13 20:17:43 2015 +0100
Create jaw_action_get_localized_name & getLocalizedName
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=740542
jni/src/jawaction.c | 36 ++++++++++++++++++++++--
wrapper/org/GNOME/Accessibility/AtkAction.java | 27 +++++++++++++++++-
2 files changed, 59 insertions(+), 4 deletions(-)
---
diff --git a/jni/src/jawaction.c b/jni/src/jawaction.c
index cbe62ac..3c7b6f9 100644
--- a/jni/src/jawaction.c
+++ b/jni/src/jawaction.c
@@ -32,13 +32,13 @@ static const gchar* jaw_action_get_description(AtkAction *action, gint i);
static const gchar* jaw_action_get_name(AtkAction *action, gint i);
static const gchar* jaw_action_get_keybinding (AtkAction *action, gint i);
static gboolean jaw_action_set_description (AtkAction *action, gint i, const gchar *description);
-/*static const gchar* jaw_get_localized_name (AtkAction *action,
- gint i);*/
+static const gchar* jaw_action_get_localized_name(AtkAction *action, gint i);
typedef struct _ActionData {
jobject atk_action;
gchar* action_name;
jstring jstrActionName;
+ jstring jstrLocalizedName;
gchar* action_description;
jstring jstrActionDescription;
gchar* action_keybinding;
@@ -54,7 +54,7 @@ jaw_action_interface_init (AtkActionIface *iface)
iface->get_name = jaw_action_get_name;
iface->get_keybinding = jaw_action_get_keybinding;
iface->set_description = jaw_action_set_description;
- iface->get_localized_name = NULL; /*jaw_get_localized_name;*/
+ iface->get_localized_name = jaw_action_get_localized_name;
}
gpointer
@@ -86,8 +86,14 @@ jaw_action_data_finalize (gpointer p)
(*jniEnv)->ReleaseStringUTFChars(jniEnv,
data->jstrActionName,
data->action_name);
+ (*jniEnv)->ReleaseStringUTFChars(jniEnv,
+ data->jstrLocalizedName,
+ data->action_name);
+
(*jniEnv)->DeleteGlobalRef(jniEnv, data->jstrActionName);
+ (*jniEnv)->DeleteGlobalRef(jniEnv, data->jstrLocalizedName);
data->jstrActionName = NULL;
+ data->jstrLocalizedName = NULL;
data->action_name = NULL;
}
@@ -252,6 +258,30 @@ jaw_action_get_name (AtkAction *action, gint i)
}
static const gchar*
+jaw_action_get_localized_name (AtkAction *action, gint i)
+{
+ JawObject *jaw_obj = JAW_OBJECT(action);
+ ActionData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_ACTION);
+ jobject atk_action = data->atk_action;
+
+ JNIEnv *env = jaw_util_get_jni_env();
+ jclass classAtkAction = (*env)->FindClass(env, "org/GNOME/Accessibility/AtkAction");
+ jmethodID jmid = (*env)->GetMethodID(env,
+ classAtkAction,
+ "getLocalizedName",
+ "(I)Ljava/lang/String;");
+ jstring jstr = (*env)->CallObjectMethod(env, atk_action, jmid, (jint)i);
+ if (data->action_name != NULL)
+ {
+ (*env)->ReleaseStringUTFChars(env, data->jstrLocalizedName, data->action_name);
+ (*env)->DeleteGlobalRef(env, data->jstrLocalizedName);
+ }
+ data->jstrLocalizedName = (*env)->NewGlobalRef(env, jstr);
+ data->action_name = (gchar*)(*env)->GetStringUTFChars(env, data->jstrLocalizedName, NULL);
+ return data->action_name;
+}
+
+static const gchar*
jaw_action_get_keybinding (AtkAction *action, gint i)
{
JawObject *jaw_obj = JAW_OBJECT(action);
diff --git a/wrapper/org/GNOME/Accessibility/AtkAction.java b/wrapper/org/GNOME/Accessibility/AtkAction.java
index fa694bb..09dedbf 100644
--- a/wrapper/org/GNOME/Accessibility/AtkAction.java
+++ b/wrapper/org/GNOME/Accessibility/AtkAction.java
@@ -82,7 +82,32 @@ public class AtkAction {
return name;
}
-
+
+ /**
+ * @param i an integer holding the index of the name of
+ * the accessible.
+ * @return the localized name of the object or otherwise,
+ * null if the "action" object does not have a
+ * name (really, java's AccessibleAction class
+ * does not provide
+ * a getter for an AccessibleAction
+ * name so a getter from the AcccessibleContext
+ * class is one way to work around that)
+ */
+ public String getLocalizedName (int i) {
+ String name = ac.getAccessibleName();
+ String description = acc_action.getAccessibleActionDescription(i);
+
+ if (description == name && description != null)
+ return description;
+ if (description == null && name != null)
+ return name;
+ else if (description != null)
+ return description;
+
+ return null;
+ }
+
private String convertModString (String mods) {
if (mods == null || mods.length() == 0) {
return "";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]