Re: gtk_notebook_map bug




Lars Hamann <lars@gtk.org> writes:

[...]

> > So, a safe rewrite for this section of code would look a bit like:
> > 
> >       children = notebook->children;
> > 
> >       while (children)
> > 	{
> > 	  page = children->data;
> > 	  children = children->next;
> > 
> > 	  if (page->tab_label)
> >             {
> >               if (notebook->show_tabs && GTK_WIDGET_VISIBLE (page->child))
> >                 {
> >                   if (GTK_WIDGET_VISIBLE (page->tab_label))
> >                     {
> >                       if (!GTK_WIDGET_MAPPED (page->tab_label))
> >                          gtk_widget_map (page->tab_label);
> >                     }
> >                   else
> >                     gtk_widget_show (page->tab_label);
> >                 }
> >               else 
> >                 {
> >                   if (GTK_WIDGET_VISIBLE (page->tab_label))
> >                     GTK_WIDGET_HIDE (page->tab_label);
> >                 }
> > 	    }
> >          }
> > 
> > That is probably overkill, since the show/hide is also going on in
> > gtk_widget_size_request, so perhaps your fix is sufficient.  But I'd
> > like to have a some idea of exactly how the problem is occurring
> > before I start changing stuff.
> 
> Your fix looks better. The code should check notebook->show_tabs at least,
> since gtk_notebook_size_request does not automatically hide tab_labels
> in case of show_tabs == FALSE.

But that is just a bug, since then if the application does a
gtk_widget_show (tab_label) at the wrong time, it can end 
up shown when it isn't supposed to be.

The::size_request handler is the only thing we know is 
guaranteed to run after any changes to the visibility of
the children. So it has to enforce the mapped and visibible
constraints for the children.

I think it is better to to keep gtk_notebook_map() as simple
as possible and put the intelligence into one place. I'm
applying the following patch, though if someone wants to come
up with something better, that would be appreciated.

I think somebody really needs to go through gtknotebook
_write down_ the expected behavior with with the mapped
and visibility states of the children and enforce that.
But that perhaps can wait until we add a ::child_shown signal
to gtk_container for 1.4.

Regards,
                                        Owen

Index: gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.65.2.6
diff -u -r1.65.2.6 gtknotebook.c
--- gtknotebook.c	1999/09/17 09:03:44	1.65.2.6
+++ gtknotebook.c	2000/01/26 04:19:48
@@ -514,8 +514,8 @@
 	  page = children->data;
 	  children = children->next;
 
-	  if (page->tab_label && 
-	      GTK_WIDGET_VISIBLE (page->child) && 
+	  if (page->tab_label &&
+	      GTK_WIDGET_VISIBLE (page->tab_label) &&
 	      !GTK_WIDGET_MAPPED (page->tab_label))
 	    gtk_widget_map (page->tab_label);
 	}
@@ -801,6 +801,15 @@
 						    TAB_OVERLAP);
 		  break;
 		}
+	    }
+	}
+      else
+	{
+	  for (children = notebook->children; children;
+	       children = children->next)
+	    {
+	      if (GTK_WIDGET_VISIBLE (page->tab_label))
+		gtk_widget_hide (page->tab_label);
 	    }
 	}
     }



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