Package: gtk

Class gtk-clipboard

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

None

Details

The gtk-clipboard object represents a clipboard of data shared between different processes or between different widgets in the same process. Each clipboard is identified by a name encoded as a gdk-atom type. Conversion to and from strings can be done with the gdk-atom-intern and gdk-atom-name functions. The default clipboard corresponds to the "CLIPBOARD" atom. Another commonly used clipboard is the "PRIMARY" clipboard, which, in X, traditionally contains the currently selected text.

To support having a number of different formats on the clipboard at the same time, the clipboard mechanism allows providing callback functions instead of the actual data. When you set the contents of the clipboard, you can either supply the data directly via functions like gtk-clipboard-set-text, or you can supply a callback function to be called at a later time when the data is needed via the gtk-clipboard-set-with-data function. Providing a callback function also avoids having to make copies of the data when it is not needed.

Requesting the data from the clipboard is essentially asynchronous. If the contents of the clipboard are provided within the same process, then a direct function call will be made to retrieve the data, but if they are provided by another process, then the data needs to be retrieved from the other process, which may take some time. To avoid blocking the user interface, the call to request the selection, the gtk-clipboard-request-contents function takes a callback function that will be called when the contents are received or when the request fails. If you do not want to deal with providing a separate callback function, you can also use the gtk-clipboard-wait-for-contents function. What this does is run the GLib main loop recursively waiting for the contents. This can simplify the code flow, but you still have to be aware that other callback functions in your program can be called while this recursive main loop is running.

Along with the functions to get the clipboard contents as an arbitrary data chunk, there are also functions to retrieve it as text, the gtk-clipboard-request-text and gtk-clipboard-wait-for-text functions. These functions take care of determining which formats are advertised by the clipboard provider, asking for the clipboard in the best available format and converting the results into the UTF-8 encoding, which is the standard form for representing strings in GTK.

Signal Details

The "owner-change" signal
 lambda (clipboard event)    :run-first      
The signal is emitted when GTK receives an event that indicates that the ownership of the selection associated with the clipboard has changed.
clipboard
The gtk-clipboard object on which the signal is emitted.
event
The gdk-event-owner-change event.
 

Inherited Slot Access Functions

See also

2021-10-20