Index: gail/ChangeLog
===================================================================
RCS file: /cvs/gnome/gail/ChangeLog,v
retrieving revision 1.732
diff -u -p -r1.732 ChangeLog
--- gail/ChangeLog	1 Jun 2004 13:18:29 -0000	1.732
+++ gail/ChangeLog	2 Jun 2004 08:54:10 -0000
@@ -1,3 +1,16 @@
+2004-06-02  Padraig O'Briain  <padraig.obriain@sun.com>
+
+	* gail/gailnotebook.c (gail_notebook_real_remove_gtk): New function
+	which emits children-changed::remove signal. The emission is done
+	here rather than in gail_notebook_child_parent_set as the underlying
+	GtkNotebook has been updated when this function is called.
+	(gail_notebook_child_parent_set): Set index of item being removed.
+	* gail/gailnotebook.h: Add remove_index to GailNotebook data
+	structure.
+
+	This fixes problem of create-tab notification being received after
+	first remove tab nortification when tabs are removed. See bug #128970.
+
 2004-06-01  Padraig O'Briain  <padraig.obriain@sun.com>
 
 	* gail/gailnotebookpage.c (get_label_from_notebook_page): Add check
Index: gail/gail/gailnotebook.c
===================================================================
RCS file: /cvs/gnome/gail/gail/gailnotebook.c,v
retrieving revision 1.27
diff -u -p -r1.27 gailnotebook.c
--- gail/gail/gailnotebook.c	20 May 2004 08:09:01 -0000	1.27
+++ gail/gail/gailnotebook.c	2 Jun 2004 08:54:10 -0000
@@ -33,6 +33,9 @@ static void         gail_notebook_real_n
 
 static AtkObject*   gail_notebook_ref_child           (AtkObject      *obj,
                                                        gint           i);
+static gint         gail_notebook_real_remove_gtk     (GtkContainer   *container,
+                                                       GtkWidget      *widget,
+                                                       gpointer       data);    
 static void         atk_selection_interface_init      (AtkSelectionIface *iface);
 static gboolean     gail_notebook_add_selection       (AtkSelection   *selection,
                                                        gint           i);
@@ -120,11 +123,7 @@ gail_notebook_class_init (GailNotebookCl
    * as the implementation in GailContainer returns the correct
    * number of children.
    */
-  /*
-   * We do not emit emit notification of when child is removed as this
-   * is done in gail_notebook_child_parent_set.
-   */
-  container_class->remove_gtk = NULL;
+  container_class->remove_gtk = gail_notebook_real_remove_gtk;
 }
 
 static void
@@ -133,6 +132,7 @@ gail_notebook_object_init (GailNotebook 
   notebook->page_cache = NULL;
   notebook->selected_page = -1;
   notebook->focus_tab_page = -1;
+  notebook->remove_index = -1;
   notebook->idle_focus_id = 0;
 }
 
@@ -514,18 +514,33 @@ create_notebook_page_accessible (GailNot
 static void
 gail_notebook_child_parent_set (GtkWidget *widget,
                                 GtkWidget *old_parent,
-                                gpointer  data)
+                                gpointer   data)
 {
   GailNotebook *gail_notebook;
-  AtkObject *obj;
-  gint index;
 
   g_return_if_fail (old_parent != NULL);
   gail_notebook = GAIL_NOTEBOOK (gtk_widget_get_accessible (old_parent));
-  index = GPOINTER_TO_INT (data);
+  if (gail_notebook->remove_index != -1)
+    g_warning ("Unexpected value for remove_index");
+  gail_notebook->remove_index = GPOINTER_TO_INT (data);
+}
+
+static gint
+gail_notebook_real_remove_gtk (GtkContainer *container,
+                               GtkWidget    *widget,
+                               gpointer      data)    
+{
+  GailNotebook *gail_notebook;
+  AtkObject *obj;
+  gint index;
+
+  g_return_val_if_fail (container != NULL, 1);
+  gail_notebook = GAIL_NOTEBOOK (gtk_widget_get_accessible (GTK_WIDGET (container)));
+  index = gail_notebook->remove_index;
+  gail_notebook->remove_index = -1;
 
   obj = find_child_in_list (gail_notebook->page_cache, index);
-  g_return_if_fail (obj);
+  g_return_val_if_fail (obj, 1);
   gail_notebook->page_cache = g_list_remove (gail_notebook->page_cache, obj);
   gail_notebook->page_count -= 1;
   g_signal_emit_by_name (gail_notebook,
@@ -533,6 +548,7 @@ gail_notebook_child_parent_set (GtkWidge
                           GAIL_NOTEBOOK_PAGE (obj)->index, 
                           obj, NULL);
   g_object_unref (obj);
+  return 1;
 }
 
 static gboolean
Index: gail/gail/gailnotebook.h
===================================================================
RCS file: /cvs/gnome/gail/gail/gailnotebook.h,v
retrieving revision 1.9
diff -u -p -r1.9 gailnotebook.h
--- gail/gail/gailnotebook.h	19 May 2004 14:11:25 -0000	1.9
+++ gail/gail/gailnotebook.h	2 Jun 2004 08:54:10 -0000
@@ -52,6 +52,8 @@ struct _GailNotebook
   gint         focus_tab_page;
   gint         page_count;
   guint        idle_focus_id;
+
+  gint         remove_index;
 };
 
 GType gail_notebook_get_type (void);
