Debian Codegraph @

clutter/cally/cally-clone.c

raw
1 /* CALLY - The Clutter Accessibility Implementation Library
2 *
3 * Copyright (C) 2010 Igalia, S.L.
4 *
5 * Author: Alejandro PiƱeiro Iglesias <[email protected]>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23 /**
24 * SECTION:cally-clone
25 * @Title: CallyClone
26 * @short_description: Implementation of the ATK interfaces for a #ClutterClone
27 * @see_also: #ClutterClone
28 *
29 * #CallyClone implements the required ATK interfaces of #ClutterClone
30 *
31 * In particular it sets a proper role for the clone, as just a image,
32 * as it is the sanest and simplest approach.
33 */
34
35 /* Design rationale for CallyClone:
36 *
37 * In the old times, it was just ClutterCloneTexture. So, from a a11y POV
38 * CallyCloneTexture was just another image, like ClutterTexture, and if
39 * it was a clone was irrevelant. So on cally-0.8, CallyCloneTexture
40 * expose a object with role ATK_ROLE_IMAGE. But now, ClutterClone is more
41 * general. You can clone any object, including groups, and made things
42 * like have one text entry, and a clone with different properties in the
43 * same window, updated both at once.
44 *
45 * The question is if the idea is have a ClutterClone as a "first-class"
46 * citizen inside the stage hierarchy (full clone), or it is just supposed
47 * to be a mirror image of the original object.
48 *
49 * In the case of the a11y POV this would mean that if the text changes on
50 * the source, the clone should emit as well the text-changing signals.
51 *
52 * As ClutterClone smartly just paint the same object with different
53 * parameters, this would mean that it should be the cally object the one
54 * that should replicate the source clutter hierarchy to do that,
55 * something that just sound crazy.
56 *
57 * Taking into account that:
58 *
59 * - ClutterClone doesn't re-emit mirrored signals from the source
60 * I think that likely the answer would be "yes, it is just a
61 * mirrored image, not a real full clone".
62 *
63 * - You can't interact directly with the clone (ie: focus, and so on).
64 * Its basic usage (right now) is clone textures.
65 *
66 * Any other solution could be overwhelming.
67 *
68 * I think that the final solution would be that ClutterClone from the
69 * a11y POV should still be managed as a image (with the proper properties,
70 * position, size, etc.).
71 */
72 #include "config.h"
73
74 #include "cally-clone.h"
75 #include "cally-actor-private.h"
76
77 /* AtkObject */
78 static void cally_clone_real_initialize (AtkObject *obj,
79 gpointer data);
80
81 G_DEFINE_TYPE (CallyClone, cally_clone, CALLY_TYPE_ACTOR)
82
83 static void
84 cally_clone_class_init (CallyCloneClass *klass)
85 {
86 /* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */
87 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
88
89 class->initialize = cally_clone_real_initialize;
90 }
91
92 static void
93 cally_clone_init (CallyClone *clone)
94 {
95 /* nothing to do yet */
96 }
97
98 /**
99 * cally_clone_new:
100 * @actor: a #ClutterActor
101 *
102 * Creates a new #CallyClone for the given @actor. @actor must be a
103 * #ClutterClone.
104 *
105 * Return value: the newly created #AtkObject
106 *
107 * Since: 1.4
108 */
109 AtkObject*
110 cally_clone_new (ClutterActor *actor)
111 {
112 GObject *object = NULL;
113 AtkObject *accessible = NULL;
114
115 g_return_val_if_fail (CLUTTER_IS_CLONE (actor), NULL);
116
117 object = g_object_new (CALLY_TYPE_CLONE, NULL);
118
119 accessible = ATK_OBJECT (object);
120 atk_object_initialize (accessible, actor);
121
122 return accessible;
123 }
124
125 static void
126 cally_clone_real_initialize (AtkObject *obj,
127 gpointer data)
128 {
129 ATK_OBJECT_CLASS (cally_clone_parent_class)->initialize (obj, data);
130
131 obj->role = ATK_ROLE_IMAGE;
132 }