summaryrefslogtreecommitdiffstats
path: root/subprojects/libhandy/src/hdy-css.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:36:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:36:24 +0000
commit9b6d8e63db85c30007b463e91f91a791969fa83f (patch)
tree0899af51d73c1bf986f73ae39a03c4436083018a /subprojects/libhandy/src/hdy-css.c
parentInitial commit. (diff)
downloadgnome-control-center-9b6d8e63db85c30007b463e91f91a791969fa83f.tar.xz
gnome-control-center-9b6d8e63db85c30007b463e91f91a791969fa83f.zip
Adding upstream version 1:3.38.4.upstream/1%3.38.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'subprojects/libhandy/src/hdy-css.c')
-rw-r--r--subprojects/libhandy/src/hdy-css.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/subprojects/libhandy/src/hdy-css.c b/subprojects/libhandy/src/hdy-css.c
new file mode 100644
index 0000000..7a056e2
--- /dev/null
+++ b/subprojects/libhandy/src/hdy-css.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2020 Purism SPC
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+#include "config.h"
+
+#include "hdy-css-private.h"
+
+void
+hdy_css_measure (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum,
+ gint *natural)
+{
+ GtkStyleContext *style_context = gtk_widget_get_style_context (widget);
+ GtkStateFlags state_flags = gtk_widget_get_state_flags (widget);
+ GtkBorder border, margin, padding;
+ gint css_width, css_height;
+
+ /* Manually apply minimum sizes, the border, the padding and the margin as we
+ * can't use the private GtkGagdet.
+ */
+ gtk_style_context_get (style_context, state_flags,
+ "min-width", &css_width,
+ "min-height", &css_height,
+ NULL);
+ gtk_style_context_get_border (style_context, state_flags, &border);
+ gtk_style_context_get_margin (style_context, state_flags, &margin);
+ gtk_style_context_get_padding (style_context, state_flags, &padding);
+ if (orientation == GTK_ORIENTATION_VERTICAL) {
+ *minimum = MAX (*minimum, css_height) +
+ border.top + margin.top + padding.top +
+ border.bottom + margin.bottom + padding.bottom;
+ *natural = MAX (*natural, css_height) +
+ border.top + margin.top + padding.top +
+ border.bottom + margin.bottom + padding.bottom;
+ } else {
+ *minimum = MAX (*minimum, css_width) +
+ border.left + margin.left + padding.left +
+ border.right + margin.right + padding.right;
+ *natural = MAX (*natural, css_width) +
+ border.left + margin.left + padding.left +
+ border.right + margin.right + padding.right;
+ }
+}
+
+void
+hdy_css_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkStyleContext *style_context;
+ GtkStateFlags state_flags;
+ GtkBorder border, margin, padding;
+
+ /* Manually apply the border, the padding and the margin as we can't use the
+ * private GtkGagdet.
+ */
+ style_context = gtk_widget_get_style_context (widget);
+ state_flags = gtk_widget_get_state_flags (widget);
+ gtk_style_context_get_border (style_context, state_flags, &border);
+ gtk_style_context_get_margin (style_context, state_flags, &margin);
+ gtk_style_context_get_padding (style_context, state_flags, &padding);
+ allocation->width -= border.left + border.right +
+ margin.left + margin.right +
+ padding.left + padding.right;
+ allocation->height -= border.top + border.bottom +
+ margin.top + margin.bottom +
+ padding.top + padding.bottom;
+ allocation->x += border.left + margin.left + padding.left;
+ allocation->y += border.top + margin.top + padding.top;
+}