1 /* ATK - Accessibility Toolkit
2 * Copyright (C) 2009 Novell, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
27 * @Short_description: Toplevel for embedding into other processes
35 static void atk_component_interface_init (AtkComponentIface *iface);
41 static gint AtkPlug_private_offset;
43 G_DEFINE_TYPE_WITH_CODE (AtkPlug, atk_plug, ATK_TYPE_OBJECT,
44 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
45 G_ADD_PRIVATE(AtkPlug))
48 atk_plug_ref_child (AtkObject *obj, int i)
50 AtkPlugPrivate *private = atk_plug_get_instance_private (ATK_PLUG (obj));
56 child = private->child;
61 return g_object_ref (child);
65 atk_plug_get_n_children (AtkObject *obj)
67 AtkPlugPrivate *private = atk_plug_get_instance_private (ATK_PLUG (obj));
69 if (private->child == NULL)
76 atk_plug_ref_state_set (AtkObject *obj)
78 AtkPlugPrivate *private = atk_plug_get_instance_private (ATK_PLUG (obj));
81 child = private->child;
86 return atk_object_ref_state_set (child);
90 atk_plug_init (AtkPlug* obj)
92 AtkObject *accessible = ATK_OBJECT (obj);
94 accessible->role = ATK_ROLE_FILLER;
95 accessible->layer = ATK_LAYER_WIDGET;
99 atk_plug_class_init (AtkPlugClass* klass)
101 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
103 if (AtkPlug_private_offset != 0)
104 g_type_class_adjust_private_offset (klass, &AtkPlug_private_offset);
106 klass->get_object_id = NULL;
108 class->get_n_children = atk_plug_get_n_children;
109 class->ref_child = atk_plug_ref_child;
110 class->ref_state_set = atk_plug_ref_state_set;
114 atk_component_interface_init (AtkComponentIface *iface)
121 * Creates a new #AtkPlug instance.
123 * Returns: (transfer full): the newly created #AtkPlug
130 return g_object_new (ATK_TYPE_PLUG, NULL);
134 * atk_plug_set_child:
135 * @plug: an #AtkPlug to be set as accessible parent of @child.
136 * @child: an #AtkObject to be set as accessible child of @plug.
138 * Sets @child as accessible child of @plug and @plug as accessible parent of
139 * @child. @child can be NULL.
141 * In some cases, one can not use the AtkPlug type directly as accessible
142 * object for the toplevel widget of the application. For instance in the gtk
143 * case, GtkPlugAccessible can not inherit both from GtkWindowAccessible and
144 * from AtkPlug. In such a case, one can create, in addition to the standard
145 * accessible object for the toplevel widget, an AtkPlug object, and make the
146 * former the child of the latter by calling atk_plug_set_child().
151 atk_plug_set_child (AtkPlug *plug, AtkObject *child)
153 AtkPlugPrivate *private = atk_plug_get_instance_private (plug);
156 atk_object_set_parent (private->child, NULL);
158 private->child = child;
161 atk_object_set_parent (child, ATK_OBJECT(plug));
168 * Gets the unique ID of an #AtkPlug object, which can be used to
169 * embed inside of an #AtkSocket using atk_socket_embed().
171 * Internally, this calls a class function that should be registered
172 * by the IPC layer (usually at-spi2-atk). The implementor of an
173 * #AtkPlug object should call this function (after atk-bridge is
174 * loaded) and pass the value to the process implementing the
175 * #AtkSocket, so it could embed the plug.
177 * Returns: the unique ID for the plug
182 atk_plug_get_id (AtkPlug* plug)
186 g_return_val_if_fail (ATK_IS_PLUG (plug), NULL);
188 klass = g_type_class_peek (ATK_TYPE_PLUG);
190 if (klass && klass->get_object_id)
191 return (klass->get_object_id) (plug);