After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776637 - Add gtk_widget_set_margin() to set all 4 margins at once (i.e. GTK+ API for property Widget:margin)
Add gtk_widget_set_margin() to set all 4 margins at once (i.e. GTK+ API for p...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: Other
3.89.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-12-30 23:31 UTC by Daniel Boles
Modified: 2018-05-02 17:56 UTC
See Also:
GNOME target: ---
GNOME version: 3.23/3.24


Attachments
[PATCH 1/2] widget: Avoid repeated calls to g_value_get...() (2.61 KB, patch)
2016-12-31 00:23 UTC, Daniel Boles
none Details | Review
[PATCH 2/2] widget: Add convenience gtk_widget_set_margin() (3.13 KB, patch)
2016-12-31 00:25 UTC, Daniel Boles
needs-work Details | Review
[PATCH 1/2] widget: Avoid repeated calls to g_value_get...() (2.60 KB, patch)
2016-12-31 00:29 UTC, Daniel Boles
none Details | Review

Description Daniel Boles 2016-12-30 23:31:12 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.
Comment 1 Daniel Boles 2016-12-30 23:34:26 UTC
fwiw, gtkmm has already anticipated the same thing, and added a widget.set_margin() method that does this.
Comment 2 Daniel Boles 2016-12-31 00:23:46 UTC
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.
Comment 3 Daniel Boles 2016-12-31 00:25:28 UTC
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.
Comment 4 Daniel Boles 2016-12-31 00:29:42 UTC
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 5 Daniel Boles 2017-08-04 00:20:34 UTC
Comment on attachment 342650 [details] [review]
[PATCH 2/2] widget: Add convenience gtk_widget_set_margin()

lol, the function name was wrong.
Comment 6 GNOME Infrastructure Team 2018-05-02 17:56:10 UTC
-- 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.