I am currently trying to implement copy and paste for my application, the problem is that i can only plaintext or images to the clipboard according to the documentation of Gtk.Clipboard : https://valadoc.org/gtk+-3.0/Gtk.Clipboard.html set_text / set_image .

But then there is also this method https://valadoc.org/gtk+-3.0/Gtk.Clipboard.set_with_data.html set_with_data , which i think i can use for adding a uri or an array of uris. But i can't figure out how and didn't find any good examples either.

UPDATE

Using the given answer i can fill the clipboard with an array of uris, but i can read them, when i try it just calls the get_func again and refills it.

CTRL C pressed clipboard get_func called Received: file:///home/marcel/Downloads/.gitignore CTRL V pressd clipboard get_func called Received: file:///home/marcel/Downloads Try Pasting: file:///home/marcel/Downloads

This is the code i use for testing CTRL + V :

print ("

CTRL V pressd

"); clipboard.request_uris ((clipboard, uris) => { foreach ( string content in uris ) { print ("Try Pasting: "); print (content); print ("

"); } });

and this is the relevant part of the get_func for CTRL + C :

clipboard.set_with_owner ( clipboard_targets, (clipboard, selection_data, info, user_data_or_owner) => { print ("clipboard get_func called

"); var w = user_data_or_owner as Window; File[] files = { w.get_selected_file () }; switch ( info ) { case ClipboardProtocol.TEXT_URI_LIST: print ("Received: "); string[] uris = {}; foreach ( var file in files ) { print (file.get_uri ()); print ("

"); uris += file.get_uri (); } selection_data.set_uris (uris); break;

As you can see in the terminal output above, it just refills the clipboard, throwing away its previous values.