diff --git a/gtk/a11y/gailnotebook.c b/gtk/a11y/gailnotebook.c index 17fb6c7095..9997547e01 100644 --- a/gtk/a11y/gailnotebook.c +++ b/gtk/a11y/gailnotebook.c @@ -35,9 +35,6 @@ static void gail_notebook_real_notify_gtk (GObject *obj, 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); @@ -75,10 +72,8 @@ gail_notebook_class_init (GailNotebookClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); AtkObjectClass *class = ATK_OBJECT_CLASS (klass); GailWidgetClass *widget_class; - GailContainerClass *container_class; widget_class = (GailWidgetClass*)klass; - container_class = (GailContainerClass*)klass; gobject_class->finalize = gail_notebook_finalize; @@ -91,7 +86,6 @@ gail_notebook_class_init (GailNotebookClass *klass) * as the implementation in GailContainer returns the correct * number of children. */ - container_class->remove_gtk = gail_notebook_real_remove_gtk; } static void @@ -150,6 +144,34 @@ gail_notebook_page_added (GtkNotebook *gtk_notebook, notebook->page_count++; } +static void +gail_notebook_page_removed (GtkNotebook *notebook, + GtkWidget *widget, + guint page_num, + gpointer data) +{ + GailNotebook *gail_notebook; + AtkObject *obj; + gint index; + + gail_notebook = GAIL_NOTEBOOK (gtk_widget_get_accessible (GTK_WIDGET (notebook))); + 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); + gail_notebook->page_cache = g_list_remove (gail_notebook->page_cache, obj); + gail_notebook->page_count -= 1; + reset_cache (gail_notebook, index); + g_signal_emit_by_name (gail_notebook, + "children_changed::remove", + page_num, + obj, + NULL); + gail_notebook_page_invalidate (GAIL_NOTEBOOK_PAGE (obj)); + g_object_unref (obj); +} + static void gail_notebook_real_initialize (AtkObject *obj, gpointer data) @@ -177,6 +199,10 @@ gail_notebook_real_initialize (AtkObject *obj, "page-added", G_CALLBACK (gail_notebook_page_added), NULL); + g_signal_connect (gtk_notebook, + "page-removed", + G_CALLBACK (gail_notebook_page_removed), + NULL); g_object_weak_ref (G_OBJECT(gtk_notebook), (GWeakNotify) gail_notebook_destroyed, obj); @@ -501,33 +527,6 @@ gail_notebook_child_parent_set (GtkWidget *widget, gail_notebook->remove_index = GAIL_NOTEBOOK_PAGE (data)->index; } -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_val_if_fail (obj, 1); - gail_notebook->page_cache = g_list_remove (gail_notebook->page_cache, obj); - gail_notebook->page_count -= 1; - reset_cache (gail_notebook, index); - g_signal_emit_by_name (gail_notebook, - "children_changed::remove", - GAIL_NOTEBOOK_PAGE (obj)->index, - obj, NULL); - g_object_unref (obj); - return 1; -} - static gboolean gail_notebook_focus_cb (GtkWidget *widget, GtkDirectionType type) diff --git a/gtk/a11y/gailnotebookpage.c b/gtk/a11y/gailnotebookpage.c index 1bf12da716..13b3e56969 100644 --- a/gtk/a11y/gailnotebookpage.c +++ b/gtk/a11y/gailnotebookpage.c @@ -185,7 +185,6 @@ gail_notebook_page_new (GtkNotebook *notebook, page = GAIL_NOTEBOOK_PAGE (object); page->notebook = notebook; - g_object_add_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook); page->index = pagenum; widget_page = gtk_notebook_get_nth_page (notebook, pagenum); page->page = widget_page; @@ -214,6 +213,18 @@ gail_notebook_page_new (GtkNotebook *notebook, return atk_object; } +void +gail_notebook_page_invalidate (GailNotebookPage *page) +{ + g_return_if_fail (GAIL_IS_NOTEBOOK_PAGE (page)); + + atk_object_notify_state_change (ATK_OBJECT (page), + ATK_STATE_DEFUNCT, + TRUE); + atk_object_set_parent (ATK_OBJECT (page), NULL); + page->notebook = NULL; +} + static void gail_notebook_page_label_map_gtk (GtkWidget *widget, gpointer data) @@ -282,9 +293,6 @@ gail_notebook_page_finalize (GObject *object) { GailNotebookPage *page = GAIL_NOTEBOOK_PAGE (object); - if (page->notebook) - g_object_remove_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook); - if (page->textutil) g_object_unref (page->textutil); diff --git a/gtk/a11y/gailnotebookpage.h b/gtk/a11y/gailnotebookpage.h index a87e0722df..78aaca4164 100644 --- a/gtk/a11y/gailnotebookpage.h +++ b/gtk/a11y/gailnotebookpage.h @@ -61,6 +61,8 @@ struct _GailNotebookPageClass AtkObject *gail_notebook_page_new(GtkNotebook *notebook, gint pagenum); +void gail_notebook_page_invalidate (GailNotebookPage *page); + G_END_DECLS #endif /* __GAIL_NOTEBOOK_PAGE_H__ */