accessible: Make widget a property

This commit is contained in:
Benjamin Otte 2011-12-18 06:55:44 +01:00
parent eed9cc94e1
commit 1998a63917

View File

@ -47,10 +47,54 @@ struct _GtkAccessiblePrivate
GtkWidget *widget;
};
enum {
PROP_0,
PROP_WIDGET
};
static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible);
G_DEFINE_TYPE (GtkAccessible, gtk_accessible, ATK_TYPE_OBJECT)
static void
gtk_accessible_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkAccessible *accessible = GTK_ACCESSIBLE (object);
switch (prop_id)
{
case PROP_WIDGET:
gtk_accessible_set_widget (accessible, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_accessible_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkAccessible *accessible = GTK_ACCESSIBLE (object);
GtkAccessiblePrivate *priv = accessible->priv;
switch (prop_id)
{
case PROP_WIDGET:
g_value_set_object (value, priv->widget);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_accessible_init (GtkAccessible *accessible)
{
@ -62,8 +106,21 @@ gtk_accessible_init (GtkAccessible *accessible)
static void
gtk_accessible_class_init (GtkAccessibleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
klass->connect_widget_destroyed = gtk_accessible_real_connect_widget_destroyed;
gobject_class->get_property = gtk_accessible_get_property;
gobject_class->set_property = gtk_accessible_set_property;
g_object_class_install_property (gobject_class,
PROP_WIDGET,
g_param_spec_object ("widget",
P_("Widget"),
P_("The widget referenced by this accessible."),
GTK_TYPE_WIDGET,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GtkAccessiblePrivate));
}
@ -83,6 +140,8 @@ gtk_accessible_set_widget (GtkAccessible *accessible,
g_return_if_fail (GTK_IS_ACCESSIBLE (accessible));
accessible->priv->widget = widget;
g_object_notify (G_OBJECT (accessible), "widget");
}
/**