* Boston, MA 02111-1307, USA.
*/
-/*
- * component.c : bonobo wrapper for accessible component implementation
- *
- */
-#include <config.h>
-#include <bonobo/Bonobo.h>
+/* table.c : implements the Table interface */
+#include <config.h>
#include <stdio.h>
+#include <bonobo/bonobo-exception.h>
+#include <atk/atktable.h>
+#include <libspi/accessible.h>
+#include <libspi/table.h>
-/*
- * This pulls the CORBA definitions for the "Accessibility::Accessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition of the SpiTable bonobo object
- */
-#include "table.h"
-/*
- * Static function declarations
- */
-
-static void
-spi_table_class_init (SpiTableClass *klass);
-static void
-spi_table_init (SpiTable *table);
-static void
-spi_table_finalize (GObject *obj);
-static Accessibility_Accessible
-impl__get_caption (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_Accessible
-impl__get_summary (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_nRows (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_nRows (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_nColumns (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_Accessible
-impl_getAccessibleAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getIndexAt (PortableServer_Servant _servant,
- const CORBA_long row, const CORBA_long column,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getRowAtIndex (PortableServer_Servant _servant,
- const CORBA_long index,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getColumnAtIndex (PortableServer_Servant _servant,
- const CORBA_long index,
- CORBA_Environment * ev);
-static CORBA_string
-impl_getRowDescription (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev);
-static CORBA_string
-impl_getColumnDescription (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getRowExtentAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getColumnExtentAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev);
-static Accessibility_Table
-impl_getRowHeader (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev);
-static Accessibility_Table
-impl_getColumnHeader (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev);
-static Accessibility_LongSeq *
-impl_getSelectedRows (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_LongSeq *
-impl_getSelectedColumns (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_boolean
-impl_isRowSelected (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev);
-static CORBA_boolean
-impl_isColumnSelected (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev);
-static CORBA_boolean
-impl_isSelected (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev);
-
-
-static GObjectClass *parent_class;
-
-GType
-spi_table_get_type (void)
+SpiTable *
+spi_table_interface_new (AtkObject *obj)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (SpiTableClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) spi_table_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (SpiTable),
- 0, /* n preallocs */
- (GInstanceInitFunc) spi_table_init,
- NULL /* value table */
- };
-
- /*
- * Bonobo_type_unique auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- BONOBO_OBJECT_TYPE,
- POA_Accessibility_Table__init,
- NULL,
- G_STRUCT_OFFSET (SpiTableClass, epv),
- &tinfo,
- "SpiAccessibleTable");
- }
-
- return type;
-}
+ SpiTable *new_table = g_object_new (SPI_TABLE_TYPE, NULL);
-static void
-spi_table_class_init (SpiTableClass *klass)
-{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Table__epv *epv = &klass->epv;
- parent_class = g_type_class_peek_parent (klass);
+ spi_base_construct (SPI_BASE (new_table), obj);
- object_class->finalize = spi_table_finalize;
-
-
- /* Initialize epv table */
-
- epv->_get_caption = impl__get_caption;
- epv->_get_summary = impl__get_summary;
- epv->_get_nRows = impl__get_nRows;
- epv->_get_nColumns = impl__get_nColumns;
- epv->getAccessibleAt = impl_getAccessibleAt;
- epv->getIndexAt = impl_getIndexAt;
- epv->getRowAtIndex = impl_getRowAtIndex;
- epv->getColumnAtIndex = impl_getColumnAtIndex;
- epv->getRowDescription = impl_getRowDescription;
- epv->getColumnDescription = impl_getColumnDescription;
- epv->getRowExtentAt = impl_getRowExtentAt;
- epv->getColumnExtentAt = impl_getColumnExtentAt;
- epv->getRowHeader = impl_getRowHeader;
- epv->getColumnHeader = impl_getColumnHeader;
- epv->getSelectedRows = impl_getSelectedRows;
- epv->getSelectedColumns = impl_getSelectedColumns;
- epv->isRowSelected = impl_isRowSelected;
- epv->isColumnSelected = impl_isColumnSelected;
- epv->isSelected = impl_isSelected;
+ return new_table;
}
-static void
-spi_table_init (SpiTable *table)
-{
-}
-static void
-spi_table_finalize (GObject *obj)
+static AtkTable *
+get_table_from_servant (PortableServer_Servant servant)
{
- SpiTable *table = SPI_TABLE (obj);
- g_object_unref (table->atko);
- table->atko = NULL;
- parent_class->finalize (obj);
-}
+ SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
-SpiTable *
-spi_table_interface_new (AtkObject *obj)
-{
- SpiTable *new_table =
- SPI_TABLE(g_object_new (SPI_TABLE_TYPE, NULL));
- new_table->atko = obj;
- g_object_ref (obj);
- return new_table;
-}
+ if (!object)
+ {
+ return NULL;
+ }
+ return ATK_TABLE (object->atko);
+}
static Accessibility_Accessible
-impl__get_caption (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl__get_caption (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
AtkObject *atk_object;
- Accessibility_Accessible rv;
+ AtkTable *table = get_table_from_servant (servant);
- atk_object = atk_table_get_caption (ATK_TABLE(table-> atko));
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
- return CORBA_Object_duplicate (rv, ev);
-}
+ g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
+
+ atk_object = atk_table_get_caption (table);
+ return spi_accessible_new_return (atk_object, FALSE, ev);
+}
static Accessibility_Accessible
-impl__get_summary (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl__get_summary (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
AtkObject *atk_object;
- Accessibility_Accessible rv;
+ AtkTable *table = get_table_from_servant (servant);
- atk_object = atk_table_get_summary (ATK_TABLE(table->atko));
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
- return CORBA_Object_duplicate (rv, ev);
-}
+ g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
+
+ atk_object = atk_table_get_summary (table);
+ return spi_accessible_new_return (atk_object, FALSE, ev);
+}
static CORBA_long
-impl__get_nRows (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl__get_nRows (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_n_rows (ATK_TABLE(table->atko) );
-}
+ AtkTable *table = get_table_from_servant (servant);
+ g_return_val_if_fail (table != NULL, 0);
+
+ return (CORBA_long) atk_table_get_n_rows (table);
+}
static CORBA_long
-impl__get_nColumns (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl__get_nColumns (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_n_columns (ATK_TABLE(table->atko));
-}
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, 0);
+ return (CORBA_long) atk_table_get_n_columns (table);
+}
static Accessibility_Accessible
-impl_getAccessibleAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev)
+impl_getAccessibleAt (PortableServer_Servant servant,
+ const CORBA_long row,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
AtkObject *atk_object;
- Accessibility_Accessible rv;
+ AtkTable *table = get_table_from_servant (servant);
- atk_object = atk_table_ref_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
- return CORBA_Object_duplicate (rv, ev);
-}
+ g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
+ atk_object = atk_table_ref_at (table,
+ (gint) row, (gint) column);
+
+ return spi_accessible_new_return (atk_object, TRUE, ev);
+}
static CORBA_long
-impl_getIndexAt (PortableServer_Servant _servant,
- const CORBA_long row, const CORBA_long column,
- CORBA_Environment * ev)
+impl_getIndexAt (PortableServer_Servant servant,
+ const CORBA_long row,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, 0);
+
return (CORBA_long)
- atk_table_get_index_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
+ atk_table_get_index_at (table, (gint) row, (gint) column);
}
-
static CORBA_long
-impl_getRowAtIndex (PortableServer_Servant _servant,
- const CORBA_long index,
- CORBA_Environment * ev)
+impl_getRowAtIndex (PortableServer_Servant servant,
+ const CORBA_long index,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, 0);
+
return (CORBA_long)
- atk_table_get_row_at_index (ATK_TABLE(table->atko), (gint) index);
+ atk_table_get_row_at_index (table, (gint) index);
}
-
static CORBA_long
-impl_getColumnAtIndex (PortableServer_Servant _servant,
- const CORBA_long index,
- CORBA_Environment * ev)
+impl_getColumnAtIndex (PortableServer_Servant servant,
+ const CORBA_long index,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, 0);
+
return (CORBA_long)
- atk_table_get_column_at_index (ATK_TABLE(table->atko), (gint) index);
+ atk_table_get_column_at_index (table, (gint) index);
}
-
static CORBA_string
-impl_getRowDescription (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev)
+impl_getRowDescription (PortableServer_Servant servant,
+ const CORBA_long row,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- CORBA_char *rv;
+ const char *rv;
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, 0);
- rv = atk_table_get_row_description (ATK_TABLE(table->atko), (gint) row);
+ rv = atk_table_get_row_description (table, row);
+
if (rv)
- return CORBA_string_dup (rv);
+ {
+ return CORBA_string_dup (rv);
+ }
else
- return CORBA_string_dup ("");
+ {
+ return CORBA_string_dup ("");
+ }
}
-
static CORBA_string
-impl_getColumnDescription (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev)
+impl_getColumnDescription (PortableServer_Servant servant,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- CORBA_char *rv;
+ const char *rv;
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, CORBA_string_dup (""));
+
+ rv = atk_table_get_row_description (table, column);
- rv = atk_table_get_column_description (ATK_TABLE(table->atko), (gint) column);
if (rv)
- return CORBA_string_dup (rv);
+ {
+ return CORBA_string_dup (rv);
+ }
else
- return CORBA_string_dup ("");
+ {
+ return CORBA_string_dup ("");
+ }
}
-
static CORBA_long
-impl_getRowExtentAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev)
+impl_getRowExtentAt (PortableServer_Servant servant,
+ const CORBA_long row,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, -1);
+
return (CORBA_long)
- atk_table_get_row_extent_at (ATK_TABLE(table->atko),
+ atk_table_get_row_extent_at (table,
(gint) row, (gint) column);
}
-
static CORBA_long
-impl_getColumnExtentAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev)
+impl_getColumnExtentAt (PortableServer_Servant servant,
+ const CORBA_long row,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, -1);
+
return (CORBA_long)
- atk_table_get_column_extent_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
+ atk_table_get_column_extent_at (table,
+ (gint) row, (gint) column);
}
-
static Accessibility_Table
-impl_getRowHeader (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev)
+impl_getRowHeader (PortableServer_Servant servant,
+ const CORBA_long row,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
AtkObject *header;
- Accessibility_Table rv;
+ AtkTable *table = get_table_from_servant (servant);
- header = atk_table_get_row_header (ATK_TABLE(table->atko), (gint) row);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
- return CORBA_Object_duplicate (rv, ev);
-}
+ g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
+ header = atk_table_get_row_header (table, (gint) row);
+
+ return spi_accessible_new_return (header, FALSE, ev);
+}
-static Accessibility_Table
-impl_getColumnHeader (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev)
+static Accessibility_Table
+impl_getColumnHeader (PortableServer_Servant servant,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
AtkObject *header;
- Accessibility_Table rv;
+ AtkTable *table = get_table_from_servant (servant);
- header = atk_table_get_column_header (ATK_TABLE(table->atko), (gint) column);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(header)));
- return CORBA_Object_duplicate (rv, ev);
-}
+ g_return_val_if_fail (table != NULL, CORBA_OBJECT_NIL);
+
+ header = atk_table_get_column_header (table, (gint) column);
+ return spi_accessible_new_return (header, FALSE, ev);
+}
static Accessibility_LongSeq *
-impl_getSelectedRows (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl_getSelectedRows (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
gint *selectedRows;
gint length;
Accessibility_LongSeq *retval;
+ AtkTable *table = get_table_from_servant (servant);
- length = atk_table_get_selected_rows (ATK_TABLE(table->atko), &selectedRows);
+ bonobo_return_val_if_fail (table != NULL, NULL, ev);
+
+ length = atk_table_get_selected_rows (table, &selectedRows);
+
+ bonobo_return_val_if_fail (length > 0, NULL, ev);
- g_return_val_if_fail (length, NULL);
retval = Accessibility_LongSeq__alloc ();
retval->_maximum = retval->_length = (CORBA_long) length;
retval->_buffer = Accessibility_LongSeq_allocbuf (length);
while (--length)
- retval->_buffer[length] = (CORBA_long) selectedRows[length];
+ {
+ retval->_buffer[length] = (CORBA_long) selectedRows[length];
+ }
+
g_free ((gpointer) selectedRows);
+
return retval;
}
-
static Accessibility_LongSeq *
-impl_getSelectedColumns (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+impl_getSelectedColumns (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
gint *selectedColumns;
gint length;
Accessibility_LongSeq *retval;
+ AtkTable *table = get_table_from_servant (servant);
- length = atk_table_get_selected_columns (ATK_TABLE(table->atko), &selectedColumns);
+ bonobo_return_val_if_fail (table != NULL, NULL, ev);
- g_return_val_if_fail (length, NULL);
+ length = atk_table_get_selected_columns (table, &selectedColumns);
+
+ bonobo_return_val_if_fail (length >= 0, NULL, ev);
retval = Accessibility_LongSeq__alloc ();
retval->_maximum = retval->_length = (CORBA_long) length;
retval->_buffer = Accessibility_LongSeq_allocbuf (length);
while (--length)
- retval->_buffer[length] = (CORBA_long) selectedColumns[length];
+ {
+ retval->_buffer[length] = (CORBA_long) selectedColumns[length];
+ }
+
g_free ((gpointer) selectedColumns);
+
return retval;
}
-
static CORBA_boolean
-impl_isRowSelected (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev)
+impl_isRowSelected (PortableServer_Servant servant,
+ const CORBA_long row,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_boolean)
- atk_table_is_row_selected (ATK_TABLE(table->atko), (gint) row);
-}
+ AtkTable *table = get_table_from_servant (servant);
+ g_return_val_if_fail (table != NULL, FALSE);
+
+ return (CORBA_boolean) atk_table_is_row_selected (table, (gint) row);
+}
static CORBA_boolean
-impl_isColumnSelected (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev)
+impl_isColumnSelected (PortableServer_Servant servant,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_boolean)
- atk_table_is_column_selected (ATK_TABLE(table->atko), (gint) column);
-}
+ AtkTable *table = get_table_from_servant (servant);
+ g_return_val_if_fail (table != NULL, FALSE);
+
+ return (CORBA_boolean) atk_table_is_column_selected (table, (gint) column);
+}
static CORBA_boolean
-impl_isSelected (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev)
+impl_isSelected (PortableServer_Servant servant,
+ const CORBA_long row,
+ const CORBA_long column,
+ CORBA_Environment *ev)
{
- SpiTable *table = SPI_TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_boolean)
- atk_table_is_selected (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
+ AtkTable *table = get_table_from_servant (servant);
+
+ g_return_val_if_fail (table != NULL, FALSE);
+
+ return (CORBA_boolean) atk_table_is_selected (table,
+ (gint) row, (gint) column);
}
+static void
+spi_table_class_init (SpiTableClass *klass)
+{
+ POA_Accessibility_Table__epv *epv = &klass->epv;
+
+ /* Initialize epv table */
+
+ epv->_get_caption = impl__get_caption;
+ epv->_get_summary = impl__get_summary;
+ epv->_get_nRows = impl__get_nRows;
+ epv->_get_nColumns = impl__get_nColumns;
+ epv->getAccessibleAt = impl_getAccessibleAt;
+ epv->getIndexAt = impl_getIndexAt;
+ epv->getRowAtIndex = impl_getRowAtIndex;
+ epv->getColumnAtIndex = impl_getColumnAtIndex;
+ epv->getRowDescription = impl_getRowDescription;
+ epv->getColumnDescription = impl_getColumnDescription;
+ epv->getRowExtentAt = impl_getRowExtentAt;
+ epv->getColumnExtentAt = impl_getColumnExtentAt;
+ epv->getRowHeader = impl_getRowHeader;
+ epv->getColumnHeader = impl_getColumnHeader;
+ epv->getSelectedRows = impl_getSelectedRows;
+ epv->getSelectedColumns = impl_getSelectedColumns;
+ epv->isRowSelected = impl_isRowSelected;
+ epv->isColumnSelected = impl_isColumnSelected;
+ epv->isSelected = impl_isSelected;
+}
+
+static void
+spi_table_init (SpiTable *table)
+{
+}
+BONOBO_TYPE_FUNC_FULL (SpiTable,
+ Accessibility_Table,
+ SPI_TYPE_BASE,
+ spi_table);