Gtk4 Screenshot with GtkSnapshot

,

Why? just use the existing snapshot function, but pass your own GtkSnapshot object.

Something like this (untested):

snapshot = gtk_snapshot_new ();
gtk_widget_snapshot (widget, snapshot);
node = gtk_snapshot_free_to_node (snapshot);
renderer = gtk_native_get_renderer (gtk_widget_get_native (widget));
texture = gsk_renderer_render_texture (renderer,
                                       node,
                                       &GRAPHENE_RECT_INIT (0, 0, widget.get_width(), widget.get_height()));
gdk_texture_save_to_png (texture, png_file);