[g-a-devel]gailbutton get_label_from_button change



This patch changes get_label_from_button's behavior when the button's
child is a box.  Instead of assuming the second child is a label, it
searches the box's children for a label.

This also fixes a crash that was occurring when the child was a box that
had only one child.

-dave
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gail/ChangeLog,v
retrieving revision 1.397
diff -u -r1.397 ChangeLog
--- ChangeLog	12 Mar 2002 19:24:26 -0000	1.397
+++ ChangeLog	13 Mar 2002 01:16:26 -0000
@@ -1,4 +1,10 @@
 (top)
+2002-03-12  Dave Camp  <dave ximian com>
+
+	* gail/gailbutton.c (get_label_from_button): If the button's child
+	is a box, loop over the children looking for a label instead of
+	guessing that the second child is a label.
+
 2002-03-12  Federico Mena Quintero  <federico ximian com>
 
 	* gail/gailcanvasitem.c (get_item_extents): Compute the extents
Index: gail/gailbutton.c
===================================================================
RCS file: /cvs/gnome/gail/gail/gailbutton.c,v
retrieving revision 1.37
diff -u -r1.37 gailbutton.c
--- gail/gailbutton.c	18 Feb 2002 15:05:37 -0000	1.37
+++ gail/gailbutton.c	13 Mar 2002 01:16:27 -0000
@@ -699,14 +699,22 @@
   if (GTK_IS_BOX (child))
     {
       /*
-       * Child is not a label; perhaps the button is for a stock item.
-       * If it is, then the second child of the child should be a label.
+       * Child is not a label.  Search for a label in the box's children.
        */
       GList *children, *tmp_list;
  
       children = gtk_container_children (GTK_CONTAINER (child));
-      tmp_list = g_list_nth (children, 1);
-      child = GTK_WIDGET (tmp_list->data);
+
+      child = NULL;
+      for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next) 
+	{
+	  if (GTK_IS_LABEL (tmp_list->data))
+	    {
+	      child = GTK_WIDGET (tmp_list->data);
+	      break;
+	    }  
+	}
+
       g_list_free (children);
     }
   return child;


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