diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-06-07 13:45:01 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-06-08 11:57:47 -0400 |
commit | 67a55935e93d1f7ecec986061ecb36392a71ca97 (patch) | |
tree | e1a7308bccfb67db1a37b136c9233d1460d7a0d4 /eel | |
parent | b774a3daa236cc89608ba8eaeaae805acc58426e (diff) | |
download | nautilus-67a55935e93d1f7ecec986061ecb36392a71ca97.tar.gz |
a11y: add a method to create a derived GtkWidgetAccessible type
For EelEditableLabel, we need to create an object derived from the
accessible type of the parent class; since that will be a
GtkWidgetAccessible, which is private, we can't just subclass it using
the regular GObject mechanisms.
This functions creates a derived GType by peeking at the parent
accessible class and type.
https://bugzilla.gnome.org/show_bug.cgi?id=672498
Diffstat (limited to 'eel')
-rw-r--r-- | eel/eel-accessibility.c | 33 | ||||
-rw-r--r-- | eel/eel-accessibility.h | 3 |
2 files changed, 36 insertions, 0 deletions
diff --git a/eel/eel-accessibility.c b/eel/eel-accessibility.c index 099dff11b..62249c9a5 100644 --- a/eel/eel-accessibility.c +++ b/eel/eel-accessibility.c @@ -110,6 +110,39 @@ eel_accessibility_create_derived_type (const char *type_name, return type; } +GType +eel_accessibility_create_accessible_gtype (const char *type_name, + GtkWidget *widget, + GClassInitFunc class_init) +{ + GType atk_type, parent_atk_type; + GTypeQuery query; + AtkObject *parent_atk; + GtkWidgetClass *parent_class; + + if ((atk_type = g_type_from_name (type_name))) { + return atk_type; + } + + parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (widget)); + parent_atk = parent_class->get_accessible (widget); + parent_atk_type = G_TYPE_FROM_INSTANCE (parent_atk); + + if (!parent_atk_type) { + return G_TYPE_INVALID; + } + + /* Figure out the size of the class and instance + * we are deriving from + */ + g_type_query (parent_atk_type, &query); + + /* Register the type */ + return g_type_register_static_simple (parent_atk_type, type_name, + query.class_size, class_init, + query.instance_size, NULL, 0); +} + static GQuark get_quark_accessible (void) diff --git a/eel/eel-accessibility.h b/eel/eel-accessibility.h index 7b4e280a4..408ea1a2a 100644 --- a/eel/eel-accessibility.h +++ b/eel/eel-accessibility.h @@ -43,6 +43,9 @@ AtkObject *eel_accessibility_set_atk_object_return (gpointer obj GType eel_accessibility_create_derived_type (const char *type_name, GType existing_gobject_with_proxy, EelAccessibilityClassInitFn class_init); +GType eel_accessibility_create_accessible_gtype (const char *type_name, + GtkWidget *widget, + GClassInitFunc class_init); char* eel_accessibility_text_get_text (AtkText *text, gint start_pos, |