[libhandy/wip/exalm/css: 17/17] header-bar: Respect CSS min-width and min-height



commit 1b8a09337118a18c765cdf155264c683f7c3f0d9
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu May 21 01:58:10 2020 +0500

    header-bar: Respect CSS min-width and min-height
    
    Fixes https://gitlab.gnome.org/GNOME/libhandy/issues/194.

 src/hdy-header-bar.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/hdy-header-bar.c b/src/hdy-header-bar.c
index b8f60768..9e1c54ea 100644
--- a/src/hdy-header-bar.c
+++ b/src/hdy-header-bar.c
@@ -974,13 +974,20 @@ hdy_header_bar_measure (GtkWidget      *widget,
   GtkStyleContext *style_context;
   GtkStateFlags state_flags;
   GtkBorder border, margin, padding;
+  gint css_width, css_height;
+
+  gtk_style_context_get (gtk_widget_get_style_context (widget),
+                         gtk_widget_get_state_flags (widget),
+                         "min-width", &css_width,
+                         "min-height", &css_height,
+                         NULL);
 
   if (for_size < 0)
     hdy_header_bar_get_size (widget, orientation, minimum, natural);
   else if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    hdy_header_bar_compute_size_for_orientation (widget, for_size, minimum, natural);
+    hdy_header_bar_compute_size_for_orientation (widget, MAX (for_size, css_height), minimum, natural);
   else
-    hdy_header_bar_compute_size_for_opposing_orientation (widget, for_size, minimum, natural);
+    hdy_header_bar_compute_size_for_opposing_orientation (widget, MAX (for_size, css_width), minimum, 
natural);
 
   /* Manually apply the border, the padding and the margin as we can't use the
    * private GtkGagdet.
@@ -995,11 +1002,17 @@ hdy_header_bar_measure (GtkWidget      *widget,
                 border.bottom + margin.bottom + padding.bottom;
     *natural += border.top + margin.top + padding.top +
                 border.bottom + margin.bottom + padding.bottom;
+
+    *minimum = MAX (*minimum, css_height);
+    *natural = MAX (*natural, css_height);
   } else {
     *minimum += border.left + margin.left + padding.left +
                 border.right + margin.right + padding.right;
     *natural += border.left + margin.left + padding.left +
                 border.right + margin.right + padding.right;
+
+    *minimum = MAX (*minimum, css_width);
+    *natural = MAX (*natural, css_width);
   }
 }
 


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