| 1 |
/* CALLY - The Clutter Accessibility Implementation Library |
| 2 |
* |
| 3 |
* Copyright (C) 2008 Igalia, S.L. |
| 4 |
* |
| 5 |
* Author: Alejandro PiƱeiro Iglesias <[email protected]> |
| 6 |
* |
| 7 |
* Based on GailContainer from GAIL |
| 8 |
* Copyright 2001, 2002, 2003 Sun Microsystems Inc. |
| 9 |
* |
| 10 |
* This library is free software; you can redistribute it and/or |
| 11 |
* modify it under the terms of the GNU Lesser General Public |
| 12 |
* License as published by the Free Software Foundation; either |
| 13 |
* version 2 of the License, or (at your option) any later version. |
| 14 |
* |
| 15 |
* This library is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
* Lesser General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU Lesser General Public |
| 21 |
* License along with this library; if not, write to the |
| 22 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 23 |
* Boston, MA 02111-1307, USA. |
| 24 |
*/ |
| 25 |
|
| 26 |
/** |
| 27 |
* SECTION:cally-group |
| 28 |
* @Title: CallyGroup |
| 29 |
* @short_description: Implementation of the ATK interfaces for a #ClutterGroup |
| 30 |
* @see_also: #ClutterGroup |
| 31 |
* |
| 32 |
* #CallyGroup implements the required ATK interfaces of #ClutterGroup |
| 33 |
* In particular it exposes each of the Clutter actors contained in the |
| 34 |
* group. |
| 35 |
*/ |
| 36 |
|
| 37 |
#include "config.h" |
| 38 |
|
| 39 |
#include "cally-group.h" |
| 40 |
#include "cally-actor-private.h" |
| 41 |
|
| 42 |
static gint cally_group_get_n_children (AtkObject *obj); |
| 43 |
static AtkObject* cally_group_ref_child (AtkObject *obj, |
| 44 |
gint i); |
| 45 |
static void cally_group_real_initialize (AtkObject *obj, |
| 46 |
gpointer data); |
| 47 |
|
| 48 |
G_DEFINE_TYPE (CallyGroup, cally_group, CALLY_TYPE_ACTOR) |
| 49 |
|
| 50 |
static void |
| 51 |
cally_group_class_init (CallyGroupClass *klass) |
| 52 |
{ |
| 53 |
/* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */ |
| 54 |
AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
| 55 |
|
| 56 |
class->get_n_children = cally_group_get_n_children; |
| 57 |
class->ref_child = cally_group_ref_child; |
| 58 |
class->initialize = cally_group_real_initialize; |
| 59 |
} |
| 60 |
|
| 61 |
static void |
| 62 |
cally_group_init (CallyGroup *group) |
| 63 |
{ |
| 64 |
/* nothing to do yet */ |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* cally_group_new: |
| 69 |
* @actor: a #ClutterGroup |
| 70 |
* |
| 71 |
* Creates a #CallyGroup for @actor |
| 72 |
* |
| 73 |
* Return value: the newly created #CallyGroup |
| 74 |
* |
| 75 |
* Since: 1.4 |
| 76 |
*/ |
| 77 |
AtkObject * |
| 78 |
cally_group_new (ClutterActor *actor) |
| 79 |
{ |
| 80 |
GObject *object = NULL; |
| 81 |
AtkObject *accessible = NULL; |
| 82 |
|
| 83 |
g_return_val_if_fail (CLUTTER_IS_GROUP (actor), NULL); |
| 84 |
|
| 85 |
object = g_object_new (CALLY_TYPE_GROUP, NULL); |
| 86 |
|
| 87 |
accessible = ATK_OBJECT (object); |
| 88 |
atk_object_initialize (accessible, actor); |
| 89 |
|
| 90 |
return accessible; |
| 91 |
} |
| 92 |
|
| 93 |
static gint |
| 94 |
cally_group_get_n_children (AtkObject *obj) |
| 95 |
{ |
| 96 |
ClutterActor *actor = NULL; |
| 97 |
gint count = 0; |
| 98 |
|
| 99 |
g_return_val_if_fail (CALLY_IS_GROUP (obj), count); |
| 100 |
|
| 101 |
actor = CALLY_GET_CLUTTER_ACTOR (obj); |
| 102 |
|
| 103 |
if (actor == NULL) /* defunct */ |
| 104 |
return 0; |
| 105 |
|
| 106 |
g_return_val_if_fail (CLUTTER_IS_GROUP(actor), count); |
| 107 |
|
| 108 |
count = clutter_actor_get_n_children (actor); |
| 109 |
|
| 110 |
return count; |
| 111 |
} |
| 112 |
|
| 113 |
static AtkObject* |
| 114 |
cally_group_ref_child (AtkObject *obj, |
| 115 |
gint i) |
| 116 |
{ |
| 117 |
AtkObject *accessible = NULL; |
| 118 |
ClutterActor *actor = NULL; |
| 119 |
ClutterActor *child = NULL; |
| 120 |
|
| 121 |
g_return_val_if_fail (CALLY_IS_GROUP (obj), NULL); |
| 122 |
g_return_val_if_fail ((i >= 0), NULL); |
| 123 |
|
| 124 |
actor = CALLY_GET_CLUTTER_ACTOR (obj); |
| 125 |
|
| 126 |
g_return_val_if_fail (CLUTTER_IS_GROUP(actor), NULL); |
| 127 |
child = clutter_actor_get_child_at_index (actor, i); |
| 128 |
|
| 129 |
if (!child) |
| 130 |
return NULL; |
| 131 |
|
| 132 |
accessible = clutter_actor_get_accessible (child); |
| 133 |
|
| 134 |
if (accessible != NULL) |
| 135 |
g_object_ref (accessible); |
| 136 |
|
| 137 |
return accessible; |
| 138 |
} |
| 139 |
|
| 140 |
static void |
| 141 |
cally_group_real_initialize (AtkObject *obj, |
| 142 |
gpointer data) |
| 143 |
{ |
| 144 |
ATK_OBJECT_CLASS (cally_group_parent_class)->initialize (obj, data); |
| 145 |
|
| 146 |
obj->role = ATK_ROLE_PANEL; |
| 147 |
} |