Class Gdk


public class Gdk extends Package
  • Constructor Details

    • Gdk

      public Gdk()
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • cairoRectangle

      public static void cairoRectangle(@Nonnull Context cr, @Nonnull Rectangle rectangle)
      Adds the given rectangle to the current path of @cr.
      Parameters:
      cr - a cairo context
      rectangle - a `GdkRectangle`
    • cairoRegion

      public static void cairoRegion(@Nonnull Context cr, @Nonnull Region region)
      Adds the given region to the current path of @cr.
      Parameters:
      cr - a cairo context
      region - a `cairo_region_t`
    • cairoRegionCreateFromSurface

      public static Region cairoRegionCreateFromSurface(@Nonnull Surface surface)
      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().
      Parameters:
      surface - a cairo surface
      Returns:
      A `cairo_region_t`
    • cairoSetSourcePixbuf

      public static void cairoSetSourcePixbuf(@Nonnull Context cr, @Nonnull Pixbuf pixbuf, double pixbuf_x, double pixbuf_y)
      Sets the given pixbuf as the source pattern for @cr.

      The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
      so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y.
      Parameters:
      cr - a cairo context
      pixbuf - a `GdkPixbuf`
      pixbuf_x - X coordinate of location to place upper left corner of @pixbuf
      pixbuf_y - Y coordinate of location to place upper left corner of @pixbuf
    • cairoSetSourceRgba

      public static void cairoSetSourceRgba(@Nonnull Context cr, @Nonnull RGBA rgba)
      Sets the specified `GdkRGBA` as the source color of @cr.
      Parameters:
      cr - a cairo context
      rgba - a `GdkRGBA`
    • contentDeserializeAsync

      public static void contentDeserializeAsync(@Nonnull InputStream stream, @Nonnull Str mime_type, long type, int io_priority, @Nullable Cancellable cancellable, Gdk.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Read 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.

      When the operation is finished, @callback will be called. You must then
      call [func@Gdk.content_deserialize_finish] to get the result of the operation.
      Parameters:
      stream - a `GInputStream` to read the serialized content from
      mime_type - the mime type to deserialize from
      type - the GType to deserialize from
      io_priority - the I/O priority of the operation
      cancellable - optional `GCancellable` object
      callback - callback to call when the operation is done
      user_data - data to pass to the callback function
    • contentDeserializeFinish

      public static boolean contentDeserializeFinish(@Nonnull AsyncResult result, @Nonnull Value value) throws AllocationError
      Finishes a content deserialization operation.
      Parameters:
      result - the `GAsyncResult`
      value - return location for the result of the operation
      Returns:
      %TRUE if the operation was successful. In this case, @value is set. %FALSE if an error occurred. In this case, @error is set
      Throws:
      AllocationError
    • contentFormatsParse

      public static ContentFormats contentFormatsParse(@Nonnull Str string)
      Parses the given @string into `GdkContentFormats` and
      returns the formats.

      Strings printed via [method@Gdk.ContentFormats.to_string]
      can be read in again successfully using this function.

      If @string does not describe valid content formats, %NULL
      is returned.
      Parameters:
      string - the string to parse
      Returns:
      the content formats if @string is valid
    • contentRegisterDeserializer

      public static void contentRegisterDeserializer(@Nonnull Str mime_type, long type, Gdk.OnContentDeserializeFunc deserialize, @Nullable Pointer data, Gdk.OnDestroyNotify notify)
      Registers a function to deserialize object of a given type.
      Parameters:
      mime_type - the mime type which the function can deserialize from
      type - the type of objects that the function creates
      deserialize - the callback
      data - data that @deserialize can access
      notify - destroy notify for @data
    • contentRegisterSerializer

      public static void contentRegisterSerializer(long type, @Nonnull Str mime_type, Gdk.OnContentSerializeFunc serialize, @Nullable Pointer data, Gdk.OnDestroyNotify notify)
      Registers a function to serialize objects of a given type.
      Parameters:
      type - the type of objects that the function can serialize
      mime_type - the mime type to serialize to
      serialize - the callback
      data - data that @serialize can access
      notify - destroy notify for @data
    • contentSerializeAsync

      public static void contentSerializeAsync(@Nonnull OutputStream stream, @Nonnull Str mime_type, @Nonnull Value value, int io_priority, @Nullable Cancellable cancellable, Gdk.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Serialize content and write it to the given output stream, asynchronously.

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

      When the operation is finished, @callback will be called. You must then
      call [func@Gdk.content_serialize_finish] to get the result of the operation.
      Parameters:
      stream - a `GOutputStream` to write the serialized content to
      mime_type - the mime type to serialize to
      value - the content to serialize
      io_priority - the I/O priority of the operation
      cancellable - optional `GCancellable` object
      callback - callback to call when the operation is done
      user_data - data to pass to the callback function
    • contentSerializeFinish

      public static boolean contentSerializeFinish(@Nonnull AsyncResult result) throws AllocationError
      Finishes a content serialization operation.
      Parameters:
      result - the `GAsyncResult`
      Returns:
      %TRUE if the operation was successful, %FALSE if an error occurred. In this case, @error is set
      Throws:
      AllocationError
    • dragActionIsUnique

      public static boolean dragActionIsUnique(int action)
      Checks if @action represents a single action or includes
      multiple actions.

      When @action is 0 - ie no action was given, %TRUE
      is returned.
      Parameters:
      action - a `GdkDragAction`
      Returns:
      %TRUE if exactly one action was given
    • glErrorQuark

      public static int glErrorQuark()
      Returns:
    • internMimeType

      public static Str internMimeType(@Nonnull Str string)
      Canonicalizes the given mime type and interns the result.

      If @string is not a valid mime type, %NULL is returned instead.
      See RFC 2048 for the syntax if mime types.
      Parameters:
      string - string of a potential mime type
      Returns:
      An interned string for the canonicalized mime type or %NULL if the string wasn't a valid mime type
    • keyvalFromName

      public static int keyvalFromName(@Nonnull Str keyval_name)
      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_”.
      Parameters:
      keyval_name - a key name
      Returns:
      the corresponding key value, or %GDK_KEY_VoidSymbol if the key name is not a valid key
    • keyvalIsLower

      public static boolean keyvalIsLower(int keyval)
      Returns %TRUE if the given key value is in lower case.
      Parameters:
      keyval - a key value.
      Returns:
      %TRUE if @keyval is in lower case, or if @keyval is not subject to case conversion.
    • keyvalIsUpper

      public static boolean keyvalIsUpper(int keyval)
      Returns %TRUE if the given key value is in upper case.
      Parameters:
      keyval - a key value.
      Returns:
      %TRUE if @keyval is in upper case, or if @keyval is not subject to case conversion.
    • keyvalName

      public static Str keyvalName(int keyval)
      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_”.
      Parameters:
      keyval - a key value
      Returns:
      a string containing the name of the key
    • keyvalToLower

      public static int keyvalToLower(int keyval)
      Converts a key value to lower case, if applicable.
      Parameters:
      keyval - a key value.
      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.
    • keyvalToUnicode

      public static int keyvalToUnicode(int keyval)
      Convert 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.
      Parameters:
      keyval - a GDK key symbol
      Returns:
      the corresponding unicode character, or 0 if there is no corresponding character.
    • keyvalToUpper

      public static int keyvalToUpper(int keyval)
      Converts a key value to upper case, if applicable.
      Parameters:
      keyval - a key value.
      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.
    • paintableNewEmpty

      public static Paintable paintableNewEmpty(int intrinsic_width, int intrinsic_height)
      Returns a paintable that has the given intrinsic size and draws nothing.

      This is often useful for implementing the
      [vfunc@Gdk.Paintable.get_current_image] virtual function
      when the paintable is in an incomplete state (like a
      [class@Gtk.MediaStream] before receiving the first frame).
      Parameters:
      intrinsic_width - The intrinsic width to report. Can be 0 for no width.
      intrinsic_height - The intrinsic height to report. Can be 0 for no height.
      Returns:
      a `GdkPaintable`
    • pixbufGetFromSurface

      public static Pixbuf pixbufGetFromSurface(@Nonnull Surface surface, int src_x, int src_y, int width, int height)
      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.
      Parameters:
      surface - surface to copy from
      src_x - Source X coordinate within @surface
      src_y - Source Y coordinate within @surface
      width - Width in pixels of region to get
      height - Height in pixels of region to get
      Returns:
      A newly-created pixbuf with a reference count of 1
    • pixbufGetFromTexture

      public static Pixbuf pixbufGetFromTexture(@Nonnull Texture texture)
      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.
      Parameters:
      texture - a `GdkTexture`
      Returns:
      a new `GdkPixbuf`
    • setAllowedBackends

      public static void setAllowedBackends(@Nonnull Str backends)
      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
      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 [func@Gdk.Display.open], `gtk_init()`, or `gtk_init_check()`
      in order to take effect.
      Parameters:
      backends - a comma-separated list of backends
    • textureErrorQuark

      public static int textureErrorQuark()
      Returns:
    • toplevelSizeGetType

      public static long toplevelSizeGetType()
      Returns:
    • unicodeToKeyval

      public static int unicodeToKeyval(int wc)
      Convert from a Unicode character to a key symbol.
      Parameters:
      wc - a Unicode character
      Returns:
      the corresponding GDK key symbol, if one exists. or, if there is no corresponding symbol, wc | 0x01000000
    • vulkanErrorQuark

      public static int vulkanErrorQuark()
      Returns: