[gtk/wip/ebassi/a11y-2: 414/442] Use modern GObject macros for GtkAccessible
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/a11y-2: 414/442] Use modern GObject macros for GtkAccessible
- Date: Fri, 5 Jun 2020 19:36:06 +0000 (UTC)
commit 9ac1eacdc898b4b0277f591810a41794b382f5ad
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Apr 20 16:47:50 2020 +0100
Use modern GObject macros for GtkAccessible
gtk/gtk-autocleanups.h | 1 -
gtk/gtkaccessible.c | 28 ++++++++++++++--------------
gtk/gtkaccessible.h | 35 ++++++++++-------------------------
3 files changed, 24 insertions(+), 40 deletions(-)
---
diff --git a/gtk/gtk-autocleanups.h b/gtk/gtk-autocleanups.h
index f7bc1f30f1..b5689b9075 100644
--- a/gtk/gtk-autocleanups.h
+++ b/gtk/gtk-autocleanups.h
@@ -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)
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index 454f12306b..ae0ba101c0 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -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;
}
-
diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h
index 2c29ab3ca9..26125f0ca4 100644
--- a/gtk/gtkaccessible.h
+++ b/gtk/gtkaccessible.h
@@ -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;
-
-struct _GtkAccessible
-{
- AtkObject parent;
+#if !ATK_CHECK_VERSION(2, 37, 0)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(AtkObject, g_object_unref)
+#endif
- /*< 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__ */
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]