+#include <gtk/gtk.h>
+
+// constants taken from GTK sources
+#define LABEL_PAD 1
+#define LABEL_SIDE_PAD 2
+
+//-----------------------------------------------------------------------------
+// "size_allocate" from m_widget
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void size_allocate(GtkWidget* widget, GtkAllocation* alloc, void*)
+{
+ // clip label as GTK >= 2.12 does
+ GtkWidget* label_widget = gtk_frame_get_label_widget(GTK_FRAME(widget));
+ int w = alloc->width -
+ 2 * widget->style->xthickness - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
+ if (w < 0)
+ w = 0;
+
+ if (label_widget->allocation.width > w)
+ {
+ GtkAllocation alloc2 = label_widget->allocation;
+ alloc2.width = w;
+ gtk_widget_size_allocate(label_widget, &alloc2);
+ }
+}
+}