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.Functions

Contents

- Methods
  - cairoDrawFromGl
  - cairoRectangle
  - cairoRegion
  - cairoRegionCreateFromSurface
  - cairoSetSourcePixbuf
  - cairoSetSourceRgba
  - contentDeserializeAsync
  - contentDeserializeFinish
  - contentRegisterDeserializer
  - contentRegisterSerializer
  - contentSerializeAsync
  - contentSerializeFinish
  - eventsGetAngle
  - eventsGetCenter
  - eventsGetDistance
  - internMimeType
  - keyvalConvertCase
  - keyvalFromName
  - keyvalGetAliases
  - keyvalIsLower
  - keyvalIsUpper
  - keyvalName
  - keyvalToLower
  - keyvalToUnicode
  - keyvalToUpper
  - pixbufGetFromSurface
  - pixbufGetFromTexture
  - setAllowedBackends
  - unicodeToKeyval

Description

Synopsis

- cairoDrawFromGl :: (HasCallStack, MonadIO m, IsSurface a) => Context -> a -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> m ()
- cairoRectangle :: (HasCallStack, MonadIO m) => Context -> Rectangle -> m ()
- cairoRegion :: (HasCallStack, MonadIO m) => Context -> Region -> m ()
- cairoRegionCreateFromSurface :: (HasCallStack, MonadIO m) => Surface -> m Region
- cairoSetSourcePixbuf :: (HasCallStack, MonadIO m, IsPixbuf a) => Context -> a -> Double -> Double -> m ()
- cairoSetSourceRgba :: (HasCallStack, MonadIO m) => Context -> RGBA -> m ()
- contentDeserializeAsync :: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) => a -> Text -> GType -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- contentDeserializeFinish :: (HasCallStack, MonadIO m, IsAsyncResult a) => a -> m GValue
- contentRegisterDeserializer :: (HasCallStack, MonadIO m) => Text -> GType -> ContentDeserializeFunc -> m ()
- contentRegisterSerializer :: (HasCallStack, MonadIO m) => GType -> Text -> ContentSerializeFunc -> m ()
- contentSerializeAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Text -> GValue -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- contentSerializeFinish :: (HasCallStack, MonadIO m, IsAsyncResult a) => a -> m ()
- eventsGetAngle :: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) => a -> b -> m (Bool, Double)
- eventsGetCenter :: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) => a -> b -> m (Bool, Double, Double)
- eventsGetDistance :: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) => a -> b -> m (Bool, Double)
- internMimeType :: (HasCallStack, MonadIO m) => Text -> m (Maybe Text)
- keyvalConvertCase :: (HasCallStack, MonadIO m) => Word32 -> m (Word32, Word32)
- keyvalFromName :: (HasCallStack, MonadIO m) => Text -> m Word32
- keyvalGetAliases :: (HasCallStack, MonadIO m) => Word32 -> m (Maybe [Word32])
- keyvalIsLower :: (HasCallStack, MonadIO m) => Word32 -> m Bool
- keyvalIsUpper :: (HasCallStack, MonadIO m) => Word32 -> m Bool
- keyvalName :: (HasCallStack, MonadIO m) => Word32 -> m (Maybe Text)
- keyvalToLower :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- keyvalToUnicode :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- keyvalToUpper :: (HasCallStack, MonadIO m) => Word32 -> m Word32
- pixbufGetFromSurface :: (HasCallStack, MonadIO m) => Surface -> Int32 -> Int32 -> Int32 -> Int32 -> m (Maybe Pixbuf)
- pixbufGetFromTexture :: (HasCallStack, MonadIO m, IsTexture a) => a -> m (Maybe Pixbuf)
- setAllowedBackends :: (HasCallStack, MonadIO m) => Text -> m ()
- unicodeToKeyval :: (HasCallStack, MonadIO m) => Word32 -> m Word32

# Methods

## cairoDrawFromGl

cairoDrawFromGl Source #

Arguments

:: (HasCallStack, MonadIO m, IsSurface a) |
=> Context | `cr`: a cairo context
-> a | `surface`: The surface we're rendering for (not necessarily into)
-> Int32 | `source`: The GL ID of the source buffer
-> Int32 | `sourceType`: The type of the `source`
-> Int32 | `bufferScale`: The scale-factor that the `source` buffer is allocated for
-> Int32 | `x`: The source x position in `source` to start copying from in GL coordinates
-> Int32 | `y`: The source y position in `source` to start copying from in GL coordinates
-> Int32 | `width`: The width of the region to draw
-> Int32 | `height`: The height of the region to draw
-> m () |

Deprecated: (Since version 4.6)The function is overly complex and produces broken outputin various combinations of arguments. If you want to draw with GL texturesin GTK, use `gLTextureNew`; if you want to use that texture inCairo, use `textureDownload` to download the data into a Cairoimage surface.

Draws GL content onto a cairo context.

It takes a render buffer ID (`sourceType` == GL_RENDERBUFFER) or a texture id (`sourceType` == GL_TEXTURE) and draws it onto `cr` with an OVER operation, respecting the current clip. The top left corner of the rectangle specified by `x`, `y`, `width` and `height` will be drawn at the current (0,0) position of the `cairo_t`.

This will work for *all* `cairo_t`, as long as `surface` is realized, but the fallback implementation that reads back the pixels from the buffer may be used in the general case. In the case of direct drawing to a surface with no special effects applied to `cr` it will however use a more efficient approach.

For GL_RENDERBUFFER the code will always fall back to software for buffers with alpha components, so make sure you use GL_TEXTURE if using alpha.

Calling this may change the current GL context.

## cairoRectangle

cairoRectangle Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Context | `cr`: a cairo context
-> Rectangle | `rectangle`: a `GdkRectangle`
-> m () |

Adds the given rectangle to the current path of `cr`.

## cairoRegion

cairoRegion Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Context | `cr`: a cairo context
-> Region | `region`: a `cairo_region_t`
-> m () |

Adds the given region to the current path of `cr`.

## cairoRegionCreateFromSurface

cairoRegionCreateFromSurface Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Surface | `surface`: a cairo surface
-> m Region | Returns: A `cairo_region_t`

Creates region that covers the area where the given `surface` is more than 50% opaque.

This function takes into account device offsets that might be set with `cairo_surface_set_device_offset()`.

## cairoSetSourcePixbuf

cairoSetSourcePixbuf Source #

Arguments

:: (HasCallStack, MonadIO m, IsPixbuf a) |
=> Context | `cr`: a cairo context
-> a | `pixbuf`: a `GdkPixbuf`
-> Double | `pixbufX`: X coordinate of location to place upper left corner of `pixbuf`
-> Double | `pixbufY`: Y coordinate of location to place upper left corner of `pixbuf`
-> m () |

Deprecated: (Since version 4.20)Use `cairo_set_source_surface()` and `textureDownload`

Sets the given pixbuf as the source pattern for `cr`.

The pattern has an extend mode of `ExtendNone` and is aligned so that the origin of `pixbuf` is `pixbufX`, `pixbufY`.

## cairoSetSourceRgba

cairoSetSourceRgba Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Context | `cr`: a cairo context
-> RGBA | `rgba`: a `GdkRGBA`
-> m () |

Sets the specified `GdkRGBA` as the source color of `cr`.

## contentDeserializeAsync

contentDeserializeAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) |
=> a | `stream`: a `GInputStream` to read the serialized content from
-> Text | `mimeType`: the mime type to deserialize from
-> GType | `type`: the GType to deserialize from
-> Int32 | `ioPriority`: the I/O priority of the operation
-> Maybe b | `cancellable`: optional `GCancellable` object
-> Maybe AsyncReadyCallback | `callback`: callback to call when the operation is done
-> m () |

Reads content from the given input stream and deserialize it, asynchronously.

The default I/O priority is `G_PRIORITY_DEFAULT` (i.e. 0), and lower numbers indicate a higher priority.

## contentDeserializeFinish

contentDeserializeFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsAsyncResult a) |
=> a | `result`: the `GAsyncResult`
-> m GValue | (Can throw `GError`)

Finishes a content deserialization operation.

## contentRegisterDeserializer

contentRegisterDeserializer Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `mimeType`: the mime type which the function can deserialize from
-> GType | `type`: the type of objects that the function creates
-> ContentDeserializeFunc | `deserialize`: the callback
-> m () |

Registers a function to deserialize object of a given type.

Since 4.20, when looking up a deserializer to use, GTK will use the last registered deserializer for a given mime type, so applications can override the built-in deserializers.

## contentRegisterSerializer

contentRegisterSerializer Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GType | `type`: the type of objects that the function can serialize
-> Text | `mimeType`: the mime type to serialize to
-> ContentSerializeFunc | `serialize`: the callback
-> m () |

Registers a function to serialize objects of a given type.

Since 4.20, when looking up a serializer to use, GTK will use the last registered serializer for a given mime type, so applications can override the built-in serializers.

## contentSerializeAsync

contentSerializeAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) |
=> a | `stream`: a `GOutputStream` to write the serialized content to
-> Text | `mimeType`: the mime type to serialize to
-> GValue | `value`: the content to serialize
-> Int32 | `ioPriority`: the I/O priority of the operation
-> Maybe b | `cancellable`: optional `GCancellable` object
-> Maybe AsyncReadyCallback | `callback`: callback to call when the operation is done
-> m () |

Serialize content and write it to the given output stream, asynchronously.

The default I/O priority is `PRIORITY_DEFAULT` (i.e. 0), and lower numbers indicate a higher priority.

## contentSerializeFinish

contentSerializeFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsAsyncResult a) |
=> a | `result`: the `GAsyncResult`
-> m () | (Can throw `GError`)

Finishes a content serialization operation.

## eventsGetAngle

eventsGetAngle Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) |
=> a | `event1`: first `GdkEvent`
-> b | `event2`: second `GdkEvent`
-> m (Bool, Double) | Returns: `True` if the angle could be calculated.

Returns the relative angle from `event1` to `event2`.

The relative angle is the angle between the X axis and the line through both events' positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

This assumes that both events have X/Y information. If not, this function returns `False`.

## eventsGetCenter

eventsGetCenter Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) |
=> a | `event1`: first `GdkEvent`
-> b | `event2`: second `GdkEvent`
-> m (Bool, Double, Double) | Returns: `True` if the center could be calculated.

Returns the point halfway between the events' positions.

This assumes that both events have X/Y information. If not, this function returns `False`.

## eventsGetDistance

eventsGetDistance Source #

Arguments

:: (HasCallStack, MonadIO m, IsEvent a, IsEvent b) |
=> a | `event1`: first `GdkEvent`
-> b | `event2`: second `GdkEvent`
-> m (Bool, Double) | Returns: `True` if the distance could be calculated.

Returns the distance between the event locations.

This assumes that both events have X/Y information. If not, this function returns `False`.

## internMimeType

internMimeType Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `string`: string of a potential mime type
-> m (Maybe Text) | Returns: An interned string for the canonicalized mime type or `Nothing` if the string wasn't a valid mime type

Canonicalizes the given mime type and interns the result.

If `string` is not a valid mime type, `Nothing` is returned instead. See RFC 2048 for the syntax if mime types.

## keyvalConvertCase

keyvalConvertCase Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `symbol`: a keyval
-> m (Word32, Word32) |

Obtains the upper- and lower-case versions of the keyval `symbol`.

Examples of keyvals are `GDK_KEY_a`, `GDK_KEY_Enter`, `GDK_KEY_F1`, etc.

## keyvalFromName

keyvalFromName Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `keyvalName`: a key name
-> m Word32 | Returns: the corresponding key value, or `GDK_KEY_VoidSymbol` if the key name is not a valid key

Converts a key name to a key value.

The names are the same as those in the `gdk/gdkkeysyms.h` header file but without the leading “GDK_KEY_”.

## keyvalGetAliases

keyvalGetAliases Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: the keyval to get aliases for
-> m (Maybe [Word32]) | Returns: an array of keyvals

Gets keyvals that are 'aliases' for `keyval`.

Aliases are meant to be functionally equivalent and should be treated the same with respect to keyboard shortcuts, etc. An example are keypad keys that are aliases for their normal counterpart, such as `GDK_KEY_KP_Left` and `GDK_KEY_Left`.

Since: 4.24

## keyvalIsLower

keyvalIsLower Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: a key value.
-> m Bool | Returns: true if `keyval` is in lower case, or if `keyval` is not subject to case conversion.

Returns true if the given key value is in lower case.

## keyvalIsUpper

keyvalIsUpper Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: a key value.
-> m Bool | Returns: true if `keyval` is in upper case, or if `keyval` is not subject to case conversion.

Returns true if the given key value is in upper case.

## keyvalName

keyvalName Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: a key value
-> m (Maybe Text) | Returns: a string containing the name of the key

Converts a key value into a symbolic name.

The names are the same as those in the `gdk/gdkkeysyms.h` header file but without the leading “GDK_KEY_”.

## keyvalToLower

keyvalToLower Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: a key value.
-> m Word32 | Returns: the lower case form of `keyval`, or `keyval` itself if it is already in lower case or it is not subject to case conversion.

Converts a key value to lower case, if applicable.

## keyvalToUnicode

keyvalToUnicode Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: a GDK key symbol
-> m Word32 | Returns: the corresponding unicode character, or 0 if there is no corresponding character.

Converts from a GDK key symbol to the corresponding Unicode character.

Note that the conversion does not take the current locale into consideration, which might be expected for particular keyvals, such as `GDK_KEY_KP_Decimal`.

## keyvalToUpper

keyvalToUpper Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `keyval`: a key value.
-> m Word32 | Returns: the upper case form of `keyval`, or `keyval` itself if it is already in upper case or it is not subject to case conversion.

Converts a key value to upper case, if applicable.

## pixbufGetFromSurface

pixbufGetFromSurface Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Surface | `surface`: surface to copy from
-> Int32 | `srcX`: Source X coordinate within `surface`
-> Int32 | `srcY`: Source Y coordinate within `surface`
-> Int32 | `width`: Width in pixels of region to get
-> Int32 | `height`: Height in pixels of region to get
-> m (Maybe Pixbuf) | Returns: A newly-created pixbuf with a reference count of 1

Deprecated: (Since version 4.12)Use `Texture` and subclasses insteadcairo surfaces and pixbufs

Transfers image data from a `cairo_surface_t` and converts it to a `GdkPixbuf`.

This allows you to efficiently read individual pixels from cairo surfaces.

This function will create an RGB pixbuf with 8 bits per channel. The pixbuf will contain an alpha channel if the `surface` contains one.

## pixbufGetFromTexture

pixbufGetFromTexture Source #

Arguments

:: (HasCallStack, MonadIO m, IsTexture a) |
=> a | `texture`: a `GdkTexture`
-> m (Maybe Pixbuf) | Returns: a new `GdkPixbuf`

Deprecated: (Since version 4.12)Use `Texture` and subclasses insteadcairo surfaces and pixbufs

Creates a new pixbuf from `texture`.

This should generally not be used in newly written code as later stages will almost certainly convert the pixbuf back into a texture to draw it on screen.

## setAllowedBackends

setAllowedBackends Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `backends`: a comma-separated list of backends
-> m () |

Sets a list of backends that GDK should try to use.

This can be useful if your application does not work with certain GDK backends.

By default, GDK tries all included backends.

For example:

### c code

    gdk_set_allowed_backends ("wayland,macos,*");

instructs GDK to try the Wayland backend first, followed by the MacOs backend, and then all others.

If the `GDK_BACKEND` environment variable is set, it determines what backends are tried in what order, while still respecting the set of allowed backends that are specified by this function.

The possible backend names are:

-     broadway

-     macos

- `wayland`.

-     win32

-     x11

You can also include a `*` in the list to try all remaining backends.

This call must happen prior to functions that open a display, such as `displayOpen`, `gtk_init()`, or `gtk_init_check()` in order to take effect.

## unicodeToKeyval

unicodeToKeyval Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `wc`: a Unicode character
-> m Word32 | Returns: the corresponding GDK key symbol, if one exists, or, if there is no corresponding symbol, `wc | 0x01000000`

Converts from a Unicode character to a key symbol.