Translation updated by Ivar Smolin.
[atk.git] / atk / atktable.c
blob5cecaf60ca423ab3b51fcf071df194fd587331ca
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: a AtkObject* representing the referred to accessible
143 AtkObject*
144 atk_table_ref_at (AtkTable *table,
145 gint row,
146 gint column)
148 AtkTableIface *iface;
150 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
151 g_return_val_if_fail (row >= 0, NULL);
152 g_return_val_if_fail (column >= 0, NULL);
154 iface = ATK_TABLE_GET_IFACE (table);
156 if (iface->ref_at)
157 return (iface->ref_at) (table, row, column);
158 else
159 return NULL;
163 * atk_table_get_index_at:
164 * @table: a GObject instance that implements AtkTableIface
165 * @row: a #gint representing a row in @table
166 * @column: a #gint representing a column in @table
168 * Gets a #gint representing the index at the specified @row and @column.
170 * Returns: a #gint representing the index at specified position.
171 * The value -1 is returned if the object at row,column is not a child
172 * of table or table does not implement this interface.
174 gint
175 atk_table_get_index_at (AtkTable *table,
176 gint row,
177 gint column)
179 AtkTableIface *iface;
181 g_return_val_if_fail (ATK_IS_TABLE (table), -1);
182 g_return_val_if_fail (row >= 0, -1);
183 g_return_val_if_fail (column >= 0, -1);
185 iface = ATK_TABLE_GET_IFACE (table);
187 if (iface->get_index_at)
188 return (iface->get_index_at) (table, row, column);
189 else
190 return -1;
194 * atk_table_get_row_at_index:
195 * @table: a GObject instance that implements AtkTableInterface
196 * @index_: a #gint representing an index in @table
198 * Gets a #gint representing the row at the specified @index_.
200 * Returns: a gint representing the row at the specified index,
201 * or -1 if the table does not implement this interface
203 gint
204 atk_table_get_row_at_index (AtkTable *table,
205 gint index)
207 AtkTableIface *iface;
209 g_return_val_if_fail (ATK_IS_TABLE (table), -1);
211 iface = ATK_TABLE_GET_IFACE (table);
213 if (iface->get_row_at_index)
214 return (iface->get_row_at_index) (table, index);
215 else
216 return -1;
220 * atk_table_get_column_at_index:
221 * @table: a GObject instance that implements AtkTableInterface
222 * @index_: a #gint representing an index in @table
224 * Gets a #gint representing the column at the specified @index_.
226 * Returns: a gint representing the column at the specified index,
227 * or -1 if the table does not implement this interface
229 gint
230 atk_table_get_column_at_index (AtkTable *table,
231 gint index)
233 AtkTableIface *iface;
235 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
237 iface = ATK_TABLE_GET_IFACE (table);
239 if (iface->get_column_at_index)
240 return (iface->get_column_at_index) (table, index);
241 else
242 return -1;
246 * atk_table_get_caption:
247 * @table: a GObject instance that implements AtkTableInterface
249 * Gets the caption for the @table.
251 * Returns: a AtkObject* representing the table caption, or %NULL
252 * if value does not implement this interface.
254 AtkObject*
255 atk_table_get_caption (AtkTable *table)
257 AtkTableIface *iface;
259 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
261 iface = ATK_TABLE_GET_IFACE (table);
263 if (iface->get_caption)
264 return (iface->get_caption) (table);
265 else
266 return NULL;
270 * atk_table_get_n_columns:
271 * @table: a GObject instance that implements AtkTableIface
273 * Gets the number of columns in the table.
275 * Returns: a gint representing the number of columns, or 0
276 * if value does not implement this interface.
278 gint
279 atk_table_get_n_columns (AtkTable *table)
281 AtkTableIface *iface;
283 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
285 iface = ATK_TABLE_GET_IFACE (table);
287 if (iface->get_n_columns)
288 return (iface->get_n_columns) (table);
289 else
290 return 0;
294 * atk_table_get_column_description:
295 * @table: a GObject instance that implements AtkTableIface
296 * @column: a #gint representing a column in @table
298 * Gets the description text of the specified @column in the table
300 * Returns: a gchar* representing the column description, or %NULL
301 * if value does not implement this interface.
303 G_CONST_RETURN gchar*
304 atk_table_get_column_description (AtkTable *table,
305 gint column)
307 AtkTableIface *iface;
309 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
311 iface = ATK_TABLE_GET_IFACE (table);
313 if (iface->get_column_description)
314 return (iface->get_column_description) (table, column);
315 else
316 return NULL;
320 * atk_table_get_column_extent_at:
321 * @table: a GObject instance that implements AtkTableIface
322 * @row: a #gint representing a row in @table
323 * @column: a #gint representing a column in @table
325 * Gets the number of columns occupied by the accessible object
326 * at the specified @row and @column in the @table.
328 * Returns: a gint representing the column extent at specified position, or 0
329 * if value does not implement this interface.
331 gint
332 atk_table_get_column_extent_at (AtkTable *table,
333 gint row,
334 gint column)
336 AtkTableIface *iface;
338 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
340 iface = ATK_TABLE_GET_IFACE (table);
342 if (iface->get_column_extent_at)
343 return (iface->get_column_extent_at) (table, row, column);
344 else
345 return 0;
349 * atk_table_get_column_header:
350 * @table: a GObject instance that implements AtkTableIface
351 * @column: a #gint representing a column in the table
353 * Gets the column header of a specified column in an accessible table.
355 * Returns: a AtkObject* representing the specified column header, or
356 * %NULL if value does not implement this interface.
358 AtkObject*
359 atk_table_get_column_header (AtkTable *table, gint column)
361 AtkTableIface *iface;
363 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
365 iface = ATK_TABLE_GET_IFACE (table);
367 if (iface->get_column_header)
368 return (iface->get_column_header) (table, column);
369 else
370 return NULL;
374 * atk_table_get_n_rows:
375 * @table: a GObject instance that implements AtkTableIface
377 * Gets the number of rows in the table.
379 * Returns: a gint representing the number of rows, or 0
380 * if value does not implement this interface.
382 gint
383 atk_table_get_n_rows (AtkTable *table)
385 AtkTableIface *iface;
387 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
389 iface = ATK_TABLE_GET_IFACE (table);
391 if (iface->get_n_rows)
392 return (iface->get_n_rows) (table);
393 else
394 return 0;
398 * atk_table_get_row_description:
399 * @table: a GObject instance that implements AtkTableIface
400 * @row: a #gint representing a row in @table
402 * Gets the description text of the specified row in the table
404 * Returns: a gchar* representing the row description, or %NULL
405 * if value does not implement this interface.
407 G_CONST_RETURN gchar*
408 atk_table_get_row_description (AtkTable *table,
409 gint row)
411 AtkTableIface *iface;
413 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
415 iface = ATK_TABLE_GET_IFACE (table);
417 if (iface->get_row_description)
418 return (iface->get_row_description) (table, row);
419 else
420 return NULL;
424 * atk_table_get_row_extent_at:
425 * @table: a GObject instance that implements AtkTableIface
426 * @row: a #gint representing a row in @table
427 * @column: a #gint representing a column in @table
429 * Gets the number of rows occupied by the accessible object
430 * at a specified @row and @column in the @table.
432 * Returns: a gint representing the row extent at specified position, or 0
433 * if value does not implement this interface.
435 gint
436 atk_table_get_row_extent_at (AtkTable *table,
437 gint row,
438 gint column)
440 AtkTableIface *iface;
442 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
444 iface = ATK_TABLE_GET_IFACE (table);
446 if (iface->get_row_extent_at)
447 return (iface->get_row_extent_at) (table, row, column);
448 else
449 return 0;
453 * atk_table_get_row_header:
454 * @table: a GObject instance that implements AtkTableIface
455 * @row: a #gint representing a row in the table
457 * Gets the row header of a specified row in an accessible table.
459 * Returns: a AtkObject* representing the specified row header, or
460 * %NULL if value does not implement this interface.
462 AtkObject*
463 atk_table_get_row_header (AtkTable *table, gint row)
465 AtkTableIface *iface;
467 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
469 iface = ATK_TABLE_GET_IFACE (table);
471 if (iface->get_row_header)
472 return (iface->get_row_header) (table, row);
473 else
474 return NULL;
478 * atk_table_get_summary:
479 * @table: a GObject instance that implements AtkTableIface
481 * Gets the summary description of the table.
483 * Returns: a AtkObject* representing a summary description of the table,
484 * or zero if value does not implement this interface.
486 AtkObject*
487 atk_table_get_summary (AtkTable *table)
489 AtkTableIface *iface;
491 g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
493 iface = ATK_TABLE_GET_IFACE (table);
495 if (iface->get_summary)
496 return (iface->get_summary) (table);
497 else
498 return NULL;
502 * atk_table_get_selected_rows:
503 * @table: a GObject instance that implements AtkTableIface
504 * @selected: a #gint** that is to contain the selected row numbers
506 * Gets the selected rows of the table by initializing **selected with
507 * the selected row numbers. This array should be freed by the caller.
509 * Returns: a gint representing the number of selected rows,
510 * or zero if value does not implement this interface.
512 gint
513 atk_table_get_selected_rows (AtkTable *table, gint **selected)
515 AtkTableIface *iface;
517 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
519 iface = ATK_TABLE_GET_IFACE (table);
521 if (iface->get_selected_rows)
522 return (iface->get_selected_rows) (table, selected);
523 else
524 return 0;
528 * atk_table_get_selected_columns:
529 * @table: a GObject instance that implements AtkTableIface
530 * @selected: a #gint** that is to contain the selected columns numbers
532 * Gets the selected columns of the table by initializing **selected with
533 * the selected column numbers. This array should be freed by the caller.
535 * Returns: a gint representing the number of selected columns,
536 * or %0 if value does not implement this interface.
538 gint
539 atk_table_get_selected_columns (AtkTable *table, gint **selected)
541 AtkTableIface *iface;
543 g_return_val_if_fail (ATK_IS_TABLE (table), 0);
545 iface = ATK_TABLE_GET_IFACE (table);
547 if (iface->get_selected_columns)
548 return (iface->get_selected_columns) (table, selected);
549 else
550 return 0;
554 * atk_table_is_column_selected:
555 * @table: a GObject instance that implements AtkTableIface
556 * @column: a #gint representing a column in @table
558 * Gets a boolean value indicating whether the specified @column
559 * is selected
561 * Returns: a gboolean representing if the column is selected, or 0
562 * if value does not implement this interface.
564 gboolean
565 atk_table_is_column_selected (AtkTable *table,
566 gint column)
568 AtkTableIface *iface;
570 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
572 iface = ATK_TABLE_GET_IFACE (table);
574 if (iface->is_column_selected)
575 return (iface->is_column_selected) (table, column);
576 else
577 return FALSE;
581 * atk_table_is_row_selected:
582 * @table: a GObject instance that implements AtkTableIface
583 * @row: a #gint representing a row in @table
585 * Gets a boolean value indicating whether the specified @row
586 * is selected
588 * Returns: a gboolean representing if the row is selected, or 0
589 * if value does not implement this interface.
591 gboolean
592 atk_table_is_row_selected (AtkTable *table,
593 gint row)
595 AtkTableIface *iface;
597 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
599 iface = ATK_TABLE_GET_IFACE (table);
601 if (iface->is_row_selected)
602 return (iface->is_row_selected) (table, row);
603 else
604 return FALSE;
608 * atk_table_is_selected:
609 * @table: a GObject instance that implements AtkTableIface
610 * @row: a #gint representing a row in @table
611 * @column: a #gint representing a column in @table
613 * Gets a boolean value indicating whether the accessible object
614 * at the specified @row and @column is selected
616 * Returns: a gboolean representing if the cell is selected, or 0
617 * if value does not implement this interface.
619 gboolean
620 atk_table_is_selected (AtkTable *table,
621 gint row,
622 gint column)
624 AtkTableIface *iface;
626 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
628 iface = ATK_TABLE_GET_IFACE (table);
630 if (iface->is_selected)
631 return (iface->is_selected) (table, row, column);
632 else
633 return FALSE;
637 * atk_table_add_row_selection:
638 * @table: a GObject instance that implements AtkTableIface
639 * @row: a #gint representing a row in @table
641 * Adds the specified @row to the selection.
643 * Returns: a gboolean representing if row was successfully added to selection,
644 * or 0 if value does not implement this interface.
646 gboolean
647 atk_table_add_row_selection (AtkTable *table,
648 gint row)
650 AtkTableIface *iface;
652 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
654 iface = ATK_TABLE_GET_IFACE (table);
656 if (iface->add_row_selection)
657 return (iface->add_row_selection) (table, row);
658 else
659 return FALSE;
662 * atk_table_remove_row_selection:
663 * @table: a GObject instance that implements AtkTableIface
664 * @row: a #gint representing a row in @table
666 * Removes the specified @row from the selection.
668 * Returns: a gboolean representing if the row was successfully removed from
669 * the selection, or 0 if value does not implement this interface.
671 gboolean
672 atk_table_remove_row_selection (AtkTable *table,
673 gint row)
675 AtkTableIface *iface;
677 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
679 iface = ATK_TABLE_GET_IFACE (table);
681 if (iface->remove_row_selection)
682 return (iface->remove_row_selection) (table, row);
683 else
684 return FALSE;
687 * atk_table_add_column_selection:
688 * @table: a GObject instance that implements AtkTableIface
689 * @column: a #gint representing a column in @table
691 * Adds the specified @column to the selection.
693 * Returns: a gboolean representing if the column was successfully added to
694 * the selection, or 0 if value does not implement this interface.
696 gboolean
697 atk_table_add_column_selection (AtkTable *table,
698 gint column)
700 AtkTableIface *iface;
702 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
704 iface = ATK_TABLE_GET_IFACE (table);
706 if (iface->add_column_selection)
707 return (iface->add_column_selection) (table, column);
708 else
709 return FALSE;
712 * atk_table_remove_column_selection:
713 * @table: a GObject instance that implements AtkTableIface
714 * @column: a #gint representing a column in @table
716 * Adds the specified @column to the selection.
718 * Returns: a gboolean representing if the column was successfully removed from
719 * the selection, or 0 if value does not implement this interface.
721 gboolean
722 atk_table_remove_column_selection (AtkTable *table,
723 gint column)
725 AtkTableIface *iface;
727 g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
729 iface = ATK_TABLE_GET_IFACE (table);
731 if (iface->remove_column_selection)
732 return (iface->remove_column_selection) (table, column);
733 else
734 return FALSE;
738 * atk_table_set_caption:
739 * @table: a GObject instance that implements AtkTableIface
740 * @caption: a #AtkObject representing the caption to set for @table
742 * Sets the caption for the table.
744 void
745 atk_table_set_caption (AtkTable *table,
746 AtkObject *caption)
748 AtkTableIface *iface;
750 g_return_if_fail (ATK_IS_TABLE (table));
752 iface = ATK_TABLE_GET_IFACE (table);
754 if (iface->set_caption)
755 (iface->set_caption) (table, caption);
759 * atk_table_set_column_description:
760 * @table: a GObject instance that implements AtkTableIface
761 * @column: a #gint representing a column in @table
762 * @description: a #gchar representing the description text
763 * to set for the specified @column of the @table
765 * Sets the description text for the specified @column of the @table.
767 void
768 atk_table_set_column_description (AtkTable *table,
769 gint column,
770 const gchar *description)
772 AtkTableIface *iface;
774 g_return_if_fail (ATK_IS_TABLE (table));
776 iface = ATK_TABLE_GET_IFACE (table);
778 if (iface->set_column_description)
779 (iface->set_column_description) (table, column, description);
783 * atk_table_set_column_header:
784 * @table: a GObject instance that implements AtkTableIface
785 * @column: a #gint representing a column in @table
786 * @header: an #AtkTable
788 * Sets the specified column header to @header.
790 void
791 atk_table_set_column_header (AtkTable *table,
792 gint column,
793 AtkObject *header)
795 AtkTableIface *iface;
797 g_return_if_fail (ATK_IS_TABLE (table));
799 iface = ATK_TABLE_GET_IFACE (table);
801 if (iface->set_column_header)
802 (iface->set_column_header) (table, column, header);
806 * atk_table_set_row_description:
807 * @table: a GObject instance that implements AtkTableIface
808 * @row: a #gint representing a row in @table
809 * @description: a #gchar representing the description text
810 * to set for the specified @row of @table
812 * Sets the description text for the specified @row of @table.
814 void
815 atk_table_set_row_description (AtkTable *table,
816 gint row,
817 const gchar *description)
819 AtkTableIface *iface;
821 g_return_if_fail (ATK_IS_TABLE (table));
823 iface = ATK_TABLE_GET_IFACE (table);
825 if (iface->set_row_description)
826 (iface->set_row_description) (table, row, description);
830 * atk_table_set_row_header:
831 * @table: a GObject instance that implements AtkTableIface
832 * @row: a #gint representing a row in @table
833 * @header: an #AtkTable
835 * Sets the specified row header to @header.
837 void
838 atk_table_set_row_header (AtkTable *table,
839 gint row,
840 AtkObject *header)
842 AtkTableIface *iface;
844 g_return_if_fail (ATK_IS_TABLE (table));
846 iface = ATK_TABLE_GET_IFACE (table);
848 if (iface->set_row_header)
849 (iface->set_row_header) (table, row, header);
853 * atk_table_set_summary:
854 * @table: a GObject instance that implements AtkTableIface
855 * @accessible: an #AtkObject representing the summary description
856 * to set for @table
858 * Sets the summary description of the table.
860 void
861 atk_table_set_summary (AtkTable *table,
862 AtkObject *accessible)
864 AtkTableIface *iface;
866 g_return_if_fail (ATK_IS_TABLE (table));
868 iface = ATK_TABLE_GET_IFACE (table);
870 if (iface->set_summary)
871 (iface->set_summary) (table, accessible);