mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
Add gtk_accessible_role_is_abstract
Move this code from the a11y overlay in the inspector. It will be used more widely, going forward.
This commit is contained in:
parent
b84650c2a3
commit
152a335cee
@ -881,6 +881,42 @@ gtk_accessible_role_is_range_subclass (GtkAccessibleRole role)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* < private >
|
||||
* gtk_accessible_role_is_abstract:
|
||||
* @role: a `GtkAccessibleRole`
|
||||
*
|
||||
* Checks if @role is considered abstract and should not be used
|
||||
* for concrete widgets.
|
||||
*
|
||||
* Returns: whether the role is abstract
|
||||
*/
|
||||
gboolean
|
||||
gtk_accessible_role_is_abstract (GtkAccessibleRole role)
|
||||
{
|
||||
switch ((int) role)
|
||||
{
|
||||
case GTK_ACCESSIBLE_ROLE_COMMAND:
|
||||
case GTK_ACCESSIBLE_ROLE_COMPOSITE:
|
||||
case GTK_ACCESSIBLE_ROLE_INPUT:
|
||||
case GTK_ACCESSIBLE_ROLE_LANDMARK:
|
||||
case GTK_ACCESSIBLE_ROLE_RANGE:
|
||||
case GTK_ACCESSIBLE_ROLE_SECTION:
|
||||
case GTK_ACCESSIBLE_ROLE_SECTION_HEAD:
|
||||
case GTK_ACCESSIBLE_ROLE_SELECT:
|
||||
case GTK_ACCESSIBLE_ROLE_STRUCTURE:
|
||||
#if 0
|
||||
/* FIXME: ARIA considers these abstract.
|
||||
* But we are using them for widgets
|
||||
*/
|
||||
case GTK_ACCESSIBLE_ROLE_WIDGET:
|
||||
case GTK_ACCESSIBLE_ROLE_WINDOW:
|
||||
#endif
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_accessible_platform_changed:
|
||||
* @self: a `GtkAccessible`
|
||||
|
@ -55,7 +55,9 @@ typedef enum {
|
||||
const char * gtk_accessible_role_to_name (GtkAccessibleRole role,
|
||||
const char *domain);
|
||||
|
||||
gboolean gtk_accessible_role_is_range_subclass (GtkAccessibleRole role);
|
||||
gboolean gtk_accessible_role_is_range_subclass (GtkAccessibleRole role);
|
||||
|
||||
gboolean gtk_accessible_role_is_abstract (GtkAccessibleRole role);
|
||||
|
||||
/* < private >
|
||||
* GtkAccessibleNaming:
|
||||
|
@ -46,25 +46,6 @@ struct _GtkA11yOverlayClass
|
||||
|
||||
G_DEFINE_TYPE (GtkA11yOverlay, gtk_a11y_overlay, GTK_TYPE_INSPECTOR_OVERLAY)
|
||||
|
||||
static GtkAccessibleRole abstract_roles[] = {
|
||||
GTK_ACCESSIBLE_ROLE_COMMAND,
|
||||
GTK_ACCESSIBLE_ROLE_COMPOSITE,
|
||||
GTK_ACCESSIBLE_ROLE_INPUT,
|
||||
GTK_ACCESSIBLE_ROLE_LANDMARK,
|
||||
GTK_ACCESSIBLE_ROLE_RANGE,
|
||||
GTK_ACCESSIBLE_ROLE_SECTION,
|
||||
GTK_ACCESSIBLE_ROLE_SECTION_HEAD,
|
||||
GTK_ACCESSIBLE_ROLE_SELECT,
|
||||
GTK_ACCESSIBLE_ROLE_STRUCTURE,
|
||||
#if 0
|
||||
/* FIXME: ARIA considers these abstract.
|
||||
* But we are using them for widgets
|
||||
*/
|
||||
GTK_ACCESSIBLE_ROLE_WIDGET,
|
||||
GTK_ACCESSIBLE_ROLE_WINDOW
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SEVERITY_GOOD,
|
||||
@ -152,14 +133,10 @@ check_accessibility_errors (GtkWidget *widget,
|
||||
gtk_at_context_realize (context);
|
||||
|
||||
/* Check for abstract roles */
|
||||
for (unsigned int i = 0; i < G_N_ELEMENTS (abstract_roles); i++)
|
||||
if (gtk_accessible_role_is_abstract (role))
|
||||
{
|
||||
if (role == abstract_roles[i])
|
||||
{
|
||||
*hint = g_strdup_printf ("%s is an abstract role", role_name);
|
||||
|
||||
return SEVERITY_ERROR;
|
||||
}
|
||||
*hint = g_strdup_printf ("%s is an abstract role", role_name);
|
||||
return SEVERITY_ERROR;
|
||||
}
|
||||
|
||||
/* Check for name and description */
|
||||
|
Loading…
Reference in New Issue
Block a user