[gtk+] Report ATK_STATE_SHOWING only when all parents are visible



commit f22239c4aae183e3ff5d19c06c21fbc8e15a40be
Author: Alejandro Piñeiro Iglesias <apinheiro igalia com>
Date:   Wed Jul 29 11:55:53 2009 +0800

    Report ATK_STATE_SHOWING only when all parents are visible
    
    Bug #509650. Checks if all the predecesors (the parent widget,
    his parent, etc) are visible. Only reports ATK_STATE_SHOWING when
    all parents are visible.
    Signed-off-by: Li Yuan <li yuan sun com>

 modules/other/gail/gailwidget.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/modules/other/gail/gailwidget.c b/modules/other/gail/gailwidget.c
index 3d0eed8..9493fc4 100644
--- a/modules/other/gail/gailwidget.c
+++ b/modules/other/gail/gailwidget.c
@@ -106,6 +106,7 @@ static void       gail_widget_real_initialize    (AtkObject     *obj,
                                                   gpointer      data);
 static GtkWidget* gail_widget_find_viewport      (GtkWidget     *widget);
 static gboolean   gail_widget_on_screen          (GtkWidget     *widget);
+static gboolean   gail_widget_all_parents_visible(GtkWidget     *widget);
 
 G_DEFINE_TYPE_WITH_CODE (GailWidget, gail_widget, GTK_TYPE_ACCESSIBLE,
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
@@ -518,8 +519,8 @@ gail_widget_ref_state_set (AtkObject *accessible)
       if (GTK_WIDGET_VISIBLE (widget))
         {
           atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
-          if (gail_widget_on_screen (widget) &&
-              GTK_WIDGET_MAPPED (widget))
+          if (gail_widget_on_screen (widget) && GTK_WIDGET_MAPPED (widget) &&
+              gail_widget_all_parents_visible (widget))
             {
               atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
             }
@@ -1079,3 +1080,30 @@ static gboolean gail_widget_on_screen (GtkWidget *widget)
 
   return return_value;
 }
+
+/**
+ * gail_widget_all_parents_visible:
+ * @widget: a #GtkWidget
+ *
+ * Checks if all the predecesors (the parent widget, his parent, etc) are visible
+ * Used to check properly the SHOWING state.
+ *
+ * Return value: TRUE if all the parent hierarchy is visible, FALSE otherwise
+ **/
+static gboolean gail_widget_all_parents_visible (GtkWidget *widget)
+{
+  GtkWidget *iter_parent = NULL;
+  gboolean result = TRUE;
+
+  for (iter_parent = gtk_widget_get_parent (widget); iter_parent;
+       iter_parent = gtk_widget_get_parent (iter_parent))
+    {
+      if (!GTK_WIDGET_VISIBLE (iter_parent))
+        {
+          result = FALSE;
+          break;
+        }
+    }
+
+  return result;
+}



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