Adding StLabel a11y support
Right now is just redefine atk_object_get_name. If someone wonders why not implement AtkText interface, or expose the internal ClutterText, here a extract from AtkText doc: "AtkText should be implemented by AtkObjects on behalf of widgets that have text content which is either attributed or otherwise non-trivial. AtkObjects whose text content is simple, unattributed, and very brief may expose that content via atk_object_get_name instead;" StLabel is attributed, but is still simple and brief. In the same way the atk_object_get_name redefinition is required, so this patch is the first step. We can implement AtkText in the future. https://bugzilla.gnome.org/show_bug.cgi?id=626658
This commit is contained in:
parent
125adb4d32
commit
450291b856
@ -44,6 +44,8 @@
|
|||||||
#include "st-private.h"
|
#include "st-private.h"
|
||||||
#include "st-widget.h"
|
#include "st-widget.h"
|
||||||
|
|
||||||
|
#include <st/st-widget-accessible.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -65,6 +67,8 @@ struct _StLabelPrivate
|
|||||||
|
|
||||||
G_DEFINE_TYPE (StLabel, st_label, ST_TYPE_WIDGET);
|
G_DEFINE_TYPE (StLabel, st_label, ST_TYPE_WIDGET);
|
||||||
|
|
||||||
|
static GType st_label_accessible_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_label_set_property (GObject *gobject,
|
st_label_set_property (GObject *gobject,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -290,6 +294,7 @@ st_label_class_init (StLabelClass *klass)
|
|||||||
actor_class->unmap = st_label_unmap;
|
actor_class->unmap = st_label_unmap;
|
||||||
|
|
||||||
widget_class->style_changed = st_label_style_changed;
|
widget_class->style_changed = st_label_style_changed;
|
||||||
|
widget_class->get_accessible_type = st_label_accessible_get_type;
|
||||||
|
|
||||||
pspec = g_param_spec_object ("clutter-text",
|
pspec = g_param_spec_object ("clutter-text",
|
||||||
"Clutter Text",
|
"Clutter Text",
|
||||||
@ -403,3 +408,100 @@ st_label_get_clutter_text (StLabel *label)
|
|||||||
|
|
||||||
return label->priv->label;
|
return label->priv->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*************************** ACCESSIBILITY SUPPORT ****************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#define ST_TYPE_LABEL_ACCESSIBLE st_label_accessible_get_type ()
|
||||||
|
|
||||||
|
#define ST_LABEL_ACCESSIBLE(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||||
|
ST_TYPE_LABEL_ACCESSIBLE, StLabelAccessible))
|
||||||
|
|
||||||
|
#define ST_IS_LABEL_ACCESSIBLE(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||||
|
ST_TYPE_LABEL_ACCESSIBLE))
|
||||||
|
|
||||||
|
#define ST_LABEL_ACCESSIBLE_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||||
|
ST_TYPE_LABEL_ACCESSIBLE, StLabelAccessibleClass))
|
||||||
|
|
||||||
|
#define ST_IS_LABEL_ACCESSIBLE_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||||
|
ST_TYPE_LABEL_ACCESSIBLE))
|
||||||
|
|
||||||
|
#define ST_LABEL_ACCESSIBLE_GET_CLASS(obj) \
|
||||||
|
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||||
|
ST_TYPE_LABEL_ACCESSIBLE, StLabelAccessibleClass))
|
||||||
|
|
||||||
|
typedef struct _StLabelAccessible StLabelAccessible;
|
||||||
|
typedef struct _StLabelAccessibleClass StLabelAccessibleClass;
|
||||||
|
|
||||||
|
struct _StLabelAccessible
|
||||||
|
{
|
||||||
|
StWidgetAccessible parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _StLabelAccessibleClass
|
||||||
|
{
|
||||||
|
StWidgetAccessibleClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void st_label_accessible_class_init (StLabelAccessibleClass *klass);
|
||||||
|
static void st_label_accessible_init (StLabelAccessible *label);
|
||||||
|
|
||||||
|
/* AtkObject */
|
||||||
|
static void st_label_accessible_initialize (AtkObject *obj,
|
||||||
|
gpointer data);
|
||||||
|
static const gchar * st_label_accessible_get_name (AtkObject *obj);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (StLabelAccessible, st_label_accessible, ST_TYPE_WIDGET_ACCESSIBLE)
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_label_accessible_class_init (StLabelAccessibleClass *klass)
|
||||||
|
{
|
||||||
|
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
atk_class->initialize = st_label_accessible_initialize;
|
||||||
|
atk_class->get_name = st_label_accessible_get_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_label_accessible_init (StLabelAccessible *self)
|
||||||
|
{
|
||||||
|
/* initialization done on AtkObject->initialize */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_label_accessible_initialize (AtkObject *obj,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
ATK_OBJECT_CLASS (st_label_accessible_parent_class)->initialize (obj, data);
|
||||||
|
|
||||||
|
obj->role = ATK_ROLE_LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
st_label_accessible_get_name (AtkObject *obj)
|
||||||
|
{
|
||||||
|
const gchar *name = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ST_IS_LABEL_ACCESSIBLE (obj), NULL);
|
||||||
|
|
||||||
|
name = ATK_OBJECT_CLASS (st_label_accessible_parent_class)->get_name (obj);
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
ClutterActor *actor = NULL;
|
||||||
|
|
||||||
|
actor = CLUTTER_ACTOR (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (obj)));
|
||||||
|
|
||||||
|
if (actor == NULL) /* State is defunct */
|
||||||
|
name = NULL;
|
||||||
|
else
|
||||||
|
name = st_label_get_text (ST_LABEL (actor));
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user