Class: Gdk::ContentProvider

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

Class structure for GdkContentProvider.

Instance Method Summary collapse

Constructor Details

#initialize(providers, n_providers) ⇒ Gdk::ContentProvider

Creates a content provider that represents all the given providers.

Whenever data needs to be written, the union provider will try the given providers in the given order and the first one supporting a format will be chosen to provide it.

This allows an easy way to support providing data in different formats. For example, an image may be provided by its file and by the image contents with a call such as

gdk_content_provider_new_union ((GdkContentProvider *[2]) {
                                  gdk_content_provider_new_typed (G_TYPE_FILE, file),
                                  gdk_content_provider_new_typed (G_TYPE_TEXTURE, texture)
                                }, 2);

Parameters:

  • providers (Array<Gdk::ContentProvider>)

    The GdkContentProviders to present the union of

  • n_providers (Integer)

    the number of providers

Instance Method Details

#content_changednil

Emits the ::content-changed signal.

Returns:

  • (nil)

#formatsGdk::ContentFormats

The possible formats that the provider can provide its data in.

Returns:

  • (Gdk::ContentFormats)

    formats

#formats=(formats) ⇒ Gdk::ContentFormats

The possible formats that the provider can provide its data in.

Parameters:

  • formats (Gdk::ContentFormats)

Returns:

  • (Gdk::ContentFormats)

    formats

  • (Gdk::ContentFormats)

    formats

#get_value(value) ⇒ Boolean

Gets the contents 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 [methodGdk.ContentProvider.ref_formats]. However, if the given GType is not supported, this operation can fail and G_IO_ERROR_NOT_SUPPORTED will be reported.

Parameters:

  • value (GObject::Value)

    the GValue to fill

Returns:

  • (Boolean)

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

#ref_formatsGdk::ContentFormats

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

Returns:

  • (Gdk::ContentFormats)

    The formats of the provider

#ref_storable_formatsGdk::ContentFormats

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 [methodGdk.ContentProvider.ref_formats].

Returns:

  • (Gdk::ContentFormats)

    The storable formats of the provider

#storable_formatsGdk::ContentFormats

The subset of formats that clipboard managers should store this provider's data in.

Returns:

  • (Gdk::ContentFormats)

    storable-formats

#storable_formats=(storable_formats) ⇒ Gdk::ContentFormats

The subset of formats that clipboard managers should store this provider's data in.

Parameters:

  • storable_formats (Gdk::ContentFormats)

Returns:

  • (Gdk::ContentFormats)

    storable-formats

  • (Gdk::ContentFormats)

    storable-formats

#write_mime_type_async(mime_type, stream, io_priority, cancellable, callback, user_data) ⇒ nil

Asynchronously writes the contents of provider to stream in the given mime_type.

When the operation is finished callback will be called. You must then call [methodGdk.ContentProvider.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 [methodGdk.ContentProvider.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:

  • mime_type (String)

    the mime type to provide the data in

  • stream (Gio::OutputStream)

    the GOutputStream to write to

  • io_priority (Integer)

    I/O priority of the request.

  • cancellable (Gio::Cancellable)

    optional GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    callback to call when the request is satisfied

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#write_mime_type_finish(result) ⇒ Boolean

Finishes an asynchronous write operation.

See [methodGdk.ContentProvider.write_mime_type_async].

Parameters:

  • result (Gio::AsyncResult)

    a GAsyncResult

Returns:

  • (Boolean)

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