Introduce GtkAccessible

GtkAccessible is an interface for accessible UI elements.

Currently, it doesn't do much except exist as a type; in the future, it
will be the entry point for all accessible state in GTK.
This commit is contained in:
Emmanuele Bassi 2020-06-16 17:40:14 +01:00
parent 82fe6fbc62
commit 14faec3ce2
5 changed files with 94 additions and 2 deletions

View File

@ -34,6 +34,7 @@
#include <gtk/gtkaboutdialog.h>
#include <gtk/gtkaccelgroup.h>
#include <gtk/gtkaccellabel.h>
#include <gtk/gtkaccessible.h>
#include <gtk/gtkactionable.h>
#include <gtk/gtkactionbar.h>
#include <gtk/gtkadjustment.h>

30
gtk/gtkaccessible.c Normal file
View File

@ -0,0 +1,30 @@
/* gtkaccessible.c: Accessible interface
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkaccessible.h"
G_DEFINE_INTERFACE (GtkAccessible, gtk_accessible, G_TYPE_OBJECT)
static void
gtk_accessible_default_init (GtkAccessibleInterface *iface)
{
}

39
gtk/gtkaccessible.h Normal file
View File

@ -0,0 +1,39 @@
/* gtkaccessible.h: Accessible interface
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib-object.h>
#include <gtk/gtktypes.h>
#include <gtk/gtkenums.h>
G_BEGIN_DECLS
#define GTK_TYPE_ACCESSIBLE (gtk_accessible_get_type())
GDK_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (GtkAccessible, gtk_accessible, GTK, ACCESSIBLE, GObject)
struct _GtkAccessibleInterface
{
GTypeInterface g_iface;
};
G_END_DECLS

View File

@ -27,6 +27,7 @@
#include "gtkwidgetprivate.h"
#include "gtkaccelgroupprivate.h"
#include "gtkaccessible.h"
#include "gtkactionobserverprivate.h"
#include "gtkapplicationprivate.h"
#include "gtkbuildable.h"
@ -599,6 +600,8 @@ static void gtk_widget_real_measure (GtkWidget
static void gtk_widget_real_state_flags_changed (GtkWidget *widget,
GtkStateFlags old_state);
static void gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface);
static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface);
static void gtk_widget_buildable_set_name (GtkBuildable *buildable,
const char *name);
@ -680,6 +683,13 @@ gtk_widget_get_type (void)
NULL, /* value_table */
};
const GInterfaceInfo accessible_info =
{
(GInterfaceInitFunc) gtk_widget_accessible_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL,
};
const GInterfaceInfo buildable_info =
{
(GInterfaceInitFunc) gtk_widget_buildable_interface_init,
@ -702,10 +712,12 @@ gtk_widget_get_type (void)
GtkWidget_private_offset =
g_type_add_instance_private (widget_type, sizeof (GtkWidgetPrivate));
g_type_add_interface_static (widget_type, GTK_TYPE_ACCESSIBLE,
&accessible_info);
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
&buildable_info) ;
&buildable_info);
g_type_add_interface_static (widget_type, GTK_TYPE_CONSTRAINT_TARGET,
&constraint_target_info) ;
&constraint_target_info);
}
return widget_type;
@ -8038,6 +8050,14 @@ gtk_widget_set_vexpand_set (GtkWidget *widget,
gtk_widget_set_expand_set (widget, GTK_ORIENTATION_VERTICAL, set);
}
/*
* GtkAccessible implementation
*/
static void
gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface)
{
}
/*
* GtkBuildable implementation
*/

View File

@ -149,6 +149,7 @@ gtk_public_sources = files([
'gtkaboutdialog.c',
'gtkaccelgroup.c',
'gtkaccellabel.c',
'gtkaccessible.c',
'gtkactionable.c',
'gtkactionbar.c',
'gtkadjustment.c',
@ -436,6 +437,7 @@ gtk_public_headers = files([
'gtkaboutdialog.h',
'gtkaccelgroup.h',
'gtkaccellabel.h',
'gtkaccessible.h',
'gtkactionable.h',
'gtkactionbar.h',
'gtkadjustment.h',