[java-atk-wrapper/wip] Implement AtkTableCell interface wrapper class



commit 56fde82a77b5bc46a4a962f5877ffd34405c3cd6
Author: Magdalen Berns <m berns thismagpie com>
Date:   Sun Jun 21 23:42:09 2015 +0100

    Implement AtkTableCell interface wrapper class
    
    AtkTableCell extends AtkTable and implements the AtkTableCell
    interface wrapper functions. This patch contains a
    jaw_table_cell_get_table wrapper function, other functions
    yet to be implemented.
    
    See https://developer.gnome.org/atk/unstable/AtkTableCell.html
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=751111

 jni/src/Makefile.am                               |    3 +-
 jni/src/jawimpl.c                                 |   24 +++++
 jni/src/jawtablecell.c                            |  101 +++++++++++++++++++++
 jni/src/jawutil.c                                 |    5 +
 jni/src/jawutil.h                                 |    5 +-
 wrapper/org/GNOME/Accessibility/AtkTable.java     |    1 -
 wrapper/org/GNOME/Accessibility/AtkTableCell.java |   52 +++++++++++
 7 files changed, 187 insertions(+), 4 deletions(-)
---
diff --git a/jni/src/Makefile.am b/jni/src/Makefile.am
index b1bd59c..2740685 100644
--- a/jni/src/Makefile.am
+++ b/jni/src/Makefile.am
@@ -14,7 +14,8 @@ libatk_wrapper_la_SOURCES = AtkWrapper.c \
                             jawimage.c \
                             jawselection.c \
                             jawvalue.c \
-                            jawtable.c
+                            jawtable.c \
+                            jawtablecell.c
 
 noinst_HEADERS = jawimpl.h \
                  jawobject.h \
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index 5ca98c8..e09d3b1 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -81,6 +81,10 @@ extern void jaw_table_interface_init (AtkTableIface*);
 extern gpointer jaw_table_data_init (jobject);
 extern void jaw_table_data_finalize (gpointer);
 
+extern void jaw_table_cell_interface_init (AtkTableCellIface*);
+extern gpointer jaw_table_cell_data_init (jobject);
+extern void jaw_table_cell_data_finalize (gpointer);
+
 typedef struct _JawInterfaceInfo {
   void (*finalize) (gpointer);
   gpointer data;
@@ -234,6 +238,16 @@ aggregate_interface(JNIEnv *jniEnv, JawObject *jaw_obj, guint tflag)
                         (gpointer)INTERFACE_TABLE,
                         (gpointer)info);
   }
+
+  if (tflag & INTERFACE_TABLE_CELL)
+  {
+    JawInterfaceInfo *info = g_new(JawInterfaceInfo, 1);
+    info->data = jaw_table_cell_data_init(ac);
+    info->finalize = jaw_table_cell_data_finalize;
+    g_hash_table_insert(jaw_impl->ifaceTable,
+                        (gpointer)INTERFACE_TABLE_CELL,
+                        (gpointer)info);
+  }
 }
 
 JawImpl*
@@ -384,6 +398,13 @@ jaw_impl_get_type (guint tflag)
     NULL
   };
 
+  static const GInterfaceInfo atk_table_cell_info =
+  {
+    (GInterfaceInitFunc) jaw_table_cell_interface_init,
+    (GInterfaceFinalizeFunc) NULL,
+    NULL
+  };
+
   if (typeTable == NULL) {
     typeTable = g_hash_table_new( NULL, NULL );
   }
@@ -435,6 +456,9 @@ jaw_impl_get_type (guint tflag)
     if (tflag & INTERFACE_TABLE)
       g_type_add_interface_static (type, ATK_TYPE_TABLE, &atk_table_info);
 
+    if (tflag & INTERFACE_TABLE_CELL)
+      g_type_add_interface_static (type, ATK_TYPE_TABLE_CELL, &atk_table_cell_info);
+
     g_hash_table_insert(typeTable, GINT_TO_POINTER(tflag), GTYPE_TO_POINTER(type));
   }
 
diff --git a/jni/src/jawtablecell.c b/jni/src/jawtablecell.c
new file mode 100644
index 0000000..89ca67b
--- /dev/null
+++ b/jni/src/jawtablecell.c
@@ -0,0 +1,101 @@
+/*
+ * Java ATK Wrapper for GNOME
+ * Copyright (C) 2015 Magdalen Berns <m berns thismagpie com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  021101301  USA
+ */
+
+#include <atk/atk.h>
+#include <glib.h>
+#include "jawimpl.h"
+#include "jawutil.h"
+
+extern void jaw_table_cell_interface_init (AtkTableCellIface*);
+extern gpointer jaw_table_cell_data_init (jobject ac);
+extern void jaw_table_cell_data_finalize (gpointer);
+
+static AtkObject *jaw_table_cell_get_table (AtkTableCell *cell);
+
+typedef struct _TableCellData {
+  jobject atk_table_cell;
+  gchar* description;
+  jstring jstrDescription;
+} TableCellData;
+
+void
+jaw_table_cell_interface_init (AtkTableCellIface *iface)
+{
+  iface->get_table = jaw_table_cell_get_table;
+}
+
+gpointer
+jaw_table_cell_data_init (jobject ac)
+{
+  TableCellData *data = g_new0(TableCellData, 1);
+
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+  jclass classTableCell = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkTableCell");
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classTableCell, "<init>", 
"(Ljavax/accessibility/AccessibleContext;)V");
+  jobject jatk_table_cell = (*jniEnv)->NewObject(jniEnv, classTableCell, jmid, ac);
+  data->atk_table_cell = (*jniEnv)->NewGlobalRef(jniEnv, jatk_table_cell);
+
+  return data;
+}
+
+void
+jaw_table_cell_data_finalize (gpointer p)
+{
+  TableCellData *data = (TableCellData*)p;
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+
+  if (data && data->atk_table_cell)
+  {
+    if (data->description != NULL)
+    {
+      (*jniEnv)->ReleaseStringUTFChars(jniEnv, data->jstrDescription, data->description);
+      (*jniEnv)->DeleteGlobalRef(jniEnv, data->jstrDescription);
+      data->jstrDescription = NULL;
+      data->description = NULL;
+    }
+
+    (*jniEnv)->DeleteGlobalRef(jniEnv, data->atk_table_cell);
+    data->atk_table_cell = NULL;
+  }
+}
+
+static AtkObject*
+jaw_table_cell_get_table(AtkTableCell *cell)
+{
+  JawObject *jaw_obj = JAW_OBJECT(cell);
+  TableCellData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_TABLE_CELL);
+  jobject jatk_table_cell = data->atk_table_cell;
+
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+  jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv,
+                                                  "org/GNOME/Accessibility/AtkTableCell");
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+                                          classAtkTableCell,
+                                          "getTable",
+                                          "()Ljavax/accessibility/AccessibleContext;");
+  jobject jac = (*jniEnv)->CallObjectMethod(jniEnv, jatk_table_cell, jmid);
+
+  if (!jac)
+    return NULL;
+
+  JawImpl* jaw_impl = jaw_impl_get_instance(jniEnv, jac);
+
+  return ATK_OBJECT(jaw_impl);
+}
+
diff --git a/jni/src/jawutil.c b/jni/src/jawutil.c
index ce2d406..1b3c5f5 100644
--- a/jni/src/jawutil.c
+++ b/jni/src/jawutil.c
@@ -411,6 +411,11 @@ jaw_util_get_tflag_from_jobj(JNIEnv *jniEnv, jobject jObj)
   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,
diff --git a/jni/src/jawutil.h b/jni/src/jawutil.h
index 4097241..e9cb4fb 100644
--- a/jni/src/jawutil.h
+++ b/jni/src/jawutil.h
@@ -35,8 +35,9 @@ G_BEGIN_DECLS
 #define INTERFACE_SELECTION               0x00000080
 #define INTERFACE_STREAMABLE_CONTENT      0x00000100
 #define INTERFACE_TABLE                   0x00000200
-#define INTERFACE_TEXT                    0x00000400
-#define INTERFACE_VALUE                   0x00000800
+#define INTERFACE_TABLE_CELL              0x00000400
+#define INTERFACE_TEXT                    0x00000800
+#define INTERFACE_VALUE                   0x00001000
 
 #define JAW_TYPE_UTIL               (jaw_util_get_type())
 #define JAW_UTIL(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), JAW_TYPE_UTIL, JawUtil))
diff --git a/wrapper/org/GNOME/Accessibility/AtkTable.java b/wrapper/org/GNOME/Accessibility/AtkTable.java
index 285f95c..17f8820 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTable.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTable.java
@@ -27,7 +27,6 @@ public class AtkTable {
        AccessibleTable acc_table;
 
   public AtkTable (AccessibleContext ac) {
-    super();
     this.ac = ac;
     this.acc_table = ac.getAccessibleTable();
   }
diff --git a/wrapper/org/GNOME/Accessibility/AtkTableCell.java 
b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
new file mode 100644
index 0000000..4781aa2
--- /dev/null
+++ b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
@@ -0,0 +1,52 @@
+/*
+ * Java ATK Wrapper for GNOME
+ * Copyright (C) 2015 Magdalen Berns <m berns thismagpie com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+package org.GNOME.Accessibility;
+
+import javax.accessibility.*;
+
+public class AtkTableCell extends AtkTable {
+
+  AccessibleContext ac;
+
+  AccessibleExtendedTable acc_table_cell;
+
+  public AtkTableCell (AccessibleContext ac) {
+    super(ac);
+    this.ac = ac;
+    AccessibleTable acc_table = ac.getAccessibleTable();
+
+    if (acc_table instanceof AccessibleExtendedTable) {
+      acc_table_cell = (AccessibleExtendedTable)acc_table;
+    } else {
+      acc_table_cell = null;
+    }
+  }
+
+/**
+ * getTable
+ * @return: Reference to the accessible of the containing table as an
+ *          AccessibleTable instance.
+ */
+  public AccessibleTable getTable() {
+    System.out.println("Get Table: " + acc_table_cell.toString());
+    return acc_table_cell;
+  }
+}
+


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