| 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 gailfactory.h 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 |
#ifndef _CALLY_FACTORY_H__ |
| 27 |
#define _CALLY_FACTORY_H__ |
| 28 |
|
| 29 |
#include <glib-object.h> |
| 30 |
#include <atk/atkobject.h> |
| 31 |
|
| 32 |
/** |
| 33 |
* CALLY_ACCESSIBLE_FACTORY: |
| 34 |
* @type: GType of the accessible which is created by the factory |
| 35 |
* @type_as_function: prefix of the accessible object methods |
| 36 |
* @opt_create_accessible: method to instantiate the accessibility object |
| 37 |
* |
| 38 |
* Defines a new #AtkObjectFactory factory to create accessible |
| 39 |
* objects of a specific GType. It defines the factory GType and also |
| 40 |
* overrides the proper #AtkObjectFactory methods. |
| 41 |
* |
| 42 |
* It assumes that the accessibility object provides a |
| 43 |
* @opt_create_accessible method in order to create the accessibility |
| 44 |
* object. It returns a @type GType object. |
| 45 |
* |
| 46 |
* Since: 1.4 |
| 47 |
*/ |
| 48 |
#define CALLY_ACCESSIBLE_FACTORY(type, type_as_function, opt_create_accessible) \ |
| 49 |
\ |
| 50 |
static GType \ |
| 51 |
type_as_function ## _factory_get_accessible_type (void) \ |
| 52 |
{ \ |
| 53 |
return type; \ |
| 54 |
} \ |
| 55 |
\ |
| 56 |
static AtkObject* \ |
| 57 |
type_as_function ## _factory_create_accessible (GObject *obj) \ |
| 58 |
{ \ |
| 59 |
ClutterActor *actor; \ |
| 60 |
AtkObject *accessible; \ |
| 61 |
\ |
| 62 |
g_return_val_if_fail (CLUTTER_ACTOR (obj), NULL); \ |
| 63 |
\ |
| 64 |
actor = CLUTTER_ACTOR (obj); \ |
| 65 |
\ |
| 66 |
accessible = opt_create_accessible (actor); \ |
| 67 |
\ |
| 68 |
return accessible; \ |
| 69 |
} \ |
| 70 |
\ |
| 71 |
static void \ |
| 72 |
type_as_function ## _factory_class_init (AtkObjectFactoryClass *klass) \ |
| 73 |
{ \ |
| 74 |
klass->create_accessible = type_as_function ## _factory_create_accessible; \ |
| 75 |
klass->get_accessible_type = type_as_function ## _factory_get_accessible_type;\ |
| 76 |
} \ |
| 77 |
\ |
| 78 |
static GType \ |
| 79 |
type_as_function ## _factory_get_type (void) \ |
| 80 |
{ \ |
| 81 |
static GType t = 0; \ |
| 82 |
\ |
| 83 |
if (!t) \ |
| 84 |
{ \ |
| 85 |
char *name; \ |
| 86 |
static const GTypeInfo tinfo = \ |
| 87 |
{ \ |
| 88 |
sizeof (AtkObjectFactoryClass), \ |
| 89 |
NULL, NULL, (GClassInitFunc) type_as_function ## _factory_class_init, \ |
| 90 |
NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL \ |
| 91 |
}; \ |
| 92 |
\ |
| 93 |
name = g_strconcat (g_type_name (type), "Factory", NULL); \ |
| 94 |
t = g_type_register_static ( \ |
| 95 |
ATK_TYPE_OBJECT_FACTORY, name, &tinfo, 0); \ |
| 96 |
g_free (name); \ |
| 97 |
} \ |
| 98 |
\ |
| 99 |
return t; \ |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* CALLY_ACTOR_SET_FACTORY: |
| 104 |
* @widget_type: GType of the clutter actor |
| 105 |
* @type_as_function: prefix of the accessible object methods |
| 106 |
* |
| 107 |
* Sets the #AtkObjectFactory to be used in order to instantiate |
| 108 |
* accessibility objects for the actor which GType is @widget_type. |
| 109 |
* |
| 110 |
* Since: 1.4 |
| 111 |
*/ |
| 112 |
#define CALLY_ACTOR_SET_FACTORY(widget_type, type_as_function) \ |
| 113 |
atk_registry_set_factory_type (atk_get_default_registry (), \ |
| 114 |
widget_type, \ |
| 115 |
type_as_function ## _factory_get_type ()) |
| 116 |
|
| 117 |
#endif /* _CALLY_FACTORY_H__ */ |