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:
parent
defc902571
commit
f9d80c32d6
@ -139,7 +139,7 @@ namespace Gtkmm2ext {
|
|||||||
LIBGTKMM2EXT_API int physical_screen_height (Glib::RefPtr<Gdk::Window>);
|
LIBGTKMM2EXT_API int physical_screen_height (Glib::RefPtr<Gdk::Window>);
|
||||||
LIBGTKMM2EXT_API int physical_screen_width (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 */
|
/* C++ API for rounded rectangles */
|
||||||
|
|
||||||
|
@ -667,12 +667,15 @@ Gtkmm2ext::physical_screen_width (Glib::RefPtr<Gdk::Window> win)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Gtkmm2ext::container_clear (Gtk::Container& c)
|
Gtkmm2ext::container_clear (Gtk::Container& c, bool and_delete)
|
||||||
{
|
{
|
||||||
list<Gtk::Widget*> children = c.get_children();
|
list<Gtk::Widget*> children = c.get_children();
|
||||||
for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
|
for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
|
||||||
(*child)->hide ();
|
(*child)->hide ();
|
||||||
c.remove (**child);
|
c.remove (**child);
|
||||||
|
if (and_delete) {
|
||||||
|
delete *child;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user