GNOME Bugzilla – Bug 776637
Add gtk_widget_set_margin() to set all 4 margins at once (i.e. GTK+ API for property Widget:margin)
Last modified: 2018-05-02 17:56:10 UTC
With Container:border-width removed, the typical replacement is to set an equivalent margin on all 4 sides of the child. That can be done using the Widget:margin property, but given that a lot more people are going to be wanting to call this in GTK+ 4, I think there should be normal GTK+ API available for it. Having to write > g_object_set (G_OBJECT (widget), "margin", an_int, NULL); is a lot more verbose and flow-breaking than > gtk_widget_set_margin (widget, an_int); would be.
fwiw, gtkmm has already anticipated the same thing, and added a widget.set_margin() method that does this.
Created attachment 342649 [details] [review] [PATCH 1/2] widget: Avoid repeated calls to g_value_get...() Based on IRC discussions with Company, I don't much expect either of these to be accepted, but I'd already gone and written them, so! This was just something I noticed on the way to implementing the suggestion in the title. The drawback as already stated by Company is that it achieves relatively little in the grand scheme of things while adding several lines. > AFAIK it's very dubious whether compilers can optimise these away across > translation units, at least if LTO is not in play, and it only costs a > few more lines to explicitly not re-query the GValues an extra 4 times.
Created attachment 342650 [details] [review] [PATCH 2/2] widget: Add convenience gtk_widget_set_margin() > With Container:border-width removed, the quick and ugly - and hence > likely to be extremely popular - replacement is to set an equivalent > margin on all 4 sides of the child. That can be done using the margin > property, but as a lot more folk will probably be wanting to call this, > perhaps there should be normal GTK+ API available for it (assuming the > whole concept of margins in code survives until GTK+ 4.0). This adds a > method to set all sides and changes the property to work in terms of it.
Created attachment 342651 [details] [review] [PATCH 1/2] widget: Avoid repeated calls to g_value_get...() fix alignment of call parentheses (read: don't align them because we rarely see that anywhere else in GTK+ and it's a real slippery slope to get started on)
Comment on attachment 342650 [details] [review] [PATCH 2/2] widget: Add convenience gtk_widget_set_margin() lol, the function name was wrong.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/731.