[maemo-commits] [maemo-commits] r13491 - projects/haf/trunk/gtk+/gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Aug 30 16:02:25 EEST 2007
Author: xan
Date: 2007-08-30 16:02:24 +0300 (Thu, 30 Aug 2007)
New Revision: 13491

Modified:
   projects/haf/trunk/gtk+/gtk/gtkentrycompletion.c
Log:
Reduce the popup size for entrycompletion if it does not fit in either direction.

Shrink the popup until it fits in the direction with more space (this will break if
not even one row fits ...).
Also fix bug in the calculation of the available space where y was used instead of height
for the entry.


Modified: projects/haf/trunk/gtk+/gtk/gtkentrycompletion.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkentrycompletion.c	2007-08-30 13:01:17 UTC (rev 13490)
+++ projects/haf/trunk/gtk+/gtk/gtkentrycompletion.c	2007-08-30 13:02:24 UTC (rev 13491)
@@ -1468,15 +1468,22 @@
         to_top = root_y;
 
       if (bottom)
-          to_bottom = bottom->y - (root_y + completion->priv->entry->allocation.y);
+        to_bottom = bottom->y - (root_y + completion->priv->entry->allocation.height);
       else
-        to_bottom = monitor.height - (root_y + completion->priv->entry->allocation.y);
+        to_bottom = monitor.height - (root_y + completion->priv->entry->allocation.height);
+ 
+      /* It does not fit in either direction, we need
+         to reduce the popup size */
+      if (popup_req.height > to_bottom && popup_req.height > to_top)
+        {
+          gint max_items =  MAX (to_bottom, to_top) / height;
 
-      /* If the popup fits below the entry we will put it there, otherwise it will
-         go above it. If it does not fit in either direction we will put it below
-         anyway. This is not exactly right, but we don't have other options */
-      if (popup_req.height <= to_bottom ||
-          popup_req.height > to_top)
+          gtk_widget_set_size_request (completion->priv->tree_view, width, max_items * height);
+          gtk_widget_size_request (completion->priv->popup_window, &popup_req);
+          gtk_widget_size_request (completion->priv->entry, &entry_req);
+        }
+
+      if (popup_req.height <= to_bottom)
         {
           above = FALSE;
           y += entry_req.height;


More information about the maemo-commits mailing list