[gtk+] API: accessible: Add widget_set and widget_unset vfuncs
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] API: accessible: Add widget_set and widget_unset vfuncs
- Date: Mon, 19 Dec 2011 15:50:12 +0000 (UTC)
commit bac73e48db57f85e4f19ea5f9b3d9669db10686c
Author: Benjamin Otte <otte redhat com>
Date: Sun Dec 18 12:55:41 2011 +0100
API: accessible: Add widget_set and widget_unset vfuncs
I expect them to be used a lot, so this approach seems better than
requiring signals that connect to "notify::widget". Also, we can't use
regular functions (like dispose or constructed), becaiuse those assume
that (un)setting of the widget only happens once and with the current
design (a puble set_widget() function) we can't really guarantee that.
Also, I split them into two separate functions as one function is part
of construction and the other part of destruction of the object. And it
doesn't sound like a good idea to have that both be part of one
function.
gtk/gtkaccessible.c | 20 ++++++++++++++++++++
gtk/gtkaccessible.h | 4 ++--
2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index eb318e1..e999b09 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -104,11 +104,23 @@ gtk_accessible_init (GtkAccessible *accessible)
}
static void
+gtk_accessible_real_widget_set (GtkAccessible *accessible)
+{
+}
+
+static void
+gtk_accessible_real_widget_unset (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;
+ klass->widget_set = gtk_accessible_real_widget_set;
+ klass->widget_unset = gtk_accessible_real_widget_unset;
gobject_class->get_property = gtk_accessible_get_property;
gobject_class->set_property = gtk_accessible_set_property;
@@ -142,16 +154,24 @@ gtk_accessible_set_widget (GtkAccessible *accessible,
GtkWidget *widget)
{
GtkAccessiblePrivate *priv;
+ GtkAccessibleClass *klass;
g_return_if_fail (GTK_IS_ACCESSIBLE (accessible));
priv = accessible->priv;
+ klass = GTK_ACCESSIBLE_GET_CLASS (accessible);
if (priv->widget == widget)
return;
+ if (priv->widget)
+ klass->widget_unset (accessible);
+
priv->widget = widget;
+ if (widget);
+ klass->widget_set (accessible);
+
g_object_notify (G_OBJECT (accessible), "widget");
}
diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h
index 04d213a..296186c 100644
--- a/gtk/gtkaccessible.h
+++ b/gtk/gtkaccessible.h
@@ -54,9 +54,9 @@ struct _GtkAccessibleClass
void (*connect_widget_destroyed) (GtkAccessible *accessible);
+ void (*widget_set) (GtkAccessible *accessible);
+ void (*widget_unset) (GtkAccessible *accessible);
/* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]