Package ch.bailu.gtk.gdk
Class Gdk
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Package
ch.bailu.gtk.gdk.Gdk
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
cairoRectangle
(Context cr, Rectangle rectangle) Adds the given rectangle to the current path of @cr.static void
cairoRegion
(Context cr, Region region) Adds the given region to the current path of @cr.static Region
cairoRegionCreateFromSurface
(Surface surface) Creates region that covers the area where the given
@surface is more than 50% opaque.static void
cairoSetSourcePixbuf
(Context cr, Pixbuf pixbuf, double pixbuf_x, double pixbuf_y) Sets the given pixbuf as the source pattern for @cr.static void
cairoSetSourceRgba
(Context cr, RGBA rgba) Sets the specified `GdkRGBA` as the source color of @cr.static void
contentDeserializeAsync
(InputStream stream, Str mime_type, long type, int io_priority, Cancellable cancellable, Gdk.OnAsyncReadyCallback callback, Pointer user_data) Read content from the given input stream and deserialize it, asynchronously.static boolean
contentDeserializeFinish
(AsyncResult result, Value value) Finishes a content deserialization operation.static ContentFormats
contentFormatsParse
(Str string) Parses the given @string into `GdkContentFormats` and
returns the formats.static void
contentRegisterDeserializer
(Str mime_type, long type, Gdk.OnContentDeserializeFunc deserialize, Pointer data, Gdk.OnDestroyNotify notify) Registers a function to deserialize object of a given type.static void
contentRegisterSerializer
(long type, Str mime_type, Gdk.OnContentSerializeFunc serialize, Pointer data, Gdk.OnDestroyNotify notify) Registers a function to serialize objects of a given type.static void
contentSerializeAsync
(OutputStream stream, Str mime_type, Value value, int io_priority, Cancellable cancellable, Gdk.OnAsyncReadyCallback callback, Pointer user_data) Serialize content and write it to the given output stream, asynchronously.static boolean
contentSerializeFinish
(AsyncResult result) Finishes a content serialization operation.static boolean
dragActionIsUnique
(int action) Checks if @action represents a single action or includes
multiple actions.static ClassHandler
static int
static Str
internMimeType
(Str string) Canonicalizes the given mime type and interns the result.static int
keyvalFromName
(Str keyval_name) Converts a key name to a key value.static boolean
keyvalIsLower
(int keyval) Returns %TRUE if the given key value is in lower case.static boolean
keyvalIsUpper
(int keyval) Returns %TRUE if the given key value is in upper case.static Str
keyvalName
(int keyval) Converts a key value into a symbolic name.static int
keyvalToLower
(int keyval) Converts a key value to lower case, if applicable.static int
keyvalToUnicode
(int keyval) Convert from a GDK key symbol to the corresponding Unicode
character.static int
keyvalToUpper
(int keyval) Converts a key value to upper case, if applicable.static Paintable
paintableNewEmpty
(int intrinsic_width, int intrinsic_height) Returns a paintable that has the given intrinsic size and draws nothing.static Pixbuf
pixbufGetFromSurface
(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`.static Pixbuf
pixbufGetFromTexture
(Texture texture) Creates a new pixbuf from @texture.static void
setAllowedBackends
(Str backends) Sets a list of backends that GDK should try to use.static int
static long
static int
unicodeToKeyval
(int wc) Convert from a Unicode character to a key symbol.static int
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
-
Constructor Details
-
Gdk
public Gdk()
-
-
Method Details
-
getClassHandler
-
cairoRectangle
Adds the given rectangle to the current path of @cr.- Parameters:
cr
- a cairo contextrectangle
- a `GdkRectangle`
-
cairoRegion
Adds the given region to the current path of @cr.- Parameters:
cr
- a cairo contextregion
- a `cairo_region_t`
-
cairoRegionCreateFromSurface
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 contextpixbuf
- a `GdkPixbuf`pixbuf_x
- X coordinate of location to place upper left corner of @pixbufpixbuf_y
- Y coordinate of location to place upper left corner of @pixbuf
-
cairoSetSourceRgba
Sets the specified `GdkRGBA` as the source color of @cr.- Parameters:
cr
- a cairo contextrgba
- 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 frommime_type
- the mime type to deserialize fromtype
- the GType to deserialize fromio_priority
- the I/O priority of the operationcancellable
- optional `GCancellable` objectcallback
- callback to call when the operation is doneuser_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
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 fromtype
- the type of objects that the function createsdeserialize
- the callbackdata
- data that @deserialize can accessnotify
- 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 serializemime_type
- the mime type to serialize toserialize
- the callbackdata
- data that @serialize can accessnotify
- 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 tomime_type
- the mime type to serialize tovalue
- the content to serializeio_priority
- the I/O priority of the operationcancellable
- optional `GCancellable` objectcallback
- callback to call when the operation is doneuser_data
- data to pass to the callback function
-
contentSerializeFinish
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
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
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
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
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 fromsrc_x
- Source X coordinate within @surfacesrc_y
- Source Y coordinate within @surfacewidth
- Width in pixels of region to getheight
- Height in pixels of region to get- Returns:
- A newly-created pixbuf with a reference count of 1
-
pixbufGetFromTexture
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
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:
-