summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rwxr-xr-xbase/gfx/gtk_util.cc13
-rwxr-xr-xbase/gfx/gtk_util.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/base/gfx/gtk_util.cc b/base/gfx/gtk_util.cc
index 1b0fc31..ba93c34 100755
--- a/base/gfx/gtk_util.cc
+++ b/base/gfx/gtk_util.cc
@@ -10,6 +10,15 @@
#include "base/gfx/rect.h"
#include "skia/include/SkBitmap.h"
+namespace {
+
+// Callback used in RemoveAllChildren.
+void RemoveWidget(GtkWidget* widget, gpointer container) {
+ gtk_container_remove(GTK_CONTAINER(container), widget);
+}
+
+} // namespace
+
namespace gfx {
const GdkColor kGdkWhite = GDK_COLOR_RGB(0xff, 0xff, 0xff);
@@ -79,4 +88,8 @@ GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
return ebox;
}
+void RemoveAllChildren(GtkWidget* container) {
+ gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container);
+}
+
} // namespace gfx
diff --git a/base/gfx/gtk_util.h b/base/gfx/gtk_util.h
index 6407554..6a6cdd6 100755
--- a/base/gfx/gtk_util.h
+++ b/base/gfx/gtk_util.h
@@ -39,6 +39,9 @@ GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap);
GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
int top, int bottom, int left, int right);
+// Remove all children from this container.
+void RemoveAllChildren(GtkWidget* container);
+
} // namespace gfx
#endif // BASE_GFX_GTK_UTIL_H_