Add Cally

The Clutter Accessibility Library is an implementation of the ATK,
the Accessibility Toolkit, which exposes Clutter actors to accessibility
tools. This allows not only writing accessible user interfaces, but also
allows testing and verification frameworks based on A11Y technologies to
inspect and test a Clutter scene graph.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2097

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
Alejandro Piñeiro 2010-06-14 13:38:25 +02:00 committed by Emmanuele Bassi
parent b9c65510cb
commit c0f753d108
24 changed files with 5126 additions and 3 deletions

View File

@ -2,7 +2,7 @@ include $(top_srcdir)/build/autotools/Makefile.am.silent
NULL =
SUBDIRS = cogl $(CLUTTER_WINSYS_BASE) $(CLUTTER_WINSYS)
SUBDIRS = cogl $(CLUTTER_WINSYS_BASE) $(CLUTTER_WINSYS) cally
if LOCAL_JSON_GLIB
SUBDIRS += json
@ -12,7 +12,7 @@ clutter_json_libadd = $(top_builddir)/clutter/json/libclutter-json.la
clutter_json_gir = ClutterJson-@CLUTTER_API_VERSION@.gir
endif
DIST_SUBDIRS = glx egl cogl json osx x11 win32 fruity
DIST_SUBDIRS = glx egl cogl json osx x11 win32 fruity cally
# common definitions
CLEANFILES =
@ -39,6 +39,7 @@ endif # SUPPORT_WIN32
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter/cally \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/pango \
-I$(top_srcdir)/clutter \
@ -260,13 +261,16 @@ source_h_priv = \
libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_LIBADD = \
$(CLUTTER_LIBS) \
$(top_builddir)/clutter/cally/libcally.la \
$(top_builddir)/clutter/cogl/cogl/libclutter-cogl.la \
$(top_builddir)/clutter/cogl/pango/libcoglpango.la \
$(top_builddir)/clutter/$(CLUTTER_WINSYS)/libclutter-$(CLUTTER_WINSYS).la \
$(clutter_json_libadd) \
$(CLUTTER_WINSYS_BASE_LIB)
libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_DEPENDENCIES = \
$(top_builddir)/clutter/cally/libcally.la \
$(top_builddir)/clutter/cogl/cogl/libclutter-cogl.la \
$(top_builddir)/clutter/cogl/pango/libcoglpango.la \
$(top_builddir)/clutter/$(CLUTTER_WINSYS)/libclutter-$(CLUTTER_WINSYS).la \
@ -289,7 +293,7 @@ libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_LDFLAGS = \
$(CLUTTER_LT_LDFLAGS) \
$(GCOV_LDFLAGS) \
-export-dynamic \
-export-symbols-regex "^(clutter|cogl|json).*" \
-export-symbols-regex "^(clutter|cogl|cally|json).*" \
-rpath $(libdir) \
$(win32_resources_ldflag) \
$(NULL)

79
clutter/cally/Makefile.am Normal file
View File

@ -0,0 +1,79 @@
include $(top_srcdir)/build/autotools/Makefile.am.silent
EXTRA_DIST =
CLEANFILES =
DISTCLEANFILES =
# pkg-config ==================================================================
pc_files = \
cally-$(CLUTTER_API_VERSION).pc
cally-$(CLUTTER_API_VERSION).pc: cally.pc
$(QUIET_GEN)cp -f $< $(@F)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pc_files)
EXTRA_DIST += cally.pc.in
CLEANFILES += $(pc_files)
noinst_LTLIBRARIES = libcally.la
cally_h_sources = cally.h \
cally-actor.h \
cally-factory.h \
cally-group.h \
cally-rectangle.h \
cally-root.h \
cally-stage.h \
cally-text.h \
cally-texture.h \
cally-clone.h \
cally-util.h
cally_private_h_sources = cally-actor-private.h
cally_c_sources = cally.c \
cally-actor.c \
cally-group.c \
cally-rectangle.c \
cally-root.c \
cally-stage.c \
cally-text.c \
cally-texture.c \
cally-clone.c \
cally-util.c
libcally_la_SOURCES = \
$(cally_private_h_sources) \
$(cally_h_sources) \
$(cally_c_sources)
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/cally \
-I$(top_srcdir)/clutter/cogl
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Cally\" \
-DCLUTTER_COMPILATION \
-DVERSION=\"$(VERSION)\" \
$(CLUTTER_DEBUG_CFLAGS)
AM_CFLAGS = \
$(CLUTTER_CFLAGS) \
$(MAINTAINER_CFLAGS)
libcallydir=$(includedir)/clutter-@CLUTTER_API_VERSION@/cally
# In opposit to GAIL, CALLY exports all the headers. It will very
# unlikely in any real final clutter-based application to use only raw
# CALLY. In fact, after HAIL experience, probably export GAIL
# interfaces would be a good idea
libcally_HEADERS = \
$(cally_h_sources)
libcally_la_LIBADD = \
$(CLUTTER_LIBS)

View File

@ -0,0 +1,35 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_ACTOR_PRIVATE_H__
#define __CALLY_ACTOR_PRIVATE_H__
#include "cally-actor.h"
/*
* Auxiliar define, in order to get the clutter actor from the AtkObject using
* AtkGObject methods
*
*/
#define CALLY_GET_CLUTTER_ACTOR(cally_object) \
(CLUTTER_ACTOR (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (cally_object))))
#endif /* __CALLY_ACTOR_PRIVATE_H__ */

1491
clutter/cally/cally-actor.c Normal file

File diff suppressed because it is too large Load Diff

108
clutter/cally/cally-actor.h Normal file
View File

@ -0,0 +1,108 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* Some parts are based on GailWidget from GAIL
* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_ACTOR_H__
#define __CALLY_ACTOR_H__
#include <atk/atk.h>
#include <clutter/clutter.h>
G_BEGIN_DECLS
#define CALLY_TYPE_ACTOR (cally_actor_get_type ())
#define CALLY_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_ACTOR, CallyActor))
#define CALLY_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_ACTOR, CallyActorClass))
#define CALLY_IS_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_ACTOR))
#define CALLY_IS_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_ACTOR))
#define CALLY_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_ACTOR, CallyActorClass))
typedef struct _CallyActor CallyActor;
typedef struct _CallyActorClass CallyActorClass;
typedef struct _CallyActorPrivate CallyActorPrivate;
/**
* CallyActionFunc:
* @cally_actor: a #CallyActor
*
* Action func, to be used on AtkAction implementation as a individual
* action
*/
typedef void (*CallyActionFunc) (CallyActor *cally_actor);
struct _CallyActor
{
AtkGObjectAccessible parent;
/* < private > */
CallyActorPrivate *priv;
};
struct _CallyActorClass
{
AtkGObjectAccessibleClass parent_class;
/* Signal handler for notify signal on Clutter Actor */
void (*notify_clutter) (GObject *object,
GParamSpec *pspec);
/*
* Signal handler for key_focus_in and key_focus_out on Clutter Actor
*/
gboolean (*focus_clutter) (ClutterActor *actor,
gpointer data);
gint (*add_actor) (ClutterActor *container,
ClutterActor *actor,
gpointer data);
gint (*remove_actor) (ClutterActor *container,
ClutterActor *actor,
gpointer data);
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_actor_get_type (void);
AtkObject* cally_actor_new (ClutterActor *actor);
guint cally_actor_add_action (CallyActor *cally_actor,
const gchar *action_name,
const gchar *action_description,
const gchar *action_keybinding,
CallyActionFunc action_func);
gboolean cally_actor_remove_action (CallyActor *cally_actor,
gint action_id);
gboolean cally_actor_remove_action_by_name (CallyActor *cally_actor,
const gchar *action_name);
G_END_DECLS
#endif /* __CALLY_ACTOR_H__ */

105
clutter/cally/cally-clone.c Normal file
View File

@ -0,0 +1,105 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2010 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:callyclutterclone
* @short_description: Implementation of the ATK interfaces for a #ClutterClone
* @see_also: #ClutterClone
*
* #CallyClutterClone implements the required ATK interfaces of #ClutterClone
*
* In particular it sets a proper role for the clone, as just a image,
* as it is the sanest and simplest approach.
*
* Check http://lists.o-hand.com/clutter/3797.html for more information
*/
#include "cally-clone.h"
#include "cally-actor-private.h"
#define CALLY_CLONE_DEFAULT_DESCRIPTION "ClutterClone accessibility object"
static void cally_clone_class_init (CallyCloneClass *klass);
static void cally_clone_init (CallyClone *clone);
/* AtkObject */
static void cally_clone_real_initialize (AtkObject *obj,
gpointer data);
static G_CONST_RETURN gchar *cally_clone_get_description (AtkObject *obj);
G_DEFINE_TYPE (CallyClone, cally_clone, CALLY_TYPE_ACTOR)
static void
cally_clone_class_init (CallyCloneClass *klass)
{
/* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = cally_clone_real_initialize;
class->get_description = cally_clone_get_description;
}
static void
cally_clone_init (CallyClone *clone)
{
/* nothing to do yet */
}
AtkObject*
cally_clone_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_CLONE (actor), NULL);
object = g_object_new (CALLY_TYPE_CLONE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
static void
cally_clone_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (cally_clone_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_IMAGE;
}
static G_CONST_RETURN gchar *
cally_clone_get_description (AtkObject *obj)
{
G_CONST_RETURN gchar *description = NULL;
g_return_val_if_fail (CALLY_IS_CLONE (obj), NULL);
description = ATK_OBJECT_CLASS (cally_clone_parent_class)->get_description (obj);
if (description == NULL)
description = CALLY_CLONE_DEFAULT_DESCRIPTION;
return description;
}

View File

@ -0,0 +1,63 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2010 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_CLONE_H__
#define __CALLY_CLONE_H__
#include "cally-actor.h"
G_BEGIN_DECLS
#define CALLY_TYPE_CLONE (cally_clone_get_type ())
#define CALLY_CLONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_CLONE, CallyClone))
#define CALLY_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_CLONE, CallyCloneClass))
#define CALLY_IS_CLONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_CLONE))
#define CALLY_IS_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_CLONE))
#define CALLY_CLONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_CLONE, CallyCloneClass))
typedef struct _CallyClone CallyClone;
typedef struct _CallyCloneClass CallyCloneClass;
typedef struct _CallyClonePrivate CallyClonePrivate;
struct _CallyClone
{
CallyActor parent;
/* < private > */
CallyClonePrivate *priv;
};
struct _CallyCloneClass
{
CallyActorClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_clone_get_type (void);
AtkObject *cally_clone_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_CLONE_H__ */

View File

@ -0,0 +1,91 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* Based on gailfactory.h from GAIL
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _CALLY_FACTORY_H__
#define _CALLY_FACTORY_H__
#include <glib-object.h>
#include <atk/atkobject.h>
#define CALLY_ACCESSIBLE_FACTORY(type, type_as_function, opt_create_accessible) \
\
static GType \
type_as_function ## _factory_get_accessible_type (void) \
{ \
return type; \
} \
\
static AtkObject* \
type_as_function ## _factory_create_accessible (GObject *obj) \
{ \
ClutterActor *actor; \
AtkObject *accessible; \
\
g_return_val_if_fail (CLUTTER_ACTOR (obj), NULL); \
\
actor = CLUTTER_ACTOR (obj); \
\
accessible = opt_create_accessible (actor); \
\
return accessible; \
} \
\
static void \
type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass) \
{ \
klass->create_accessible = type_as_function ## _factory_create_accessible; \
klass->get_accessible_type = type_as_function ## _factory_get_accessible_type;\
} \
\
static GType \
type_as_function ## _factory_get_type (void) \
{ \
static GType t = 0; \
\
if (!t) \
{ \
char *name; \
static const GTypeInfo tinfo = \
{ \
sizeof (AtkObjectFactoryClass), \
NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init, \
NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL \
}; \
\
name = g_strconcat (g_type_name (type), "Factory", NULL); \
t = g_type_register_static ( \
ATK_TYPE_OBJECT_FACTORY, name, &tinfo, 0); \
g_free (name); \
} \
\
return t; \
}
#define CALLY_ACTOR_SET_FACTORY(widget_type, type_as_function) \
atk_registry_set_factory_type (atk_get_default_registry (), \
widget_type, \
type_as_function ## _factory_get_type ())
#endif /* _CALLY_FACTORY_H__ */

138
clutter/cally/cally-group.c Normal file
View File

@ -0,0 +1,138 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* Based on GailContainer from GAIL
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:callycluttergroup
* @short_description: Implementation of the ATK interfaces for a #ClutterGroup
* @see_also: #ClutterGroup
*
* #CallyClutterGroup implements the required ATK interfaces of #ClutterGroup
* In particular it exposes:
* <itemizedlist>
* <listitem>Each of the Clutter actors contained in the Clutter Group.</listitem>
* </itemizedlist>
*/
#include "cally-group.h"
#include "cally-actor-private.h"
static void cally_group_class_init (CallyGroupClass *klass);
static void cally_group_init (CallyGroup *group);
static gint cally_group_get_n_children (AtkObject *obj);
static AtkObject* cally_group_ref_child (AtkObject *obj,
gint i);
static void cally_group_real_initialize (AtkObject *obj,
gpointer data);
G_DEFINE_TYPE (CallyGroup, cally_group, CALLY_TYPE_ACTOR)
static void
cally_group_class_init (CallyGroupClass *klass)
{
/* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_n_children = cally_group_get_n_children;
class->ref_child = cally_group_ref_child;
class->initialize = cally_group_real_initialize;
}
static void
cally_group_init (CallyGroup *group)
{
/* nothing to do yet */
}
AtkObject*
cally_group_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_GROUP (actor), NULL);
object = g_object_new (CALLY_TYPE_GROUP, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
static gint
cally_group_get_n_children (AtkObject *obj)
{
ClutterActor *actor = NULL;
gint count = 0;
g_return_val_if_fail (CALLY_IS_GROUP (obj), count);
actor = CALLY_GET_CLUTTER_ACTOR (obj);
if (actor == NULL) /* defunct */
return 0;
g_return_val_if_fail (CLUTTER_IS_GROUP(actor), count);
count = clutter_group_get_n_children (CLUTTER_GROUP (actor));
return count;
}
static AtkObject*
cally_group_ref_child (AtkObject *obj,
gint i)
{
AtkObject *accessible = NULL;
ClutterActor *actor = NULL;
ClutterActor *child = NULL;
g_return_val_if_fail (CALLY_IS_GROUP (obj), NULL);
g_return_val_if_fail ((i >= 0), NULL);
actor = CALLY_GET_CLUTTER_ACTOR (obj);
g_return_val_if_fail (CLUTTER_IS_GROUP(actor), NULL);
child = clutter_group_get_nth_child (CLUTTER_GROUP(actor), i);
if (!child)
return NULL;
accessible = clutter_actor_get_accessible (child);
if (accessible != NULL)
g_object_ref (accessible);
return accessible;
}
static void
cally_group_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (cally_group_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_PANEL;
}

View File

@ -0,0 +1,65 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* Based on GailContainer from GAIL
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_GROUP_H__
#define __CALLY_GROUP_H__
#include "cally-actor.h"
G_BEGIN_DECLS
#define CALLY_TYPE_GROUP (cally_group_get_type ())
#define CALLY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_GROUP, CallyGroup))
#define CALLY_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_GROUP, CallyGroupClass))
#define CALLY_IS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_GROUP))
#define CALLY_IS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_GROUP))
#define CALLY_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_GROUP, CallyGroupClass))
typedef struct _CallyGroup CallyGroup;
typedef struct _CallyGroupClass CallyGroupClass;
typedef struct _CallyGroupPrivate CallyGroupPrivate;
struct _CallyGroup
{
CallyActor parent;
/* < private > */
CallyGroupPrivate *priv;
};
struct _CallyGroupClass
{
CallyActorClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_group_get_type (void);
AtkObject* cally_group_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_GROUP_H__ */

View File

@ -0,0 +1,102 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:callyclutterrectangle
* @short_description: Implementation of the ATK interfaces for a #ClutterRectangle
* @see_also: #ClutterRectangle
*
* #CallyClutterRectangle implements the required ATK interfaces of #ClutterRectangle
*
* In particular it sets a proper role for the rectangle.
*/
#include "cally-rectangle.h"
#include "cally-actor-private.h"
#define CALLY_RECTANGLE_DEFAULT_DESCRIPTION "A rectangle"
static void cally_rectangle_class_init (CallyRectangleClass *klass);
static void cally_rectangle_init (CallyRectangle *rectangle);
/* AtkObject */
static void cally_rectangle_real_initialize (AtkObject *obj,
gpointer data);
static G_CONST_RETURN gchar *cally_rectangle_get_description (AtkObject *obj);
G_DEFINE_TYPE (CallyRectangle, cally_rectangle, CALLY_TYPE_ACTOR)
static void
cally_rectangle_class_init (CallyRectangleClass *klass)
{
/* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = cally_rectangle_real_initialize;
class->get_description = cally_rectangle_get_description;
}
static void
cally_rectangle_init (CallyRectangle *rectangle)
{
/* nothing to do yet */
}
AtkObject*
cally_rectangle_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_RECTANGLE (actor), NULL);
object = g_object_new (CALLY_TYPE_RECTANGLE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
static void
cally_rectangle_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (cally_rectangle_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_IMAGE;
}
static G_CONST_RETURN gchar *
cally_rectangle_get_description (AtkObject *obj)
{
G_CONST_RETURN gchar *description = NULL;
g_return_val_if_fail (CALLY_IS_RECTANGLE (obj), NULL);
description = ATK_OBJECT_CLASS (cally_rectangle_parent_class)->get_description (obj);
if (description == NULL)
description = CALLY_RECTANGLE_DEFAULT_DESCRIPTION;
return description;
}

View File

@ -0,0 +1,63 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_RECTANGLE_H__
#define __CALLY_RECTANGLE_H__
#include "cally-actor.h"
G_BEGIN_DECLS
#define CALLY_TYPE_RECTANGLE (cally_rectangle_get_type ())
#define CALLY_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_RECTANGLE, CallyRectangle))
#define CALLY_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_RECTANGLE, CallyRectangleClass))
#define CALLY_IS_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_RECTANGLE))
#define CALLY_IS_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_RECTANGLE))
#define CALLY_RECTANGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_RECTANGLE, CallyRectangleClass))
typedef struct _CallyRectangle CallyRectangle;
typedef struct _CallyRectangleClass CallyRectangleClass;
typedef struct _CallyRectanglePrivate CallyRectanglePrivate;
struct _CallyRectangle
{
CallyActor parent;
/* < private > */
CallyRectanglePrivate *priv;
};
struct _CallyRectangleClass
{
CallyActorClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_rectangle_get_type (void);
AtkObject* cally_rectangle_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_RECTANGLE_H__ */

273
clutter/cally/cally-root.c Normal file
View File

@ -0,0 +1,273 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:callyroot
* @short_description: Root object for the CALLY toolkit
* @see_also: #ClutterStage
*
* #CallyRoot is the root object of the accessibility tree-like
* hierarchy, exposing the application level.
*
* Somewhat equivalent to GailTopLevel. We consider that this class
* expose the a11y information of the ClutterStageManager, as the
* children of this object are the different ClutterStage managed (so
* the GObject used in the atk_object_initialize is the
* ClutterStageManager).
*
*/
#include <clutter/clutter.h>
#include "cally-root.h"
/* GObject */
static void cally_root_class_init (CallyRootClass *klass);
static void cally_root_init (CallyRoot *root);
static void cally_root_finalize (GObject *object);
/* AtkObject.h */
static void cally_root_initialize (AtkObject *accessible,
gpointer data);
static gint cally_root_get_n_children (AtkObject *obj);
static AtkObject *cally_root_ref_child (AtkObject *obj,
gint i);
static AtkObject *cally_root_get_parent (AtkObject *obj);
/* Private */
static void cally_util_stage_added_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data);
static void cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data);
#define CALLY_ROOT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CALLY_TYPE_ROOT, CallyRootPrivate))
G_DEFINE_TYPE (CallyRoot, cally_root, ATK_TYPE_GOBJECT_ACCESSIBLE)
struct _CallyRootPrivate
{
/* We save the CallyStage objects. Other option could save the stage
* list, and then just get the a11y object on the ref_child, etc. But
* the ref_child is more common that the init and the stage-add,
* stage-remove, so we avoid getting the accessible object
* constantly
*/
GSList *stage_list;
/* signals id */
guint stage_added_id;
guint stage_removed_id;
};
static void
cally_root_class_init (CallyRootClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = cally_root_finalize;
/* AtkObject */
class->get_n_children = cally_root_get_n_children;
class->ref_child = cally_root_ref_child;
class->get_parent = cally_root_get_parent;
class->initialize = cally_root_initialize;
g_type_class_add_private (gobject_class, sizeof (CallyRootPrivate));
}
static void
cally_root_init (CallyRoot *root)
{
root->priv = CALLY_ROOT_GET_PRIVATE (root);
root->priv->stage_list = NULL;
root->priv->stage_added_id = 0;
root->priv->stage_removed_id = 0;
}
AtkObject*
cally_root_new (void)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
ClutterStageManager *stage_manager = NULL;
object = g_object_new (CALLY_TYPE_ROOT, NULL);
accessible = ATK_OBJECT (object);
stage_manager = clutter_stage_manager_get_default ();
atk_object_initialize (accessible, stage_manager);
return accessible;
}
static void
cally_root_finalize (GObject *object)
{
CallyRoot *root = CALLY_ROOT (object);
GObject *stage_manager = NULL;
g_return_if_fail (CALLY_IS_ROOT (object));
if (root->priv->stage_list)
{
g_slist_free (root->priv->stage_list);
root->priv->stage_list = NULL;
}
stage_manager = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (root));
g_signal_handler_disconnect (stage_manager,
root->priv->stage_added_id);
g_signal_handler_disconnect (stage_manager,
root->priv->stage_added_id);
G_OBJECT_CLASS (cally_root_parent_class)->finalize (object);
}
/* AtkObject.h */
static void
cally_root_initialize (AtkObject *accessible,
gpointer data)
{
ClutterStageManager *stage_manager = NULL;
const GSList *iter = NULL;
const GSList *stage_list = NULL;
ClutterStage *clutter_stage = NULL;
AtkObject *cally_stage = NULL;
CallyRoot *root = NULL;
accessible->role = ATK_ROLE_APPLICATION;
accessible->name = g_get_prgname();
accessible->accessible_parent = NULL;
/* children initialization */
root = CALLY_ROOT (accessible);
stage_manager = CLUTTER_STAGE_MANAGER (data);
stage_list = clutter_stage_manager_peek_stages (stage_manager);
for (iter = stage_list; iter != NULL; iter = g_slist_next (iter))
{
clutter_stage = CLUTTER_STAGE (iter->data);
cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (clutter_stage));
root->priv->stage_list = g_slist_append (root->priv->stage_list,
cally_stage);
}
root->priv->stage_added_id =
g_signal_connect (G_OBJECT (stage_manager), "stage-added",
G_CALLBACK (cally_util_stage_added_cb), root);
root->priv->stage_removed_id =
g_signal_connect (G_OBJECT (stage_manager), "stage-removed",
G_CALLBACK (cally_util_stage_removed_cb), root);
ATK_OBJECT_CLASS (cally_root_parent_class)->initialize (accessible, data);
}
static gint
cally_root_get_n_children (AtkObject *obj)
{
CallyRoot *root = CALLY_ROOT (obj);
return g_slist_length (root->priv->stage_list);
}
static AtkObject*
cally_root_ref_child (AtkObject *obj,
gint i)
{
CallyRoot *cally_root = NULL;
GSList *stage_list = NULL;
gint num = 0;
AtkObject *item = NULL;
cally_root = CALLY_ROOT (obj);
stage_list = cally_root->priv->stage_list;
num = g_slist_length (stage_list);
g_return_val_if_fail ((i < num)&&(i >= 0), NULL);
item = g_slist_nth_data (stage_list, i);
if (!item)
{
return NULL;
}
g_object_ref (item);
return item;
}
static AtkObject*
cally_root_get_parent (AtkObject *obj)
{
return NULL;
}
/* -------------------------------- PRIVATE --------------------------------- */
static void
cally_util_stage_added_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data)
{
CallyRoot *root = CALLY_ROOT (data);
AtkObject *cally_stage = NULL;
gint index = -1;
cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
root->priv->stage_list = g_slist_append (root->priv->stage_list,
cally_stage);
index = g_slist_index (root->priv->stage_list, cally_stage);
g_signal_emit_by_name (root, "children_changed::add",
index, cally_stage, NULL);
}
static void
cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data)
{
CallyRoot *root = CALLY_ROOT (data);
AtkObject *cally_stage = NULL;
gint index = -1;
cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
index = g_slist_index (root->priv->stage_list, cally_stage);
root->priv->stage_list = g_slist_remove (root->priv->stage_list,
cally_stage);
index = g_slist_index (root->priv->stage_list, cally_stage);
g_signal_emit_by_name (root, "children_changed::remove",
index, cally_stage, NULL);
}

View File

@ -0,0 +1,64 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_ROOT_H__
#define __CALLY_ROOT_H__
#include <atk/atk.h>
G_BEGIN_DECLS
#define CALLY_TYPE_ROOT (cally_root_get_type ())
#define CALLY_ROOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_ROOT, CallyRoot))
#define CALLY_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_ROOT, CallyRootClass))
#define CALLY_IS_ROOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_ROOT))
#define CALLY_IS_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_ROOT))
#define CALLY_ROOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_ROOT, CallyRootClass))
typedef struct _CallyRoot CallyRoot;
typedef struct _CallyRootClass CallyRootClass;
typedef struct _CallyRootPrivate CallyRootPrivate;
struct _CallyRoot
{
AtkGObjectAccessible parent;
/* < private > */
CallyRootPrivate *priv;
};
struct _CallyRootClass
{
AtkGObjectAccessibleClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_root_get_type (void);
AtkObject *cally_root_new (void);
G_END_DECLS
#endif /* __CALLY_ROOT_H__ */

258
clutter/cally/cally-stage.c Normal file
View File

@ -0,0 +1,258 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:callystage
* @short_description: Implementation of the ATK interfaces for a #ClutterStage
* @see_also: #ClutterStage
*
* #CallyStage implements the required ATK interfaces of #ClutterStage
*
*/
#include "cally-stage.h"
#include "cally-actor-private.h"
enum {
ACTIVATE,
CREATE,
DEACTIVATE,
DESTROY,
LAST_SIGNAL
};
static guint cally_stage_signals [LAST_SIGNAL] = { 0, };
static void cally_stage_class_init (CallyStageClass *klass);
static void cally_stage_init (CallyStage *stage);
/* AtkObject.h */
static G_CONST_RETURN gchar *cally_stage_get_name (AtkObject *obj);
static G_CONST_RETURN gchar *cally_stage_get_description (AtkObject *obj);
static void cally_stage_real_initialize (AtkObject *obj,
gpointer data);
static AtkStateSet* cally_stage_ref_state_set (AtkObject *obj);
/* Auxiliar */
static void cally_stage_activate_cb (ClutterStage *stage,
gpointer data);
static void cally_stage_deactivate_cb (ClutterStage *stage,
gpointer data);
#define CALLY_STAGE_DEFAULT_NAME "Stage"
#define CALLY_STAGE_DEFAULT_DESCRIPTION "Top level 'window' on which child actors are placed and manipulated"
G_DEFINE_TYPE (CallyStage, cally_stage, CALLY_TYPE_GROUP);
#define CALLY_STAGE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CALLY_TYPE_STAGE, CallyStagePrivate))
struct _CallyStagePrivate
{
gboolean active;
};
static void
cally_stage_class_init (CallyStageClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
/* CallyActorClass *cally_class = CALLY_ACTOR_CLASS (klass); */
/* AtkObject */
class->get_name = cally_stage_get_name;
class->get_description = cally_stage_get_description;
class->initialize = cally_stage_real_initialize;
class->ref_state_set = cally_stage_ref_state_set;
g_type_class_add_private (gobject_class, sizeof (CallyStagePrivate));
cally_stage_signals [ACTIVATE] =
g_signal_new ("activate",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, /* default signal handler */
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
cally_stage_signals [CREATE] =
g_signal_new ("create",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, /* default signal handler */
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
cally_stage_signals [DEACTIVATE] =
g_signal_new ("deactivate",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, /* default signal handler */
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
cally_stage_signals [DESTROY] =
g_signal_new ("destroy",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, /* default signal handler */
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
cally_stage_init (CallyStage *cally_stage)
{
CallyStagePrivate *priv = CALLY_STAGE_GET_PRIVATE (cally_stage);
cally_stage->priv = priv;
priv->active = FALSE;
}
AtkObject*
cally_stage_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_STAGE (actor), NULL);
object = g_object_new (CALLY_TYPE_STAGE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
/* AtkObject.h */
static G_CONST_RETURN gchar *
cally_stage_get_name (AtkObject *obj)
{
G_CONST_RETURN gchar *name = NULL;
g_return_val_if_fail (CALLY_IS_STAGE (obj), NULL);
/* parent name */
name = ATK_OBJECT_CLASS (cally_stage_parent_class)->get_name (obj);
if (name == NULL)
name = CALLY_STAGE_DEFAULT_NAME;
return name;
}
static G_CONST_RETURN gchar *
cally_stage_get_description (AtkObject *obj)
{
G_CONST_RETURN gchar *description = NULL;
g_return_val_if_fail (CALLY_IS_STAGE (obj), NULL);
/* parent description */
description = ATK_OBJECT_CLASS (cally_stage_parent_class)->get_description (obj);
if (description == NULL)
description = CALLY_STAGE_DEFAULT_DESCRIPTION;
return description;
}
static void
cally_stage_real_initialize (AtkObject *obj,
gpointer data)
{
ClutterStage *stage = NULL;
g_return_if_fail (CALLY_IS_STAGE (obj));
ATK_OBJECT_CLASS (cally_stage_parent_class)->initialize (obj, data);
stage = CLUTTER_STAGE (CALLY_GET_CLUTTER_ACTOR (obj));
g_signal_connect (stage, "activate", G_CALLBACK (cally_stage_activate_cb), obj);
g_signal_connect (stage, "deactivate", G_CALLBACK (cally_stage_deactivate_cb), obj);
obj->role = ATK_ROLE_CANVAS;
}
static AtkStateSet*
cally_stage_ref_state_set (AtkObject *obj)
{
CallyStage *cally_stage = NULL;
AtkStateSet *state_set = NULL;
ClutterStage *stage = NULL;
g_return_val_if_fail (CALLY_IS_STAGE (obj), NULL);
cally_stage = CALLY_STAGE (obj);
state_set = ATK_OBJECT_CLASS (cally_stage_parent_class)->ref_state_set (obj);
stage = CLUTTER_STAGE (CALLY_GET_CLUTTER_ACTOR (cally_stage));
if (stage == NULL)
return state_set;
if (cally_stage->priv->active)
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
return state_set;
}
/* Auxiliar */
static void
cally_stage_activate_cb (ClutterStage *stage,
gpointer data)
{
CallyStage *cally_stage = NULL;
g_return_if_fail (CALLY_IS_STAGE (data));
cally_stage = CALLY_STAGE (data);
cally_stage->priv->active = TRUE;
atk_object_notify_state_change (ATK_OBJECT (cally_stage),
ATK_STATE_ACTIVE, TRUE);
g_signal_emit (cally_stage, cally_stage_signals [ACTIVATE], 0);
}
static void
cally_stage_deactivate_cb (ClutterStage *stage,
gpointer data)
{
CallyStage *cally_stage = NULL;
g_return_if_fail (CALLY_IS_STAGE (data));
cally_stage = CALLY_STAGE (data);
cally_stage->priv->active = FALSE;
atk_object_notify_state_change (ATK_OBJECT (cally_stage),
ATK_STATE_ACTIVE, FALSE);
g_signal_emit (cally_stage, cally_stage_signals [DEACTIVATE], 0);
}

View File

@ -0,0 +1,62 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_STAGE_H__
#define __CALLY_STAGE_H__
#include "cally-group.h"
G_BEGIN_DECLS
#define CALLY_TYPE_STAGE (cally_stage_get_type ())
#define CALLY_STAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_STAGE, CallyStage))
#define CALLY_STAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_STAGE, CallyStageClass))
#define CALLY_IS_STAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_STAGE))
#define CALLY_IS_STAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_STAGE))
#define CALLY_STAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_STAGE, CallyStageClass))
typedef struct _CallyStage CallyStage;
typedef struct _CallyStageClass CallyStageClass;
typedef struct _CallyStagePrivate CallyStagePrivate;
struct _CallyStage
{
CallyGroup parent;
/* < private > */
CallyStagePrivate *priv;
};
struct _CallyStageClass
{
CallyGroupClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_stage_get_type (void);
AtkObject *cally_stage_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_STAGE_H__ */

1255
clutter/cally/cally-text.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_TEXT_H__
#define __CALLY_TEXT_H__
#include "cally-actor.h"
G_BEGIN_DECLS
#define CALLY_TYPE_TEXT (cally_text_get_type ())
#define CALLY_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_TEXT, CallyText))
#define CALLY_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_TEXT, CallyTextClass))
#define CALLY_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_TEXT))
#define CALLY_IS_TEXT_CLASS(klass)(G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_TEXT))
#define CALLY_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_TEXT, CallyTextClass))
typedef struct _CallyText CallyText;
typedef struct _CallyTextClass CallyTextClass;
typedef struct _CallyTextPrivate CallyTextPrivate;
struct _CallyText
{
CallyActor parent;
/* < private > */
CallyTextPrivate *priv;
};
struct _CallyTextClass
{
CallyActorClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_text_get_type (void);
AtkObject* cally_text_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_TEXT_H__ */

View File

@ -0,0 +1,103 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:callycluttertexture
* @short_description: Implementation of the ATK interfaces for a #ClutterTexture
* @see_also: #ClutterTexture
*
* #CallyClutterTexture implements the required ATK interfaces of #ClutterTexture
*
* In particular it sets a proper role for the texture.
*/
#include "cally-texture.h"
#include "cally-actor-private.h"
#define CALLY_TEXTURE_DEFAULT_DESCRIPTION "A texture"
static void cally_texture_class_init (CallyTextureClass *klass);
static void cally_texture_init (CallyTexture *texture);
/* AtkObject */
static void cally_texture_real_initialize (AtkObject *obj,
gpointer data);
static G_CONST_RETURN gchar *cally_texture_get_description (AtkObject *obj);
G_DEFINE_TYPE (CallyTexture, cally_texture, CALLY_TYPE_ACTOR)
static void
cally_texture_class_init (CallyTextureClass *klass)
{
/* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = cally_texture_real_initialize;
class->get_description = cally_texture_get_description;
}
static void
cally_texture_init (CallyTexture *texture)
{
/* nothing to do yet */
}
AtkObject*
cally_texture_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_TEXTURE (actor), NULL);
object = g_object_new (CALLY_TYPE_TEXTURE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
static void
cally_texture_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (cally_texture_parent_class)->initialize (obj, data);
/* default role */
obj->role = ATK_ROLE_IMAGE;
}
static G_CONST_RETURN gchar *
cally_texture_get_description (AtkObject *obj)
{
G_CONST_RETURN gchar *description = NULL;
g_return_val_if_fail (CALLY_IS_TEXTURE (obj), NULL);
description = ATK_OBJECT_CLASS (cally_texture_parent_class)->get_description (obj);
if (description == NULL)
description = CALLY_TEXTURE_DEFAULT_DESCRIPTION;
return description;
}

View File

@ -0,0 +1,63 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_TEXTURE_H__
#define __CALLY_TEXTURE_H__
#include "cally-actor.h"
G_BEGIN_DECLS
#define CALLY_TYPE_TEXTURE (cally_texture_get_type ())
#define CALLY_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_TEXTURE, CallyTexture))
#define CALLY_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_TEXTURE, CallyTextureClass))
#define CALLY_IS_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_TEXTURE))
#define CALLY_IS_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_TEXTURE))
#define CALLY_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_TEXTURE, CallyTextureClass))
typedef struct _CallyTexture CallyTexture;
typedef struct _CallyTextureClass CallyTextureClass;
typedef struct _CallyTexturePrivate CallyTexturePrivate;
struct _CallyTexture
{
CallyActor parent;
/* < private > */
CallyTexturePrivate *priv;
};
struct _CallyTextureClass
{
CallyActorClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_texture_get_type (void);
AtkObject *cally_texture_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_TEXTURE_H__ */

557
clutter/cally/cally-util.c Normal file
View File

@ -0,0 +1,557 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* Based on GailUtil from GAIL
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <clutter/clutter.h>
#include "cally-util.h"
#include "cally-root.h"
#include "cally-stage.h"
#ifdef HAVE_CLUTTER_X11
#include <X11/extensions/XKB.h>
#endif
static void cally_util_class_init (CallyUtilClass *klass);
static void cally_util_init (CallyUtil *cally_util);
/* atkutil.h */
static guint cally_util_add_global_event_listener (GSignalEmissionHook listener,
const gchar* event_type);
static void cally_util_remove_global_event_listener (guint remove_listener);
static guint cally_util_add_key_event_listener (AtkKeySnoopFunc listener,
gpointer data);
static void cally_util_remove_key_event_listener (guint remove_listener);
static AtkObject* cally_util_get_root (void);
static G_CONST_RETURN gchar *cally_util_get_toolkit_name (void);
static G_CONST_RETURN gchar *cally_util_get_toolkit_version (void);
/* private */
static void _listener_info_destroy (gpointer data);
static guint add_listener (GSignalEmissionHook listener,
const gchar *object_type,
const gchar *signal,
const gchar *hook_data);
static void cally_util_simulate_snooper_install (void);
static void cally_util_simulate_snooper_remove (void);
static gboolean cally_key_snooper (ClutterActor *actor,
ClutterEvent *event,
gpointer user_data);
static void cally_util_stage_added_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data);
static void cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data);
static gboolean notify_hf (gpointer key,
gpointer value,
gpointer data);
static void insert_hf (gpointer key,
gpointer value,
gpointer data);
static AtkKeyEventStruct * atk_key_event_from_clutter_event_key (ClutterKeyEvent *event);
static void do_window_event_initialization (void);
/* This is just a copy of the Gail one, a shared library or place to
define it could be a good idea. */
typedef struct _CallyUtilListenerInfo CallyUtilListenerInfo;
typedef struct _CallyKeyEventInfo CallyKeyEventInfo;
struct _CallyUtilListenerInfo
{
gint key;
guint signal_id;
gulong hook_id;
};
struct _CallyKeyEventInfo
{
AtkKeySnoopFunc listener;
gpointer func_data;
};
static AtkObject* root = NULL;
static GHashTable *listener_list = NULL;
static GHashTable *key_listener_list = NULL;
static gint listener_idx = 1;
G_DEFINE_TYPE (CallyUtil, cally_util, ATK_TYPE_UTIL);
static void
cally_util_class_init (CallyUtilClass *klass)
{
AtkUtilClass *atk_class;
gpointer data;
data = g_type_class_peek (ATK_TYPE_UTIL);
atk_class = ATK_UTIL_CLASS (data);
atk_class->add_global_event_listener = cally_util_add_global_event_listener;
atk_class->remove_global_event_listener = cally_util_remove_global_event_listener;
atk_class->add_key_event_listener = cally_util_add_key_event_listener;
atk_class->remove_key_event_listener = cally_util_remove_key_event_listener;
atk_class->get_root = cally_util_get_root;
atk_class->get_toolkit_name = cally_util_get_toolkit_name;
atk_class->get_toolkit_version = cally_util_get_toolkit_version;
/* FIXME: Instead of create this on the class, I think that would
worth to implement CallyUtil as a singleton instance, so the
class methods will access this instance. This will be a good
future enhancement, meanwhile, just using the same *working*
implementation used on GailUtil */
listener_list = g_hash_table_new_full (g_int_hash, g_int_equal, NULL,
_listener_info_destroy);
}
static void
cally_util_init (CallyUtil *cally_util)
{
/* instance init: usually not required */
}
/* ------------------------------ ATK UTIL METHODS -------------------------- */
static AtkObject*
cally_util_get_root (void)
{
if (!root)
root = cally_root_new ();
return root;
}
static G_CONST_RETURN gchar *
cally_util_get_toolkit_name (void)
{
return "CALLY";
}
static G_CONST_RETURN gchar *
cally_util_get_toolkit_version (void)
{
/*
* FIXME:
* Version is passed in as a -D flag when this file is
* compiled.
*/
return "0.1";
}
static guint
cally_util_add_global_event_listener (GSignalEmissionHook listener,
const gchar *event_type)
{
guint rc = 0;
gchar **split_string;
split_string = g_strsplit (event_type, ":", 3);
if (split_string)
{
if (!strcmp ("window", split_string[0]))
{
/* Using ClutterStage as the window equivalent, although
several methods (move, etc) are missing. This would be
probably defined for other window-related classes (MxWindow)
FIXME: for this reason, this process should be extendable
on the future.*/
static gboolean initialized = FALSE;
if (initialized == FALSE)
{
do_window_event_initialization ();
initialized = TRUE;
}
rc = add_listener (listener, "CallyStage", split_string[1], event_type);
}
else
{
rc = add_listener (listener, split_string[1], split_string[2], event_type);
}
g_strfreev (split_string);
}
return rc;
}
static void
cally_util_remove_global_event_listener (guint remove_listener)
{
if (remove_listener > 0)
{
CallyUtilListenerInfo *listener_info;
gint tmp_idx = remove_listener;
listener_info = (CallyUtilListenerInfo *)
g_hash_table_lookup(listener_list, &tmp_idx);
if (listener_info != NULL)
{
/* Hook id of 0 and signal id of 0 are invalid */
if (listener_info->hook_id != 0 && listener_info->signal_id != 0)
{
/* Remove the emission hook */
g_signal_remove_emission_hook(listener_info->signal_id,
listener_info->hook_id);
/* Remove the element from the hash */
g_hash_table_remove(listener_list, &tmp_idx);
}
else
{
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
listener_info->hook_id, listener_info->signal_id);
}
}
else
{
g_warning("No listener with the specified listener id %d",
remove_listener);
}
}
else
{
g_warning("Invalid listener_id %d", remove_listener);
}
}
static guint
cally_util_add_key_event_listener (AtkKeySnoopFunc listener,
gpointer data)
{
static guint key=0;
CallyKeyEventInfo *event_info = NULL;
if (!key_listener_list)
{
key_listener_list = g_hash_table_new_full (NULL, NULL, NULL, g_free);
cally_util_simulate_snooper_install ();
}
event_info = g_new (CallyKeyEventInfo, 1);
event_info->listener = listener;
event_info->func_data = data;
g_hash_table_insert (key_listener_list, GUINT_TO_POINTER (key++), event_info);
/* XXX: we don't check to see if n_listeners > MAXUINT */
return key - 1;
}
static void
cally_util_remove_key_event_listener (guint remove_listener)
{
if (!g_hash_table_remove (key_listener_list, GUINT_TO_POINTER (remove_listener))) {
g_warning ("Not able to remove listener with id %i", remove_listener);
}
if (g_hash_table_size (key_listener_list) == 0)
{
cally_util_simulate_snooper_remove ();
}
}
/* ------------------------------ PRIVATE FUNCTIONS ------------------------- */
static void
_listener_info_destroy (gpointer data)
{
g_free(data);
}
static guint
add_listener (GSignalEmissionHook listener,
const gchar *object_type,
const gchar *signal,
const gchar *hook_data)
{
GType type;
guint signal_id;
gint rc = 0;
type = g_type_from_name (object_type);
if (type)
{
signal_id = g_signal_lookup (signal, type);
if (signal_id > 0)
{
CallyUtilListenerInfo *listener_info;
rc = listener_idx;
listener_info = g_new (CallyUtilListenerInfo, 1);
listener_info->key = listener_idx;
listener_info->hook_id =
g_signal_add_emission_hook (signal_id, 0, listener,
g_strdup (hook_data),
(GDestroyNotify) g_free);
listener_info->signal_id = signal_id;
g_hash_table_insert(listener_list, &(listener_info->key), listener_info);
listener_idx++;
}
else
{
/* This is mainly because some "window:xxx" methods not
implemented on CallyStage */
g_debug ("Signal type %s not supported\n", signal);
}
}
else
{
g_warning("Invalid object type %s\n", object_type);
}
return rc;
}
/* Trying to emulate gtk_key_snooper install (a kind of wrapper). This
could be implemented without it, but I will maintain it in this
way, so if in the future clutter implements it natively it would be
easier the transition */
static void
cally_util_simulate_snooper_install (void)
{
ClutterStageManager *stage_manager = NULL;
ClutterStage *stage = NULL;
GSList *stage_list = NULL;
GSList *iter = NULL;
stage_manager = clutter_stage_manager_get_default ();
stage_list = clutter_stage_manager_list_stages (stage_manager);
for (iter = stage_list; iter != NULL; iter = g_slist_next (iter))
{
stage = CLUTTER_STAGE (iter->data);
g_signal_connect (G_OBJECT (stage), "captured-event",
G_CALLBACK (cally_key_snooper), NULL);
}
g_signal_connect (G_OBJECT (stage_manager), "stage-added",
G_CALLBACK (cally_util_stage_added_cb), cally_key_snooper);
g_signal_connect (G_OBJECT (stage_manager), "stage-removed",
G_CALLBACK (cally_util_stage_removed_cb), cally_key_snooper);
}
static void
cally_util_simulate_snooper_remove (void)
{
ClutterStageManager *stage_manager = NULL;
ClutterStage *stage = NULL;
GSList *stage_list = NULL;
GSList *iter = NULL;
gint num = 0;
stage_manager = clutter_stage_manager_get_default ();
stage_list = clutter_stage_manager_list_stages (stage_manager);
for (iter = stage_list; iter != NULL; iter = g_slist_next (iter))
{
stage = CLUTTER_STAGE (iter->data);
num += g_signal_handlers_disconnect_by_func (stage, cally_key_snooper, NULL);
}
g_signal_handlers_disconnect_by_func (G_OBJECT (stage_manager),
G_CALLBACK (cally_util_stage_added_cb),
cally_key_snooper);
g_signal_handlers_disconnect_by_func (G_OBJECT (stage_manager),
G_CALLBACK (cally_util_stage_removed_cb),
cally_key_snooper);
#ifdef CALLY_DEBUG
g_print ("Number of snooper callbacks disconnected: %i\n", num);
#endif
}
static AtkKeyEventStruct *
atk_key_event_from_clutter_event_key (ClutterKeyEvent *clutter_event)
{
AtkKeyEventStruct *atk_event = g_new0 (AtkKeyEventStruct, 1);
gunichar key_unichar;
switch (clutter_event->type)
{
case CLUTTER_KEY_PRESS:
atk_event->type = ATK_KEY_EVENT_PRESS;
break;
case CLUTTER_KEY_RELEASE:
atk_event->type = ATK_KEY_EVENT_RELEASE;
break;
default:
g_assert_not_reached ();
return NULL;
}
atk_event->state = clutter_event->modifier_state;
/* We emit the clutter keyval. This is not exactly the one expected
by AtkKeyEventStruct, as it expects a Gdk-like event, with the
modifiers applied. But to avoid a dependency to gdk, we delegate
that on the AT application.
More information: Bug 1952 and bug 2072
*/
atk_event->keyval = clutter_event->keyval;
/* It is expected to store a key defining string here (ie "Space" in
case you press a space). Anyway, there are no function on clutter
to obtain that, and we want to avoid a gdk dependency here, so we
delegate on the AT application to obtain that string using the
rest of the data on the ATK event struct.
More information: Bug 1952 and 2072
*/
key_unichar = clutter_event_get_key_unicode ((ClutterEvent *) clutter_event);
if (g_unichar_validate (key_unichar) && !g_unichar_iscntrl (key_unichar))
{
GString *new = NULL;
new = g_string_new ("");
new = g_string_insert_unichar (new, 0, key_unichar);
atk_event->string = new->str;
g_string_free (new, FALSE);
}
else
atk_event->string = NULL;
atk_event->length = 0;
atk_event->keycode = clutter_event->hardware_keycode;
atk_event->timestamp = clutter_event->time;
#ifdef CALLY_DEBUG
g_debug ("CallyKeyEvent:\tsym 0x%x\n\t\tmods %x\n\t\tcode %u\n\t\ttime %lx \n\t\tstring %s\n",
(unsigned int) atk_event->keyval,
(unsigned int) atk_event->state,
(unsigned int) atk_event->keycode,
(unsigned long int) atk_event->timestamp,
atk_event->string);
#endif
return atk_event;
}
static gboolean
notify_hf (gpointer key, gpointer value, gpointer data)
{
CallyKeyEventInfo *info = (CallyKeyEventInfo *) value;
AtkKeyEventStruct *key_event = (AtkKeyEventStruct *)data;
return (*(AtkKeySnoopFunc) info->listener) (key_event, info->func_data) ? TRUE : FALSE;
}
static void
insert_hf (gpointer key, gpointer value, gpointer data)
{
GHashTable *new_table = (GHashTable *) data;
g_hash_table_insert (new_table, key, value);
}
static gboolean
cally_key_snooper (ClutterActor *actor,
ClutterEvent *event,
gpointer user_data)
{
AtkKeyEventStruct *key_event = NULL;
gint consumed = 0;
/* filter key events */
if ((event->type != CLUTTER_KEY_PRESS) && (event->type != CLUTTER_KEY_RELEASE))
{
return FALSE;
}
if (key_listener_list)
{
GHashTable *new_hash = g_hash_table_new (NULL, NULL);
g_hash_table_foreach (key_listener_list, insert_hf, new_hash);
key_event = atk_key_event_from_clutter_event_key ((ClutterKeyEvent *)event);
/* func data is inside the hash table */
consumed = g_hash_table_foreach_steal (new_hash, notify_hf, key_event);
g_hash_table_destroy (new_hash);
}
g_free (key_event->string);
g_free (key_event);
return (consumed ? 1 : 0);
}
static void
cally_util_stage_added_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data)
{
GCallback cally_key_snooper = G_CALLBACK (data);
AtkObject *cally_stage = NULL;
g_signal_connect (G_OBJECT (stage), "captured-event", cally_key_snooper, NULL);
cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
if (cally_stage != NULL)
g_signal_emit_by_name (G_OBJECT(cally_stage), "create", 0);
}
static void
cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
ClutterStage *stage,
gpointer data)
{
GCallback cally_key_snooper = G_CALLBACK (data);
gint num = 0;
AtkObject *cally_stage = NULL;
num = g_signal_handlers_disconnect_by_func (stage, cally_key_snooper, NULL);
cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
if (cally_stage != NULL)
g_signal_emit_by_name (G_OBJECT(cally_stage), "destroy", 0);
}
static void
do_window_event_initialization (void)
{
/*
* Ensure that CallyStageClass exists.
*/
g_type_class_unref (g_type_class_ref (CALLY_TYPE_STAGE));
}

View File

@ -0,0 +1,61 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2008 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __CALLY_UTIL_H__
#define __CALLY_UTIL_H__
#include <atk/atk.h>
G_BEGIN_DECLS
#define CALLY_TYPE_UTIL (cally_util_get_type ())
#define CALLY_UTIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_UTIL, CallyUtil))
#define CALLY_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_UTIL, CallyUtilClass))
#define CALLY_IS_UTIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_UTIL))
#define CALLY_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_UTIL))
#define CALLY_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_UTIL, CallyUtilClass))
typedef struct _CallyUtil CallyUtil;
typedef struct _CallyUtilClass CallyUtilClass;
typedef struct _CallyUtilPrivate CallyUtilPrivate;
struct _CallyUtil
{
AtkUtil parent;
/* < private > */
CallyUtilPrivate *priv;
};
struct _CallyUtilClass
{
AtkUtilClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[30];
};
GType cally_util_get_type (void);
G_END_DECLS
#endif /* __CALLY_UTIL_H__ */

18
clutter/cally/cally.pc.in Normal file
View File

@ -0,0 +1,18 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
apiversion=@CLUTTER_API_VERSION@
requires=@CLUTTER_REQUIRES@
backend=@COGL_WINSYS@ #only kept for backward compatability
winsys=@COGL_WINSYS@
cogl=@COGL_DRIVER@ #only kept for backward compatability
driver=@COGL_DRIVER@
Name: Cally
Description: Clutter Accessibility Implementation Library
Version: @VERSION@
Requires: atk clutter-1.0
Libs: -L${libdir} -lclutter-${winsys}-${apiversion}
Cflags: -I${includedir}/clutter-${apiversion}
Requires: ${requires}

View File

@ -1017,6 +1017,8 @@ AC_CONFIG_FILES([
clutter/osx/Makefile
clutter/win32/Makefile
clutter/win32/clutter-win32.pc
clutter/cally/Makefile
clutter/cally/cally.pc
clutter/cogl/Makefile
clutter/cogl/cogl/Makefile
clutter/cogl/cogl/cogl-defines.h