I've got a pack box in my GTK application and I'm replacing it every once in a while with a completely new entry (at least for now cause I'm in a hurry).
Since I'm replacing it with a new instance, do I need to explicitly free from memory the old pack box contents or is there some garbage collection in GTK?
If I do need to explicitly need to free the object, is there a command that will recursively go to all objects in that tree (like will it clear my button in a box container inside my main pack box)? Also, what about the signals and handlers connected to the objects?
I'm using C/GTK-2.0 (gcc v4.4.3 and GTK 2.20.0).
GtkWidget is the base class all widgets in GTK derive from. It manages the widget lifecycle, layout, states and style.
GTK is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK is suitable for projects ranging from small one-off tools to complete application suites.
To begin our introduction to GTK, we'll start with a simple Hello World GTK application. Create a new file with the following content named hello-world-gtk. c . For more information on how to compile a GTK application, please refer to the Compiling GTK Applications section in the GTK API reference.
Description. A GtkWindow is a toplevel window which can contain other widgets. Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,...).
GObjects are reference-counted. When you pack a widget into a container, the container takes over ownership.
When you do gtk_container_remove()
, the reference held by the container is dropped, which typically causes the widget to be destroyed.
So no, you shouldn't need to explicitly destroy it, just removing it from the container is enough.
The documentation for the gtk_container_remove()
API also says that it can be more efficient to just call gtk_widget_destroy()
directly on the child, so if that's what you're already doing you're fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With