How can I get the type of Clipboard-Content?

Hi

I set an callbackfunction for the “owner-change”-Signal.

After receiving that signal, I want to test, what type of content is in the clipboard,
to react in a certain way.

How can I do that ?

Hi,

You can use Gdk.Clipboard.get_formats to get a Gdk.ContentFormats , which offers cool APIs to detect the content type, like Gdk.ContentFormats.get_gtypes or Gdk.ContentFormats.get_mime_types .

The “owner-change” signal comes from GtkClipboard in GTK3; you should always specify which version of GTK you’re using, given that there are two stable branches (GTK3 and GTK4) at any given time.

If you want to know which targets have been set, use gtk_clipboard_request_targets() and in the callback you can check which targets are provided by the owner of the clipboard.

1 Like

Thank you both.
I am working now with “gtk_clipboard_request_targets()”.

1 Like

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