Index: gtklabel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklabel.c,v
retrieving revision 1.138
diff -u -p -r1.138 gtklabel.c
--- gtklabel.c	10 Dec 2002 12:02:43 -0000	1.138
+++ gtklabel.c	22 Jan 2003 11:23:34 -0000
@@ -768,14 +768,20 @@ gtk_label_set_mnemonic_widget (GtkLabel 
     g_return_if_fail (GTK_IS_WIDGET (widget));
 
   if (label->mnemonic_widget)
-    g_object_weak_unref (G_OBJECT (label->mnemonic_widget),
-			 label_mnemonic_widget_weak_notify,
-			 label);
+    {
+      g_object_weak_unref (G_OBJECT (label->mnemonic_widget),
+  			   label_mnemonic_widget_weak_notify,
+			   label);
+      _gtk_widget_remove_mnemonic_label (label->mnemonic_widget, label);
+    }
   label->mnemonic_widget = widget;
   if (label->mnemonic_widget)
-    g_object_weak_ref (G_OBJECT (label->mnemonic_widget),
-		       label_mnemonic_widget_weak_notify,
-		       label);
+    {
+      g_object_weak_ref (G_OBJECT (label->mnemonic_widget),
+		         label_mnemonic_widget_weak_notify,
+		         label);
+      _gtk_widget_add_mnemonic_label (label->mnemonic_widget, label);
+    }
   
   g_object_notify (G_OBJECT (label), "mnemonic_widget");
 }
Index: gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.340
diff -u -p -r1.340 gtkwidget.c
--- gtkwidget.c	18 Dec 2002 23:45:51 -0000	1.340
+++ gtkwidget.c	22 Jan 2003 11:23:35 -0000
@@ -244,6 +244,7 @@ static GQuark		quark_colormap = 0;
 static GQuark		quark_pango_context = 0;
 static GQuark		quark_rc_style = 0;
 static GQuark		quark_accessible_object = 0;
+static GQuark		quark_mnemonic_labels = 0;
 GParamSpecPool         *_gtk_widget_child_property_pool = NULL;
 GObjectNotifyContext   *_gtk_widget_child_property_notify_context = NULL;
 
@@ -317,6 +318,7 @@ gtk_widget_class_init (GtkWidgetClass *k
   quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
   quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
   quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
+  quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
 
   style_property_spec_pool = g_param_spec_pool_new (FALSE);
   _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
@@ -5959,6 +5961,7 @@ gtk_widget_finalize (GObject *object)
   gint *events;
   GdkExtensionMode *mode;
   GtkAccessible *accessible;
+  GList *mnemonic_labels;
   
   gtk_grab_remove (widget);
 
@@ -5984,6 +5987,10 @@ gtk_widget_finalize (GObject *object)
   if (accessible)
     g_object_unref (accessible);
 
+  mnemonic_labels = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels);
+  if (mnemonic_labels)
+    g_list_free (mnemonic_labels);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -6872,4 +6879,55 @@ gtk_widget_get_clipboard (GtkWidget *wid
   
   return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
 					selection);
+}
+
+/**
+ * gtk_widget_get_mnemonic_labels:
+ * @widget: a #GtkWidget
+ * 
+ * Returns a list of the widgets, normally labels, for which this widget
+ * is a mnemonic widget. 
+ * 
+ * Return value: the list of mnemonic labels
+ *
+ * Since: 2.4
+ **/
+GList *
+gtk_widget_get_mnemonic_labels (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+  return g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels);
+}
+
+void
+_gtk_widget_add_mnemonic_label (GtkWidget *widget,
+                                GtkWidget *label)
+{
+  GList *old_list, *new_list;
+
+  old_list = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels);
+  new_list = g_list_append (old_list, label);
+  if (new_list != old_list)
+    {
+      g_object_set_qdata (G_OBJECT (widget), 
+                          quark_mnemonic_labels,
+                          new_list);
+    }
+}
+
+void
+_gtk_widget_remove_mnemonic_label (GtkWidget *widget,
+                                   GtkWidget *label)
+{
+  GList *old_list, *new_list;
+
+  old_list = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels);
+  new_list = g_list_remove (old_list, label);
+  if (new_list != old_list)
+    {
+      g_object_set_qdata (G_OBJECT (widget), 
+                          quark_mnemonic_labels,
+                          new_list);
+    }
 }
Index: gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.141
diff -u -p -r1.141 gtkwidget.h
--- gtkwidget.h	10 Nov 2002 20:52:34 -0000	1.141
+++ gtkwidget.h	22 Jan 2003 11:23:35 -0000
@@ -748,6 +748,7 @@ void	     gtk_widget_class_path	   (GtkW
 					    guint     *path_length,
 					    gchar    **path,
 					    gchar    **path_reversed);
+GList*      gtk_widget_get_mnemonic_labels (GtkWidget *widget);
 
 GType           gtk_requisition_get_type (void);
 GtkRequisition *gtk_requisition_copy     (const GtkRequisition *requisition);
@@ -767,7 +768,10 @@ void              _gtk_widget_propagate_
 
 GdkColormap* _gtk_widget_peek_colormap (void);
 
-
+void              _gtk_widget_add_mnemonic_label          (GtkWidget    *widget,
+                                                           GtkWidget    *label);
+void              _gtk_widget_remove_mnemonic_label       (GtkWidget    *widget,
+                                                           GtkWidget    *label);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
