a11y: Use G_DECLARE macro for GtkWidgetAccessible

Allows us to drop the Private structure typedef.
This commit is contained in:
Emmanuele Bassi 2020-04-27 17:57:27 +01:00
parent fc512f0b9f
commit f95d54a13d
2 changed files with 48 additions and 36 deletions

View File

@ -17,18 +17,43 @@
#include "config.h"
#include <gtk/gtk.h>
#include "gtkwidgetaccessibleprivate.h"
#include "gtknotebookpageaccessible.h"
struct _GtkWidgetAccessiblePrivate
#include "gtkaccellabel.h"
#include "gtkadjustment.h"
#include "gtkbox.h"
#include "gtkbutton.h"
#include "gtkcombobox.h"
#include "gtkdragicon.h"
#include "gtkdrawingarea.h"
#include "gtkglarea.h"
#include "gtkimage.h"
#include "gtklevelbar.h"
#include "gtkmediacontrols.h"
#include "gtknotebookpageaccessible.h"
#include "gtknotebook.h"
#include "gtkorientable.h"
#include "gtkpicture.h"
#include "gtkprogressbar.h"
#include "gtkscrollable.h"
#include "gtkscrollbar.h"
#include "gtkseparator.h"
#include "gtkshortcutlabel.h"
#include "gtkshortcutsshortcut.h"
#include "gtkspinner.h"
#include "gtkstacksidebar.h"
#include "gtkstatusbar.h"
#include "gtkvideo.h"
#include "gtkviewport.h"
#include "gtkwidgetprivate.h"
typedef struct
{
AtkLayer layer;
};
} GtkWidgetAccessiblePrivate;
extern GtkWidget *_focus_widget;
static gboolean gtk_widget_accessible_on_screen (GtkWidget *widget);
static gboolean gtk_widget_accessible_all_parents_visible (GtkWidget *widget);
@ -170,10 +195,12 @@ gtk_widget_accessible_initialize (AtkObject *object,
gpointer data)
{
GtkWidgetAccessible *self = GTK_WIDGET_ACCESSIBLE (object);
GtkWidgetAccessiblePrivate *priv = gtk_widget_accessible_get_instance_private (self);
GtkWidget *widget = data;
self->priv->layer = ATK_LAYER_WIDGET;
object->role = ATK_ROLE_UNKNOWN;
priv->layer = ATK_LAYER_WIDGET;
atk_object_set_role (object, ATK_ROLE_UNKNOWN);
/* XXX: This will go away once we move all GtkWidgetAccessibleClass.notify_gtk()
* implementations to explicit API on their respective classes
@ -587,7 +614,6 @@ gtk_widget_accessible_class_init (GtkWidgetAccessibleClass *klass)
static void
gtk_widget_accessible_init (GtkWidgetAccessible *accessible)
{
accessible->priv = gtk_widget_accessible_get_instance_private (accessible);
}
static void
@ -630,9 +656,10 @@ gtk_widget_accessible_get_extents (AtkComponent *component,
static AtkLayer
gtk_widget_accessible_get_layer (AtkComponent *component)
{
GtkWidgetAccessible *accessible = GTK_WIDGET_ACCESSIBLE (component);
GtkWidgetAccessible *self = GTK_WIDGET_ACCESSIBLE (component);
GtkWidgetAccessiblePrivate *priv = gtk_widget_accessible_get_instance_private (self);
return accessible->priv->layer;
return priv->layer;
}
static gboolean
@ -764,10 +791,11 @@ gtk_widget_accessible_all_parents_visible (GtkWidget *widget)
GtkWidget *iter_parent = NULL;
gboolean result = TRUE;
for (iter_parent = gtk_widget_get_parent (widget); iter_parent;
iter_parent = gtk_widget_get_parent (iter_parent))
for (iter_parent = _gtk_widget_get_parent (widget);
iter_parent != NULL;
iter_parent = _gtk_widget_get_parent (iter_parent))
{
if (!gtk_widget_get_visible (iter_parent))
if (!_gtk_widget_get_visible (iter_parent))
{
result = FALSE;
break;
@ -778,8 +806,10 @@ gtk_widget_accessible_all_parents_visible (GtkWidget *widget)
}
void
_gtk_widget_accessible_set_layer (GtkWidgetAccessible *accessible,
_gtk_widget_accessible_set_layer (GtkWidgetAccessible *self,
AtkLayer layer)
{
accessible->priv->layer = layer;
GtkWidgetAccessiblePrivate *priv = gtk_widget_accessible_get_instance_private (self);
priv->layer = layer;
}

View File

@ -26,25 +26,10 @@
G_BEGIN_DECLS
#define GTK_TYPE_WIDGET_ACCESSIBLE (gtk_widget_accessible_get_type ())
#define GTK_WIDGET_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WIDGET_ACCESSIBLE, GtkWidgetAccessible))
#define GTK_WIDGET_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIDGET_ACCESSIBLE, GtkWidgetAccessibleClass))
#define GTK_IS_WIDGET_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WIDGET_ACCESSIBLE))
#define GTK_IS_WIDGET_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIDGET_ACCESSIBLE))
#define GTK_WIDGET_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET_ACCESSIBLE, GtkWidgetAccessibleClass))
#define GTK_TYPE_WIDGET_ACCESSIBLE (gtk_widget_accessible_get_type())
typedef struct _GtkWidgetAccessible GtkWidgetAccessible;
typedef struct _GtkWidgetAccessibleClass GtkWidgetAccessibleClass;
typedef struct _GtkWidgetAccessiblePrivate GtkWidgetAccessiblePrivate;
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidgetAccessible, g_object_unref)
struct _GtkWidgetAccessible
{
GtkAccessible parent;
GtkWidgetAccessiblePrivate *priv;
};
GDK_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (GtkWidgetAccessible, gtk_widget_accessible, GTK, WIDGET_ACCESSIBLE, GtkAccessible)
struct _GtkWidgetAccessibleClass
{
@ -58,9 +43,6 @@ struct _GtkWidgetAccessibleClass
};
GDK_AVAILABLE_IN_ALL
GType gtk_widget_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_WIDGET_ACCESSIBLE_H__ */