From f59cb0e05da9e5968ecd97fd00240593dbe879fc Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 29 Jun 2011 16:17:07 +0200 Subject: [PATCH] a11y: Keep the gail notebook in the notebook page We used to keep the GtkNotebook, but that causes issues at creation time of the GailNotebook, when the GtkNotebook does not yet have an accessible set and so it can't be queried. --- gtk/a11y/gailnotebook.c | 2 +- gtk/a11y/gailnotebookpage.c | 23 +++++++++++------------ gtk/a11y/gailnotebookpage.h | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gtk/a11y/gailnotebook.c b/gtk/a11y/gailnotebook.c index f00283abf2..dd8a5ca63f 100644 --- a/gtk/a11y/gailnotebook.c +++ b/gtk/a11y/gailnotebook.c @@ -402,7 +402,7 @@ create_notebook_page_accessible (GailNotebook *gail_notebook, { AtkObject *obj; - obj = gail_notebook_page_new (notebook, child); + obj = gail_notebook_page_new (gail_notebook, child); g_hash_table_insert (gail_notebook->pages, child, obj); diff --git a/gtk/a11y/gailnotebookpage.c b/gtk/a11y/gailnotebookpage.c index 6b31280449..b323d1988d 100644 --- a/gtk/a11y/gailnotebookpage.c +++ b/gtk/a11y/gailnotebookpage.c @@ -167,20 +167,21 @@ notify_child_added (gpointer data) } AtkObject* -gail_notebook_page_new (GtkNotebook *notebook, - GtkWidget *child) +gail_notebook_page_new (GailNotebook *notebook, + GtkWidget *child) { GObject *object; AtkObject *atk_object; GailNotebookPage *page; GtkWidget *label; - g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL); + g_return_val_if_fail (GAIL_IS_NOTEBOOK (notebook), NULL); + g_return_val_if_fail (GTK_WIDGET (child), NULL); object = g_object_new (GAIL_TYPE_NOTEBOOK_PAGE, NULL); page = GAIL_NOTEBOOK_PAGE (object); - page->notebook = notebook; + page->notebook = GTK_ACCESSIBLE (notebook); page->child = child; page->textutil = NULL; @@ -325,10 +326,7 @@ gail_notebook_page_get_parent (AtkObject *accessible) page = GAIL_NOTEBOOK_PAGE (accessible); - if (!page->notebook) - return NULL; - - return gtk_widget_get_accessible (GTK_WIDGET (page->notebook)); + return ATK_OBJECT (page->notebook); } static gint @@ -352,7 +350,7 @@ gail_notebook_page_ref_child (AtkObject *accessible, return NULL; page = GAIL_NOTEBOOK_PAGE (accessible); - if (!page->notebook) + if (!page->child) return NULL; child_obj = gtk_widget_get_accessible (page->child); @@ -366,10 +364,11 @@ gail_notebook_page_get_index_in_parent (AtkObject *accessible) GailNotebookPage *page; page = GAIL_NOTEBOOK_PAGE (accessible); - if (!page->notebook || !page->child) + if (!page->child) return -1; - return gtk_notebook_page_num (page->notebook, page->child); + return gtk_notebook_page_num (GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook)), + page->child); } static AtkStateSet* @@ -778,7 +777,7 @@ get_label_from_notebook_page (GailNotebookPage *page) GtkWidget *child; GtkNotebook *notebook; - notebook = page->notebook; + notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook)); if (!notebook) return NULL; diff --git a/gtk/a11y/gailnotebookpage.h b/gtk/a11y/gailnotebookpage.h index 5f68b5f1af..9c8aba6f7b 100644 --- a/gtk/a11y/gailnotebookpage.h +++ b/gtk/a11y/gailnotebookpage.h @@ -39,7 +39,7 @@ struct _GailNotebookPage { AtkObject parent; - GtkNotebook *notebook; + GtkAccessible *notebook; GtkWidget *child; guint notify_child_added_id; @@ -54,7 +54,7 @@ struct _GailNotebookPageClass AtkObjectClass parent_class; }; -AtkObject *gail_notebook_page_new(GtkNotebook *notebook, GtkWidget *child); +AtkObject *gail_notebook_page_new (GailNotebook *notebook, GtkWidget *child); void gail_notebook_page_invalidate (GailNotebookPage *page);