Do not dist gir_DATA
[platform/upstream/atk.git] / atk / atktable.c
index fc37ebc..5cecaf6 100755 (executable)
@@ -27,30 +27,16 @@ enum {
   COLUMN_DELETED,
   ROW_REORDERED,
   COLUMN_REORDERED,
+  MODEL_CHANGED,
   LAST_SIGNAL
 };
 
-struct _AtkTableIfaceClass
-{
-  GObjectClass parent;
-};
-
-typedef struct _AtkTableIfaceClass AtkTableIfaceClass;
-
 static void  atk_table_base_init (gpointer *g_class);
 
-static gint  atk_table_real_get_index_at        (AtkTable *table,
-                                                 gint     row,
-                                                 gint     column);
-static gint  atk_table_real_get_column_at_index (AtkTable *table,
-                                                 gint     index);
-static gint  atk_table_real_get_row_at_index    (AtkTable *table,
-                                                 gint     index);
-
 static guint atk_table_signals[LAST_SIGNAL] = { 0 };
 
 GType
-atk_table_get_type ()
+atk_table_get_type (void)
 {
   static GType type = 0;
   
@@ -131,6 +117,15 @@ atk_table_base_init (gpointer *g_class)
                      g_cclosure_marshal_VOID__VOID,
                      G_TYPE_NONE,
                      0);
+      atk_table_signals[MODEL_CHANGED] =
+        g_signal_new ("model_changed",
+                      ATK_TYPE_TABLE,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (AtkTableIface, model_changed),
+                      (GSignalAccumulator) NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0);
+
       initialized = TRUE;
     }
 }
@@ -153,6 +148,8 @@ atk_table_ref_at (AtkTable *table,
   AtkTableIface *iface;
 
   g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
+  g_return_val_if_fail (row >= 0, NULL);
+  g_return_val_if_fail (column >= 0, NULL);
 
   iface = ATK_TABLE_GET_IFACE (table);
 
@@ -168,15 +165,11 @@ atk_table_ref_at (AtkTable *table,
  * @row: a #gint representing a row in @table
  * @column: a #gint representing a column in @table
  *
- * Gets a #gint representing the index at the specified @row and @column,
- * or 0 if value does not implement this interface.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
+ * Gets a #gint representing the index at the specified @row and @column.
  *
- * Returns: a #gint representing the index at specified position, or 0
- * if value does not implement this interface.
+ * Returns: a #gint representing the index at specified position.
+ * The value -1 is returned if the object at row,column is not a child
+ * of table or table does not implement this interface.
  **/
 gint
 atk_table_get_index_at (AtkTable *table,
@@ -185,32 +178,27 @@ atk_table_get_index_at (AtkTable *table,
 {
   AtkTableIface *iface;
 
-  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
-  g_return_val_if_fail (row >= 0, 0);
-  g_return_val_if_fail (column >= 0, 0);
+  g_return_val_if_fail (ATK_IS_TABLE (table), -1);
+  g_return_val_if_fail (row >= 0, -1);
+  g_return_val_if_fail (column >= 0, -1);
 
   iface = ATK_TABLE_GET_IFACE (table);
 
   if (iface->get_index_at)
     return (iface->get_index_at) (table, row, column);
   else
-    return atk_table_real_get_index_at (table, row, column);
+    return -1;
 }
 
 /**
  * atk_table_get_row_at_index:
  * @table: a GObject instance that implements AtkTableInterface
- * @index: a #gint representing an index in @table
+ * @index_: a #gint representing an index in @table
  *
- * Gets a #gint representing the row at the specified @index, or 0
- * if the value does not implement this interface
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
+ * Gets a #gint representing the row at the specified @index_.
  *
- * Returns: a gint representing the row at the specified  index, or 0
- * if value does not implement this interface.
+ * Returns: a gint representing the row at the specified index,
+ * or -1 if the table does not implement this interface
  **/
 gint
 atk_table_get_row_at_index (AtkTable *table,
@@ -218,30 +206,25 @@ atk_table_get_row_at_index (AtkTable *table,
 {
   AtkTableIface *iface;
 
-  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
+  g_return_val_if_fail (ATK_IS_TABLE (table), -1);
 
   iface = ATK_TABLE_GET_IFACE (table);
 
   if (iface->get_row_at_index)
     return (iface->get_row_at_index) (table, index);
   else
-    return atk_table_real_get_row_at_index (table, index);
+    return -1;
 }
 
 /**
  * atk_table_get_column_at_index:
  * @table: a GObject instance that implements AtkTableInterface
- * @index: a #gint representing an index in @table
+ * @index_: a #gint representing an index in @table
  *
- * Gets a #gint representing the column at the specified @index, or 0
- * if the value does not implement this interface
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
+ * Gets a #gint representing the column at the specified @index_. 
  *
- * Returns: a gint representing the column at the specified  index, or 0
- * if value does not implement this interface.
+ * Returns: a gint representing the column at the specified index,
+ * or -1 if the table does not implement this interface
  **/
 gint
 atk_table_get_column_at_index (AtkTable *table,
@@ -256,7 +239,7 @@ atk_table_get_column_at_index (AtkTable *table,
   if (iface->get_column_at_index)
     return (iface->get_column_at_index) (table, index);
   else
-    return atk_table_real_get_column_at_index (table, index);
+    return -1;
 }
 
 /**
@@ -264,15 +247,11 @@ atk_table_get_column_at_index (AtkTable *table,
  * @table: a GObject instance that implements AtkTableInterface
  *
  * Gets the caption for the @table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
- * Returns: a gchar* representing the table caption, or %NULL
+ * Returns: a AtkObject* representing the table caption, or %NULL
  * if value does not implement this interface.
  **/
-G_CONST_RETURN gchar*
+AtkObject*
 atk_table_get_caption (AtkTable *table)
 {
   AtkTableIface *iface;
@@ -292,10 +271,6 @@ atk_table_get_caption (AtkTable *table)
  * @table: a GObject instance that implements AtkTableIface
  *
  * Gets the number of columns in the table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gint representing the number of columns, or 0
  * if value does not implement this interface.
@@ -321,10 +296,6 @@ atk_table_get_n_columns (AtkTable *table)
  * @column: a #gint representing a column in @table
  *
  * Gets the description text of the specified @column in the table
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gchar* representing the column description, or %NULL
  * if value does not implement this interface.
@@ -353,10 +324,6 @@ atk_table_get_column_description (AtkTable *table,
  *
  * Gets the number of columns occupied by the accessible object
  * at the specified @row and @column in the @table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gint representing the column extent at specified position, or 0
  * if value does not implement this interface.
@@ -384,10 +351,6 @@ atk_table_get_column_extent_at (AtkTable *table,
  * @column: a #gint representing a column in the table
  *
  * Gets the column header of a specified column in an accessible table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a AtkObject* representing the specified column header, or
  * %NULL if value does not implement this interface.
@@ -412,10 +375,6 @@ atk_table_get_column_header (AtkTable *table, gint column)
  * @table: a GObject instance that implements AtkTableIface
  *
  * Gets the number of rows in the table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gint representing the number of rows, or 0
  * if value does not implement this interface.
@@ -441,10 +400,6 @@ atk_table_get_n_rows (AtkTable *table)
  * @row: a #gint representing a row in @table
  *
  * Gets the description text of the specified row in the table
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gchar* representing the row description, or %NULL
  * if value does not implement this interface.
@@ -473,10 +428,6 @@ atk_table_get_row_description (AtkTable *table,
  *
  * Gets the number of rows occupied by the accessible object
  * at a specified @row and @column in the @table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gint representing the row extent at specified position, or 0
  * if value does not implement this interface.
@@ -504,10 +455,6 @@ atk_table_get_row_extent_at (AtkTable *table,
  * @row: a #gint representing a row in the table
  *
  * Gets the row header of a specified row in an accessible table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a AtkObject* representing the specified row header, or
  * %NULL if value does not implement this interface.
@@ -532,10 +479,6 @@ atk_table_get_row_header (AtkTable *table, gint row)
  * @table: a GObject instance that implements AtkTableIface
  *
  * Gets the summary description of the table.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a AtkObject* representing a summary description of the table,
  * or zero if value does not implement this interface.
@@ -562,10 +505,6 @@ atk_table_get_summary (AtkTable *table)
  *
  * Gets the selected rows of the table by initializing **selected with 
  * the selected row numbers. This array should be freed by the caller.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gint representing the number of selected rows,
  * or zero if value does not implement this interface.
@@ -592,10 +531,6 @@ atk_table_get_selected_rows (AtkTable *table, gint **selected)
  *
  * Gets the selected columns of the table by initializing **selected with 
  * the selected column numbers. This array should be freed by the caller.
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gint representing the number of selected columns,
  * or %0 if value does not implement this interface.
@@ -622,10 +557,6 @@ atk_table_get_selected_columns (AtkTable *table, gint **selected)
  *
  * Gets a boolean value indicating whether the specified @column
  * is selected
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if the column is selected, or 0
  * if value does not implement this interface.
@@ -653,10 +584,6 @@ atk_table_is_column_selected (AtkTable *table,
  *
  * Gets a boolean value indicating whether the specified @row
  * is selected
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if the row is selected, or 0
  * if value does not implement this interface.
@@ -685,10 +612,6 @@ atk_table_is_row_selected (AtkTable *table,
  *
  * Gets a boolean value indicating whether the accessible object
  * at the specified @row and @column is selected
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if the cell is selected, or 0
  * if value does not implement this interface.
@@ -716,10 +639,6 @@ atk_table_is_selected (AtkTable *table,
  * @row: a #gint representing a row in @table
  *
  * Adds the specified @row to the selection. 
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if row was successfully added to selection,
  * or 0 if value does not implement this interface.
@@ -745,10 +664,6 @@ atk_table_add_row_selection (AtkTable *table,
  * @row: a #gint representing a row in @table
  *
  * Removes the specified @row from the selection. 
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if the row was successfully removed from
  * the selection, or 0 if value does not implement this interface.
@@ -774,10 +689,6 @@ atk_table_remove_row_selection (AtkTable *table,
  * @column: a #gint representing a column in @table
  *
  * Adds the specified @column to the selection. 
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if the column was successfully added to 
  * the selection, or 0 if value does not implement this interface.
@@ -803,10 +714,6 @@ atk_table_add_column_selection (AtkTable *table,
  * @column: a #gint representing a column in @table
  *
  * Adds the specified @column to the selection. 
- * Note: callers should not rely on %NULL or on a zero value for
- * indication of whether AtkSelectionIface is implemented, they should
- * use type checking/interface checking macros or the
- * atk_get_accessible_table() convenience method.
  *
  * Returns: a gboolean representing if the column was successfully removed from
  * the selection, or 0 if value does not implement this interface.
@@ -830,13 +737,13 @@ atk_table_remove_column_selection (AtkTable *table,
 /**
  * atk_table_set_caption:
  * @table: a GObject instance that implements AtkTableIface
- * @caption: a #gchar representing the caption to set for @table
+ * @caption: a #AtkObject representing the caption to set for @table
  *
  * Sets the caption for the table.
  **/
 void
 atk_table_set_caption (AtkTable       *table,
-                       const gchar    *caption)
+                       AtkObject      *caption)
 {
   AtkTableIface *iface;
 
@@ -963,47 +870,3 @@ atk_table_set_summary (AtkTable       *table,
   if (iface->set_summary)
     (iface->set_summary) (table, accessible);
 }
-
-static gint
-atk_table_real_get_index_at (AtkTable *table,
-                             gint     row,
-                             gint     column)
-{
-  gint n_cols, n_rows;
-
-  n_cols = atk_table_get_n_columns (table);
-  n_rows = atk_table_get_n_rows (table);
-
-  g_return_val_if_fail (row < n_rows, 0);
-  g_return_val_if_fail (column < n_cols, 0);
-
-  return row * n_cols + column;
-}
-
-static gint
-atk_table_real_get_column_at_index (AtkTable *table,
-                                    gint     index)
-{
-  gint n_cols;
-
-  n_cols = atk_table_get_n_columns (table);
-
-  if (n_cols == 0)
-    return 0;
-  else
-    return (gint) (index % n_cols);
-}
-
-static gint
-atk_table_real_get_row_at_index (AtkTable *table,
-                                 gint     index)
-{
-  gint n_cols;
-
-  n_cols = atk_table_get_n_columns (table);
-
-  if (n_cols == 0)
-    return 0;
-  else
-    return (gint) (index / n_cols);
-}