From 430b32617486a25e4e5b0b439e3dfd8014513d3c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 19 Aug 2025 14:20:39 +0200 Subject: [PATCH] YTKMM: expose ytk_set_child_packing --- libs/tk/ytkmm/box.cc | 16 ++++++++++++++++ libs/tk/ytkmm/ytkmm/box.h | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/libs/tk/ytkmm/box.cc b/libs/tk/ytkmm/box.cc index 3ee15a109d..f618566d66 100644 --- a/libs/tk/ytkmm/box.cc +++ b/libs/tk/ytkmm/box.cc @@ -134,6 +134,22 @@ void Box::pack_end(Widget& child, PackOptions options, guint padding) gtk_box_pack_end(gobj(), child.gobj(), (gboolean)expand, (gboolean)fill, padding); } +void Box::set_child_packing(Widget& child, bool expand, bool fill, guint padding) +{ + gboolean p_expand = 0; + gboolean p_fill = 0; + guint p_padding = 0; + GtkPackType p_pack_type = GTK_PACK_START; + + gtk_box_query_child_packing (gobj(), (child).gobj(), &p_expand, &p_fill, &p_padding, &p_pack_type); + + if (p_expand == expand && p_fill == fill && p_padding == padding) { + return; + } + + gtk_box_set_child_packing(gobj(), (child).gobj(), expand, fill, padding, p_pack_type); +} + } /* namespace Gtk */ diff --git a/libs/tk/ytkmm/ytkmm/box.h b/libs/tk/ytkmm/ytkmm/box.h index 48687ae18a..86785ab81a 100644 --- a/libs/tk/ytkmm/ytkmm/box.h +++ b/libs/tk/ytkmm/ytkmm/box.h @@ -392,6 +392,24 @@ public: */ void pack_end(Widget& child, PackOptions options = PACK_EXPAND_WIDGET, guint padding = 0); + /** Updates the way @child is packed into @a box The pack-type (start, end) is retained. + * + * @param child The Widget to be update + * @param expand true if the new child is to be given extra space allocated to + * @a box. The extra space will be divided evenly between all children of + * @a box that use this option. + * @param fill true if space given to @a child by the @a expand option is + * actually allocated to @a child, rather than just padding it. This + * parameter has no effect if @a expand is set to false. A child is + * always allocated the full height of a Gtk::HBox and the full width + * of a Gtk::VBox. This option affects the other dimension. + * @param padding Extra space in pixels to put between this child and its + * neighbors, over and above the global amount specified by + * Gtk::Box::property_spacing() property. If @a child is a widget at one of the + * reference ends of @a box, then @a padding pixels are also put between + * @a child and the reference edge of @a box. + */ + void set_child_packing(Widget& child, bool expand, bool fill, guint padding = 0); /** Sets the Gtk::Box::property_homogeneous() property of @a box, controlling * whether or not all children of @a box are given equal space