diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-06-07 23:27:01 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-06-07 23:50:34 -0400 |
commit | 6c5baeb7626eda6629fc6642c9eb513ef8bc5c8e (patch) | |
tree | db88221bacedc6853a9e853291acbd16f2c48ab8 /eel | |
parent | d9fafc1f0f53139bbc3eef432c98ede145b6724d (diff) | |
download | nautilus-6c5baeb7626eda6629fc6642c9eb513ef8bc5c8e.tar.gz |
a11y: fix accessibility implementation for NautilusIconContainer
Clean up a11y code and make sure inheritance for
EelCanvasAccessible->NautilusIconContainerAccessible and for
EelCanvasItemAccessible->NautilusIconCanvasItemAccessible work properly.
This makes the ATK state machinery in EelCanvasItemAccessible work
again, which fixes
https://bugzilla.gnome.org/show_bug.cgi?id=677509
Diffstat (limited to 'eel')
-rw-r--r-- | eel/eel-canvas.c | 111 | ||||
-rw-r--r-- | eel/eel-canvas.h | 16 |
2 files changed, 39 insertions, 88 deletions
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index ebca1bbde..a17bbf79a 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -4122,74 +4122,32 @@ eel_canvas_item_accessible_ref_state_set (AtkObject *accessible) } static void -eel_canvas_item_accessible_class_init (AtkObjectClass *klass) +eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass *klass) { + AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); + accessible_item_parent_class = g_type_class_peek_parent (klass); - klass->initialize = eel_canvas_item_accessible_initialize; - klass->ref_state_set = eel_canvas_item_accessible_ref_state_set; + atk_class->initialize = eel_canvas_item_accessible_initialize; + atk_class->ref_state_set = eel_canvas_item_accessible_ref_state_set; } -static GType -eel_canvas_item_accessible_get_type (void) +static void +eel_canvas_item_accessible_init (EelCanvasItemAccessible *self) { - static GType type = 0; - - if (!type) { - static const GInterfaceInfo atk_component_info = { - (GInterfaceInitFunc) eel_canvas_item_accessible_component_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - AtkObjectFactory *factory; - GType parent_atk_type; - GTypeQuery query; - GTypeInfo tinfo = { 0 }; - - factory = atk_registry_get_factory (atk_get_default_registry(), - G_TYPE_INITIALLY_UNOWNED); - if (!factory) { - return G_TYPE_INVALID; - } - parent_atk_type = atk_object_factory_get_accessible_type (factory); - if (!parent_atk_type) { - return G_TYPE_INVALID; - } - g_type_query (parent_atk_type, &query); - tinfo.class_init = (GClassInitFunc) eel_canvas_item_accessible_class_init; - tinfo.class_size = query.class_size; - tinfo.instance_size = query.instance_size; - type = g_type_register_static (parent_atk_type, - "EelCanvasItemAccessibility", - &tinfo, 0); - - g_type_add_interface_static (type, ATK_TYPE_COMPONENT, - &atk_component_info); - - } - return type; } -static AtkObject * -eel_canvas_item_accessible_create (GObject *for_object) -{ - GType type; - AtkObject *accessible; - EelCanvasItem *item; - - item = EEL_CANVAS_ITEM (for_object); - g_return_val_if_fail (item != NULL, NULL); +G_DEFINE_TYPE_WITH_CODE (EelCanvasItemAccessible, + eel_canvas_item_accessible, + ATK_TYPE_GOBJECT_ACCESSIBLE, + G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, + eel_canvas_item_accessible_component_interface_init)); - type = eel_canvas_item_accessible_get_type (); - if (type == G_TYPE_INVALID) { - return atk_no_op_object_new (for_object); - } - - accessible = g_object_new (type, NULL); - atk_object_initialize (accessible, for_object); - return accessible; -} +typedef AtkObjectFactory EelCanvasItemAccessibleFactory; +typedef AtkObjectFactoryClass EelCanvasItemAccessibleFactoryClass; +G_DEFINE_TYPE (EelCanvasItemAccessibleFactory, eel_canvas_item_accessible_factory, + ATK_TYPE_OBJECT_FACTORY) static GType eel_canvas_item_accessible_factory_get_accessible_type (void) @@ -4198,15 +4156,19 @@ eel_canvas_item_accessible_factory_get_accessible_type (void) } static AtkObject* -eel_canvas_item_accessible_factory_create_accessible (GObject *obj) +eel_canvas_item_accessible_factory_create_accessible (GObject *for_object) { AtkObject *accessible; - g_return_val_if_fail (G_IS_OBJECT (obj), NULL); + accessible = g_object_new (eel_canvas_item_accessible_get_type (), NULL); + atk_object_initialize (accessible, for_object); + return accessible; +} - accessible = eel_canvas_item_accessible_create (obj); +static void +eel_canvas_item_accessible_factory_init (EelCanvasItemAccessibleFactory *self) +{ - return accessible; } static void @@ -4215,31 +4177,6 @@ eel_canvas_item_accessible_factory_class_init (AtkObjectFactoryClass *klass) klass->create_accessible = eel_canvas_item_accessible_factory_create_accessible; klass->get_accessible_type = eel_canvas_item_accessible_factory_get_accessible_type; } - -static GType -eel_canvas_item_accessible_factory_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo tinfo = { - sizeof (AtkObjectFactoryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) eel_canvas_item_accessible_factory_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (AtkObjectFactory), - 0, /* n_preallocs */ - NULL - }; - type = g_type_register_static (ATK_TYPE_OBJECT_FACTORY, - "EelCanvasItemAccessibilityFactory", - &tinfo, 0); - } - - return type; -} /* Class initialization function for EelCanvasItemClass */ static void diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index 1853936bf..685bfa6a1 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -515,7 +515,7 @@ void eel_canvas_world_to_window (EelCanvas *canvas, double worldx, double worldy, double *winx, double *winy); /* Accessible implementation */ -GType eel_canvas_accessible_get_type(void); +GType eel_canvas_accessible_get_type (void); typedef struct _EelCanvasAccessible EelCanvasAccessible; struct _EelCanvasAccessible @@ -529,6 +529,20 @@ struct _EelCanvasAccessibleClass GtkAccessibleClass parent_class; }; +GType eel_canvas_item_accessible_get_type (void); + +typedef struct _EelCanvasItemAccessible EelCanvasItemAccessible; +struct _EelCanvasItemAccessible +{ + GtkAccessible parent; +}; + +typedef struct _EelCanvasItemAccessibleClass EelCanvasItemAccessibleClass; +struct _EelCanvasItemAccessibleClass +{ + GtkAccessibleClass parent_class; +}; + G_END_DECLS #endif |