[gtk+] accessible: Make widget a property



commit 1998a6391780e9bc91ea807ee6c6e2460af6f6c7
Author: Benjamin Otte <otte redhat com>
Date:   Sun Dec 18 06:55:44 2011 +0100

    accessible: Make widget a property

 gtk/gtkaccessible.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index 161ab73..3eebc6b 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -47,11 +47,55 @@ 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)
 {
   accessible->priv = G_TYPE_INSTANCE_GET_PRIVATE (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");
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]