3

I'm trying to write a a GTK/C application that puts some files on the Gtk clipboard, so a user with Nautilus will be able to paste them. There is a good example of Gtk Clipboard local file copy and paste on stackoverflow. Unofrtunately the files I need to paste are not on the local disk, and cannot be accessed via a standard GVFS URI scheme like file:// Only my application can access these source file after setting up a TCP connection, authenticating and opening an extra channel.

How can I have these application managed remote files on the Gtk clipboard for pasting with Nautilus ? And in the future, for Dolphin/KDE too ?

After googling around I came to the following idea: I need to develop a new gvfs URI scheme handler (ie: my-app://). But it's hard to find examples or documentation. Is it the only way ? And, can my application register itself as a temporary GVFS URI scheme handler without changing any external system configuration file ? How ?

Community
  • 1
  • 1
giox069
  • 137
  • 3
  • 1
    I wrote an example in vala, but it might still be helpful: https://stackoverflow.com/questions/50319438/inserting-uris-into-gtk-clipboard-with-vala/50320539#50320539 –  May 18 '18 at 17:32
  • Ok, with your example you can put an URI on the clipboard. In your specific case they are files on the local filesystem, like '/home/lukas/tmp/test.txt'. But, as said above, I have no files on the filesystem: the content stream I want to put on the clipboard is generated on the fly by the application when the user want to paste it into nautilus. In windows there seems to be a function: RegisterClipboardFormat(CFSTR_FILECONTENTS) which allows Windows Explorer to paste an application generated stream. But not for nautilus. – giox069 Mar 17 '19 at 12:29

1 Answers1

1

This is an old question, but I had to solve a similar issue. By creating a custom fuse filesystem it was possible to utilize the normal clipboard behavior (kde and gnome way of announcing files to copy in the clipboard) and have network resources only utilized if the data is actually accessed.

akallabeth
  • 21
  • 2