[gtk] entry: Measure icons again



commit b658a1a8e32847adfc2cb6e408d77b93db177cb4
Author: Timm Bäder <mail baedert org>
Date:   Sun Jul 21 09:58:08 2019 +0200

    entry: Measure icons again
    
    This was previously removed because it changes the minimum and natural
    size of the entry when the icons are shown/hidden at runtime. Just not
    measuring them does not work however, so reintroduce this.

 gtk/gtkentry.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index b746537ba4..16ca45c106 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -1529,6 +1529,7 @@ gtk_entry_measure (GtkWidget      *widget,
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
+  int i;
 
   gtk_widget_measure (priv->text,
                       orientation,
@@ -1536,6 +1537,30 @@ gtk_entry_measure (GtkWidget      *widget,
                       minimum, natural,
                       minimum_baseline, natural_baseline);
 
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
+      int icon_min, icon_nat;
+
+      if (!icon_info)
+        continue;
+
+      gtk_widget_measure (icon_info->widget,
+                          GTK_ORIENTATION_HORIZONTAL,
+                          -1, &icon_min, &icon_nat, NULL, NULL);
+
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          *minimum += icon_min;
+          *natural += icon_nat;
+        }
+      else
+        {
+          *minimum = MAX (*minimum, icon_min);
+          *natural = MAX (*natural, icon_nat);
+        }
+    }
+
   if (priv->progress_widget && gtk_widget_get_visible (priv->progress_widget))
     {
       int prog_min, prog_nat;


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