Index: gtklabel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklabel.c,v
retrieving revision 1.139
diff -u -p -r1.139 gtklabel.c
--- gtklabel.c	31 Jan 2003 00:08:33 -0000	1.139
+++ gtklabel.c	21 Jul 2003 14:30:33 -0000
@@ -737,6 +737,7 @@ label_mnemonic_widget_weak_notify (gpoin
   GtkLabel *label = data;
 
   label->mnemonic_widget = NULL;
+  gtk_widget_remove_mnemonic_label (label->mnemonic_widget, GTK_WIDGET (label));
   g_object_notify (G_OBJECT (label), "mnemonic_widget");
 }
 
@@ -773,9 +774,12 @@ gtk_label_set_mnemonic_widget (GtkLabel 
 			 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, GTK_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.354
diff -u -p -r1.354 gtkwidget.c
--- gtkwidget.c	18 Jul 2003 22:12:51 -0000	1.354
+++ gtkwidget.c	21 Jul 2003 14:30:34 -0000
@@ -245,6 +245,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;
 
@@ -318,6 +319,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);
@@ -6120,6 +6122,7 @@ gtk_widget_finalize (GObject *object)
   gint *events;
   GdkExtensionMode *mode;
   GtkAccessible *accessible;
+  GList *mnemonic_labels;
   
   gtk_grab_remove (widget);
 
@@ -6145,6 +6148,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);
 }
 
@@ -7049,4 +7056,69 @@ gtk_widget_get_clipboard (GtkWidget *wid
   
   return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
 					selection);
+}
+
+/**
+ * gtk_widget_list_mnemonic_labels:
+ * @widget: a #GtkWidget
+ * 
+ * Returns a newly allocated list of the widgets, normally labels, for 
+ * which this widget is a the target of a mnemonic ( see for example, 
+ * gtk_label_set_mnemonic_widget()).  The widgets
+ * in the list are not individually referenced. If you want
+ * to iterate through the list and perform actions involving
+ * callbacks that might destroy the widgets, you <emphasis>must</emphasis> call
+ * <literal>g_list_foreach (result, (GFunc)g_object_ref, NULL)</literal> first,
+and
+ * then unref all the widgets afterwards.
+
+ * 
+ * Return value: the list of mnemonic labels
+ *
+ * Since: 2.4
+ **/
+GList *
+gtk_widget_list_mnemonic_labels (GtkWidget *widget)
+{
+  GList *l;
+  GList *list = NULL;
+  
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+  for (l = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels); l; l = l->next)
+    list = g_list_prepend (list, l->data);
+
+  return list;
+}
+
+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.142
diff -u -p -r1.142 gtkwidget.h
--- gtkwidget.h	18 Jul 2003 17:37:15 -0000	1.142
+++ gtkwidget.h	21 Jul 2003 14:30:35 -0000
@@ -749,6 +749,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);
@@ -768,7 +769,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 */
