Synopsis#include <gtk/gtk.h> GtkClipboard; void (*GtkClipboardReceivedFunc) (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); void (*GtkClipboardTextReceivedFunc) (GtkClipboard *clipboard, const gchar *text, gpointer data); void (*GtkClipboardImageReceivedFunc) (GtkClipboard *clipboard, GdkPixbuf *pixbuf, gpointer data); void (*GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard, GdkAtom *atoms, gint n_atoms, gpointer data); void (*GtkClipboardRichTextReceivedFunc) (GtkClipboard *clipboard, GdkAtom format, const guint8 *text, gsize length, gpointer data); void (*GtkClipboardURIReceivedFunc) (GtkClipboard *clipboard, gchar **uris, gpointer data); void (*GtkClipboardGetFunc) (GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer user_data_or_owner); void (*GtkClipboardClearFunc) (GtkClipboard *clipboard, gpointer user_data_or_owner); GtkClipboard* gtk_clipboard_get (GdkAtom selection); GtkClipboard* gtk_clipboard_get_for_display (GdkDisplay *display, GdkAtom selection); GdkDisplay* gtk_clipboard_get_display (GtkClipboard *clipboard); gboolean gtk_clipboard_set_with_data (GtkClipboard *clipboard, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc get_func, GtkClipboardClearFunc clear_func, gpointer user_data); gboolean gtk_clipboard_set_with_owner (GtkClipboard *clipboard, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc get_func, GtkClipboardClearFunc clear_func, GObject *owner); GObject* gtk_clipboard_get_owner (GtkClipboard *clipboard); void gtk_clipboard_clear (GtkClipboard *clipboard); void gtk_clipboard_set_text (GtkClipboard *clipboard, const gchar *text, gint len); void gtk_clipboard_set_image (GtkClipboard *clipboard, GdkPixbuf *pixbuf); void gtk_clipboard_request_contents (GtkClipboard *clipboard, GdkAtom target, GtkClipboardReceivedFunc callback, gpointer user_data); void gtk_clipboard_request_text (GtkClipboard *clipboard, GtkClipboardTextReceivedFunc callback, gpointer user_data); void gtk_clipboard_request_image (GtkClipboard *clipboard, GtkClipboardImageReceivedFunc callback, gpointer user_data); void gtk_clipboard_request_targets (GtkClipboard *clipboard, GtkClipboardTargetsReceivedFunc callback, gpointer user_data); void gtk_clipboard_request_rich_text (GtkClipboard *clipboard, GtkTextBuffer *buffer, GtkClipboardRichTextReceivedFunc callback, gpointer user_data); void gtk_clipboard_request_uris (GtkClipboard *clipboard, GtkClipboardURIReceivedFunc callback, gpointer user_data); GtkSelectionData* gtk_clipboard_wait_for_contents (GtkClipboard *clipboard, GdkAtom target); gchar* gtk_clipboard_wait_for_text (GtkClipboard *clipboard); GdkPixbuf* gtk_clipboard_wait_for_image (GtkClipboard *clipboard); guint8* gtk_clipboard_wait_for_rich_text (GtkClipboard *clipboard, GtkTextBuffer *buffer, GdkAtom *format, gsize *length); gchar** gtk_clipboard_wait_for_uris (GtkClipboard *clipboard); gboolean gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard); gboolean gtk_clipboard_wait_is_image_available (GtkClipboard *clipboard); gboolean gtk_clipboard_wait_is_rich_text_available (GtkClipboard *clipboard, GtkTextBuffer *buffer); gboolean gtk_clipboard_wait_is_uris_available (GtkClipboard *clipboard); gboolean gtk_clipboard_wait_for_targets (GtkClipboard *clipboard, GdkAtom **targets, gint *n_targets); gboolean gtk_clipboard_wait_is_target_available (GtkClipboard *clipboard, GdkAtom target); void gtk_clipboard_set_can_store (GtkClipboard *clipboard, const GtkTargetEntry *targets, gint n_targets); void gtk_clipboard_store (GtkClipboard *clipboard); Description
The GtkClipboard 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
GdkAtom. (Conversion to and from strings can be done with
To support having a number of different formats on the clipboard
at the same time, the clipboard mechanism allows providing
callbacks instead of the actual data. When you set the contents
of the clipboard, you can either supply the data directly (via
functions like
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,
Along with the functions to get the clipboard contents as an
arbitrary data chunk, there are also functions to retrieve
it as text, DetailsGtkClipboardReceivedFunc ()void (*GtkClipboardReceivedFunc) (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data);
A function to be called when the results of
GtkClipboardTextReceivedFunc ()void (*GtkClipboardTextReceivedFunc) (GtkClipboard *clipboard, const gchar *text, gpointer data);
A function to be called when the results of
GtkClipboardImageReceivedFunc ()void (*GtkClipboardImageReceivedFunc) (GtkClipboard *clipboard, GdkPixbuf *pixbuf, gpointer data);
A function to be called when the results of
Since 2.6 GtkClipboardTargetsReceivedFunc ()void (*GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard, GdkAtom *atoms, gint n_atoms, gpointer data);
A function to be called when the results of
Since 2.4 GtkClipboardRichTextReceivedFunc ()void (*GtkClipboardRichTextReceivedFunc) (GtkClipboard *clipboard, GdkAtom format, const guint8 *text, gsize length, gpointer data);
GtkClipboardURIReceivedFunc ()void (*GtkClipboardURIReceivedFunc) (GtkClipboard *clipboard, gchar **uris, gpointer data);
GtkClipboardGetFunc ()void (*GtkClipboardGetFunc) (GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer user_data_or_owner);
A function that will be called to provide the contents of the selection.
If multiple types of data were advertised, the requested type can
be determined from the
GtkClipboardClearFunc ()void (*GtkClipboardClearFunc) (GtkClipboard *clipboard, gpointer user_data_or_owner);
A function that will be called when the contents of the clipboard are changed
or cleared. Once this has called, the
gtk_clipboard_get ()GtkClipboard* gtk_clipboard_get (GdkAtom selection);
Returns the clipboard object for the given selection.
See
gtk_clipboard_get_for_display ()GtkClipboard* gtk_clipboard_get_for_display (GdkDisplay *display, GdkAtom selection);
Returns the clipboard object for the given selection.
Cut/copy/paste menu items and keyboard shortcuts should use
the default clipboard, returned by passing
(Passing GDK_NONE is the same as using It's possible to have arbitrary named clipboards; if you do invent new clipboards, you should prefix the selection name with an underscore (because the ICCCM requires that nonstandard atoms are underscore-prefixed), and namespace it as well. For example, if your application called "Foo" has a special-purpose clipboard, you might call it "_FOO_SPECIAL_CLIPBOARD".
Since 2.2 gtk_clipboard_get_display ()GdkDisplay* gtk_clipboard_get_display (GtkClipboard *clipboard);
Gets the GdkDisplay associated with
Since 2.2 gtk_clipboard_set_with_data ()gboolean gtk_clipboard_set_with_data (GtkClipboard *clipboard, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc get_func, GtkClipboardClearFunc clear_func, gpointer user_data); Virtually sets the contents of the specified clipboard by providing a list of supported formats for the clipboard data and a function to call to get the actual data when it is requested.
gtk_clipboard_set_with_owner ()gboolean gtk_clipboard_set_with_owner (GtkClipboard *clipboard, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc get_func, GtkClipboardClearFunc clear_func, GObject *owner); Virtually sets the contents of the specified clipboard by providing a list of supported formats for the clipboard data and a function to call to get the actual data when it is requested.
The difference between this function and
gtk_clipboard_get_owner ()GObject* gtk_clipboard_get_owner (GtkClipboard *clipboard);
If the clipboard contents callbacks were set with
gtk_clipboard_clear ()void gtk_clipboard_clear (GtkClipboard *clipboard);
Clears the contents of the clipboard. Generally this should only
be called between the time you call
gtk_clipboard_set_text ()void gtk_clipboard_set_text (GtkClipboard *clipboard, const gchar *text, gint len); Sets the contents of the clipboard to the given UTF-8 string. GTK+ will make a copy of the text and take responsibility for responding for requests for the text, and for converting the text into the requested format.
gtk_clipboard_set_image ()void gtk_clipboard_set_image (GtkClipboard *clipboard, GdkPixbuf *pixbuf); Sets the contents of the clipboard to the given GdkPixbuf. GTK+ will take responsibility for responding for requests for the image, and for converting the image into the requested format.
Since 2.6 gtk_clipboard_request_contents ()void gtk_clipboard_request_contents (GtkClipboard *clipboard, GdkAtom target, GtkClipboardReceivedFunc callback, gpointer user_data); Requests the contents of clipboard as the given target. When the results of the result are later received the supplied callback will be called.
gtk_clipboard_request_text ()void gtk_clipboard_request_text (GtkClipboard *clipboard, GtkClipboardTextReceivedFunc callback, gpointer user_data);
Requests the contents of the clipboard as text. When the text is
later received, it will be converted to UTF-8 if necessary, and
The
gtk_clipboard_request_image ()void gtk_clipboard_request_image (GtkClipboard *clipboard, GtkClipboardImageReceivedFunc callback, gpointer user_data);
Requests the contents of the clipboard as image. When the image is
later received, it will be converted to a GdkPixbuf, and
The
Since 2.6 gtk_clipboard_request_targets ()void gtk_clipboard_request_targets (GtkClipboard *clipboard, GtkClipboardTargetsReceivedFunc callback, gpointer user_data);
Requests the contents of the clipboard as list of supported targets.
When the list is later received,
The
Since 2.4 gtk_clipboard_request_rich_text ()void gtk_clipboard_request_rich_text (GtkClipboard *clipboard, GtkTextBuffer *buffer, GtkClipboardRichTextReceivedFunc callback, gpointer user_data);
Requests the contents of the clipboard as rich text. When the rich
text is later received,
The
Since 2.10 gtk_clipboard_request_uris ()void gtk_clipboard_request_uris (GtkClipboard *clipboard, GtkClipboardURIReceivedFunc callback, gpointer user_data);
Requests the contents of the clipboard as URIs. When the URIs are
later received
The
Since 2.14 gtk_clipboard_wait_for_contents ()GtkSelectionData* gtk_clipboard_wait_for_contents (GtkClipboard *clipboard, GdkAtom target); Requests the contents of the clipboard using the given target. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
gtk_clipboard_wait_for_text ()gchar* gtk_clipboard_wait_for_text (GtkClipboard *clipboard); Requests the contents of the clipboard as text and converts the result to UTF-8 if necessary. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
gtk_clipboard_wait_for_image ()GdkPixbuf* gtk_clipboard_wait_for_image (GtkClipboard *clipboard); Requests the contents of the clipboard as image and converts the result to a GdkPixbuf. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
Since 2.6 gtk_clipboard_wait_for_rich_text ()guint8* gtk_clipboard_wait_for_rich_text (GtkClipboard *clipboard, GtkTextBuffer *buffer, GdkAtom *format, gsize *length); Requests the contents of the clipboard as rich text. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
Since 2.10 gtk_clipboard_wait_for_uris ()gchar** gtk_clipboard_wait_for_uris (GtkClipboard *clipboard); Requests the contents of the clipboard as URIs. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
Since 2.14 gtk_clipboard_wait_is_text_available ()gboolean gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard); Test to see if there is text available to be pasted This is done by requesting the TARGETS atom and checking if it contains any of the supported text targets. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
This function is a little faster than calling
gtk_clipboard_wait_is_image_available ()gboolean gtk_clipboard_wait_is_image_available (GtkClipboard *clipboard); Test to see if there is an image available to be pasted This is done by requesting the TARGETS atom and checking if it contains any of the supported image targets. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
This function is a little faster than calling
Since 2.6 gtk_clipboard_wait_is_rich_text_available ()gboolean gtk_clipboard_wait_is_rich_text_available (GtkClipboard *clipboard, GtkTextBuffer *buffer); Test to see if there is rich text available to be pasted This is done by requesting the TARGETS atom and checking if it contains any of the supported rich text targets. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
This function is a little faster than calling
Since 2.10 gtk_clipboard_wait_is_uris_available ()gboolean gtk_clipboard_wait_is_uris_available (GtkClipboard *clipboard); Test to see if there is a list of URIs available to be pasted This is done by requesting the TARGETS atom and checking if it contains the URI targets. This function waits for the data to be received using the main loop, so events, timeouts, etc, may be dispatched during the wait.
This function is a little faster than calling
Since 2.14 gtk_clipboard_wait_for_targets ()gboolean gtk_clipboard_wait_for_targets (GtkClipboard *clipboard, GdkAtom **targets, gint *n_targets);
Returns a list of targets that are present on the clipboard, or
Since 2.4 gtk_clipboard_wait_is_target_available ()gboolean gtk_clipboard_wait_is_target_available (GtkClipboard *clipboard, GdkAtom target); Checks if a clipboard supports pasting data of a given type. This function can be used to determine if a "Paste" menu item should be insensitive or not.
If you want to see if there's text available on the clipboard, use
Since 2.6 gtk_clipboard_set_can_store ()void gtk_clipboard_set_can_store (GtkClipboard *clipboard, const GtkTargetEntry *targets, gint n_targets);
Hints that the clipboard data should be stored somewhere when the
application exits or when
This value is reset when the clipboard owner changes.
Where the clipboard data is stored is platform dependent,
see
Since 2.6 gtk_clipboard_store ()void gtk_clipboard_store (GtkClipboard *clipboard); Stores the current clipboard data somewhere so that it will stay around after the application has quit.
Since 2.6 Signal DetailsThe
|
|
the GtkClipboard on which the signal is emitted |
|
the GdkEventOwnerChange event
|
|
user data set when the signal handler was connected. |
Since 2.6
GtkSelection |
GtkClipboard provides a high-level wrapper around the lower level routines that deal with X selections. It is also possibly to directly manipulate the X selections, though it is seldom necessary to do so. |