+ g_object_unref (ghyperlink);
+}
+
+static void
+register_gobject (GObject *gobj, GObject *container)
+{
+ guint ref;
+ g_return_if_fail (G_IS_OBJECT(gobj));
+
+ ref = assign_reference();
+
+ g_hash_table_insert (ref2ptr, GINT_TO_POINTER(ref), gobj);
+ g_object_set_data (G_OBJECT(gobj), "dbus-id", GINT_TO_POINTER(ref));
+ g_object_weak_ref(G_OBJECT(gobj), deregister_object, NULL);
+
+ if (container)
+ {
+ GHashTable *subrefs = (GHashTable *) g_object_get_data (G_OBJECT (container), "dbus-subrefs-atk");
+ if (!subrefs)
+ {
+ subrefs = g_hash_table_new(g_direct_hash, g_direct_equal);
+ g_object_set_data (G_OBJECT (container), "dbus-subrefs-atk", subrefs);
+ }
+ g_hash_table_insert (subrefs, GINT_TO_POINTER(ref), gobj);
+ }
+
+ if (ATK_IS_HYPERLINK (gobj))
+ g_object_ref (gobj);
+ else if (ATK_IS_OBJECT (gobj))
+ {
+ AtkObject *accessible = ATK_OBJECT (gobj);
+ AtkStateSet *state = atk_object_ref_state_set (accessible);
+ if (atk_state_set_contains_state (state, ATK_STATE_TRANSIENT) &&
+ atk_state_set_contains_state (state, ATK_STATE_SHOWING))
+ {
+ g_object_ref (gobj);
+ }
+ g_object_unref (state);
+ }