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 <locale.h>
23
#include <string.h>
24

            
25
#include <glib-object.h>
26
#include <glib/gi18n-lib.h>
27

            
28
#include "atk.h"
29
#include "atkmarshal.h"
30
#include "atkprivate.h"
31

            
32
/**
33
 * AtkObject:
34
 *
35
 * The base object class for the Accessibility Toolkit API.
36
 *
37
 * This class is the primary class for accessibility support via the
38
 * Accessibility ToolKit (ATK).  Objects which are instances of
39
 * #AtkObject (or instances of AtkObject-derived types) are queried
40
 * for properties which relate basic (and generic) properties of a UI
41
 * component such as name and description.  Instances of #AtkObject
42
 * may also be queried as to whether they implement other ATK
43
 * interfaces (e.g. #AtkAction, #AtkComponent, etc.), as appropriate
44
 * to the role which a given UI component plays in a user interface.
45
 *
46
 * All UI components in an application which provide useful
47
 * information or services to the user must provide corresponding
48
 * #AtkObject instances on request (in GTK+, for instance, usually on
49
 * a call to #gtk_widget_get_accessible ()), either via ATK support
50
 * built into the toolkit for the widget class or ancestor class, or
51
 * in the case of custom widgets, if the inherited #AtkObject
52
 * implementation is insufficient, via instances of a new #AtkObject
53
 * subclass.
54
 *
55
 * See [class@AtkObjectFactory], [class@AtkRegistry].  (GTK+ users see also
56
 * #GtkAccessible).
57
 *
58
 */
59

            
60
static GPtrArray *role_names = NULL;
61

            
62
enum
63
{
64
  PROP_0, /* gobject convention */
65

            
66
  PROP_NAME,
67
  PROP_DESCRIPTION,
68
  PROP_PARENT, /* ancestry has changed */
69
  PROP_VALUE,
70
  PROP_ROLE,
71
  PROP_LAYER,
72
  PROP_MDI_ZORDER,
73
  PROP_TABLE_CAPTION,
74
  PROP_TABLE_COLUMN_DESCRIPTION,
75
  PROP_TABLE_COLUMN_HEADER,
76
  PROP_TABLE_ROW_DESCRIPTION,
77
  PROP_TABLE_ROW_HEADER,
78
  PROP_TABLE_SUMMARY,
79
  PROP_TABLE_CAPTION_OBJECT,
80
  PROP_HYPERTEXT_NUM_LINKS,
81
  PROP_ACCESSIBLE_ID,
82
  PROP_HELP_TEXT,
83
  PROP_LAST /* gobject convention */
84
};
85

            
86
enum
87
{
88
  CHILDREN_CHANGED,
89
  FOCUS_EVENT,
90
  PROPERTY_CHANGE,
91
  STATE_CHANGE,
92
  VISIBLE_DATA_CHANGED,
93
  ACTIVE_DESCENDANT_CHANGED,
94
  ANNOUNCEMENT,
95
  NOTIFICATION,
96
  ATTRIBUTE_CHANGED,
97

            
98
  LAST_SIGNAL
99
};
100

            
101
typedef struct
102
{
103
  gchar *accessible_id;
104
  gchar *help_text;
105
} AtkObjectPrivate;
106

            
107
static gint AtkObject_private_offset;
108

            
109
static void atk_object_class_init (AtkObjectClass *klass);
110
static void atk_object_init (AtkObject *accessible,
111
                             AtkObjectClass *klass);
112
static AtkRelationSet *atk_object_real_ref_relation_set (AtkObject *accessible);
113
static void atk_object_real_initialize (AtkObject *accessible,
114
                                        gpointer data);
115
static void atk_object_real_set_property (GObject *object,
116
                                          guint prop_id,
117
                                          const GValue *value,
118
                                          GParamSpec *pspec);
119
static void atk_object_real_get_property (GObject *object,
120
                                          guint prop_id,
121
                                          GValue *value,
122
                                          GParamSpec *pspec);
123
static void atk_object_finalize (GObject *object);
124
static const gchar *atk_object_real_get_name (AtkObject *object);
125
static const gchar *atk_object_real_get_description (AtkObject *object);
126
static AtkObject *atk_object_real_get_parent (AtkObject *object);
127
static AtkRole atk_object_real_get_role (AtkObject *object);
128
static AtkLayer atk_object_real_get_layer (AtkObject *object);
129
static AtkStateSet *atk_object_real_ref_state_set (AtkObject *object);
130
static void atk_object_real_set_name (AtkObject *object,
131
                                      const gchar *name);
132
static void atk_object_real_set_description (AtkObject *object,
133
                                             const gchar *description);
134
static void atk_object_real_set_parent (AtkObject *object,
135
                                        AtkObject *parent);
136
static void atk_object_real_set_role (AtkObject *object,
137
                                      AtkRole role);
138
static void atk_object_notify (GObject *obj,
139
                               GParamSpec *pspec);
140
static const gchar *atk_object_real_get_object_locale (AtkObject *object);
141

            
142
static guint atk_object_signals[LAST_SIGNAL] = {
143
  0,
144
};
145

            
146
static gpointer parent_class = NULL;
147

            
148
static const gchar *const atk_object_name_property_name = "accessible-name";
149
static const gchar *const atk_object_name_property_description = "accessible-description";
150
static const gchar *const atk_object_name_property_parent = "accessible-parent";
151
static const gchar *const atk_object_name_property_value = "accessible-value";
152
static const gchar *const atk_object_name_property_role = "accessible-role";
153
static const gchar *const atk_object_name_property_component_layer = "accessible-component-layer";
154
static const gchar *const atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
155
static const gchar *const atk_object_name_property_table_caption = "accessible-table-caption";
156
static const gchar *const atk_object_name_property_table_column_description = "accessible-table-column-description";
157
static const gchar *const atk_object_name_property_table_column_header = "accessible-table-column-header";
158
static const gchar *const atk_object_name_property_table_row_description = "accessible-table-row-description";
159
static const gchar *const atk_object_name_property_table_row_header = "accessible-table-row-header";
160
static const gchar *const atk_object_name_property_table_summary = "accessible-table-summary";
161
static const gchar *const atk_object_name_property_table_caption_object = "accessible-table-caption-object";
162
static const gchar *const atk_object_name_property_hypertext_num_links = "accessible-hypertext-nlinks";
163
static const gchar *const atk_object_name_property_accessible_id = "accessible-id";
164
static const gchar *const atk_object_name_property_help_text = "accessible-help-text";
165

            
166
static void
167
162
initialize_role_names ()
168
{
169
  GTypeClass *enum_class;
170
  GEnumValue *enum_value;
171
  int i;
172
162
  gchar *role_name = NULL;
173

            
174
162
  if (role_names)
175
    return;
176

            
177
162
  role_names = g_ptr_array_new ();
178
162
  enum_class = g_type_class_ref (ATK_TYPE_ROLE);
179
162
  if (!G_IS_ENUM_CLASS (enum_class))
180
    return;
181

            
182
20898
  for (i = 0; i < ATK_ROLE_LAST_DEFINED; i++)
183
    {
184
20736
      enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class), i);
185
20736
      role_name = g_strdup (enum_value->value_nick);
186
      // We want the role names to be in the format "check button" and not "check-button"
187
20736
      _compact_name (role_name);
188
20736
      g_ptr_array_add (role_names, role_name);
189
    }
190

            
191
162
  g_type_class_unref (enum_class);
192
}
193

            
194
GType
195
75544
atk_object_get_type (void)
196
{
197
  static GType type = 0;
198

            
199
75544
  if (!type)
200
    {
201
      static const GTypeInfo typeInfo = {
202
        sizeof (AtkObjectClass),
203
        (GBaseInitFunc) NULL,
204
        (GBaseFinalizeFunc) NULL,
205
        (GClassInitFunc) atk_object_class_init,
206
        (GClassFinalizeFunc) NULL,
207
        NULL,
208
        sizeof (AtkObject),
209
        0,
210
        (GInstanceInitFunc) atk_object_init,
211
      };
212
164
      type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0);
213

            
214
164
      AtkObject_private_offset =
215
164
          g_type_add_instance_private (type, sizeof (AtkObjectPrivate));
216
    }
217
75544
  return type;
218
}
219

            
220
static inline gpointer
221
5437
atk_object_get_instance_private (AtkObject *self)
222
{
223
5437
  return (G_STRUCT_MEMBER_P (self, AtkObject_private_offset));
224
}
225

            
226
static void
227
164
atk_object_class_init (AtkObjectClass *klass)
228
{
229
164
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
230

            
231
164
  parent_class = g_type_class_peek_parent (klass);
232

            
233
164
  if (AtkObject_private_offset != 0)
234
164
    g_type_class_adjust_private_offset (klass, &AtkObject_private_offset);
235

            
236
164
  gobject_class->set_property = atk_object_real_set_property;
237
164
  gobject_class->get_property = atk_object_real_get_property;
238
164
  gobject_class->finalize = atk_object_finalize;
239
164
  gobject_class->notify = atk_object_notify;
240

            
241
164
  klass->get_name = atk_object_real_get_name;
242
164
  klass->get_description = atk_object_real_get_description;
243
164
  klass->get_parent = atk_object_real_get_parent;
244
164
  klass->get_n_children = NULL;
245
164
  klass->ref_child = NULL;
246
164
  klass->get_index_in_parent = NULL;
247
164
  klass->ref_relation_set = atk_object_real_ref_relation_set;
248
164
  klass->get_role = atk_object_real_get_role;
249
164
  klass->get_layer = atk_object_real_get_layer;
250
164
  klass->get_mdi_zorder = NULL;
251
164
  klass->initialize = atk_object_real_initialize;
252
164
  klass->ref_state_set = atk_object_real_ref_state_set;
253
164
  klass->set_name = atk_object_real_set_name;
254
164
  klass->set_description = atk_object_real_set_description;
255
164
  klass->set_parent = atk_object_real_set_parent;
256
164
  klass->set_role = atk_object_real_set_role;
257
164
  klass->get_object_locale = atk_object_real_get_object_locale;
258

            
259
  /*
260
   * We do not define default signal handlers here
261
   */
262
164
  klass->children_changed = NULL;
263
164
  klass->focus_event = NULL;
264
164
  klass->property_change = NULL;
265
164
  klass->visible_data_changed = NULL;
266
164
  klass->active_descendant_changed = NULL;
267

            
268
164
  _gettext_initialization ();
269

            
270
164
  g_object_class_install_property (gobject_class,
271
                                   PROP_NAME,
272
                                   g_param_spec_string (atk_object_name_property_name,
273
                                                        _ ("Accessible Name"),
274
                                                        _ ("Object instance’s name formatted for assistive technology access"),
275
                                                        NULL,
276
                                                        G_PARAM_READWRITE));
277
164
  g_object_class_install_property (gobject_class,
278
                                   PROP_DESCRIPTION,
279
                                   g_param_spec_string (atk_object_name_property_description,
280
                                                        _ ("Accessible Description"),
281
                                                        _ ("Description of an object, formatted for assistive technology access"),
282
                                                        NULL,
283
                                                        G_PARAM_READWRITE));
284
164
  g_object_class_install_property (gobject_class,
285
                                   PROP_PARENT,
286
                                   g_param_spec_object (atk_object_name_property_parent,
287
                                                        _ ("Accessible Parent"),
288
                                                        _ ("Parent of the current accessible as returned by atk_object_get_parent()"),
289
                                                        ATK_TYPE_OBJECT,
290
                                                        G_PARAM_READWRITE));
291

            
292
  /**
293
   * AtkObject:accessible-value:
294
   *
295
   * Numeric value of this object, in case being and AtkValue.
296
   *
297
   * Deprecated: Since 2.12. Use atk_value_get_value_and_text() to get
298
   * the value, and value-changed signal to be notified on their value
299
   * changes.
300
   */
301
164
  g_object_class_install_property (gobject_class,
302
                                   PROP_VALUE,
303
                                   g_param_spec_double (atk_object_name_property_value,
304
                                                        _ ("Accessible Value"),
305
                                                        _ ("Is used to notify that the value has changed"),
306
                                                        0.0,
307
                                                        G_MAXDOUBLE,
308
                                                        0.0,
309
                                                        G_PARAM_READWRITE));
310
164
  g_object_class_install_property (gobject_class,
311
                                   PROP_ROLE,
312
                                   g_param_spec_enum (atk_object_name_property_role,
313
                                                      _ ("Accessible Role"),
314
                                                      _ ("The accessible role of this object"),
315
                                                      ATK_TYPE_ROLE,
316
                                                      ATK_ROLE_UNKNOWN,
317
                                                      G_PARAM_READWRITE));
318
164
  g_object_class_install_property (gobject_class,
319
                                   PROP_LAYER,
320
                                   g_param_spec_int (atk_object_name_property_component_layer,
321
                                                     _ ("Accessible Layer"),
322
                                                     _ ("The accessible layer of this object"),
323
                                                     0,
324
                                                     G_MAXINT,
325
                                                     0,
326
                                                     G_PARAM_READABLE));
327
164
  g_object_class_install_property (gobject_class,
328
                                   PROP_MDI_ZORDER,
329
                                   g_param_spec_int (atk_object_name_property_component_mdi_zorder,
330
                                                     _ ("Accessible MDI Value"),
331
                                                     _ ("The accessible MDI value of this object"),
332
                                                     G_MININT,
333
                                                     G_MAXINT,
334
                                                     G_MININT,
335
                                                     G_PARAM_READABLE));
336

            
337
  /**
338
   * AtkObject:accessible-table-caption:
339
   *
340
   * Table caption.
341
   *
342
   * Deprecated: Since 1.3. Use table-caption-object instead.
343
   */
344
164
  g_object_class_install_property (gobject_class,
345
                                   PROP_TABLE_CAPTION,
346
                                   g_param_spec_string (atk_object_name_property_table_caption,
347
                                                        _ ("Accessible Table Caption"),
348
                                                        _ ("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
349
                                                        NULL,
350
                                                        G_PARAM_READWRITE));
351
  /**
352
   * AtkObject:accessible-table-column-header:
353
   *
354
   * Accessible table column header.
355
   *
356
   * Deprecated: Since 2.12. Use atk_table_get_column_header() and
357
   * atk_table_set_column_header() instead.
358
   */
359
164
  g_object_class_install_property (gobject_class,
360
                                   PROP_TABLE_COLUMN_HEADER,
361
                                   g_param_spec_object (atk_object_name_property_table_column_header,
362
                                                        _ ("Accessible Table Column Header"),
363
                                                        _ ("Is used to notify that the table column header has changed"),
364
                                                        ATK_TYPE_OBJECT,
365
                                                        G_PARAM_READWRITE));
366

            
367
  /**
368
   * AtkObject:accessible-table-column-description:
369
   *
370
   * Accessible table column description.
371
   *
372
   * Deprecated: Since 2.12. Use atk_table_get_column_description()
373
   * and atk_table_set_column_description() instead.
374
   */
375
164
  g_object_class_install_property (gobject_class,
376
                                   PROP_TABLE_COLUMN_DESCRIPTION,
377
                                   g_param_spec_string (atk_object_name_property_table_column_description,
378
                                                        _ ("Accessible Table Column Description"),
379
                                                        _ ("Is used to notify that the table column description has changed"),
380
                                                        NULL,
381
                                                        G_PARAM_READWRITE));
382

            
383
  /**
384
   * AtkObject:accessible-table-row-header:
385
   *
386
   * Accessible table row header.
387
   *
388
   * Deprecated: Since 2.12. Use atk_table_get_row_header() and
389
   * atk_table_set_row_header() instead.
390
   */
391
164
  g_object_class_install_property (gobject_class,
392
                                   PROP_TABLE_ROW_HEADER,
393
                                   g_param_spec_object (atk_object_name_property_table_row_header,
394
                                                        _ ("Accessible Table Row Header"),
395
                                                        _ ("Is used to notify that the table row header has changed"),
396
                                                        ATK_TYPE_OBJECT,
397
                                                        G_PARAM_READWRITE));
398
  /**
399
   * AtkObject:accessible-table-row-description:
400
   *
401
   * Accessible table row description.
402
   *
403
   * Deprecated: Since 2.12. Use atk_table_get_row_description() and
404
   * atk_table_set_row_description() instead.
405
   */
406
164
  g_object_class_install_property (gobject_class,
407
                                   PROP_TABLE_ROW_DESCRIPTION,
408
                                   g_param_spec_string (atk_object_name_property_table_row_description,
409
                                                        _ ("Accessible Table Row Description"),
410
                                                        _ ("Is used to notify that the table row description has changed"),
411
                                                        NULL,
412
                                                        G_PARAM_READWRITE));
413
164
  g_object_class_install_property (gobject_class,
414
                                   PROP_TABLE_SUMMARY,
415
                                   g_param_spec_object (atk_object_name_property_table_summary,
416
                                                        _ ("Accessible Table Summary"),
417
                                                        _ ("Is used to notify that the table summary has changed"),
418
                                                        ATK_TYPE_OBJECT,
419
                                                        G_PARAM_READWRITE));
420
164
  g_object_class_install_property (gobject_class,
421
                                   PROP_TABLE_CAPTION_OBJECT,
422
                                   g_param_spec_object (atk_object_name_property_table_caption_object,
423
                                                        _ ("Accessible Table Caption Object"),
424
                                                        _ ("Is used to notify that the table caption has changed"),
425
                                                        ATK_TYPE_OBJECT,
426
                                                        G_PARAM_READWRITE));
427
164
  g_object_class_install_property (gobject_class,
428
                                   PROP_HYPERTEXT_NUM_LINKS,
429
                                   g_param_spec_int (atk_object_name_property_hypertext_num_links,
430
                                                     _ ("Number of Accessible Hypertext Links"),
431
                                                     _ ("The number of links which the current AtkHypertext has"),
432
                                                     0,
433
                                                     G_MAXINT,
434
                                                     0,
435
                                                     G_PARAM_READABLE));
436

            
437
164
  g_object_class_install_property (gobject_class,
438
                                   PROP_ACCESSIBLE_ID,
439
                                   g_param_spec_string (atk_object_name_property_accessible_id,
440
                                                        _ ("Accessible ID"),
441
                                                        _ ("ID for the accessible; useful for automated testing"),
442
                                                        NULL,
443
                                                        G_PARAM_READWRITE));
444
164
  g_object_class_install_property (gobject_class,
445
                                   PROP_HELP_TEXT,
446
                                   g_param_spec_string (atk_object_name_property_help_text,
447
                                                        _ ("Help text"),
448
                                                        _ ("Help text associated with the accessible"),
449
                                                        NULL,
450
                                                        G_PARAM_READWRITE));
451
  /**
452
   * AtkObject::children-changed:
453
   * @atkobject: the object which received the signal.
454
   * @arg1: The index of the added or removed child. The value can be
455
   * -1. This is used if the value is not known by the implementor
456
   * when the child is added/removed or irrelevant.
457
   * @arg2: (type AtkObject): A gpointer to the child AtkObject which was added or
458
   * removed. If the child was removed, it is possible that it is not
459
   * available for the implementor. In that case this pointer can be
460
   * NULL.
461
   *
462
   * The signal "children-changed" is emitted when a child is added or
463
   * removed from an object. It supports two details: "add" and
464
   * "remove"
465
   */
466
164
  atk_object_signals[CHILDREN_CHANGED] =
467
164
      g_signal_new ("children_changed",
468
                    G_TYPE_FROM_CLASS (klass),
469
                    G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
470
                    G_STRUCT_OFFSET (AtkObjectClass, children_changed),
471
                    NULL, NULL,
472
                    g_cclosure_marshal_VOID__UINT_POINTER,
473
                    G_TYPE_NONE,
474
                    2, G_TYPE_UINT, G_TYPE_POINTER);
475

            
476
  /**
477
   * AtkObject::focus-event:
478
   * @atkobject: the object which received the signal
479
   * @arg1: a boolean value which indicates whether the object gained
480
   * or lost focus.
481
   *
482
   * The signal "focus-event" is emitted when an object gained or lost
483
   * focus.
484
   *
485
   * Deprecated: 2.9.4: Use the #AtkObject::state-change signal instead.
486
   */
487
164
  atk_object_signals[FOCUS_EVENT] =
488
164
      g_signal_new ("focus_event",
489
                    G_TYPE_FROM_CLASS (klass),
490
                    G_SIGNAL_RUN_LAST,
491
                    G_STRUCT_OFFSET (AtkObjectClass, focus_event),
492
                    NULL, NULL,
493
                    g_cclosure_marshal_VOID__BOOLEAN,
494
                    G_TYPE_NONE,
495
                    1, G_TYPE_BOOLEAN);
496
  /**
497
   * AtkObject::property-change:
498
   * @atkobject: the object which received the signal.
499
   * @arg1: (type AtkPropertyValues): an #AtkPropertyValues containing the new
500
   * value of the property which changed.
501
   *
502
   * The signal "property-change" is emitted when an object's property
503
   * value changes. @arg1 contains an #AtkPropertyValues with the name
504
   * and the new value of the property whose value has changed. Note
505
   * that, as with GObject notify, getting this signal does not
506
   * guarantee that the value of the property has actually changed; it
507
   * may also be emitted when the setter of the property is called to
508
   * reinstate the previous value.
509
   *
510
   * Toolkit implementor note: ATK implementors should use
511
   * g_object_notify() to emit property-changed
512
   * notifications. #AtkObject::property-changed is needed by the
513
   * implementation of atk_add_global_event_listener() because GObject
514
   * notify doesn't support emission hooks.
515
   */
516
164
  atk_object_signals[PROPERTY_CHANGE] =
517
164
      g_signal_new ("property_change",
518
                    G_TYPE_FROM_CLASS (klass),
519
                    G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
520
                    G_STRUCT_OFFSET (AtkObjectClass, property_change),
521
                    (GSignalAccumulator) NULL, NULL,
522
                    g_cclosure_marshal_VOID__POINTER,
523
                    G_TYPE_NONE, 1,
524
                    G_TYPE_POINTER);
525

            
526
  /**
527
   * AtkObject::state-change:
528
   * @atkobject: the object which received the signal.
529
   * @arg1: The name of the state which has changed
530
   * @arg2: A boolean which indicates whether the state has been set or unset.
531
   *
532
   * The "state-change" signal is emitted when an object's state
533
   * changes.  The detail value identifies the state type which has
534
   * changed.
535
   */
536
164
  atk_object_signals[STATE_CHANGE] =
537
164
      g_signal_new ("state_change",
538
                    G_TYPE_FROM_CLASS (klass),
539
                    G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
540
                    G_STRUCT_OFFSET (AtkObjectClass, state_change),
541
                    (GSignalAccumulator) NULL, NULL,
542
                    atk_marshal_VOID__STRING_BOOLEAN,
543
                    G_TYPE_NONE, 2,
544
                    G_TYPE_STRING,
545
                    G_TYPE_BOOLEAN);
546

            
547
  /**
548
   * AtkObject::visible-data-changed:
549
   * @atkobject: the object which received the signal.
550
   *
551
   * The "visible-data-changed" signal is emitted when the visual
552
   * appearance of the object changed.
553
   */
554
164
  atk_object_signals[VISIBLE_DATA_CHANGED] =
555
164
      g_signal_new ("visible_data_changed",
556
                    G_TYPE_FROM_CLASS (klass),
557
                    G_SIGNAL_RUN_LAST,
558
                    G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
559
                    (GSignalAccumulator) NULL, NULL,
560
                    g_cclosure_marshal_VOID__VOID,
561
                    G_TYPE_NONE, 0);
562

            
563
  /**
564
   * AtkObject::active-descendant-changed:
565
   * @atkobject: the object which received the signal.
566
   * @arg1: (type AtkObject): the newly focused object.
567
   *
568
   * The "active-descendant-changed" signal is emitted by an object
569
   * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
570
   * object in the object changes. For instance, a table will emit the
571
   * signal when the cell in the table which has focus changes.
572
   */
573
164
  atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
574
164
      g_signal_new ("active_descendant_changed",
575
                    G_TYPE_FROM_CLASS (klass),
576
                    G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
577
                    G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
578
                    NULL, NULL,
579
                    g_cclosure_marshal_VOID__POINTER,
580
                    G_TYPE_NONE,
581
                    1, G_TYPE_POINTER);
582

            
583
  /**
584
   * AtkObject::announcement
585
   * @atkobject: the object which received the signal.
586
   * @arg1: the text to be announced.
587
   *
588
   * The "announcement" signal can be emitted to pass an announcement on to
589
   * be read by a screen reader.
590
   *
591
   * Depcrecated (2.50): Use AtkObject::notification instead.
592
   *
593
   * Since: 2.46
594
   */
595
164
  atk_object_signals[ANNOUNCEMENT] =
596
164
      g_signal_new ("announcement",
597
                    G_TYPE_FROM_CLASS (klass),
598
                    G_SIGNAL_RUN_LAST,
599
                    0, /* no class handler in order to avoid breaking ABI */
600
                    NULL, NULL,
601
                    g_cclosure_marshal_VOID__STRING,
602
                    G_TYPE_NONE,
603
                    1, G_TYPE_STRING);
604

            
605
  /**
606
   * AtkObject::notification
607
   * @atkobject: the object which received the signal.
608
   * @arg1: the text to be announced.
609
   * @arg2: an #AtkLive specifying the politeness of the notification.
610
   * Should be either ATK_LIVE_POLITE or ATK_LIVE_ASSERTIVE.
611
   *
612
   * The "notification" signal can be emitted to pass an announcement on to
613
   * be read by a screen reader.
614
   *
615
   * Since: 2.50
616
   */
617
164
  atk_object_signals[NOTIFICATION] =
618
164
      g_signal_new ("notification",
619
                    G_TYPE_FROM_CLASS (klass),
620
                    G_SIGNAL_RUN_LAST,
621
                    0, /* no class handler in order to avoid breaking ABI */
622
                    NULL, NULL,
623
                    atk_marshal_VOID__STRING_INT,
624
                    G_TYPE_NONE,
625
                    2, G_TYPE_STRING, G_TYPE_INT);
626

            
627
  /**
628
   * AtkObject::attribute-changed
629
   * @atkobject: the object which received the signal.
630
   * @arg1: the name of the attribute being modified, or %NULL if not
631
   *          available.
632
   * @arg2: the attribute's new value, or %null if not available.
633
   *
634
   * The "attribute-changed" signal should be emitted when one of an object's
635
   * attributes changes.
636
   *
637
   * Since: 2.52
638
   */
639
164
  atk_object_signals[ATTRIBUTE_CHANGED] =
640
164
      g_signal_new ("attribute-changed",
641
                    G_TYPE_FROM_CLASS (klass),
642
                    G_SIGNAL_RUN_LAST,
643
                    0, /* no class handler in order to avoid breaking ABI */
644
                    NULL, NULL,
645
                    atk_marshal_VOID__STRING_STRING,
646
                    G_TYPE_NONE,
647
                    2, G_TYPE_STRING, G_TYPE_STRING);
648
164
}
649

            
650
static void
651
1921
atk_object_init (AtkObject *accessible,
652
                 AtkObjectClass *klass)
653
{
654
1921
  AtkObjectPrivate *private = atk_object_get_instance_private (accessible);
655

            
656
1921
  accessible->name = NULL;
657
1921
  accessible->description = NULL;
658
1921
  accessible->accessible_parent = NULL;
659
1921
  accessible->relation_set = atk_relation_set_new ();
660
1921
  accessible->role = ATK_ROLE_UNKNOWN;
661
1921
  private->accessible_id = NULL;
662
  private
663
1921
    ->help_text = NULL;
664
1921
}
665

            
666
GType
667
atk_implementor_get_type (void)
668
{
669
  static GType type = 0;
670

            
671
  if (!type)
672
    {
673
      static const GTypeInfo typeInfo = {
674
        sizeof (AtkImplementorIface),
675
        (GBaseInitFunc) NULL,
676
        (GBaseFinalizeFunc) NULL,
677
      };
678

            
679
      type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0);
680
    }
681

            
682
  return type;
683
}
684

            
685
/**
686
 * atk_object_get_name:
687
 * @accessible: an #AtkObject
688
 *
689
 * Gets the accessible name of the accessible.
690
 *
691
 * Returns: a character string representing the accessible name of the object.
692
 **/
693
const gchar *
694
3508
atk_object_get_name (AtkObject *accessible)
695
{
696
  AtkObjectClass *klass;
697

            
698
3508
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
699

            
700
3508
  klass = ATK_OBJECT_GET_CLASS (accessible);
701
3508
  if (klass->get_name)
702
3508
    return (klass->get_name) (accessible);
703
  else
704
    return NULL;
705
}
706

            
707
/**
708
 * atk_object_get_description:
709
 * @accessible: an #AtkObject
710
 *
711
 * Gets the accessible description of the accessible.
712
 *
713
 * Returns: a character string representing the accessible description
714
 * of the accessible.
715
 *
716
 **/
717
const gchar *
718
3019
atk_object_get_description (AtkObject *accessible)
719
{
720
  AtkObjectClass *klass;
721

            
722
3019
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
723

            
724
3019
  klass = ATK_OBJECT_GET_CLASS (accessible);
725
3019
  if (klass->get_description)
726
3019
    return (klass->get_description) (accessible);
727
  else
728
    return NULL;
729
}
730

            
731
/**
732
 * atk_object_get_parent:
733
 * @accessible: an #AtkObject
734
 *
735
 * Gets the accessible parent of the accessible. By default this is
736
 * the one assigned with atk_object_set_parent(), but it is assumed
737
 * that ATK implementors have ways to get the parent of the object
738
 * without the need of assigning it manually with
739
 * atk_object_set_parent(), and will return it with this method.
740
 *
741
 * If you are only interested on the parent assigned with
742
 * atk_object_set_parent(), use atk_object_peek_parent().
743
 *
744
 * Returns: (transfer none): an #AtkObject representing the accessible
745
 * parent of the accessible
746
 **/
747
AtkObject *
748
5723
atk_object_get_parent (AtkObject *accessible)
749
{
750
  AtkObjectClass *klass;
751

            
752
5723
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
753

            
754
5723
  klass = ATK_OBJECT_GET_CLASS (accessible);
755
5723
  if (klass->get_parent)
756
5723
    return (klass->get_parent) (accessible);
757
  else
758
    return NULL;
759
}
760

            
761
/**
762
 * atk_object_peek_parent:
763
 * @accessible: an #AtkObject
764
 *
765
 * Gets the accessible parent of the accessible, if it has been
766
 * manually assigned with atk_object_set_parent. Otherwise, this
767
 * function returns %NULL.
768
 *
769
 * This method is intended as an utility for ATK implementors, and not
770
 * to be exposed to accessible tools. See atk_object_get_parent() for
771
 * further reference.
772
 *
773
 * Returns: (transfer none): an #AtkObject representing the accessible
774
 * parent of the accessible if assigned
775
 **/
776
AtkObject *
777
5723
atk_object_peek_parent (AtkObject *accessible)
778
{
779
5723
  return accessible->accessible_parent;
780
}
781

            
782
/**
783
 * atk_object_get_n_accessible_children:
784
 * @accessible: an #AtkObject
785
 *
786
 * Gets the number of accessible children of the accessible.
787
 *
788
 * Returns: an integer representing the number of accessible children
789
 * of the accessible.
790
 **/
791
gint
792
3234
atk_object_get_n_accessible_children (AtkObject *accessible)
793
{
794
  AtkObjectClass *klass;
795

            
796
3234
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
797

            
798
3234
  klass = ATK_OBJECT_GET_CLASS (accessible);
799
3234
  if (klass->get_n_children)
800
3234
    return (klass->get_n_children) (accessible);
801
  else
802
    return 0;
803
}
804

            
805
/**
806
 * atk_object_ref_accessible_child:
807
 * @accessible: an #AtkObject
808
 * @i: a gint representing the position of the child, starting from 0
809
 *
810
 * Gets a reference to the specified accessible child of the object.
811
 * The accessible children are 0-based so the first accessible child is
812
 * at index 0, the second at index 1 and so on.
813
 *
814
 * Returns: (transfer full): an #AtkObject representing the specified
815
 * accessible child of the accessible.
816
 **/
817
AtkObject *
818
4697
atk_object_ref_accessible_child (AtkObject *accessible,
819
                                 gint i)
820
{
821
  AtkObjectClass *klass;
822

            
823
4697
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
824

            
825
4697
  klass = ATK_OBJECT_GET_CLASS (accessible);
826
4697
  if (klass->ref_child)
827
4697
    return (klass->ref_child) (accessible, i);
828
  else
829
    return NULL;
830
}
831

            
832
/**
833
 * atk_object_ref_relation_set:
834
 * @accessible: an #AtkObject
835
 *
836
 * Gets the #AtkRelationSet associated with the object.
837
 *
838
 * Returns: (transfer full): an #AtkRelationSet representing the relation set
839
 * of the object.
840
 **/
841
AtkRelationSet *
842
54
atk_object_ref_relation_set (AtkObject *accessible)
843
{
844
  AtkObjectClass *klass;
845

            
846
54
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
847

            
848
54
  klass = ATK_OBJECT_GET_CLASS (accessible);
849
54
  if (klass->ref_relation_set)
850
54
    return (klass->ref_relation_set) (accessible);
851
  else
852
    return NULL;
853
}
854

            
855
/**
856
 * atk_role_register:
857
 * @name: a character string describing the new role.
858
 *
859
 * Registers the role specified by @name. @name must be a meaningful
860
 * name. So it should not be empty, or consisting on whitespaces.
861
 *
862
 * Deprecated: Since 2.12. If your application/toolkit doesn't find a
863
 * suitable role for a specific object defined at #AtkRole, please
864
 * submit a bug in order to add a new role to the specification.
865
 *
866
 * Returns: an #AtkRole for the new role if added
867
 * properly. ATK_ROLE_INVALID in case of error.
868
 **/
869
AtkRole
870
atk_role_register (const gchar *name)
871
{
872
  gboolean valid = FALSE;
873
  gint i = 0;
874
  glong length = g_utf8_strlen (name, -1);
875

            
876
  for (i = 0; i < length; i++)
877
    {
878
      if (name[i] != ' ')
879
        {
880
          valid = TRUE;
881
          break;
882
        }
883
    }
884

            
885
  if (!valid)
886
    return ATK_ROLE_INVALID;
887

            
888
  if (!role_names)
889
    initialize_role_names ();
890

            
891
  g_ptr_array_add (role_names, g_strdup (name));
892
  return role_names->len - 1;
893
}
894

            
895
/**
896
 * atk_object_get_role:
897
 * @accessible: an #AtkObject
898
 *
899
 * Gets the role of the accessible.
900
 *
901
 * Returns: an #AtkRole which is the role of the accessible
902
 **/
903
AtkRole
904
8793
atk_object_get_role (AtkObject *accessible)
905
{
906
  AtkObjectClass *klass;
907

            
908
8793
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
909

            
910
8793
  klass = ATK_OBJECT_GET_CLASS (accessible);
911
8793
  if (klass->get_role)
912
8793
    return (klass->get_role) (accessible);
913
  else
914
    return ATK_ROLE_UNKNOWN;
915
}
916

            
917
/**
918
 * atk_object_get_layer:
919
 * @accessible: an #AtkObject
920
 *
921
 * Gets the layer of the accessible.
922
 *
923
 * Deprecated: Use atk_component_get_layer instead.
924
 *
925
 * Returns: an #AtkLayer which is the layer of the accessible
926
 **/
927
AtkLayer
928
atk_object_get_layer (AtkObject *accessible)
929
{
930
  AtkObjectClass *klass;
931

            
932
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
933

            
934
  klass = ATK_OBJECT_GET_CLASS (accessible);
935
  if (klass->get_layer)
936
    return (klass->get_layer) (accessible);
937
  else
938
    return ATK_LAYER_INVALID;
939
}
940

            
941
/**
942
 * atk_object_get_mdi_zorder:
943
 * @accessible: an #AtkObject
944
 *
945
 * Gets the zorder of the accessible. The value G_MININT will be returned
946
 * if the layer of the accessible is not ATK_LAYER_MDI.
947
 *
948
 * Deprecated: Use atk_component_get_mdi_zorder instead.
949
 *
950
 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
951
 * which the component is shown in relation to other components in the same
952
 * container.
953
 *
954
 **/
955
gint
956
atk_object_get_mdi_zorder (AtkObject *accessible)
957
{
958
  AtkObjectClass *klass;
959

            
960
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
961

            
962
  klass = ATK_OBJECT_GET_CLASS (accessible);
963
  if (klass->get_mdi_zorder)
964
    return (klass->get_mdi_zorder) (accessible);
965
  else
966
    return G_MININT;
967
}
968

            
969
/**
970
 * atk_object_ref_state_set:
971
 * @accessible: an #AtkObject
972
 *
973
 * Gets a reference to the state set of the accessible; the caller must
974
 * unreference it when it is no longer needed.
975
 *
976
 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
977
 * set of the accessible
978
 **/
979
AtkStateSet *
980
3810
atk_object_ref_state_set (AtkObject *accessible)
981
{
982
  AtkObjectClass *klass;
983

            
984
3810
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
985

            
986
3810
  klass = ATK_OBJECT_GET_CLASS (accessible);
987
3810
  if (klass->ref_state_set)
988
3810
    return (klass->ref_state_set) (accessible);
989
  else
990
    return NULL;
991
}
992

            
993
/**
994
 * atk_object_get_index_in_parent:
995
 * @accessible: an #AtkObject
996
 *
997
 * Gets the 0-based index of this accessible in its parent; returns -1 if the
998
 * accessible does not have an accessible parent.
999
 *
 * Returns: an integer which is the index of the accessible in its parent
 **/
gint
1428
atk_object_get_index_in_parent (AtkObject *accessible)
{
  AtkObjectClass *klass;
1428
  g_return_val_if_fail (ATK_OBJECT (accessible), -1);
1428
  klass = ATK_OBJECT_GET_CLASS (accessible);
1428
  if (klass->get_index_in_parent)
1428
    return (klass->get_index_in_parent) (accessible);
  else
    return -1;
}
/**
 * atk_object_set_name:
 * @accessible: an #AtkObject
 * @name: a character string to be set as the accessible name
 *
 * Sets the accessible name of the accessible. You can't set the name
 * to NULL. This is reserved for the initial value. In this aspect
 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
 * a empty value you can use "".
 **/
void
1595
atk_object_set_name (AtkObject *accessible,
                     const gchar *name)
{
  AtkObjectClass *klass;
1595
  gboolean notify = FALSE;
1595
  g_return_if_fail (ATK_IS_OBJECT (accessible));
1595
  g_return_if_fail (name != NULL);
1595
  klass = ATK_OBJECT_GET_CLASS (accessible);
1595
  if (klass->set_name)
    {
      /* Do not notify for initial name setting. See bug 665870 */
1595
      notify = (accessible->name != NULL);
1595
      (klass->set_name) (accessible, name);
1595
      if (notify)
        g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
    }
}
/**
 * atk_object_set_description:
 * @accessible: an #AtkObject
 * @description: a character string to be set as the accessible description
 *
 * Sets the accessible description of the accessible. You can't set
 * the description to NULL. This is reserved for the initial value. In
 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
 * the name to a empty value you can use "".
 **/
void
1595
atk_object_set_description (AtkObject *accessible,
                            const gchar *description)
{
  AtkObjectClass *klass;
1595
  gboolean notify = FALSE;
1595
  g_return_if_fail (ATK_IS_OBJECT (accessible));
1595
  g_return_if_fail (description != NULL);
1595
  klass = ATK_OBJECT_GET_CLASS (accessible);
1595
  if (klass->set_description)
    {
      /* Do not notify for initial name setting. See bug 665870 */
1595
      notify = (accessible->description != NULL);
1595
      (klass->set_description) (accessible, description);
1595
      if (notify)
        g_object_notify (G_OBJECT (accessible),
                         atk_object_name_property_description);
    }
}
/**
 * atk_object_set_parent:
 * @accessible: an #AtkObject
 * @parent: an #AtkObject to be set as the accessible parent
 *
 * Sets the accessible parent of the accessible. @parent can be NULL.
 **/
void
1434
atk_object_set_parent (AtkObject *accessible,
                       AtkObject *parent)
{
  AtkObjectClass *klass;
1434
  g_return_if_fail (ATK_IS_OBJECT (accessible));
1434
  klass = ATK_OBJECT_GET_CLASS (accessible);
1434
  if (klass->set_parent)
    {
1434
      (klass->set_parent) (accessible, parent);
1434
      g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
    }
}
/**
 * atk_object_set_role:
 * @accessible: an #AtkObject
 * @role: an #AtkRole to be set as the role
 *
 * Sets the role of the accessible.
 **/
void
1595
atk_object_set_role (AtkObject *accessible,
                     AtkRole role)
{
  AtkObjectClass *klass;
  AtkRole old_role;
1595
  g_return_if_fail (ATK_IS_OBJECT (accessible));
1595
  klass = ATK_OBJECT_GET_CLASS (accessible);
1595
  if (klass->set_role)
    {
1595
      old_role = atk_object_get_role (accessible);
1595
      if (old_role != role)
        {
1595
          (klass->set_role) (accessible, role);
1595
          if (old_role != ATK_ROLE_UNKNOWN)
            /* Do not notify for initial role setting */
            g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
        }
    }
}
/**
 * atk_object_connect_property_change_handler: (skip)
 * @accessible: an #AtkObject
 * @handler: a function to be called when a property changes its value
 *
 * Calls @handler on property changes.
 *
 * Returns: a #guint which is the handler id used in
 *   atk_object_remove_property_change_handler()
 *
 * Deprecated: 2.12: Connect directly to #AtkObject::property-change or
 *   the relevant #GObject::notify signal for each desired property.
 */
guint
atk_object_connect_property_change_handler (AtkObject *accessible,
                                            AtkPropertyChangeHandler *handler)
{
  AtkObjectClass *klass;
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
  g_return_val_if_fail ((handler != NULL), 0);
  klass = ATK_OBJECT_GET_CLASS (accessible);
  if (klass->connect_property_change_handler)
    return (klass->connect_property_change_handler) (accessible, handler);
  else
    return 0;
}
/**
 * atk_object_remove_property_change_handler:
 * @accessible: an #AtkObject
 * @handler_id: a guint which identifies the handler to be removed.
 *
 * Removes a property change handler.
 *
 * Deprecated: 2.12: See atk_object_connect_property_change_handler()
 */
void
atk_object_remove_property_change_handler (AtkObject *accessible,
                                           guint handler_id)
{
  AtkObjectClass *klass;
  g_return_if_fail (ATK_IS_OBJECT (accessible));
  klass = ATK_OBJECT_GET_CLASS (accessible);
  if (klass->remove_property_change_handler)
    (klass->remove_property_change_handler) (accessible, handler_id);
}
/**
 * atk_object_notify_state_change:
 * @accessible: an #AtkObject
 * @state: an #AtkState whose state is changed
 * @value: a gboolean which indicates whether the state is being set on or off
 *
 * Emits a state-change signal for the specified state.
 *
 * Note that as a general rule when the state of an existing object changes,
 * emitting a notification is expected.
 **/
void
atk_object_notify_state_change (AtkObject *accessible,
                                AtkState state,
                                gboolean value)
{
  const gchar *name;
  g_return_if_fail (ATK_IS_OBJECT (accessible));
  name = atk_state_type_get_name (state);
  g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
                 g_quark_from_string (name),
                 name, value, NULL);
}
/**
 * atk_implementor_ref_accessible:
 * @implementor: The #GObject instance which should implement #AtkImplementorIface
 * if a non-null return value is required.
 *
 * Gets a reference to an object's #AtkObject implementation, if
 * the object implements #AtkObjectIface
 *
 * Returns: (transfer full): a reference to an object's #AtkObject
 * implementation
 */
AtkObject *
atk_implementor_ref_accessible (AtkImplementor *implementor)
{
  AtkImplementorIface *iface;
  AtkObject *accessible = NULL;
  g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor), NULL);
  iface = ATK_IMPLEMENTOR_GET_IFACE (implementor);
  if (iface != NULL)
    accessible = iface->ref_accessible (implementor);
  g_return_val_if_fail ((accessible != NULL), NULL);
  return accessible;
}
/**
 * atk_object_get_attributes:
 * @accessible: An #AtkObject.
 *
 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
 * as distinct from strongly-typed object data available via other get/set methods.
 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
 *
 * Since: 1.12
 *
 * Returns: (transfer full): an #AtkAttributeSet consisting of all
 * explicit properties/annotations applied to the object, or an empty
 * set if the object has no name-value pair attributes assigned to
 * it. This #atkattributeset should be freed by a call to
 * atk_attribute_set_free().
 */
AtkAttributeSet *
9
atk_object_get_attributes (AtkObject *accessible)
{
  AtkObjectClass *klass;
9
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
9
  klass = ATK_OBJECT_GET_CLASS (accessible);
9
  if (klass->get_attributes)
9
    return (klass->get_attributes) (accessible);
  else
    return NULL;
}
static AtkRelationSet *
2
atk_object_real_ref_relation_set (AtkObject *accessible)
{
2
  g_return_val_if_fail (accessible->relation_set, NULL);
2
  g_object_ref (accessible->relation_set);
2
  return accessible->relation_set;
}
static void
6380
atk_object_real_set_property (GObject *object,
                              guint prop_id,
                              const GValue *value,
                              GParamSpec *pspec)
{
  AtkObject *accessible;
6380
  accessible = ATK_OBJECT (object);
6380
  switch (prop_id)
    {
1595
    case PROP_NAME:
1595
      atk_object_set_name (accessible, g_value_get_string (value));
1595
      break;
1595
    case PROP_DESCRIPTION:
1595
      atk_object_set_description (accessible, g_value_get_string (value));
1595
      break;
1595
    case PROP_ROLE:
1595
      atk_object_set_role (accessible, g_value_get_enum (value));
1595
      break;
    case PROP_PARENT:
      atk_object_set_parent (accessible, g_value_get_object (value));
      break;
    case PROP_VALUE:
      if (ATK_IS_VALUE (accessible))
        atk_value_set_current_value (ATK_VALUE (accessible), value);
      break;
    case PROP_TABLE_SUMMARY:
      if (ATK_IS_TABLE (accessible))
        atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
      break;
    case PROP_TABLE_CAPTION_OBJECT:
      if (ATK_IS_TABLE (accessible))
        atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
      break;
    case PROP_ACCESSIBLE_ID:
      atk_object_set_accessible_id (accessible, g_value_get_string (value));
      break;
1595
    case PROP_HELP_TEXT:
1595
      atk_object_set_help_text (accessible, g_value_get_string (value));
1595
      break;
    default:
      break;
    }
6380
}
static void
7814
atk_object_real_get_property (GObject *object,
                              guint prop_id,
                              GValue *value,
                              GParamSpec *pspec)
{
  AtkObject *accessible;
7814
  accessible = ATK_OBJECT (object);
7814
  switch (prop_id)
    {
1595
    case PROP_NAME:
1595
      g_value_set_string (value, atk_object_get_name (accessible));
1595
      break;
1595
    case PROP_DESCRIPTION:
1595
      g_value_set_string (value, atk_object_get_description (accessible));
1595
      break;
1595
    case PROP_ROLE:
1595
      g_value_set_enum (value, atk_object_get_role (accessible));
1595
      break;
    case PROP_LAYER:
      if (ATK_IS_COMPONENT (accessible))
        g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
      break;
    case PROP_MDI_ZORDER:
      if (ATK_IS_COMPONENT (accessible))
        g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
      break;
1434
    case PROP_PARENT:
1434
      g_value_set_object (value, atk_object_get_parent (accessible));
1434
      break;
    case PROP_VALUE:
      if (ATK_IS_VALUE (accessible))
        atk_value_get_current_value (ATK_VALUE (accessible), value);
      break;
    case PROP_TABLE_SUMMARY:
      if (ATK_IS_TABLE (accessible))
        g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
      break;
    case PROP_TABLE_CAPTION_OBJECT:
      if (ATK_IS_TABLE (accessible))
        g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
      break;
    case PROP_HYPERTEXT_NUM_LINKS:
      if (ATK_IS_HYPERTEXT (accessible))
        g_value_set_int (value, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible)));
      break;
    case PROP_ACCESSIBLE_ID:
      g_value_set_string (value, atk_object_get_accessible_id (accessible));
      break;
1595
    case PROP_HELP_TEXT:
1595
      g_value_set_string (value, atk_object_get_help_text (accessible));
1595
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
7814
}
static void
325
atk_object_finalize (GObject *object)
{
  AtkObject *accessible;
  AtkObjectPrivate *private;
325
  g_return_if_fail (ATK_IS_OBJECT (object));
325
  accessible = ATK_OBJECT (object);
325
  private = atk_object_get_instance_private (accessible);
325
  g_free (accessible->name);
325
  g_free (accessible->description);
  /*
   * Free memory allocated for relation set if it have been allocated.
   */
325
  if (accessible->relation_set)
325
    g_object_unref (accessible->relation_set);
325
  if (accessible->accessible_parent)
    g_object_unref (accessible->accessible_parent);
325
  g_free (private->accessible_id);
325
  g_free (private->help_text);
325
  G_OBJECT_CLASS (parent_class)->finalize (object);
}
static const gchar *
3508
atk_object_real_get_name (AtkObject *object)
{
3508
  return object->name;
}
static const gchar *
3019
atk_object_real_get_description (AtkObject *object)
{
3019
  return object->description;
}
static AtkObject *
5723
atk_object_real_get_parent (AtkObject *object)
{
5723
  return atk_object_peek_parent (object);
}
static AtkRole
8793
atk_object_real_get_role (AtkObject *object)
{
8793
  return object->role;
}
static AtkLayer
atk_object_real_get_layer (AtkObject *object)
{
  return object->layer;
}
static AtkStateSet *
atk_object_real_ref_state_set (AtkObject *accessible)
{
  AtkStateSet *state_set;
  AtkObject *focus_object;
  state_set = atk_state_set_new ();
  focus_object = atk_get_focus_object ();
  if (focus_object == accessible)
    atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
  return state_set;
}
static void
1595
atk_object_real_set_name (AtkObject *object,
                          const gchar *name)
{
1595
  g_free (object->name);
1595
  object->name = g_strdup (name);
1595
}
static void
1595
atk_object_real_set_description (AtkObject *object,
                                 const gchar *description)
{
1595
  g_free (object->description);
1595
  object->description = g_strdup (description);
1595
}
static void
1434
atk_object_real_set_parent (AtkObject *object,
                            AtkObject *parent)
{
1434
  if (object->accessible_parent)
    g_object_unref (object->accessible_parent);
1434
  object->accessible_parent = parent;
1434
  if (object->accessible_parent)
1434
    g_object_ref (object->accessible_parent);
1434
}
static void
1595
atk_object_real_set_role (AtkObject *object,
                          AtkRole role)
{
1595
  object->role = role;
1595
}
/**
 * atk_object_initialize:
 * @accessible: a #AtkObject
 * @data: a #gpointer which identifies the object for which the AtkObject was created.
 *
 * This function is called when implementing subclasses of #AtkObject.
 * It does initialization required for the new object. It is intended
 * that this function should called only in the ..._new() functions used
 * to create an instance of a subclass of #AtkObject
 **/
void
atk_object_initialize (AtkObject *accessible,
                       gpointer data)
{
  AtkObjectClass *klass;
  g_return_if_fail (ATK_IS_OBJECT (accessible));
  klass = ATK_OBJECT_GET_CLASS (accessible);
  if (klass->initialize)
    klass->initialize (accessible, data);
}
/*
 * This function is a signal handler for notify signal which gets emitted
 * when a property changes value.
 *
 * It constructs an AtkPropertyValues structure and emits a "property_changed"
 * signal which causes the user specified AtkPropertyChangeHandler
 * to be called.
 */
static void
7814
atk_object_notify (GObject *obj,
                   GParamSpec *pspec)
{
7814
  AtkPropertyValues values = {
    NULL,
  };
7814
  g_value_init (&values.new_value, pspec->value_type);
7814
  g_object_get_property (obj, pspec->name, &values.new_value);
7814
  values.property_name = pspec->name;
7814
  g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
                 g_quark_from_string (pspec->name),
                 &values, NULL);
7814
  g_value_unset (&values.new_value);
7814
}
/**
 * atk_role_get_name:
 * @role: The #AtkRole whose name is required
 *
 * Gets the description string describing the #AtkRole @role.
 *
 * Returns: the string describing the AtkRole
 */
const gchar *
3
atk_role_get_name (AtkRole role)
{
  g_return_val_if_fail (role >= 0, NULL);
3
  if (!role_names)
1
    initialize_role_names ();
3
  if (role < role_names->len)
2
    return g_ptr_array_index (role_names, role);
1
  return NULL;
}
/**
 * atk_role_get_localized_name:
 * @role: The #AtkRole whose localized name is required
 *
 * Gets the localized description string describing the #AtkRole @role.
 *
 * Returns: the localized string describing the AtkRole
 **/
const gchar *
atk_role_get_localized_name (AtkRole role)
{
  _gettext_initialization ();
  return dgettext (GETTEXT_PACKAGE, atk_role_get_name (role));
}
static const gchar *
1
atk_object_real_get_object_locale (AtkObject *object)
{
1
  return setlocale (LC_MESSAGES, NULL);
}
/**
 * atk_object_get_object_locale:
 * @accessible: an #AtkObject
 *
 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
 * of @accessible.
 *
 * Since: 2.8
 *
 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
 *          locale of @accessible.
 **/
const gchar *
1
atk_object_get_object_locale (AtkObject *accessible)
{
  AtkObjectClass *klass;
1
  g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
1
  klass = ATK_OBJECT_GET_CLASS (accessible);
1
  if (klass->get_object_locale)
1
    return (klass->get_object_locale) (accessible);
  else
    return NULL;
}
/**
 * atk_role_for_name:
 * @name: a string which is the (non-localized) name of an ATK role.
 *
 * Get the #AtkRole type corresponding to a rolew name.
 *
 * Returns: the #AtkRole enumerated type corresponding to the specified name,
 *          or #ATK_ROLE_INVALID if no matching role is found.
 **/
AtkRole
1597
atk_role_for_name (const gchar *name)
{
1597
  AtkRole role = ATK_ROLE_INVALID;
  gint i;
1597
  g_return_val_if_fail (name, ATK_ROLE_INVALID);
1597
  if (!role_names)
161
    initialize_role_names ();
66852
  for (i = 0; i < role_names->len; i++)
    {
66851
      gchar *role_name = (gchar *) g_ptr_array_index (role_names, i);
66851
      g_return_val_if_fail (role_name, ATK_ROLE_INVALID);
66851
      if (strcmp (name, role_name) == 0)
        {
1596
          role = i;
1596
          break;
        }
    }
1597
  return role;
}
/**
 * atk_object_add_relationship:
 * @object: The #AtkObject to which an AtkRelation is to be added.
 * @relationship: The #AtkRelationType of the relation
 * @target: The #AtkObject which is to be the target of the relation.
 *
 * Adds a relationship of the specified type with the specified target.
 *
 * Returns: TRUE if the relationship is added.
 **/
gboolean
1
atk_object_add_relationship (AtkObject *object,
                             AtkRelationType relationship,
                             AtkObject *target)
{
  AtkObject *array[1];
  AtkRelation *relation;
1
  g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1
  g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1
  if (atk_relation_set_contains_target (object->relation_set,
                                        relationship, target))
    return FALSE;
1
  array[0] = target;
1
  relation = atk_relation_new (array, 1, relationship);
1
  atk_relation_set_add (object->relation_set, relation);
1
  g_object_unref (relation);
1
  return TRUE;
}
/**
 * atk_object_remove_relationship:
 * @object: The #AtkObject from which an AtkRelation is to be removed.
 * @relationship: The #AtkRelationType of the relation
 * @target: The #AtkObject which is the target of the relation to be removed.
 *
 * Removes a relationship of the specified type with the specified target.
 *
 * Returns: TRUE if the relationship is removed.
 **/
gboolean
1
atk_object_remove_relationship (AtkObject *object,
                                AtkRelationType relationship,
                                AtkObject *target)
{
1
  gboolean ret = FALSE;
  AtkRelation *relation;
  GPtrArray *array;
1
  g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1
  g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1
  relation = atk_relation_set_get_relation_by_type (object->relation_set, relationship);
1
  if (relation)
    {
1
      ret = atk_relation_remove_target (relation, target);
1
      array = atk_relation_get_target (relation);
1
      if (!array || array->len == 0)
1
        atk_relation_set_remove (object->relation_set, relation);
    }
1
  return ret;
}
/**
 * atk_object_get_accessible_id:
 * @accessible: an #AtkObject
 *
 * Gets the accessible id of the accessible.
 *
 * Since: 2.34
 *
 * Returns: a character string representing the accessible id of the object, or
 * NULL if no such string was set.
 **/
const gchar *
atk_object_get_accessible_id (AtkObject *accessible)
{
  AtkObjectPrivate *private = atk_object_get_instance_private (accessible);
  return private->accessible_id;
}
/**
 * atk_object_set_accessible_id:
 * @accessible: an #AtkObject
 * @id: a character string to be set as the accessible id
 *
 * Sets the accessible ID of the accessible.  This is not meant to be presented
 * to the user, but to be an ID which is stable over application development.
 * Typically, this is the gtkbuilder ID. Such an ID will be available for
 * instance to identify a given well-known accessible object for tailored screen
 * reading, or for automatic regression testing.
 *
 * Since: 2.34
 **/
void
atk_object_set_accessible_id (AtkObject *accessible, const gchar *id)
{
  AtkObjectPrivate *private = atk_object_get_instance_private (accessible);
  g_free (private->accessible_id);
  private->accessible_id = g_strdup (id);
}
/**
 * atk_object_get_help_text:
 * @accessible: an #AtkObject
 *
 * Gets the help text associated with the accessible.
 *
 * Since: 2.52
 *
 * Returns: a character string representing the help text or the object, or
 * NULL if no such string was set.
 **/
const gchar *
1596
atk_object_get_help_text (AtkObject *accessible)
{
1596
  AtkObjectPrivate *private = atk_object_get_instance_private (accessible);
1596
  return private->help_text;
}
/**
 * atk_object_set_help_text:
 * @accessible: an #AtkObject
 * @help_text: a character string to be set as the accessible's help text
 *
 * Sets the help text associated with the accessible. This can be used to
 * expose context-sensitive information to help a user understand how to
 * interact with the object.
 *
 * Since: 2.52
 **/
void
1595
atk_object_set_help_text (AtkObject *accessible, const gchar *help_text)
{
1595
  AtkObjectPrivate *private = atk_object_get_instance_private (accessible);
1595
  g_free (private->help_text);
private
1595
  ->help_text = g_strdup (help_text);
1595
}
static void
atk_object_real_initialize (AtkObject *accessible,
                            gpointer data)
{
  return;
}