13
0

Allow to destroy Widgets when removing them from a container

This is useful when the container uses manage()d Widgets,
which are otherwise not destroyed.
This commit is contained in:
Robin Gareus 2022-04-09 15:00:57 +02:00
parent defc902571
commit f9d80c32d6
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 5 additions and 2 deletions

View File

@ -139,7 +139,7 @@ namespace Gtkmm2ext {
LIBGTKMM2EXT_API int physical_screen_height (Glib::RefPtr<Gdk::Window>);
LIBGTKMM2EXT_API int physical_screen_width (Glib::RefPtr<Gdk::Window>);
LIBGTKMM2EXT_API void container_clear (Gtk::Container&);
LIBGTKMM2EXT_API void container_clear (Gtk::Container&, bool and_delete = false);
/* C++ API for rounded rectangles */

View File

@ -667,12 +667,15 @@ Gtkmm2ext::physical_screen_width (Glib::RefPtr<Gdk::Window> win)
}
void
Gtkmm2ext::container_clear (Gtk::Container& c)
Gtkmm2ext::container_clear (Gtk::Container& c, bool and_delete)
{
list<Gtk::Widget*> children = c.get_children();
for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
(*child)->hide ();
c.remove (**child);
if (and_delete) {
delete *child;
}
}
}