## GdkContentProvider GdkContentProvider — Provides content for data transfer between applications |

## Functions

GdkContentProvider * | gdk_content_provider_new_for_value ()
GdkContentProvider * | gdk_content_provider_new_for_bytes ()
GdkContentFormats * | gdk_content_provider_ref_formats ()
GdkContentFormats * | gdk_content_provider_ref_storable_formats ()
void | gdk_content_provider_content_changed ()
void | gdk_content_provider_write_mime_type_async ()
gboolean | gdk_content_provider_write_mime_type_finish ()
gboolean | gdk_content_provider_get_value ()

## Types and Values

| GdkContentProvider

## Object Hierarchy

        GObject
        ╰── GdkContentProvider

## Includes

    #include <gdk/gdkwayland.h>

## Description

A GdkContentProvider is used to provide content for the clipboard in a number of formats.

To create a GdkContentProvider, use `gdk_content_provider_new_for_value()` or `gdk_content_provider_new_for_bytes()`.

GDK knows how to handle common text and image formats out-of-the-box. See GdkContentSerializer and GdkContentDeserializer if you want to add support for application-specific data formats.

## Functions

### gdk_content_provider_new_for_value ()

    GdkContentProvider *
    gdk_content_provider_new_for_value (const GValue *value);

Create a content provider that provides the given `value` .

#### Parameters

value | a GValue |

#### Returns

a new GdkContentProvider

### gdk_content_provider_new_for_bytes ()

    GdkContentProvider *
    gdk_content_provider_new_for_bytes (const char *mime_type,
                                        GBytes *bytes);

Create a content provider that provides the given `bytes` as data for the given `mime_type` .

#### Parameters

mime_type | the mime type |
bytes | a GBytes with the data for `mime_type` . | [transfer none]

#### Returns

a new GdkContentProvider

### gdk_content_provider_ref_formats ()

    GdkContentFormats *
    gdk_content_provider_ref_formats (GdkContentProvider *provider);

Gets the formats that the provider can provide its current contents in.

#### Parameters

provider | a GdkContentProvider |

#### Returns

The formats of the provider.

[transfer full]

### gdk_content_provider_ref_storable_formats ()

    GdkContentFormats *
    gdk_content_provider_ref_storable_formats
                                   (GdkContentProvider *provider);

Gets the formats that the provider suggests other applications to store the data in. An example of such an application would be a clipboard manager.

This can be assumed to be a subset of `gdk_content_provider_ref_formats()`.

#### Parameters

provider | a GdkContentProvider |

#### Returns

The storable formats of the provider.

[transfer full]

### gdk_content_provider_content_changed ()

    void
    gdk_content_provider_content_changed (GdkContentProvider *provider);

Emits the “contents-changed” signal.

#### Parameters

provider | a GdkContentProvider |

### gdk_content_provider_write_mime_type_async ()

    void
    gdk_content_provider_write_mime_type_async
                                   (GdkContentProvider *provider,
                                    const char *mime_type,
                                    GOutputStream *stream,
                                    int io_priority,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Asynchronously writes the contents of `provider` to `stream` in the given `mime_type` . When the operation is finished `callback` will be called. You can then call `gdk_content_provider_write_mime_type_finish()` to get the result of the operation.

The given mime type does not need to be listed in the formats returned by `gdk_content_provider_ref_formats()`. However, if the given GType is not supported, G_IO_ERROR_NOT_SUPPORTED will be reported.

The given `stream` will not be closed.

#### Parameters

provider | a GdkContentProvider |
mime_type | the mime type to provide the data in |
stream | the GOutputStream to write to |
io_priority | the I/O priority of the request. |
cancellable | optional GCancellable object, `NULL` to ignore. | [nullable]
callback | callback to call when the request is satisfied. | [scope async]
user_data | the data to pass to callback function. | [closure]

### gdk_content_provider_write_mime_type_finish ()

    gboolean
    gdk_content_provider_write_mime_type_finish
                                   (GdkContentProvider *provider,
                                    GAsyncResult *result,
                                    GError **error);

Finishes an asynchronous write operation started with `gdk_content_provider_write_mime_type_async()`.

#### Parameters

provider | a GdkContentProvider |
result | a GAsyncResult |
error | a GError location to store the error occurring, or `NULL` to ignore. |

#### Returns

`TRUE` if the operation was completed successfully. Otherwise `error` will be set to describe the failure.

### gdk_content_provider_get_value ()

    gboolean
    gdk_content_provider_get_value (GdkContentProvider *provider,
                                    GValue *value,
                                    GError **error);

Gets the convtents of `provider` stored in `value` .

The `value` will have been initialized to the GType the value should be provided in. This given GType does not need to be listed in the formats returned by `gdk_content_provider_ref_formats()`. However, if the given GType is not supported, this operation can fail and G_IO_ERROR_NOT_SUPPORTED will be reported.

#### Parameters

provider | a GdkContentProvider |
value | the GValue to fill |
error | a GError location to store the error occurring, or `NULL` to ignore. |

#### Returns

`TRUE` if the value was set successfully. Otherwise `error` will be set to describe the failure.

## Types and Values

### GdkContentProvider

    typedef struct _GdkContentProvider GdkContentProvider;

Should not be directly accessed.

## See Also

GdkContentSerializer, GdkContentDeserializer