/** * gtk_test_create_widget: * @widget_type: a valid widget type. * @first_property_name: (allow-none): Name of first property to set or %NULL * @...: value to set the first property to, followed by more * name-value pairs, terminated by %NULL * * This function wraps g_object_new() for widget types. * It'll automatically show all created non window widgets, also * g_object_ref_sink() them (to keep them alive across a running test) * and set them up for destruction during the next test teardown phase. * * Returns: (transfer none): a newly created widget. * * Since: 2.14 */ GtkWidget* gtk_test_create_widget (GType widget_type, const gchar *first_property_name, ...) { GtkWidget *widget; va_list var_args; g_return_val_if_fail (g_type_is_a (widget_type, GTK_TYPE_WIDGET), NULL); va_start (var_args, first_property_name); widget = (GtkWidget*) g_object_new_valist (widget_type, first_property_name, var_args); va_end (var_args); if (widget) { if (!GTK_IS_WINDOW (widget)) gtk_widget_show (widget); g_object_ref_sink (widget); g_test_queue_unref (widget); g_test_queue_destroy ((GDestroyNotify) gtk_widget_destroy, widget); } return widget; }
GdkPixmap* create_pixmap (int width, int height) { GdkColormap* colormap; GdkDrawable* drawable; cairo_t * cr; colormap = gdk_screen_get_system_colormap (gdk_screen_get_default ()); g_assert (colormap); drawable = gdk_pixmap_new (NULL, 200, 200, gdk_colormap_get_visual (colormap)->depth); g_test_queue_unref (drawable); gdk_drawable_set_colormap (drawable, colormap); cr = gdk_cairo_create (drawable); cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_paint (cr); cairo_destroy (cr); return drawable; }