Re: [g-a-devel] GAIL: Problem with is_attached_menu_window function



>>> This is *not* the correct solution; if you change
>>> is_attached_menu_window, the attached menu appears at the wrong place in
>>> the at-spi hierarchy.
>>>
>>> So, the problem is not in is_attached_menu_window - the window should
>>> NOT appear there, it should appear elsewhere, as a child of the widget
>>> to which it is attached.
>>>     
>>
>>
>> It seems that the problem is not in Gail. So where should I search a
>> source of the problem if not in Gail? Maybe it is a bug of Gtk+?
>>   
> 
> Hi Martin:
> 
> I think the bug is still probably in Gail, but not where you originally
> thought.  It's an RFE I suppose; I am not sure whether it should live in
> gailwidget.c or perhaps some other gail file, but an AtkObject for a
> widget that has an attached menu should include the attached menu among
> its children, and that child AtkObject should become VISIBLE and SHOWING
> when it pops up (also with FOCUSSED property at the appropriate place
> within the menu, which is probably already taken care of by the existing
> Gail menu code).
> 
> That is - the AtkObject which represents the menu should exist, and be
> created by Gail as it is created now, but instead of being a toplevel
> window, it should be a child of the object to which the menu is attached.

Hi Bill,
I found some mistakes in gailbutton.c. Problems which I've found were
placed in two functions: gail_button_get_n_children and
gail_button_ref_child. The patch in the attachment resolves all problems
with menus attached to buttons. After adding the attachment, attached
menus exist as children of the buttons.

Regards,
Marcin
--- gail-1.8.11.orig/gail/gailbutton.c	2006-11-27 14:25:40.000000000 +0100
+++ gail-1.8.11/gail/gailbutton.c	2006-12-11 15:08:42.000000000 +0100
@@ -23,6 +23,8 @@
 #include "gailbutton.h"
 #include <libgail-util/gailmisc.h>
 
+#define GAIL_BUTTON_ATTACHED_MENUS "gtk-attached-menus"
+
 static void                  gail_button_class_init       (GailButtonClass *klass);
 static void                  gail_button_object_init      (GailButton      *button);
 
@@ -132,6 +134,10 @@
 static void                  set_role_for_button        (AtkObject      *accessible,
                                                          GtkWidget      *button);
 
+static gint                  get_n_attached_menus       (GtkWidget      *widget);
+static GtkWidget*            get_nth_attached_menu      (GtkWidget      *widget,
+                                                         gint           index);
+
 static GailContainer* parent_class = NULL;
 
 GType
@@ -807,10 +813,11 @@
     return 0;
 
   /*
-   * Check whether we have an attached menu for PanelMenuButton
+   * Check whether we have an attached menus for PanelMenuButton
    */
-  if (g_object_get_data (G_OBJECT (widget), "gtk-attached-menu"))
-    return 1;
+  n_children = get_n_attached_menus (widget);
+  if (n_children > 0)
+    return n_children;
 
   n_children = get_n_labels_from_button (widget);
   if (n_children <= 1)
@@ -836,10 +843,15 @@
      */
     return NULL;
 
-  if (i == 0)
-    child_widget = g_object_get_data (G_OBJECT (widget), "gtk-attached-menu");
+  if (i >= gail_button_get_n_children (obj))
+    return NULL;
+
+  if (get_n_attached_menus (widget) > 0)
+  {
+    child_widget = get_nth_attached_menu (widget, i);
+  }
   else
-    child_widget = NULL;
+    child_widget = NULL;    
 
   if (!child_widget) 
     {
@@ -1622,3 +1634,37 @@
   accessible->role =  role;
 }
 
+static gint
+get_n_attached_menus (GtkWidget  *widget)
+{
+  GList *list_menus;
+  
+  if (widget == NULL)
+    return 0;
+
+  list_menus = g_object_get_data (G_OBJECT (widget), GAIL_BUTTON_ATTACHED_MENUS);
+  if (list_menus == NULL)
+    return 0;
+
+  return g_list_length (list_menus);
+}
+
+static GtkWidget*
+get_nth_attached_menu (GtkWidget  *widget,
+                       gint       index)
+{
+  GtkWidget *attached_menu;
+  GList *list_menus;
+
+  if (widget == NULL)
+    return NULL;
+
+  list_menus = g_object_get_data (G_OBJECT (widget), GAIL_BUTTON_ATTACHED_MENUS);
+  if (list_menus == NULL ||
+      index >= g_list_length (list_menus))
+    return NULL;
+
+  attached_menu = (GtkWidget *) g_list_nth_data (list_menus, index);
+
+  return attached_menu;
+}


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