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 651605 - Replace gtk_misc_set/get_padding() api and use the new GtkWidget "margin" properties instead
Replace gtk_misc_set/get_padding() api and use the new GtkWidget "margin" pro...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.1.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on: 629777
Blocks: 645780
 
 
Reported: 2011-06-01 02:16 UTC by Javier Jardón (IRC: jjardon)
Modified: 2011-12-12 19:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Replace gtk_misc_set/get_padding() api (22.31 KB, patch)
2011-06-01 02:16 UTC, Javier Jardón (IRC: jjardon)
needs-work Details | Review
Replace gtk_misc_set_padding() with GtkWidget:margin properties (6.54 KB, patch)
2011-06-02 11:59 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review

Description Javier Jardón (IRC: jjardon) 2011-06-01 02:16:28 UTC
Created attachment 188967 [details] [review]
Replace gtk_misc_set/get_padding() api

Patch following
Comment 1 Matthias Clasen 2011-06-01 02:27:15 UTC
Review of attachment 188967 [details] [review]:

::: gtk/gtkaccellabel.c
@@ +432,2 @@
       if (direction == GTK_TEXT_DIR_RTL)
+        x = (margin_left + margin_right) / 2;

This is not really the same thing, or is it ?
I would expect to use margin_left/_right here, as appropriate

::: gtk/gtkarrow.c
@@ +355,3 @@
 
+  x = (margin_left + margin_right) / 2 + ((width - extent) * xalign);
+  y = (margin_top + margin_bottom) / 2 + ((height - extent) * yalign);

Again here. Whats with all the averaging ?

::: gtk/gtklabel.c
@@ +3967,3 @@
   gtk_widget_get_allocation (widget, &allocation);
 
+  x = floor (allocation.x + (margin_right + margin_left) / 2 + xalign * (allocation.width - req_width) - logical.x);

Here too, I would expect to use either left or right as appropriate, not their average.
Comment 2 Benjamin Otte (Company) 2011-06-02 11:40:33 UTC
You cannot use gtk_widget_get_margin_*() APIs in draw, size_allocate or get_preferred_*() functions. They work completely different. Margins are taken care of automatically already.
That said, changing those functions would also stop gtk_misc_set_padding() from working, so it's an API break.

If we wanted to replace it like that, we should make gtk_misc_set_padding() call gtk_widget_set_margin() and replace all gtk_misc_get_padding() calls with 0.
Comment 3 Javier Jardón (IRC: jjardon) 2011-06-02 11:59:13 UTC
Created attachment 189074 [details] [review]
Replace gtk_misc_set_padding() with GtkWidget:margin properties

After talking with Benjamin, seems that we cannot replace misc_get_padding() with widget_get_margin().
We can only replace misc_get_padding() with 0 - but that breaks anybody using misc_set_padding, so seems we can only remove the misc_set() calls
Comment 4 Benjamin Otte (Company) 2011-06-02 16:01:30 UTC
Apart from me wondering if we should have a gtk_widget_set_margin() shorthand and using that instead of g_object_set(), the patch looks fine.
Comment 5 Javier Jardón (IRC: jjardon) 2011-06-02 16:51:17 UTC
Comment on attachment 189074 [details] [review]
Replace gtk_misc_set_padding() with GtkWidget:margin properties

commit 32ef28bc8592e0983c5b31ae64a30847164b981e
Comment 6 Javier Jardón (IRC: jjardon) 2011-06-02 16:54:22 UTC
(In reply to comment #4)
> Apart from me wondering if we should have a gtk_widget_set_margin() shorthand
> and using that instead of g_object_set(), 

Filled bug #651720