changeset 1546:189b27f24d64

Attempt to find the size of contents on GTK2 while packing.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 13 Jan 2012 15:20:51 +0000
parents 6edf3fce77f2
children 2fd9ff675d79
files gtk/dw.c
diffstat 1 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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);
       }