Index: gail/gailwidget.c
===================================================================
RCS file: /cvs/gnome/gail/gail/gailwidget.c,v
retrieving revision 1.69
diff -u -p -r1.69 gailwidget.c
--- gail/gailwidget.c	3 Dec 2002 13:12:00 -0000	1.69
+++ gail/gailwidget.c	22 Jan 2003 14:11:28 -0000
@@ -33,6 +33,7 @@ static G_CONST_RETURN gchar* gail_widget
 static G_CONST_RETURN gchar* gail_widget_get_description (AtkObject *accessible);
 static AtkObject* gail_widget_get_parent (AtkObject *accessible);
 static AtkStateSet* gail_widget_ref_state_set (AtkObject *accessible);
+static AtkRelationSet* gail_widget_ref_relation_set (AtkObject *accessible);
 static gint gail_widget_get_index_in_parent (AtkObject *accessible);
 
 static void atk_component_interface_init (AtkComponentIface *iface);
@@ -159,6 +160,7 @@ gail_widget_class_init (GailWidgetClass 
   class->get_description = gail_widget_get_description;
   class->get_parent = gail_widget_get_parent;
   class->ref_state_set = gail_widget_ref_state_set;
+  class->ref_relation_set = gail_widget_ref_relation_set;
   class->get_index_in_parent = gail_widget_get_index_in_parent;
   class->initialize = gail_widget_real_initialize;
 }
@@ -403,6 +405,58 @@ gail_widget_ref_state_set (AtkObject *ac
         }
     }
   return state_set;
+}
+
+AtkRelationSet*
+gail_widget_ref_relation_set (AtkObject *obj)
+{
+  GtkWidget *widget;
+  AtkRelationSet *relation_set;
+
+  g_return_val_if_fail (GAIL_IS_WIDGET (obj), NULL);
+
+  widget = GTK_ACCESSIBLE (obj)->widget;
+  if (widget == NULL)
+    /*
+     * State is defunct
+     */
+	return NULL;
+
+  relation_set = ATK_OBJECT_CLASS (parent_class)->ref_relation_set (obj);
+
+  if (!atk_relation_set_contains (relation_set, ATK_RELATION_LABELLED_BY))
+    {
+      GList *list, *t;
+      guint length;
+      AtkObject **array;
+      gint i;
+      AtkRelation *relation;
+
+      list = gtk_widget_get_mnemonic_labels (widget);
+
+      if (list)
+        {
+          length = g_list_length (list);
+          array = g_new (AtkObject*, length);
+          i = 0;
+          for (t = list; t; t = t->next)
+            {
+              /* Ignore GtkLabel inside a GtkButton */
+              if (GTK_IS_BUTTON (widget) && 
+                  widget == gtk_widget_get_parent (GTK_WIDGET (t->data)))
+                continue;
+
+              array [i++] = gtk_widget_get_accessible (GTK_WIDGET (t->data));
+            }
+          if (i > 0)
+            {
+              relation = atk_relation_new (array, i, ATK_RELATION_LABELLED_BY);
+              atk_relation_set_add (relation_set, relation);
+              g_object_unref (relation);
+            }
+        }
+    }
+  return relation_set;
 }
 
 static gint
