gtk_container_queue_resize(), gtk_widget_unparent()



While looking at making gtk_container_queue_resize() non-exported,
I noticed in gtktable.c:

      if (child->widget == widget)
	{
	  gboolean was_visible = GTK_WIDGET_VISIBLE (widget);
	  
	  gtk_widget_unparent (widget);
	  
	  table->children = g_list_remove (table->children, child);
	  g_free (child);
	  
	  if (was_visible && GTK_WIDGET_VISIBLE (container))
	    gtk_container_queue_resize (container);
	  break;
	}

Now, most other widgets do the marginally less efficient
gtk_widget_queue_resize (container), which is probably good
enough, but I was trying to figure out if we could do
better.

It seems natural to do this in gtk_widget_unparent, allowing us to
write:

      if (child->widget == widget)
	{
	  gtk_widget_unparent (widget);
	  
	  table->children = g_list_remove (table->children, child);
	  g_free (child);

          break;
        }

The only problem with this is if we have an "immediate"
resize mode, then it doesn't work, since the old size
will be found, not the new size. We probably could write,
instead:
          
      if (child->widget == widget)
	{
	  table->children = g_list_remove (table->children, child);
	  g_free (child);

	  gtk_widget_unparent (widget);
	  
          break;
        }

But it seems a little tricky that the order would matter here.
So, perhaps simply requiring people to do gtk_widget_queue_resize()
is best. 

(Again, it seems to me, resize_immediate probably would have been
better never added; it's just a useless codepath iniviting untested
reentrancy problems.)

Regards,
                                        Owen




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