问题
In glade it is possible to set an unique ID to an object. In the code one can obtain a pointer to this object by searching for it's "glade ID" via gtk_builder_get_object().
However for my current use-case I just want to read out this ID from an GObject. What's the API to do so ?
回答1:
You can't. The builder ID is stored in the builder internally, not in the GObject.
The reason for this is that IDs must be unique per builder, which would be impossible to enforce if you were able to get and set them via some GObject API.
回答2:
You could use gtk_widget_get_name() to identify an object.
来源:https://stackoverflow.com/questions/38812379/how-can-i-read-out-the-glade-id-of-a-gtk3-object