# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1326468051 0 # Node ID 189b27f24d64f300b0a9c4f52782a5839a3144a6 # Parent 6edf3fce77f2a801feb33920982857127f88dd2b Attempt to find the size of contents on GTK2 while packing. diff -r 6edf3fce77f2 -r 189b27f24d64 gtk/dw.c --- a/gtk/dw.c Fri Jan 13 06:37:28 2012 +0000 +++ b/gtk/dw.c Fri Jan 13 15:20:51 2012 +0000 @@ -10119,14 +10119,44 @@ int thiswidth = width, thisheight = height; /* If it is a scrolled item and not expandable... - * set the default size to 500x200. + * Clamp to minumum or maximum. */ if(GTK_IS_SCROLLED_WINDOW(item)) { - if(thiswidth < 1 && !hsize) - thiswidth = 500; - if(thisheight < 1 && !vsize) - thisheight = 200; + GtkWidget *widget = gtk_object_get_user_data(GTK_OBJECT(item)); + + /* Try to figure out the contents for MLE and Container */ + if(widget && (GTK_IS_TEXT_VIEW(widget) || GTK_IS_CLIST(widget))) + { + GtkRequisition req; + + gtk_widget_size_request(widget, &req); + + if(thiswidth < 1 && !hsize) + { + thiswidth = req.width + 20; + if(thiswidth < _DW_SCROLLED_MIN_WIDTH) + thiswidth = _DW_SCROLLED_MIN_WIDTH; + if(thiswidth > _DW_SCROLLED_MAX_WIDTH) + thiswidth = _DW_SCROLLED_MAX_WIDTH; + } + if(thisheight < 1 && !vsize) + { + thisheight = req.height + 20; + if(thisheight < _DW_SCROLLED_MIN_HEIGHT) + thisheight = _DW_SCROLLED_MIN_HEIGHT; + if(thisheight > _DW_SCROLLED_MAX_HEIGHT) + thisheight = _DW_SCROLLED_MAX_HEIGHT; + } + } + else + { + /* Set to max for others */ + if(thiswidth < 1 && !hsize) + thiswidth = _DW_SCROLLED_MAX_WIDTH; + if(thisheight < 1 && !vsize) + thisheight = _DW_SCROLLED_MAX_HEIGHT; + } } gtk_widget_set_usize(item, thiswidth, thisheight); }