1
/* ATK -  Accessibility Toolkit
2
 * Copyright 2001 Sun Microsystems Inc.
3
 *
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.
8
 *
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.
13
 *
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.
18
 */
19

            
20
#include "config.h"
21

            
22
#include "atkmarshal.h"
23
#include "atktable.h"
24

            
25
/**
26
 * AtkTable:
27
 *
28
 * The ATK interface implemented for UI components which contain tabular or row/column information.
29
 *
30
 * #AtkTable should be implemented by components which present
31
 * elements ordered via rows and columns.  It may also be used to
32
 * present tree-structured information if the nodes of the trees can
33
 * be said to contain multiple "columns".  Individual elements of an
34
 * #AtkTable are typically referred to as "cells". Those cells should
35
 * implement the interface #AtkTableCell, but #Atk doesn't require
36
 * them to be direct children of the current #AtkTable. They can be
37
 * grand-children, grand-grand-children etc. #AtkTable provides the
38
 * API needed to get a individual cell based on the row and column
39
 * numbers.
40
 *
41
 * Children of #AtkTable are frequently "lightweight" objects, that
42
 * is, they may not have backing widgets in the host UI toolkit.  They
43
 * are therefore often transient.
44
 *
45
 * Since tables are often very complex, #AtkTable includes provision
46
 * for offering simplified summary information, as well as row and
47
 * column headers and captions.  Headers and captions are #AtkObjects
48
 * which may implement other interfaces (#AtkText, #AtkImage, etc.) as
49
 * appropriate.  #AtkTable summaries may themselves be (simplified)
50
 * #AtkTables, etc.
51
 *
52
 * Note for implementors: in the past, #AtkTable required that all the
53
 * cells should be direct children of #AtkTable, and provided some
54
 * index based methods to request the cells. The practice showed that
55
 * that forcing made #AtkTable implementation complex, and hard to
56
 * expose other kind of children, like rows or captions. Right now,
57
 * index-based methods are deprecated.
58
 */
59

            
60
enum
61
{
62
  ROW_INSERTED,
63
  ROW_DELETED,
64
  COLUMN_INSERTED,
65
  COLUMN_DELETED,
66
  ROW_REORDERED,
67
  COLUMN_REORDERED,
68
  MODEL_CHANGED,
69
  LAST_SIGNAL
70
};
71

            
72
static void atk_table_base_init (gpointer *g_class);
73

            
74
static guint atk_table_signals[LAST_SIGNAL] = { 0 };
75

            
76
GType
77
3081
atk_table_get_type (void)
78
{
79
  static GType type = 0;
80

            
81
3081
  if (!type)
82
    {
83
161
      GTypeInfo tinfo = {
84
        sizeof (AtkTableIface),
85
        (GBaseInitFunc) atk_table_base_init,
86
        (GBaseFinalizeFunc) NULL,
87

            
88
      };
89

            
90
161
      type = g_type_register_static (G_TYPE_INTERFACE, "AtkTable", &tinfo, 0);
91
    }
92

            
93
3081
  return type;
94
}
95

            
96
static void
97
354
atk_table_base_init (gpointer *g_class)
98
{
99
  static gboolean initialized = FALSE;
100

            
101
354
  if (!initialized)
102
    {
103
      /**
104
       * AtkTable::row-inserted:
105
       * @atktable: the object which received the signal.
106
       * @arg1: The index of the first row inserted.
107
       * @arg2: The number of rows inserted.
108
       *
109
       * The "row-inserted" signal is emitted by an object which
110
       * implements the AtkTable interface when a row is inserted.
111
       */
112
161
      atk_table_signals[ROW_INSERTED] =
113
161
          g_signal_new ("row_inserted",
114
                        ATK_TYPE_TABLE,
115
                        G_SIGNAL_RUN_LAST,
116
                        G_STRUCT_OFFSET (AtkTableIface, row_inserted),
117
                        (GSignalAccumulator) NULL, NULL,
118
                        atk_marshal_VOID__INT_INT,
119
                        G_TYPE_NONE,
120
                        2, G_TYPE_INT, G_TYPE_INT);
121
      /**
122
       * AtkTable::column-inserted:
123
       * @atktable: the object which received the signal.
124
       * @arg1: The index of the column inserted.
125
       * @arg2: The number of colums inserted.
126
       *
127
       * The "column-inserted" signal is emitted by an object which
128
       * implements the AtkTable interface when a column is inserted.
129
       */
130
161
      atk_table_signals[COLUMN_INSERTED] =
131
161
          g_signal_new ("column_inserted",
132
                        ATK_TYPE_TABLE,
133
                        G_SIGNAL_RUN_LAST,
134
                        G_STRUCT_OFFSET (AtkTableIface, column_inserted),
135
                        (GSignalAccumulator) NULL, NULL,
136
                        atk_marshal_VOID__INT_INT,
137
                        G_TYPE_NONE,
138
                        2, G_TYPE_INT, G_TYPE_INT);
139
      /**
140
       * AtkTable::row-deleted:
141
       * @atktable: the object which received the signal.
142
       * @arg1: The index of the first row deleted.
143
       * @arg2: The number of rows deleted.
144
       *
145
       * The "row-deleted" signal is emitted by an object which
146
       * implements the AtkTable interface when a row is deleted.
147
       */
148
161
      atk_table_signals[ROW_DELETED] =
149
161
          g_signal_new ("row_deleted",
150
                        ATK_TYPE_TABLE,
151
                        G_SIGNAL_RUN_LAST,
152
                        G_STRUCT_OFFSET (AtkTableIface, row_deleted),
153
                        (GSignalAccumulator) NULL, NULL,
154
                        atk_marshal_VOID__INT_INT,
155
                        G_TYPE_NONE,
156
                        2, G_TYPE_INT, G_TYPE_INT);
157
      /**
158
       * AtkTable::column-deleted:
159
       * @atktable: the object which received the signal.
160
       * @arg1: The index of the first column deleted.
161
       * @arg2: The number of columns deleted.
162
       *
163
       * The "column-deleted" signal is emitted by an object which
164
       * implements the AtkTable interface when a column is deleted.
165
       */
166
161
      atk_table_signals[COLUMN_DELETED] =
167
161
          g_signal_new ("column_deleted",
168
                        ATK_TYPE_TABLE,
169
                        G_SIGNAL_RUN_LAST,
170
                        G_STRUCT_OFFSET (AtkTableIface, column_deleted),
171
                        (GSignalAccumulator) NULL, NULL,
172
                        atk_marshal_VOID__INT_INT,
173
                        G_TYPE_NONE,
174
                        2, G_TYPE_INT, G_TYPE_INT);
175
      /**
176
       * AtkTable::row-reordered:
177
       * @atktable: the object which received the signal.
178
       *
179
       * The "row-reordered" signal is emitted by an object which
180
       * implements the AtkTable interface when the rows are
181
       * reordered.
182
       */
183
161
      atk_table_signals[ROW_REORDERED] =
184
161
          g_signal_new ("row_reordered",
185
                        ATK_TYPE_TABLE,
186
                        G_SIGNAL_RUN_LAST,
187
                        G_STRUCT_OFFSET (AtkTableIface, row_reordered),
188
                        (GSignalAccumulator) NULL, NULL,
189
                        g_cclosure_marshal_VOID__VOID,
190
                        G_TYPE_NONE,
191
                        0);
192
      /**
193
       * AtkTable::column-reordered:
194
       * @atktable: the object which received the signal.
195
       *
196
       * The "column-reordered" signal is emitted by an object which
197
       * implements the AtkTable interface when the columns are
198
       * reordered.
199
       */
200
161
      atk_table_signals[COLUMN_REORDERED] =
201
161
          g_signal_new ("column_reordered",
202
                        ATK_TYPE_TABLE,
203
                        G_SIGNAL_RUN_LAST,
204
                        G_STRUCT_OFFSET (AtkTableIface, column_reordered),
205
                        (GSignalAccumulator) NULL, NULL,
206
                        g_cclosure_marshal_VOID__VOID,
207
                        G_TYPE_NONE,
208
                        0);
209

            
210
      /**
211
       * AtkTable::model-changed:
212
       * @atktable: the object which received the signal.
213
       *
214
       * The "model-changed" signal is emitted by an object which
215
       * implements the AtkTable interface when the model displayed by
216
       * the table changes.
217
       */
218
161
      atk_table_signals[MODEL_CHANGED] =
219
161
          g_signal_new ("model_changed",
220
                        ATK_TYPE_TABLE,
221
                        G_SIGNAL_RUN_LAST,
222
                        G_STRUCT_OFFSET (AtkTableIface, model_changed),
223
                        (GSignalAccumulator) NULL, NULL,
224
                        g_cclosure_marshal_VOID__VOID,
225
                        G_TYPE_NONE, 0);
226

            
227
161
      initialized = TRUE;
228
    }
229
354
}
230

            
231
/**
232
 * atk_table_ref_at:
233
 * @table: a GObject instance that implements AtkTableIface
234
 * @row: a #gint representing a row in @table
235
 * @column: a #gint representing a column in @table
236
 *
237
 * Get a reference to the table cell at @row, @column. This cell
238
 * should implement the interface #AtkTableCell
239
 *
240
 * Returns: (transfer full): an #AtkObject representing the referred
241
 * to accessible
242
 **/
243
AtkObject *
244
6
atk_table_ref_at (AtkTable *table,
245
                  gint row,
246
                  gint column)
247
{
248
  AtkTableIface *iface;
249

            
250
6
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
251
6
  g_return_val_if_fail (row >= 0, NULL);
252
6
  g_return_val_if_fail (column >= 0, NULL);
253

            
254
6
  iface = ATK_TABLE_GET_IFACE (table);
255

            
256
6
  if (iface->ref_at)
257
6
    return (iface->ref_at) (table, row, column);
258
  else
259
    return NULL;
260
}
261

            
262
/**
263
 * atk_table_get_index_at:
264
 * @table: a GObject instance that implements AtkTableIface
265
 * @row: a #gint representing a row in @table
266
 * @column: a #gint representing a column in @table
267
 *
268
 * Gets a #gint representing the index at the specified @row and
269
 * @column.
270
 *
271
 * Deprecated: Since 2.12. Use atk_table_ref_at() in order to get the
272
 * accessible that represents the cell at (@row, @column)
273
 *
274
 * Returns: a #gint representing the index at specified position.
275
 * The value -1 is returned if the object at row,column is not a child
276
 * of table or table does not implement this interface.
277
 **/
278
gint
279
3
atk_table_get_index_at (AtkTable *table,
280
                        gint row,
281
                        gint column)
282
{
283
  AtkTableIface *iface;
284

            
285
3
  g_return_val_if_fail (ATK_IS_TABLE (table), -1);
286
3
  g_return_val_if_fail (row >= 0, -1);
287
3
  g_return_val_if_fail (column >= 0, -1);
288

            
289
3
  iface = ATK_TABLE_GET_IFACE (table);
290

            
291
3
  if (iface->get_index_at)
292
3
    return (iface->get_index_at) (table, row, column);
293
  else
294
    return -1;
295
}
296

            
297
/**
298
 * atk_table_get_row_at_index:
299
 * @table: a GObject instance that implements AtkTableInterface
300
 * @index_: a #gint representing an index in @table
301
 *
302
 * Gets a #gint representing the row at the specified @index_.
303
 *
304
 * Deprecated: since 2.12.
305
 *
306
 * Returns: a gint representing the row at the specified index,
307
 * or -1 if the table does not implement this method.
308
 **/
309
gint
310
5
atk_table_get_row_at_index (AtkTable *table,
311
                            gint index)
312
{
313
  AtkTableIface *iface;
314

            
315
5
  g_return_val_if_fail (ATK_IS_TABLE (table), -1);
316

            
317
5
  iface = ATK_TABLE_GET_IFACE (table);
318

            
319
5
  if (iface->get_row_at_index)
320
5
    return (iface->get_row_at_index) (table, index);
321
  else
322
    return -1;
323
}
324

            
325
/**
326
 * atk_table_get_column_at_index:
327
 * @table: a GObject instance that implements AtkTableInterface
328
 * @index_: a #gint representing an index in @table
329
 *
330
 * Gets a #gint representing the column at the specified @index_.
331
 *
332
 * Deprecated: Since 2.12.
333
 *
334
 * Returns: a gint representing the column at the specified index,
335
 * or -1 if the table does not implement this method.
336
 **/
337
gint
338
4
atk_table_get_column_at_index (AtkTable *table,
339
                               gint index)
340
{
341
  AtkTableIface *iface;
342

            
343
4
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
344

            
345
4
  iface = ATK_TABLE_GET_IFACE (table);
346

            
347
4
  if (iface->get_column_at_index)
348
4
    return (iface->get_column_at_index) (table, index);
349
  else
350
    return -1;
351
}
352

            
353
/**
354
 * atk_table_get_caption:
355
 * @table: a GObject instance that implements AtkTableInterface
356
 *
357
 * Gets the caption for the @table.
358
 *
359
 * Returns: (nullable) (transfer none): a AtkObject* representing the
360
 * table caption, or %NULL if value does not implement this interface.
361
 **/
362
AtkObject *
363
1
atk_table_get_caption (AtkTable *table)
364
{
365
  AtkTableIface *iface;
366

            
367
1
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
368

            
369
1
  iface = ATK_TABLE_GET_IFACE (table);
370

            
371
1
  if (iface->get_caption)
372
1
    return (iface->get_caption) (table);
373
  else
374
    return NULL;
375
}
376

            
377
/**
378
 * atk_table_get_n_columns:
379
 * @table: a GObject instance that implements AtkTableIface
380
 *
381
 * Gets the number of columns in the table.
382
 *
383
 * Returns: a gint representing the number of columns, or 0
384
 * if value does not implement this interface.
385
 **/
386
gint
387
10
atk_table_get_n_columns (AtkTable *table)
388
{
389
  AtkTableIface *iface;
390

            
391
10
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
392

            
393
10
  iface = ATK_TABLE_GET_IFACE (table);
394

            
395
10
  if (iface->get_n_columns)
396
10
    return (iface->get_n_columns) (table);
397
  else
398
    return 0;
399
}
400

            
401
/**
402
 * atk_table_get_column_description:
403
 * @table: a GObject instance that implements AtkTableIface
404
 * @column: a #gint representing a column in @table
405
 *
406
 * Gets the description text of the specified @column in the table
407
 *
408
 * Returns: a gchar* representing the column description, or %NULL
409
 * if value does not implement this interface.
410
 **/
411
const gchar *
412
2
atk_table_get_column_description (AtkTable *table,
413
                                  gint column)
414
{
415
  AtkTableIface *iface;
416

            
417
2
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
418

            
419
2
  iface = ATK_TABLE_GET_IFACE (table);
420

            
421
2
  if (iface->get_column_description)
422
2
    return (iface->get_column_description) (table, column);
423
  else
424
    return NULL;
425
}
426

            
427
/**
428
 * atk_table_get_column_extent_at:
429
 * @table: a GObject instance that implements AtkTableIface
430
 * @row: a #gint representing a row in @table
431
 * @column: a #gint representing a column in @table
432
 *
433
 * Gets the number of columns occupied by the accessible object
434
 * at the specified @row and @column in the @table.
435
 *
436
 * Returns: a gint representing the column extent at specified position, or 0
437
 * if value does not implement this interface.
438
 **/
439
gint
440
2
atk_table_get_column_extent_at (AtkTable *table,
441
                                gint row,
442
                                gint column)
443
{
444
  AtkTableIface *iface;
445

            
446
2
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
447

            
448
2
  iface = ATK_TABLE_GET_IFACE (table);
449

            
450
2
  if (iface->get_column_extent_at)
451
2
    return (iface->get_column_extent_at) (table, row, column);
452
  else
453
    return 0;
454
}
455

            
456
/**
457
 * atk_table_get_column_header:
458
 * @table: a GObject instance that implements AtkTableIface
459
 * @column: a #gint representing a column in the table
460
 *
461
 * Gets the column header of a specified column in an accessible table.
462
 *
463
 * Returns: (nullable) (transfer none): a AtkObject* representing the
464
 * specified column header, or %NULL if value does not implement this
465
 * interface.
466
 **/
467
AtkObject *
468
3
atk_table_get_column_header (AtkTable *table, gint column)
469
{
470
  AtkTableIface *iface;
471

            
472
3
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
473

            
474
3
  iface = ATK_TABLE_GET_IFACE (table);
475

            
476
3
  if (iface->get_column_header)
477
3
    return (iface->get_column_header) (table, column);
478
  else
479
    return NULL;
480
}
481

            
482
/**
483
 * atk_table_get_n_rows:
484
 * @table: a GObject instance that implements AtkTableIface
485
 *
486
 * Gets the number of rows in the table.
487
 *
488
 * Returns: a gint representing the number of rows, or 0
489
 * if value does not implement this interface.
490
 **/
491
gint
492
10
atk_table_get_n_rows (AtkTable *table)
493
{
494
  AtkTableIface *iface;
495

            
496
10
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
497

            
498
10
  iface = ATK_TABLE_GET_IFACE (table);
499

            
500
10
  if (iface->get_n_rows)
501
10
    return (iface->get_n_rows) (table);
502
  else
503
    return 0;
504
}
505

            
506
/**
507
 * atk_table_get_row_description:
508
 * @table: a GObject instance that implements AtkTableIface
509
 * @row: a #gint representing a row in @table
510
 *
511
 * Gets the description text of the specified row in the table
512
 *
513
 * Returns: (nullable): a gchar* representing the row description, or
514
 * %NULL if value does not implement this interface.
515
 **/
516
const gchar *
517
2
atk_table_get_row_description (AtkTable *table,
518
                               gint row)
519
{
520
  AtkTableIface *iface;
521

            
522
2
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
523

            
524
2
  iface = ATK_TABLE_GET_IFACE (table);
525

            
526
2
  if (iface->get_row_description)
527
2
    return (iface->get_row_description) (table, row);
528
  else
529
    return NULL;
530
}
531

            
532
/**
533
 * atk_table_get_row_extent_at:
534
 * @table: a GObject instance that implements AtkTableIface
535
 * @row: a #gint representing a row in @table
536
 * @column: a #gint representing a column in @table
537
 *
538
 * Gets the number of rows occupied by the accessible object
539
 * at a specified @row and @column in the @table.
540
 *
541
 * Returns: a gint representing the row extent at specified position, or 0
542
 * if value does not implement this interface.
543
 **/
544
gint
545
2
atk_table_get_row_extent_at (AtkTable *table,
546
                             gint row,
547
                             gint column)
548
{
549
  AtkTableIface *iface;
550

            
551
2
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
552

            
553
2
  iface = ATK_TABLE_GET_IFACE (table);
554

            
555
2
  if (iface->get_row_extent_at)
556
2
    return (iface->get_row_extent_at) (table, row, column);
557
  else
558
    return 0;
559
}
560

            
561
/**
562
 * atk_table_get_row_header:
563
 * @table: a GObject instance that implements AtkTableIface
564
 * @row: a #gint representing a row in the table
565
 *
566
 * Gets the row header of a specified row in an accessible table.
567
 *
568
 * Returns: (nullable) (transfer none): a AtkObject* representing the
569
 * specified row header, or %NULL if value does not implement this
570
 * interface.
571
 **/
572
AtkObject *
573
2
atk_table_get_row_header (AtkTable *table, gint row)
574
{
575
  AtkTableIface *iface;
576

            
577
2
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
578

            
579
2
  iface = ATK_TABLE_GET_IFACE (table);
580

            
581
2
  if (iface->get_row_header)
582
2
    return (iface->get_row_header) (table, row);
583
  else
584
    return NULL;
585
}
586

            
587
/**
588
 * atk_table_get_summary:
589
 * @table: a GObject instance that implements AtkTableIface
590
 *
591
 * Gets the summary description of the table.
592
 *
593
 * Returns: (transfer full): a AtkObject* representing a summary description
594
 * of the table, or zero if value does not implement this interface.
595
 **/
596
AtkObject *
597
1
atk_table_get_summary (AtkTable *table)
598
{
599
  AtkTableIface *iface;
600

            
601
1
  g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
602

            
603
1
  iface = ATK_TABLE_GET_IFACE (table);
604

            
605
1
  if (iface->get_summary)
606
1
    return (iface->get_summary) (table);
607
  else
608
    return NULL;
609
}
610

            
611
/**
612
 * atk_table_get_selected_rows:
613
 * @table: a GObject instance that implements AtkTableIface
614
 * @selected: a #gint** that is to contain the selected row numbers
615
 *
616
 * Gets the selected rows of the table by initializing **selected with
617
 * the selected row numbers. This array should be freed by the caller.
618
 *
619
 * Returns: a gint representing the number of selected rows,
620
 * or zero if value does not implement this interface.
621
 **/
622
gint
623
2
atk_table_get_selected_rows (AtkTable *table, gint **selected)
624
{
625
  AtkTableIface *iface;
626

            
627
2
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
628

            
629
2
  iface = ATK_TABLE_GET_IFACE (table);
630

            
631
2
  if (iface->get_selected_rows)
632
2
    return (iface->get_selected_rows) (table, selected);
633
  else
634
    return 0;
635
}
636

            
637
/**
638
 * atk_table_get_selected_columns:
639
 * @table: a GObject instance that implements AtkTableIface
640
 * @selected: a #gint** that is to contain the selected columns numbers
641
 *
642
 * Gets the selected columns of the table by initializing **selected with
643
 * the selected column numbers. This array should be freed by the caller.
644
 *
645
 * Returns: a gint representing the number of selected columns,
646
 * or %0 if value does not implement this interface.
647
 **/
648
gint
649
2
atk_table_get_selected_columns (AtkTable *table, gint **selected)
650
{
651
  AtkTableIface *iface;
652

            
653
2
  g_return_val_if_fail (ATK_IS_TABLE (table), 0);
654

            
655
2
  iface = ATK_TABLE_GET_IFACE (table);
656

            
657
2
  if (iface->get_selected_columns)
658
2
    return (iface->get_selected_columns) (table, selected);
659
  else
660
    return 0;
661
}
662

            
663
/**
664
 * atk_table_is_column_selected:
665
 * @table: a GObject instance that implements AtkTableIface
666
 * @column: a #gint representing a column in @table
667
 *
668
 * Gets a boolean value indicating whether the specified @column
669
 * is selected
670
 *
671
 * Returns: a gboolean representing if the column is selected, or 0
672
 * if value does not implement this interface.
673
 **/
674
gboolean
675
6
atk_table_is_column_selected (AtkTable *table,
676
                              gint column)
677
{
678
  AtkTableIface *iface;
679

            
680
6
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
681

            
682
6
  iface = ATK_TABLE_GET_IFACE (table);
683

            
684
6
  if (iface->is_column_selected)
685
6
    return (iface->is_column_selected) (table, column);
686
  else
687
    return FALSE;
688
}
689

            
690
/**
691
 * atk_table_is_row_selected:
692
 * @table: a GObject instance that implements AtkTableIface
693
 * @row: a #gint representing a row in @table
694
 *
695
 * Gets a boolean value indicating whether the specified @row
696
 * is selected
697
 *
698
 * Returns: a gboolean representing if the row is selected, or 0
699
 * if value does not implement this interface.
700
 **/
701
gboolean
702
6
atk_table_is_row_selected (AtkTable *table,
703
                           gint row)
704
{
705
  AtkTableIface *iface;
706

            
707
6
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
708

            
709
6
  iface = ATK_TABLE_GET_IFACE (table);
710

            
711
6
  if (iface->is_row_selected)
712
6
    return (iface->is_row_selected) (table, row);
713
  else
714
    return FALSE;
715
}
716

            
717
/**
718
 * atk_table_is_selected:
719
 * @table: a GObject instance that implements AtkTableIface
720
 * @row: a #gint representing a row in @table
721
 * @column: a #gint representing a column in @table
722
 *
723
 * Gets a boolean value indicating whether the accessible object
724
 * at the specified @row and @column is selected
725
 *
726
 * Returns: a gboolean representing if the cell is selected, or 0
727
 * if value does not implement this interface.
728
 **/
729
gboolean
730
3
atk_table_is_selected (AtkTable *table,
731
                       gint row,
732
                       gint column)
733
{
734
  AtkTableIface *iface;
735

            
736
3
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
737

            
738
3
  iface = ATK_TABLE_GET_IFACE (table);
739

            
740
3
  if (iface->is_selected)
741
3
    return (iface->is_selected) (table, row, column);
742
  else
743
    return FALSE;
744
}
745

            
746
/**
747
 * atk_table_add_row_selection:
748
 * @table: a GObject instance that implements AtkTableIface
749
 * @row: a #gint representing a row in @table
750
 *
751
 * Adds the specified @row to the selection.
752
 *
753
 * Returns: a gboolean representing if row was successfully added to selection,
754
 * or 0 if value does not implement this interface.
755
 **/
756
gboolean
757
1
atk_table_add_row_selection (AtkTable *table,
758
                             gint row)
759
{
760
  AtkTableIface *iface;
761

            
762
1
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
763

            
764
1
  iface = ATK_TABLE_GET_IFACE (table);
765

            
766
1
  if (iface->add_row_selection)
767
1
    return (iface->add_row_selection) (table, row);
768
  else
769
    return FALSE;
770
}
771
/**
772
 * atk_table_remove_row_selection:
773
 * @table: a GObject instance that implements AtkTableIface
774
 * @row: a #gint representing a row in @table
775
 *
776
 * Removes the specified @row from the selection.
777
 *
778
 * Returns: a gboolean representing if the row was successfully removed from
779
 * the selection, or 0 if value does not implement this interface.
780
 **/
781
gboolean
782
1
atk_table_remove_row_selection (AtkTable *table,
783
                                gint row)
784
{
785
  AtkTableIface *iface;
786

            
787
1
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
788

            
789
1
  iface = ATK_TABLE_GET_IFACE (table);
790

            
791
1
  if (iface->remove_row_selection)
792
1
    return (iface->remove_row_selection) (table, row);
793
  else
794
    return FALSE;
795
}
796
/**
797
 * atk_table_add_column_selection:
798
 * @table: a GObject instance that implements AtkTableIface
799
 * @column: a #gint representing a column in @table
800
 *
801
 * Adds the specified @column to the selection.
802
 *
803
 * Returns: a gboolean representing if the column was successfully added to
804
 * the selection, or 0 if value does not implement this interface.
805
 **/
806
gboolean
807
1
atk_table_add_column_selection (AtkTable *table,
808
                                gint column)
809
{
810
  AtkTableIface *iface;
811

            
812
1
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
813

            
814
1
  iface = ATK_TABLE_GET_IFACE (table);
815

            
816
1
  if (iface->add_column_selection)
817
1
    return (iface->add_column_selection) (table, column);
818
  else
819
    return FALSE;
820
}
821
/**
822
 * atk_table_remove_column_selection:
823
 * @table: a GObject instance that implements AtkTableIface
824
 * @column: a #gint representing a column in @table
825
 *
826
 * Adds the specified @column to the selection.
827
 *
828
 * Returns: a gboolean representing if the column was successfully removed from
829
 * the selection, or 0 if value does not implement this interface.
830
 **/
831
gboolean
832
1
atk_table_remove_column_selection (AtkTable *table,
833
                                   gint column)
834
{
835
  AtkTableIface *iface;
836

            
837
1
  g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
838

            
839
1
  iface = ATK_TABLE_GET_IFACE (table);
840

            
841
1
  if (iface->remove_column_selection)
842
1
    return (iface->remove_column_selection) (table, column);
843
  else
844
    return FALSE;
845
}
846

            
847
/**
848
 * atk_table_set_caption:
849
 * @table: a GObject instance that implements AtkTableIface
850
 * @caption: a #AtkObject representing the caption to set for @table
851
 *
852
 * Sets the caption for the table.
853
 **/
854
void
855
atk_table_set_caption (AtkTable *table,
856
                       AtkObject *caption)
857
{
858
  AtkTableIface *iface;
859

            
860
  g_return_if_fail (ATK_IS_TABLE (table));
861

            
862
  iface = ATK_TABLE_GET_IFACE (table);
863

            
864
  if (iface->set_caption)
865
    (iface->set_caption) (table, caption);
866
}
867

            
868
/**
869
 * atk_table_set_column_description:
870
 * @table: a GObject instance that implements AtkTableIface
871
 * @column: a #gint representing a column in @table
872
 * @description: a #gchar representing the description text
873
 * to set for the specified @column of the @table
874
 *
875
 * Sets the description text for the specified @column of the @table.
876
 **/
877
void
878
atk_table_set_column_description (AtkTable *table,
879
                                  gint column,
880
                                  const gchar *description)
881
{
882
  AtkTableIface *iface;
883

            
884
  g_return_if_fail (ATK_IS_TABLE (table));
885

            
886
  iface = ATK_TABLE_GET_IFACE (table);
887

            
888
  if (iface->set_column_description)
889
    (iface->set_column_description) (table, column, description);
890
}
891

            
892
/**
893
 * atk_table_set_column_header:
894
 * @table: a GObject instance that implements AtkTableIface
895
 * @column: a #gint representing a column in @table
896
 * @header: an #AtkTable
897
 *
898
 * Sets the specified column header to @header.
899
 **/
900
void
901
atk_table_set_column_header (AtkTable *table,
902
                             gint column,
903
                             AtkObject *header)
904
{
905
  AtkTableIface *iface;
906

            
907
  g_return_if_fail (ATK_IS_TABLE (table));
908

            
909
  iface = ATK_TABLE_GET_IFACE (table);
910

            
911
  if (iface->set_column_header)
912
    (iface->set_column_header) (table, column, header);
913
}
914

            
915
/**
916
 * atk_table_set_row_description:
917
 * @table: a GObject instance that implements AtkTableIface
918
 * @row: a #gint representing a row in @table
919
 * @description: a #gchar representing the description text
920
 * to set for the specified @row of @table
921
 *
922
 * Sets the description text for the specified @row of @table.
923
 **/
924
void
925
atk_table_set_row_description (AtkTable *table,
926
                               gint row,
927
                               const gchar *description)
928
{
929
  AtkTableIface *iface;
930

            
931
  g_return_if_fail (ATK_IS_TABLE (table));
932

            
933
  iface = ATK_TABLE_GET_IFACE (table);
934

            
935
  if (iface->set_row_description)
936
    (iface->set_row_description) (table, row, description);
937
}
938

            
939
/**
940
 * atk_table_set_row_header:
941
 * @table: a GObject instance that implements AtkTableIface
942
 * @row: a #gint representing a row in @table
943
 * @header: an #AtkTable
944
 *
945
 * Sets the specified row header to @header.
946
 **/
947
void
948
atk_table_set_row_header (AtkTable *table,
949
                          gint row,
950
                          AtkObject *header)
951
{
952
  AtkTableIface *iface;
953

            
954
  g_return_if_fail (ATK_IS_TABLE (table));
955

            
956
  iface = ATK_TABLE_GET_IFACE (table);
957

            
958
  if (iface->set_row_header)
959
    (iface->set_row_header) (table, row, header);
960
}
961

            
962
/**
963
 * atk_table_set_summary:
964
 * @table: a GObject instance that implements AtkTableIface
965
 * @accessible: an #AtkObject representing the summary description
966
 * to set for @table
967
 *
968
 * Sets the summary description of the table.
969
 **/
970
void
971
atk_table_set_summary (AtkTable *table,
972
                       AtkObject *accessible)
973
{
974
  AtkTableIface *iface;
975

            
976
  g_return_if_fail (ATK_IS_TABLE (table));
977

            
978
  iface = ATK_TABLE_GET_IFACE (table);
979

            
980
  if (iface->set_summary)
981
    (iface->set_summary) (table, accessible);
982
}