How can I read out the “glade ID” of a gtk3 object

99封情书 提交于 2019-12-13 14:19:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!