gizmo: Add a way to set accessible role

This will be used for some of the gizmo used
inside GtkNotebook.
This commit is contained in:
Matthias Clasen 2020-10-14 18:37:14 -04:00
parent 512387afcc
commit 984e8ac5e3
2 changed files with 31 additions and 0 deletions

View File

@ -130,9 +130,30 @@ gtk_gizmo_new (const char *css_name,
GtkGizmoContainsFunc contains_func,
GtkGizmoFocusFunc focus_func,
GtkGizmoGrabFocusFunc grab_focus_func)
{
return gtk_gizmo_new_with_role (css_name,
GTK_ACCESSIBLE_ROLE_WIDGET,
measure_func,
allocate_func,
snapshot_func,
contains_func,
focus_func,
grab_focus_func);
}
GtkWidget *
gtk_gizmo_new_with_role (const char *css_name,
GtkAccessibleRole role,
GtkGizmoMeasureFunc measure_func,
GtkGizmoAllocateFunc allocate_func,
GtkGizmoSnapshotFunc snapshot_func,
GtkGizmoContainsFunc contains_func,
GtkGizmoFocusFunc focus_func,
GtkGizmoGrabFocusFunc grab_focus_func)
{
GtkGizmo *gizmo = GTK_GIZMO (g_object_new (GTK_TYPE_GIZMO,
"css-name", css_name,
"accessible-role", role,
NULL));
gizmo->measure_func = measure_func;

View File

@ -3,6 +3,7 @@
#define __GTK_GIZMO_H__
#include "gtkwidget.h"
#include "gtkenums.h"
#define GTK_TYPE_GIZMO (gtk_gizmo_get_type ())
#define GTK_GIZMO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_GIZMO, GtkGizmo))
@ -61,5 +62,14 @@ GtkWidget *gtk_gizmo_new (const char *css_name,
GtkGizmoFocusFunc focus_func,
GtkGizmoGrabFocusFunc grab_focus_func);
GtkWidget *gtk_gizmo_new_with_role (const char *css_name,
GtkAccessibleRole role,
GtkGizmoMeasureFunc measure_func,
GtkGizmoAllocateFunc allocate_func,
GtkGizmoSnapshotFunc snapshot_func,
GtkGizmoContainsFunc contains_func,
GtkGizmoFocusFunc focus_func,
GtkGizmoGrabFocusFunc grab_focus_func);
#endif