Is it possible to only claim the clipboard with gtk4 without filling the actual data?

With gtk3, we could just “claim” the clipboard, advertising the list of mime types for which we can provide data, using gtk_clipboard_set_with_owner.
I cannot find a way to do that with gtk4 as it seems we need to pass the data to the content providers we create, which mean we have to fetch/compute said data in advance. If we want to provide e.g both text/plain and text/html (with different contents), we thus have to generate the two, when formerly we would just claim the two mime types and generate the appropriate one when requested.
Is there any way around this, or was it too X11 specific?

You can implement a https://docs.gtk.org/gdk4/class.ContentProvider.html yourself that provides data on demand.

This is a somewhat low level API though, so you’ll definitely want to have the GTK sources ready - both for looking at how GTK itself implements content providers as well as to debug any issues that might come up.

Sounds obvious now… Thanks a lot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.