Bug 640574: gobject-introspection annotation and documentation fixes
[atk.git] / atk / atktable.c
blob729f6ecde8c2ca4dead53a73314aaaa4dceb63c0
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "atktable.h"
21 #include "atkmarshal.h"
23 enum {
24 ROW_INSERTED,
25 ROW_DELETED,
26 COLUMN_INSERTED,
27 COLUMN_DELETED,
28 ROW_REORDERED,
29 COLUMN_REORDERED,
30 MODEL_CHANGED,
31 LAST_SIGNAL
34 static void atk_table_base_init (gpointer *g_class);
36 static guint atk_table_signals[LAST_SIGNAL] = { 0 };
38 GType
39 atk_table_get_type (void)
41 static GType type = 0;
43 if (!type) {
44 GTypeInfo tinfo =
46 sizeof (AtkTableIface),
47 (GBaseInitFunc) atk_table_base_init,
48 (GBaseFinalizeFunc) NULL,
52 type = g_type_register_static (G_TYPE_INTERFACE, "AtkTable", &tinfo, 0);
55 return type;
59 static void
60 atk_table_base_init (gpointer *g_class)
62 static gboolean initialized = FALSE;
64 if (!initialized)
66 atk_table_signals[ROW_INSERTED] =
67 g_signal_new ("row_inserted",
68 ATK_TYPE_TABLE,
69 G_SIGNAL_RUN_LAST,
70 G_STRUCT_OFFSET (AtkTableIface, row_inserted),
71 (GSignalAccumulator) NULL, NULL,
72 atk_marshal_VOID__INT_INT,
73 G_TYPE_NONE,
74 2, G_TYPE_INT, G_TYPE_INT);
75 atk_table_signals[COLUMN_INSERTED] =
76 g_signal_new ("column_inserted",
77 ATK_TYPE_TABLE,
78 G_SIGNAL_RUN_LAST,
79 G_STRUCT_OFFSET (AtkTableIface, column_inserted),
80 (GSignalAccumulator) NULL, NULL,
81 atk_marshal_VOID__INT_INT,
82 G_TYPE_NONE,
83 2, G_TYPE_INT, G_TYPE_INT);
84 atk_table_signals[ROW_DELETED] =
85 g_signal_new ("row_deleted",
86 ATK_TYPE_TABLE,
87 G_SIGNAL_RUN_LAST,
88 G_STRUCT_OFFSET (AtkTableIface, row_deleted),
89 (GSignalAccumulator) NULL, NULL,
90 atk_marshal_VOID__INT_INT,
91 G_TYPE_NONE,
92 2, G_TYPE_INT, G_TYPE_INT);
93 atk_table_signals[COLUMN_DELETED] =
94 g_signal_new ("column_deleted",
95 ATK_TYPE_TABLE,
96 G_SIGNAL_RUN_LAST,
97 G_STRUCT_OFFSET (AtkTableIface, column_deleted),
98 (GSignalAccumulator) NULL, NULL,
99 atk_marshal_VOID__INT_INT,
100 G_TYPE_NONE,
101 2, G_TYPE_INT, G_TYPE_INT);
102 atk_table_signals[ROW_REORDERED] =
103 g_signal_new ("row_reordered",
104 ATK_TYPE_TABLE,
105 G_SIGNAL_RUN_LAST,
106 G_STRUCT_OFFSET (AtkTableIface, row_reordered),
107 (GSignalAccumulator) NULL, NULL,
108 g_cclosure_marshal_VOID__VOID,
109 G_TYPE_NONE,
111 atk_table_signals[COLUMN_REORDERED] =
112 g_signal_new ("column_reordered",
113 ATK_TYPE_TABLE,
114 G_SIGNAL_RUN_LAST,
115 G_STRUCT_OFFSET (AtkTableIface, column_reordered),
116 (GSignalAccumulator) NULL, NULL,
117 g_cclosure_marshal_VOID__VOID,
118 G_TYPE_NONE,
120 atk_table_signals[MODEL_CHANGED] =
121 g_signal_new ("model_changed",
122 ATK_TYPE_TABLE,
123 G_SIGNAL_RUN_LAST,
124 G_STRUCT_OFFSET (AtkTableIface, model_changed),
125 (GSignalAccumulator) NULL, NULL,
126 g_cclosure_marshal_VOID__VOID,
127 G_TYPE_NONE, 0);
129 initialized = TRUE;
134 * atk_table_ref_at:
135 * @table: a GObject instance that implements AtkTableIface
136 * @row: a #gint representing a row in @table
137 * @column: a #gint representing a column in @table
139 * Get a reference to the table cell at @row, @column.
141 * Returns: (transfer full): a AtkObject* representing the referred to
142 * accessible
144 AtkObject*
145 atk_table_ref_at (AtkTable *table,
146 gint row,
147 gint column)
149 AtkTableIface *iface;
151 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
152 g_return_val_if_fail (row >= 0, NULL);
153 g_return_val_if_fail (column >= 0, NULL);
155 iface = ATK_TABLE_GET_IFACE (table);
157 if (iface->ref_at)
158 return (iface->ref_at) (table, row, column);
159 else
160 return NULL;
164 * atk_table_get_index_at:
165 * @table: a GObject instance that implements AtkTableIface
166 * @row: a #gint representing a row in @table
167 * @column: a #gint representing a column in @table
169 * Gets a #gint representing the index at the specified @row and @column.
171 * Returns: a #gint representing the index at specified position.
172 * The value -1 is returned if the object at row,column is not a child
173 * of table or table does not implement this interface.
175 gint
176 atk_table_get_index_at (AtkTable *table,
177 gint row,
178 gint column)
180 AtkTableIface *iface;
182 g_return_val_if_fail (ATK_IS_TABLE (table), -1);
183 g_return_val_if_fail (row >= 0, -1);
184 g_return_val_if_fail (column >= 0, -1);
186 iface = ATK_TABLE_GET_IFACE (table);
188 if (iface->get_index_at)
189 return (iface->get_index_at) (table, row, column);
190 else
191 return -1;
195 * atk_table_get_row_at_index:
196 * @table: a GObject instance that implements AtkTableInterface
197 * @index_: a #gint representing an index in @table
199 * Gets a #gint representing the row at the specified @index_.
201 * Returns: a gint representing the row at the specified index,
202 * or -1 if the table does not implement this interface
204 gint
205 atk_table_get_row_at_index (AtkTable *table,
206 gint index)
208 AtkTableIface *iface;
210 g_return_val_if_fail (ATK_IS_TABLE (table), -1);
212 iface = ATK_TABLE_GET_IFACE (table);
214 if (iface->get_row_at_index)
215 return (iface->get_row_at_index) (table, index);
216 else
217 return -1;
221 * atk_table_get_column_at_index:
222 * @table: a GObject instance that implements AtkTableInterface
223 * @index_: a #gint representing an index in @table
225 * Gets a #gint representing the column at the specified @index_.
227 * Returns: a gint representing the column at the specified index,
228 * or -1 if the table does not implement this interface
230 gint
231 atk_table_get_column_at_index (AtkTable *table,
232 gint index)
234 AtkTableIface *iface;
236 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
238 iface = ATK_TABLE_GET_IFACE (table);
240 if (iface->get_column_at_index)
241 return (iface->get_column_at_index) (table, index);
242 else
243 return -1;
247 * atk_table_get_caption:
248 * @table: a GObject instance that implements AtkTableInterface
250 * Gets the caption for the @table.
252 * Returns: (transfer none): a AtkObject* representing the table caption, or
253 * %NULL if value does not implement this interface.
255 AtkObject*
256 atk_table_get_caption (AtkTable *table)
258 AtkTableIface *iface;
260 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
262 iface = ATK_TABLE_GET_IFACE (table);
264 if (iface->get_caption)
265 return (iface->get_caption) (table);
266 else
267 return NULL;
271 * atk_table_get_n_columns:
272 * @table: a GObject instance that implements AtkTableIface
274 * Gets the number of columns in the table.
276 * Returns: a gint representing the number of columns, or 0
277 * if value does not implement this interface.
279 gint
280 atk_table_get_n_columns (AtkTable *table)
282 AtkTableIface *iface;
284 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
286 iface = ATK_TABLE_GET_IFACE (table);
288 if (iface->get_n_columns)
289 return (iface->get_n_columns) (table);
290 else
291 return 0;
295 * atk_table_get_column_description:
296 * @table: a GObject instance that implements AtkTableIface
297 * @column: a #gint representing a column in @table
299 * Gets the description text of the specified @column in the table
301 * Returns: a gchar* representing the column description, or %NULL
302 * if value does not implement this interface.
304 G_CONST_RETURN gchar*
305 atk_table_get_column_description (AtkTable *table,
306 gint column)
308 AtkTableIface *iface;
310 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
312 iface = ATK_TABLE_GET_IFACE (table);
314 if (iface->get_column_description)
315 return (iface->get_column_description) (table, column);
316 else
317 return NULL;
321 * atk_table_get_column_extent_at:
322 * @table: a GObject instance that implements AtkTableIface
323 * @row: a #gint representing a row in @table
324 * @column: a #gint representing a column in @table
326 * Gets the number of columns occupied by the accessible object
327 * at the specified @row and @column in the @table.
329 * Returns: a gint representing the column extent at specified position, or 0
330 * if value does not implement this interface.
332 gint
333 atk_table_get_column_extent_at (AtkTable *table,
334 gint row,
335 gint column)
337 AtkTableIface *iface;
339 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
341 iface = ATK_TABLE_GET_IFACE (table);
343 if (iface->get_column_extent_at)
344 return (iface->get_column_extent_at) (table, row, column);
345 else
346 return 0;
350 * atk_table_get_column_header:
351 * @table: a GObject instance that implements AtkTableIface
352 * @column: a #gint representing a column in the table
354 * Gets the column header of a specified column in an accessible table.
356 * Returns: (transfer none): a AtkObject* representing the specified column
357 * header, or %NULL if value does not implement this interface.
359 AtkObject*
360 atk_table_get_column_header (AtkTable *table, gint column)
362 AtkTableIface *iface;
364 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
366 iface = ATK_TABLE_GET_IFACE (table);
368 if (iface->get_column_header)
369 return (iface->get_column_header) (table, column);
370 else
371 return NULL;
375 * atk_table_get_n_rows:
376 * @table: a GObject instance that implements AtkTableIface
378 * Gets the number of rows in the table.
380 * Returns: a gint representing the number of rows, or 0
381 * if value does not implement this interface.
383 gint
384 atk_table_get_n_rows (AtkTable *table)
386 AtkTableIface *iface;
388 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
390 iface = ATK_TABLE_GET_IFACE (table);
392 if (iface->get_n_rows)
393 return (iface->get_n_rows) (table);
394 else
395 return 0;
399 * atk_table_get_row_description:
400 * @table: a GObject instance that implements AtkTableIface
401 * @row: a #gint representing a row in @table
403 * Gets the description text of the specified row in the table
405 * Returns: a gchar* representing the row description, or %NULL
406 * if value does not implement this interface.
408 G_CONST_RETURN gchar*
409 atk_table_get_row_description (AtkTable *table,
410 gint row)
412 AtkTableIface *iface;
414 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
416 iface = ATK_TABLE_GET_IFACE (table);
418 if (iface->get_row_description)
419 return (iface->get_row_description) (table, row);
420 else
421 return NULL;
425 * atk_table_get_row_extent_at:
426 * @table: a GObject instance that implements AtkTableIface
427 * @row: a #gint representing a row in @table
428 * @column: a #gint representing a column in @table
430 * Gets the number of rows occupied by the accessible object
431 * at a specified @row and @column in the @table.
433 * Returns: a gint representing the row extent at specified position, or 0
434 * if value does not implement this interface.
436 gint
437 atk_table_get_row_extent_at (AtkTable *table,
438 gint row,
439 gint column)
441 AtkTableIface *iface;
443 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
445 iface = ATK_TABLE_GET_IFACE (table);
447 if (iface->get_row_extent_at)
448 return (iface->get_row_extent_at) (table, row, column);
449 else
450 return 0;
454 * atk_table_get_row_header:
455 * @table: a GObject instance that implements AtkTableIface
456 * @row: a #gint representing a row in the table
458 * Gets the row header of a specified row in an accessible table.
460 * Returns: (transfer none): a AtkObject* representing the specified row
461 * header, or %NULL if value does not implement this interface.
463 AtkObject*
464 atk_table_get_row_header (AtkTable *table, gint row)
466 AtkTableIface *iface;
468 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
470 iface = ATK_TABLE_GET_IFACE (table);
472 if (iface->get_row_header)
473 return (iface->get_row_header) (table, row);
474 else
475 return NULL;
479 * atk_table_get_summary:
480 * @table: a GObject instance that implements AtkTableIface
482 * Gets the summary description of the table.
484 * Returns: (transfer full): a AtkObject* representing a summary description
485 * of the table, or zero if value does not implement this interface.
487 AtkObject*
488 atk_table_get_summary (AtkTable *table)
490 AtkTableIface *iface;
492 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
494 iface = ATK_TABLE_GET_IFACE (table);
496 if (iface->get_summary)
497 return (iface->get_summary) (table);
498 else
499 return NULL;
503 * atk_table_get_selected_rows:
504 * @table: a GObject instance that implements AtkTableIface
505 * @selected: a #gint** that is to contain the selected row numbers
507 * Gets the selected rows of the table by initializing **selected with
508 * the selected row numbers. This array should be freed by the caller.
510 * Returns: a gint representing the number of selected rows,
511 * or zero if value does not implement this interface.
513 gint
514 atk_table_get_selected_rows (AtkTable *table, gint **selected)
516 AtkTableIface *iface;
518 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
520 iface = ATK_TABLE_GET_IFACE (table);
522 if (iface->get_selected_rows)
523 return (iface->get_selected_rows) (table, selected);
524 else
525 return 0;
529 * atk_table_get_selected_columns:
530 * @table: a GObject instance that implements AtkTableIface
531 * @selected: a #gint** that is to contain the selected columns numbers
533 * Gets the selected columns of the table by initializing **selected with
534 * the selected column numbers. This array should be freed by the caller.
536 * Returns: a gint representing the number of selected columns,
537 * or %0 if value does not implement this interface.
539 gint
540 atk_table_get_selected_columns (AtkTable *table, gint **selected)
542 AtkTableIface *iface;
544 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
546 iface = ATK_TABLE_GET_IFACE (table);
548 if (iface->get_selected_columns)
549 return (iface->get_selected_columns) (table, selected);
550 else
551 return 0;
555 * atk_table_is_column_selected:
556 * @table: a GObject instance that implements AtkTableIface
557 * @column: a #gint representing a column in @table
559 * Gets a boolean value indicating whether the specified @column
560 * is selected
562 * Returns: a gboolean representing if the column is selected, or 0
563 * if value does not implement this interface.
565 gboolean
566 atk_table_is_column_selected (AtkTable *table,
567 gint column)
569 AtkTableIface *iface;
571 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
573 iface = ATK_TABLE_GET_IFACE (table);
575 if (iface->is_column_selected)
576 return (iface->is_column_selected) (table, column);
577 else
578 return FALSE;
582 * atk_table_is_row_selected:
583 * @table: a GObject instance that implements AtkTableIface
584 * @row: a #gint representing a row in @table
586 * Gets a boolean value indicating whether the specified @row
587 * is selected
589 * Returns: a gboolean representing if the row is selected, or 0
590 * if value does not implement this interface.
592 gboolean
593 atk_table_is_row_selected (AtkTable *table,
594 gint row)
596 AtkTableIface *iface;
598 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
600 iface = ATK_TABLE_GET_IFACE (table);
602 if (iface->is_row_selected)
603 return (iface->is_row_selected) (table, row);
604 else
605 return FALSE;
609 * atk_table_is_selected:
610 * @table: a GObject instance that implements AtkTableIface
611 * @row: a #gint representing a row in @table
612 * @column: a #gint representing a column in @table
614 * Gets a boolean value indicating whether the accessible object
615 * at the specified @row and @column is selected
617 * Returns: a gboolean representing if the cell is selected, or 0
618 * if value does not implement this interface.
620 gboolean
621 atk_table_is_selected (AtkTable *table,
622 gint row,
623 gint column)
625 AtkTableIface *iface;
627 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
629 iface = ATK_TABLE_GET_IFACE (table);
631 if (iface->is_selected)
632 return (iface->is_selected) (table, row, column);
633 else
634 return FALSE;
638 * atk_table_add_row_selection:
639 * @table: a GObject instance that implements AtkTableIface
640 * @row: a #gint representing a row in @table
642 * Adds the specified @row to the selection.
644 * Returns: a gboolean representing if row was successfully added to selection,
645 * or 0 if value does not implement this interface.
647 gboolean
648 atk_table_add_row_selection (AtkTable *table,
649 gint row)
651 AtkTableIface *iface;
653 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
655 iface = ATK_TABLE_GET_IFACE (table);
657 if (iface->add_row_selection)
658 return (iface->add_row_selection) (table, row);
659 else
660 return FALSE;
663 * atk_table_remove_row_selection:
664 * @table: a GObject instance that implements AtkTableIface
665 * @row: a #gint representing a row in @table
667 * Removes the specified @row from the selection.
669 * Returns: a gboolean representing if the row was successfully removed from
670 * the selection, or 0 if value does not implement this interface.
672 gboolean
673 atk_table_remove_row_selection (AtkTable *table,
674 gint row)
676 AtkTableIface *iface;
678 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
680 iface = ATK_TABLE_GET_IFACE (table);
682 if (iface->remove_row_selection)
683 return (iface->remove_row_selection) (table, row);
684 else
685 return FALSE;
688 * atk_table_add_column_selection:
689 * @table: a GObject instance that implements AtkTableIface
690 * @column: a #gint representing a column in @table
692 * Adds the specified @column to the selection.
694 * Returns: a gboolean representing if the column was successfully added to
695 * the selection, or 0 if value does not implement this interface.
697 gboolean
698 atk_table_add_column_selection (AtkTable *table,
699 gint column)
701 AtkTableIface *iface;
703 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
705 iface = ATK_TABLE_GET_IFACE (table);
707 if (iface->add_column_selection)
708 return (iface->add_column_selection) (table, column);
709 else
710 return FALSE;
713 * atk_table_remove_column_selection:
714 * @table: a GObject instance that implements AtkTableIface
715 * @column: a #gint representing a column in @table
717 * Adds the specified @column to the selection.
719 * Returns: a gboolean representing if the column was successfully removed from
720 * the selection, or 0 if value does not implement this interface.
722 gboolean
723 atk_table_remove_column_selection (AtkTable *table,
724 gint column)
726 AtkTableIface *iface;
728 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
730 iface = ATK_TABLE_GET_IFACE (table);
732 if (iface->remove_column_selection)
733 return (iface->remove_column_selection) (table, column);
734 else
735 return FALSE;
739 * atk_table_set_caption:
740 * @table: a GObject instance that implements AtkTableIface
741 * @caption: a #AtkObject representing the caption to set for @table
743 * Sets the caption for the table.
745 void
746 atk_table_set_caption (AtkTable *table,
747 AtkObject *caption)
749 AtkTableIface *iface;
751 g_return_if_fail (ATK_IS_TABLE (table));
753 iface = ATK_TABLE_GET_IFACE (table);
755 if (iface->set_caption)
756 (iface->set_caption) (table, caption);
760 * atk_table_set_column_description:
761 * @table: a GObject instance that implements AtkTableIface
762 * @column: a #gint representing a column in @table
763 * @description: a #gchar representing the description text
764 * to set for the specified @column of the @table
766 * Sets the description text for the specified @column of the @table.
768 void
769 atk_table_set_column_description (AtkTable *table,
770 gint column,
771 const gchar *description)
773 AtkTableIface *iface;
775 g_return_if_fail (ATK_IS_TABLE (table));
777 iface = ATK_TABLE_GET_IFACE (table);
779 if (iface->set_column_description)
780 (iface->set_column_description) (table, column, description);
784 * atk_table_set_column_header:
785 * @table: a GObject instance that implements AtkTableIface
786 * @column: a #gint representing a column in @table
787 * @header: an #AtkTable
789 * Sets the specified column header to @header.
791 void
792 atk_table_set_column_header (AtkTable *table,
793 gint column,
794 AtkObject *header)
796 AtkTableIface *iface;
798 g_return_if_fail (ATK_IS_TABLE (table));
800 iface = ATK_TABLE_GET_IFACE (table);
802 if (iface->set_column_header)
803 (iface->set_column_header) (table, column, header);
807 * atk_table_set_row_description:
808 * @table: a GObject instance that implements AtkTableIface
809 * @row: a #gint representing a row in @table
810 * @description: a #gchar representing the description text
811 * to set for the specified @row of @table
813 * Sets the description text for the specified @row of @table.
815 void
816 atk_table_set_row_description (AtkTable *table,
817 gint row,
818 const gchar *description)
820 AtkTableIface *iface;
822 g_return_if_fail (ATK_IS_TABLE (table));
824 iface = ATK_TABLE_GET_IFACE (table);
826 if (iface->set_row_description)
827 (iface->set_row_description) (table, row, description);
831 * atk_table_set_row_header:
832 * @table: a GObject instance that implements AtkTableIface
833 * @row: a #gint representing a row in @table
834 * @header: an #AtkTable
836 * Sets the specified row header to @header.
838 void
839 atk_table_set_row_header (AtkTable *table,
840 gint row,
841 AtkObject *header)
843 AtkTableIface *iface;
845 g_return_if_fail (ATK_IS_TABLE (table));
847 iface = ATK_TABLE_GET_IFACE (table);
849 if (iface->set_row_header)
850 (iface->set_row_header) (table, row, header);
854 * atk_table_set_summary:
855 * @table: a GObject instance that implements AtkTableIface
856 * @accessible: an #AtkObject representing the summary description
857 * to set for @table
859 * Sets the summary description of the table.
861 void
862 atk_table_set_summary (AtkTable *table,
863 AtkObject *accessible)
865 AtkTableIface *iface;
867 g_return_if_fail (ATK_IS_TABLE (table));
869 iface = ATK_TABLE_GET_IFACE (table);
871 if (iface->set_summary)
872 (iface->set_summary) (table, accessible);