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 702563 - gtk_widget_class_automate_child() takes private offset
gtk_widget_class_automate_child() takes private offset
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on: 702996
Blocks: 700898
 
 
Reported: 2013-06-18 13:39 UTC by Allison Karlitskaya (desrt)
Modified: 2013-07-26 13:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
widget: Use a real offset in gtk_widget_class_automate_child (4.66 KB, patch)
2013-07-02 12:05 UTC, Alexander Larsson
none Details | Review
widget: Use a real offset in gtk_widget_class_automate_child / v2.0 (55.92 KB, patch)
2013-07-05 00:01 UTC, Emmanuele Bassi (:ebassi)
accepted-commit_now Details | Review

Description Allison Karlitskaya (desrt) 2013-06-18 13:39:29 UTC
gtk_widget_class_automate_child should take an offset relative to the _instance_ pointer rather than the private pointer.  These days, private pointers are at a constant offset to the instance which is a change that we made so that GProperty could remove this instance/private distinction.

Doing it this way would solve a very very common case: people who want to use this stuff to build their main window and have the children as pointers on their instance, without creating a private struct (which is semi-pointless since they're not doing libraries).
Comment 1 Alexander Larsson 2013-07-02 12:05:58 UTC
Created attachment 248212 [details] [review]
widget: Use a real offset in gtk_widget_class_automate_child

Using an offset from the struct means you can have children in
both the public and private (via G_PRIVATE_OFFSET) parts of the
instance. It also matches the new private macros nicer.

This is a WIP and not yet tested, because it doesn't work until
all users are converted to use the new _WITH_PRIVATE/ADD_PRIVATE
setup.
Comment 2 Emmanuele Bassi (:ebassi) 2013-07-05 00:01:03 UTC
Created attachment 248428 [details] [review]
widget: Use a real offset in gtk_widget_class_automate_child / v2.0

same patch as Alex's, but this one has all the call sites updated, plus the correct check on the field offset not being zero, instead of it being positive (as the private offset is negative).

tested on master, and it works pretty nicely.
Comment 3 Emmanuele Bassi (:ebassi) 2013-07-05 01:20:19 UTC
forgot to say: this patch depends on the patchset for bug 702996 which transitions all GTK classes to the new private macros and offset-based access.
Comment 4 Tristan Van Berkom 2013-07-06 03:46:45 UTC
Review of attachment 248428 [details] [review]:

Looks pretty straight forward.

With the last issue fixed, checking for 'child_class->offset != 0', 
the patch looks perfectly safe to me.

Marking as commit-now (but of course it still depends on, yet another
uncommitted patch).

I'll try to keep my eye on this, when these patches land we should
announce it on gtk-devel-list, as there are a couple of projects
already using this API.
Comment 5 Allison Karlitskaya (desrt) 2013-07-06 09:46:49 UTC
Note in particular that Vala is codegening to this API.
Comment 6 Emmanuele Bassi (:ebassi) 2013-07-06 09:51:24 UTC
(In reply to comment #5)
> Note in particular that Vala is codegening to this API.

yes, I've already talked to Lethalman on #vala about the changes, including the ones for bug 700898 (and discovered a bug in the Vala implementation in the process that would be fixed by this patch).
Comment 7 Emmanuele Bassi (:ebassi) 2013-07-26 10:12:27 UTC
we *really* need to land this before the 3.10 freeze date, otherwise we're going to be stuck with the current API.