+GdkDrawable*
+ghb_curved_rect_mask(gint width, gint height, gint radius)
+{
+ GdkDrawable *shape;
+ cairo_t *cr;
+ double w, h;
+
+ if (!width || !height)
+ return NULL;
+
+ shape = (GdkDrawable *)gdk_pixmap_new (NULL, width, height, 1);
+
+ cr = gdk_cairo_create (shape);
+
+ w = width;
+ h = height;
+ if (radius > width / 2)
+ radius = width / 2;
+ if (radius > height / 2)
+ radius = height / 2;
+
+ // fill shape with black
+ cairo_save(cr);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ cairo_move_to (cr, 0, radius);
+ cairo_curve_to (cr, 0 , 0, 0 , 0, radius, 0);
+ cairo_line_to (cr, w - radius, 0);
+ cairo_curve_to (cr, w, 0, w, 0, w, radius);
+ cairo_line_to (cr, w , h - radius);
+ cairo_curve_to (cr, w, h, w, h, w - radius, h);
+ cairo_line_to (cr, 0 + radius, h);
+ cairo_curve_to (cr, 0, h, 0, h, 0, h - radius);
+
+ cairo_close_path(cr);
+
+ cairo_set_source_rgb(cr, 1, 1, 1);
+ cairo_fill(cr);
+
+ cairo_destroy(cr);
+
+ return shape;
+}
+
+G_MODULE_EXPORT void
+preview_hud_size_alloc_cb(
+ GtkWidget *widget,
+ GtkAllocation *allocation,
+ signal_user_data_t *ud)
+{
+ GdkDrawable *shape;
+
+ //g_message("preview_hud_size_alloc_cb()");
+ if (GTK_WIDGET_VISIBLE(widget) && allocation->height > 50)
+ {
+ shape = ghb_curved_rect_mask(allocation->width,
+ allocation->height, allocation->height/4);
+ if (shape != NULL)
+ {
+ gtk_widget_shape_combine_mask(widget, shape, 0, 0);
+ gdk_pixmap_unref(shape);
+ }
+ }
+}
+