Use modern GObject macros for GtkAccessible

This commit is contained in:
Emmanuele Bassi 2020-04-20 16:47:50 +01:00
parent 8e7395a7e3
commit 9ac1eacdc8
3 changed files with 24 additions and 40 deletions

View File

@ -21,7 +21,6 @@
#ifndef __GI_SCANNER__
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkActionBar, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkActionable, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAdjustment, g_object_unref)

View File

@ -1,5 +1,6 @@
/* GTK - The GIMP Toolkit
* Copyright 2001 Sun Microsystems Inc.
* Copyright 2020 GNOME Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -40,12 +41,13 @@
* in #GtkWidgetClass.
*/
struct _GtkAccessiblePrivate
typedef struct
{
GtkWidget *widget;
};
} GtkAccessiblePrivate;
enum {
enum
{
PROP_0,
PROP_WIDGET
};
@ -78,7 +80,7 @@ gtk_accessible_get_property (GObject *object,
GParamSpec *pspec)
{
GtkAccessible *accessible = GTK_ACCESSIBLE (object);
GtkAccessiblePrivate *priv = accessible->priv;
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
switch (prop_id)
{
@ -94,18 +96,18 @@ gtk_accessible_get_property (GObject *object,
static void
gtk_accessible_init (GtkAccessible *accessible)
{
accessible->priv = gtk_accessible_get_instance_private (accessible);
}
static AtkStateSet *
gtk_accessible_ref_state_set (AtkObject *object)
{
GtkAccessible *accessible = GTK_ACCESSIBLE (object);
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
AtkStateSet *state_set;
state_set = ATK_OBJECT_CLASS (gtk_accessible_parent_class)->ref_state_set (object);
if (accessible->priv->widget == NULL)
if (priv->widget == NULL)
atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
return state_set;
@ -172,23 +174,20 @@ void
gtk_accessible_set_widget (GtkAccessible *accessible,
GtkWidget *widget)
{
GtkAccessiblePrivate *priv;
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
GtkAccessibleClass *klass;
g_return_if_fail (GTK_IS_ACCESSIBLE (accessible));
priv = accessible->priv;
klass = GTK_ACCESSIBLE_GET_CLASS (accessible);
if (priv->widget == widget)
return;
klass = GTK_ACCESSIBLE_GET_CLASS (accessible);
if (priv->widget)
klass->widget_unset (accessible);
priv->widget = widget;
if (widget)
if (priv->widget)
klass->widget_set (accessible);
g_object_notify (G_OBJECT (accessible), "widget");
@ -208,8 +207,9 @@ gtk_accessible_set_widget (GtkAccessible *accessible,
GtkWidget*
gtk_accessible_get_widget (GtkAccessible *accessible)
{
GtkAccessiblePrivate *priv = gtk_accessible_get_instance_private (accessible);
g_return_val_if_fail (GTK_IS_ACCESSIBLE (accessible), NULL);
return accessible->priv->widget;
return priv->widget;
}

View File

@ -1,5 +1,6 @@
/* GTK - The GIMP Toolkit
* Copyright 2001 Sun Microsystems Inc.
* Copyright 2020 GNOME Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -28,37 +29,23 @@
G_BEGIN_DECLS
#define GTK_TYPE_ACCESSIBLE (gtk_accessible_get_type ())
#define GTK_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessible))
#define GTK_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass))
#define GTK_IS_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACCESSIBLE))
#define GTK_IS_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCESSIBLE))
#define GTK_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass))
typedef struct _GtkAccessible GtkAccessible;
typedef struct _GtkAccessiblePrivate GtkAccessiblePrivate;
typedef struct _GtkAccessibleClass GtkAccessibleClass;
#if !ATK_CHECK_VERSION(2, 37, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(AtkObject, g_object_unref)
#endif
struct _GtkAccessible
{
AtkObject parent;
/*< private >*/
GtkAccessiblePrivate *priv;
};
GDK_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (GtkAccessible, gtk_accessible, GTK, ACCESSIBLE, AtkObject)
struct _GtkAccessibleClass
{
AtkObjectClass parent_class;
void (*widget_set) (GtkAccessible *accessible);
void (*widget_unset) (GtkAccessible *accessible);
/* Padding for future expansion */
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
void (* widget_set) (GtkAccessible *accessible);
void (* widget_unset) (GtkAccessible *accessible);
GDK_AVAILABLE_IN_ALL
GType gtk_accessible_get_type (void) G_GNUC_CONST;
gpointer _padding[8];
};
GDK_AVAILABLE_IN_ALL
void gtk_accessible_set_widget (GtkAccessible *accessible,
@ -69,5 +56,3 @@ GtkWidget *gtk_accessible_get_widget (GtkAccessible *accessible);
G_END_DECLS
#endif /* __GTK_ACCESSIBLE_H__ */