[gtk+] a11y: Make notebookpage emit child-added signal sync



commit 5d57716ef8588cb72d4f18a2b426526c35315541
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jun 29 02:15:18 2011 +0200

    a11y: Make notebookpage emit child-added signal sync
    
    Don't use an idle handler

 gtk/a11y/gailnotebook.c     |   13 +++++++++----
 gtk/a11y/gailnotebookpage.c |   31 -------------------------------
 gtk/a11y/gailnotebookpage.h |    1 -
 3 files changed, 9 insertions(+), 36 deletions(-)
---
diff --git a/gtk/a11y/gailnotebook.c b/gtk/a11y/gailnotebook.c
index dd8a5ca..c1d16ff 100644
--- a/gtk/a11y/gailnotebook.c
+++ b/gtk/a11y/gailnotebook.c
@@ -45,7 +45,8 @@ static gboolean     gail_notebook_is_child_selected   (AtkSelection   *selection
                                                        gint           i);
 static void         create_notebook_page_accessible   (GailNotebook   *gail_notebook,
                                                        GtkNotebook    *notebook,
-                                                       GtkWidget      *child);
+                                                       GtkWidget      *child,
+                                                       int             page_num);
 static gboolean     gail_notebook_focus_cb            (GtkWidget      *widget,
                                                        GtkDirectionType type);
 static gboolean     gail_notebook_check_focus_tab     (gpointer       data);
@@ -129,7 +130,7 @@ gail_notebook_page_added (GtkNotebook *gtk_notebook,
 
   atk_obj = gtk_widget_get_accessible (GTK_WIDGET (gtk_notebook));
   notebook = GAIL_NOTEBOOK (atk_obj);
-  create_notebook_page_accessible (notebook, gtk_notebook, child);
+  create_notebook_page_accessible (notebook, gtk_notebook, child, page_num);
 }
 
 static void
@@ -170,7 +171,8 @@ gail_notebook_real_initialize (AtkObject *obj,
     {
       create_notebook_page_accessible (notebook,
                                        gtk_notebook,
-                                       gtk_notebook_get_nth_page (gtk_notebook, i));
+                                       gtk_notebook_get_nth_page (gtk_notebook, i),
+                                       i);
     }
   notebook->selected_page = gtk_notebook_get_current_page (gtk_notebook);
 
@@ -398,7 +400,8 @@ gail_notebook_is_child_selected (AtkSelection *selection,
 static void
 create_notebook_page_accessible (GailNotebook *gail_notebook,
                                  GtkNotebook  *notebook,
-                                 GtkWidget    *child)
+                                 GtkWidget    *child,
+                                 int           page_num)
 {
   AtkObject *obj;
 
@@ -406,6 +409,8 @@ create_notebook_page_accessible (GailNotebook *gail_notebook,
   g_hash_table_insert (gail_notebook->pages,
                        child,
                        obj);
+  atk_object_set_parent (obj, ATK_OBJECT (gail_notebook));
+  g_signal_emit_by_name (gail_notebook, "children_changed::add", page_num, obj, NULL);
 }
 
 static gboolean
diff --git a/gtk/a11y/gailnotebookpage.c b/gtk/a11y/gailnotebookpage.c
index b323d19..9f6b000 100644
--- a/gtk/a11y/gailnotebookpage.c
+++ b/gtk/a11y/gailnotebookpage.c
@@ -139,33 +139,6 @@ gail_notebook_page_init (GailNotebookPage *page)
 {
 }
 
-static gint
-notify_child_added (gpointer data)
-{
-  GailNotebookPage *page;
-  AtkObject *atk_object, *atk_parent;
-
-  g_return_val_if_fail (GAIL_IS_NOTEBOOK_PAGE (data), FALSE);
-  page = GAIL_NOTEBOOK_PAGE (data);
-  atk_object = ATK_OBJECT (data);
-
-  page->notify_child_added_id = 0;
-
-  /* The widget page->notebook may be deleted before this handler is called */
-  if (page->notebook != NULL)
-    {
-      atk_parent = gtk_widget_get_accessible (GTK_WIDGET (page->notebook));
-      atk_object_set_parent (atk_object, atk_parent);
-      g_signal_emit_by_name (atk_parent,
-                             "children_changed::add",
-                             gtk_notebook_page_num (page->notebook, page->child),
-                             atk_object,
-                             NULL);
-    }
-  
-  return FALSE;
-}
-
 AtkObject*
 gail_notebook_page_new (GailNotebook *notebook, 
                         GtkWidget    *child)
@@ -189,7 +162,6 @@ gail_notebook_page_new (GailNotebook *notebook,
   atk_object->role = ATK_ROLE_PAGE_TAB;
   atk_object->layer = ATK_LAYER_WIDGET;
 
-  page->notify_child_added_id = gdk_threads_add_idle (notify_child_added, atk_object);
   /*
    * We get notified of changes to the label
    */
@@ -292,9 +264,6 @@ gail_notebook_page_finalize (GObject *object)
   if (page->textutil)
     g_object_unref (page->textutil);
 
-  if (page->notify_child_added_id)
-    g_source_remove (page->notify_child_added_id);
-
   G_OBJECT_CLASS (gail_notebook_page_parent_class)->finalize (object);
 }
 
diff --git a/gtk/a11y/gailnotebookpage.h b/gtk/a11y/gailnotebookpage.h
index 9c8aba6..b8e7a29 100644
--- a/gtk/a11y/gailnotebookpage.h
+++ b/gtk/a11y/gailnotebookpage.h
@@ -42,7 +42,6 @@ struct _GailNotebookPage
   GtkAccessible *notebook;
   
   GtkWidget *child;
-  guint notify_child_added_id;
 
   GailTextUtil *textutil;
 };



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]