gi-gdk4-4.0.10: Gdk bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gdk.Structs.ContentFormats

Contents

- Exported types
- Methods
  - containGtype
  - containMimeType
  - getGtypes
  - getMimeTypes
  - isEmpty
  - match
  - matchGtype
  - matchMimeType
  - new
  - newForGtype
  - parse
  - print
  - ref
  - toString
  - union
  - unionDeserializeGtypes
  - unionDeserializeMimeTypes
  - unionSerializeGtypes
  - unionSerializeMimeTypes
  - unref

Description

Used to advertise and negotiate the format of content.

You will encounter `GdkContentFormats` when interacting with objects controlling operations that pass data between different widgets, window or application, like `Drag`, `Drop`, `Clipboard` or `ContentProvider`.

GDK supports content in 2 forms: `GType` and mime type. Using `GTypes` is meant only for in-process content transfers. Mime types are meant to be used for data passing both in-process and out-of-process. The details of how data is passed is described in the documentation of the actual implementations. To transform between the two forms, `ContentSerializer` and `ContentDeserializer` are used.

A `GdkContentFormats` describes a set of possible formats content can be exchanged in. It is assumed that this set is ordered. `GTypes` are more important than mime types. Order between different `GTypes` or mime types is the order they were added in, most important first. Functions that care about order, such as `contentFormatsUnion`, will describe in their documentation how they interpret that order, though in general the order of the first argument is considered the primary order of the result, followed by the order of further arguments.

For debugging purposes, the function `contentFormatsToString` exists. It will print a comma-separated list of formats from most important to least important.

`GdkContentFormats` is an immutable struct. After creation, you cannot change the types it represents. Instead, new `GdkContentFormats` have to be created. The `ContentFormatsBuilder` structure is meant to help in this endeavor.

Synopsis

- newtype ContentFormats = ContentFormats (ManagedPtr ContentFormats)
- contentFormatsContainGtype :: (HasCallStack, MonadIO m) => ContentFormats -> GType -> m Bool
- contentFormatsContainMimeType :: (HasCallStack, MonadIO m) => ContentFormats -> Text -> m Bool
- contentFormatsGetGtypes :: (HasCallStack, MonadIO m) => ContentFormats -> m (Maybe [GType], CSize)
- contentFormatsGetMimeTypes :: (HasCallStack, MonadIO m) => ContentFormats -> m (Maybe [Text], CSize)
- contentFormatsIsEmpty :: (HasCallStack, MonadIO m) => ContentFormats -> m Bool
- contentFormatsMatch :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m Bool
- contentFormatsMatchGtype :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m GType
- contentFormatsMatchMimeType :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m (Maybe Text)
- contentFormatsNew :: (HasCallStack, MonadIO m) => Maybe [Text] -> m ContentFormats
- contentFormatsNewForGtype :: (HasCallStack, MonadIO m) => GType -> m ContentFormats
- contentFormatsParse :: (HasCallStack, MonadIO m) => Text -> m (Maybe ContentFormats)
- contentFormatsPrint :: (HasCallStack, MonadIO m) => ContentFormats -> String -> m ()
- contentFormatsRef :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsToString :: (HasCallStack, MonadIO m) => ContentFormats -> m Text
- contentFormatsUnion :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m ContentFormats
- contentFormatsUnionDeserializeGtypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnionDeserializeMimeTypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnionSerializeGtypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnionSerializeMimeTypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnref :: (HasCallStack, MonadIO m) => ContentFormats -> m ()

# Exported types

newtype ContentFormats Source #

Memory-managed wrapper type.

Constructors

ContentFormats (ManagedPtr ContentFormats) |

#### Instances

Instances details

Eq ContentFormats Source # |
Instance details Defined in GI.Gdk.Structs.ContentFormats Methods (==) :: ContentFormats -> ContentFormats -> Bool Source # (/=) :: ContentFormats -> ContentFormats -> Bool Source #
GBoxed ContentFormats Source # |
Instance details Defined in GI.Gdk.Structs.ContentFormats
ManagedPtrNewtype ContentFormats Source # |
Instance details Defined in GI.Gdk.Structs.ContentFormats Methods toManagedPtr :: ContentFormats -> ManagedPtr ContentFormats Source #
TypedObject ContentFormats Source # |
Instance details Defined in GI.Gdk.Structs.ContentFormats Methods glibType :: IO GType Source #
HasParentTypes ContentFormats Source # |
Instance details Defined in GI.Gdk.Structs.ContentFormats
IsGValue (Maybe ContentFormats) Source # | Convert `ContentFormats` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gdk.Structs.ContentFormats Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe ContentFormats -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe ContentFormats) Source #
type ParentTypes ContentFormats Source # |
Instance details Defined in GI.Gdk.Structs.ContentFormats type ParentTypes ContentFormats = '[] :: [Type]

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

containGtype, containMimeType, isEmpty, match, matchGtype, matchMimeType, print, ref, toString, union, unionDeserializeGtypes, unionDeserializeMimeTypes, unionSerializeGtypes, unionSerializeMimeTypes, unref.

#### Getters

getGtypes, getMimeTypes.

#### Setters

None.

## containGtype

contentFormatsContainGtype Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> GType | `type`: the `GType` to search for
-> m Bool | Returns: `True` if the `GType` was found

Checks if a given `GType` is part of the given `formats`.

## containMimeType

contentFormatsContainMimeType Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> Text | `mimeType`: the mime type to search for
-> m Bool | Returns: `True` if the mime_type was found

Checks if a given mime type is part of the given `formats`.

## getGtypes

contentFormatsGetGtypes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m (Maybe [GType], CSize) | Returns: `G_TYPE_INVALID`-terminated array of types included in `formats`

Gets the `GType`s included in `formats`.

Note that `formats` may not contain any `GType`s, in particular when they are empty. In that case `Nothing` will be returned.

## getMimeTypes

contentFormatsGetMimeTypes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m (Maybe [Text], CSize) | Returns: `Nothing`-terminated array of interned strings of mime types included in `formats`

Gets the mime types included in `formats`.

Note that `formats` may not contain any mime types, in particular when they are empty. In that case `Nothing` will be returned.

## isEmpty

contentFormatsIsEmpty Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: content formats
-> m Bool | Returns: true if `formats` contains no mime types and no GTypes

Returns whether the content formats contain any formats.

Since: 4.18

## match

contentFormatsMatch Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `first`: the primary `GdkContentFormats` to intersect
-> ContentFormats | `second`: the `GdkContentFormats` to intersect with
-> m Bool | Returns: `True` if a matching format was found.

Checks if `first` and `second` have any matching formats.

## matchGtype

contentFormatsMatchGtype Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `first`: the primary `GdkContentFormats` to intersect
-> ContentFormats | `second`: the `GdkContentFormats` to intersect with
-> m GType | Returns: The first common `GType` or `G_TYPE_INVALID` if none.

Finds the first `GType` from `first` that is also contained in `second`.

If no matching `GType` is found, `G_TYPE_INVALID` is returned.

## matchMimeType

contentFormatsMatchMimeType Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `first`: the primary `GdkContentFormats` to intersect
-> ContentFormats | `second`: the `GdkContentFormats` to intersect with
-> m (Maybe Text) | Returns: The first common mime type or `Nothing` if none

Finds the first mime type from `first` that is also contained in `second`.

If no matching mime type is found, `Nothing` is returned.

## new

contentFormatsNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe [Text] | `mimeTypes`: Pointer to an array of mime types
-> m ContentFormats | Returns: the new `GdkContentFormats`.

Creates a new `GdkContentFormats` from an array of mime types.

The mime types must be valid and different from each other or the behavior of the return value is undefined. If you cannot guarantee this, use `ContentFormatsBuilder` instead.

## newForGtype

contentFormatsNewForGtype Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GType | `type`: a `GType`
-> m ContentFormats | Returns: a new `GdkContentFormats`

Creates a new `GdkContentFormats` for a given `GType`.

## parse

contentFormatsParse Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `string`: the string to parse
-> m (Maybe ContentFormats) | Returns: the content formats if `string` is valid

Parses the given `string` into `GdkContentFormats` and returns the formats.

Strings printed via `contentFormatsToString` can be read in again successfully using this function.

If `string` does not describe valid content formats, `Nothing` is returned.

Since: 4.4

## print

contentFormatsPrint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> String | `string`: a `GString` to print into
-> m () |

Prints the given `formats` into a string for human consumption.

The result of this function can later be parsed with `contentFormatsParse`.

## ref

contentFormatsRef Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m ContentFormats | Returns: the passed in `GdkContentFormats`.

Increases the reference count of a `GdkContentFormats` by one.

## toString

contentFormatsToString Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m Text | Returns: a new string

Prints the given `formats` into a human-readable string.

The resulting string can be parsed with `contentFormatsParse`.

This is a small wrapper around `contentFormatsPrint` to help when debugging.

## union

contentFormatsUnion Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `first`: the `GdkContentFormats` to merge into
-> ContentFormats | `second`: the `GdkContentFormats` to merge from
-> m ContentFormats | Returns: a new `GdkContentFormats`

Append all missing types from `second` to `first`, in the order they had in `second`.

## unionDeserializeGtypes

contentFormatsUnionDeserializeGtypes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m ContentFormats | Returns: a new `GdkContentFormats`

Add GTypes for mime types in `formats` for which deserializers are registered.

## unionDeserializeMimeTypes

contentFormatsUnionDeserializeMimeTypes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m ContentFormats | Returns: a new `GdkContentFormats`

Add mime types for GTypes in `formats` for which deserializers are registered.

## unionSerializeGtypes

contentFormatsUnionSerializeGtypes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m ContentFormats | Returns: a new `GdkContentFormats`

Add GTypes for the mime types in `formats` for which serializers are registered.

## unionSerializeMimeTypes

contentFormatsUnionSerializeMimeTypes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m ContentFormats | Returns: a new `GdkContentFormats`

Add mime types for GTypes in `formats` for which serializers are registered.

## unref

contentFormatsUnref Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ContentFormats | `formats`: a `GdkContentFormats`
-> m () |

Decreases the reference count of a `GdkContentFormats` by one.

If the resulting reference count is zero, frees the formats.