Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Gdk.cairo_draw_from_gl(cr, surface, source, source_type, buffer_scale, x, y, width, height)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextsurface (
Gdk.Surface
) – The surface we’re rendering for (not necessarily into)source (
int
) – The GL ID of the source buffersource_type (
int
) – The type of the sourcebuffer_scale (
int
) – The scale-factor that the source buffer is allocated forx (
int
) – The source x position in source to start copying from in GL coordinatesy (
int
) – The source y position in source to start copying from in GL coordinateswidth (
int
) – The width of the region to drawheight (
int
) – The height of the region to draw
The main way to not draw GL content in GTK.
It takes a render buffer ID (source_type == GL_RENDERBUFFER) or a texture id (source_type == 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.
Deprecated since version 4.6: The function is overly complex and produces broken output in various combinations of arguments. If you want to draw with GL textures in GTK, use [ctor`Gdk`.GLTexture.new]; if you want to use that texture in Cairo, use [method`Gdk`.Texture.download] to download the data into a Cairo image surface.
- Gdk.cairo_rectangle(cr, rectangle)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextrectangle (
Gdk.Rectangle
) – aGdkRectangle
Adds the given rectangle to the current path of cr.
- Gdk.cairo_region(cr, region)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextregion (
cairo.Region
) – acairo_region_t
Adds the given region to the current path of cr.
- Gdk.cairo_region_create_from_surface(surface)[source]¶
- Parameters:
surface (
cairo.Surface
) – a cairo surface- Returns:
A
cairo_region_t
- Return type:
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
().
- Gdk.cairo_set_source_pixbuf(cr, pixbuf, pixbuf_x, pixbuf_y)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextpixbuf (
GdkPixbuf.Pixbuf
) – aGdkPixbuf
pixbuf_x (
float
) – X coordinate of location to place upper left corner of pixbufpixbuf_y (
float
) – Y coordinate of location to place upper left corner of pixbuf
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.
- Gdk.cairo_set_source_rgba(cr, rgba)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextrgba (
Gdk.RGBA
) – aGdkRGBA
Sets the specified
GdkRGBA
as the source color of cr.
- Gdk.color_state_get_oklab()[source]¶
- Returns:
the color state object for oklab
- Return type:
Returns the color state object representing the oklab color space.
This is a perceptually uniform color state.
New in version 4.18.
- Gdk.color_state_get_oklch()[source]¶
- Returns:
the color state object for oklch
- Return type:
Returns the color state object representing the oklch color space.
This is the polar variant of oklab, in which the hue is encoded as a polar coordinate.
New in version 4.18.
- Gdk.color_state_get_rec2100_linear()[source]¶
- Returns:
the color state object for linearized rec2100
- Return type:
Returns the color state object representing the linear rec2100 color space.
This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and a linear transfer function.
It is equivalent to the Cicp tuple 9/8/0/1.
See e.g. the CSS HDR Module for details about this colorstate.
New in version 4.16.
- Gdk.color_state_get_rec2100_pq()[source]¶
- Returns:
the color state object for rec2100-pq
- Return type:
Returns the color state object representing the rec2100-pq color space.
This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and the transfer function defined by SMPTE ST 2084 and BT.2100-2.
It is equivalent to the Cicp tuple 9/16/0/1.
See e.g. the CSS HDR Module for details about this colorstate.
New in version 4.16.
- Gdk.color_state_get_srgb()[source]¶
- Returns:
the color state object for sRGB
- Return type:
Returns the color state object representing the sRGB color space.
This color state uses the primaries defined by BT.709-6 and the transfer function defined by IEC 61966-2-1.
It is equivalent to the Cicp tuple 1/13/0/1.
See e.g. the CSS Color Module for details about this colorstate.
New in version 4.16.
- Gdk.color_state_get_srgb_linear()[source]¶
- Returns:
the color state object for linearized sRGB
- Return type:
Returns the color state object representing the linearized sRGB color space.
This color state uses the primaries defined by BT.709-6 and a linear transfer function.
It is equivalent to the Cicp tuple 1/8/0/1.
See e.g. the CSS Color Module for details about this colorstate.
New in version 4.16.
- Gdk.content_deserialize_async(stream, mime_type, type, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
stream (
Gio.InputStream
) – aGInputStream
to read the serialized content frommime_type (
str
) – the mime type to deserialize fromtype (
GObject.GType
) – theGObject.GType
to deserialize fromio_priority (
int
) – the I/O priority of the operationcancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the operation is doneuser_data (
object
orNone
) – data to pass to the callback function
Read content from the given input stream and deserialize it, asynchronously.
The default I/O priority is
GLib.PRIORITY_DEFAULT
(i.e. 0), and lower numbers indicate a higher priority.
- Gdk.content_deserialize_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – theGAsyncResult
- Raises:
- Returns:
True
if the operation was successful. In this case, value is set.False
if an error occurred. In this case, error is set- value:
return location for the result of the operation
- Return type:
(
bool
, value:GObject.Value
)
Finishes a content deserialization operation.
- Gdk.content_formats_parse(string)[source]¶
- Parameters:
string (
str
) – the string to parse- Returns:
the content formats if string is valid
- Return type:
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,
None
is returned.New in version 4.4.
- Gdk.content_register_deserializer(mime_type, type, deserialize, *data)[source]¶
- Parameters:
mime_type (
str
) – the mime type which the function can deserialize fromtype (
GObject.GType
) – the type of objects that the function createsdeserialize (
Gdk.ContentDeserializeFunc
) – the callback
Registers a function to deserialize object of a given type.
- Gdk.content_register_serializer(type, mime_type, serialize, *data)[source]¶
- Parameters:
type (
GObject.GType
) – the type of objects that the function can serializemime_type (
str
) – the mime type to serialize toserialize (
Gdk.ContentSerializeFunc
) – the callback
Registers a function to serialize objects of a given type.
- Gdk.content_serialize_async(stream, mime_type, value, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
stream (
Gio.OutputStream
) – aGOutputStream
to write the serialized content tomime_type (
str
) – the mime type to serialize tovalue (
GObject.Value
) – the content to serializeio_priority (
int
) – the I/O priority of the operationcancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the operation is doneuser_data (
object
orNone
) – data to pass to the callback function
Serialize content and write it to the given output stream, asynchronously.
The default I/O priority is
GLib.PRIORITY_DEFAULT
(i.e. 0), and lower numbers indicate a higher priority.
- Gdk.content_serialize_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – theGAsyncResult
- Raises:
- Returns:
True
if the operation was successful,False
if an error occurred. In this case, error is set- Return type:
Finishes a content serialization operation.
- Gdk.dmabuf_error_quark()[source]¶
- Returns:
the error quark
- Return type:
Registers an error quark for [class`Gdk`.DmabufTexture] errors.
- Gdk.drag_action_is_unique(action)[source]¶
- Parameters:
action (
Gdk.DragAction
) – aGdkDragAction
- Returns:
True
if exactly one action was given- Return type:
Checks if action represents a single action or includes multiple actions.
When action is 0 - ie no action was given,
True
is returned.
- Gdk.events_get_angle(event1, event2)[source]¶
- Parameters:
- Returns:
True
if the angle could be calculated.- angle:
return location for the relative angle between both events
- Return type:
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
.
- Gdk.events_get_center(event1, event2)[source]¶
- Parameters:
- Returns:
True
if the center could be calculated.- x:
return location for the X coordinate of the center
- y:
return location for the Y coordinate of the center
- Return type:
Returns the point halfway between the events’ positions.
This assumes that both events have X/Y information. If not, this function returns
False
.
- Gdk.events_get_distance(event1, event2)[source]¶
- Parameters:
- Returns:
True
if the distance could be calculated.- distance:
return location for the distance
- Return type:
Returns the distance between the event locations.
This assumes that both events have X/Y information. If not, this function returns
False
.
- Gdk.gl_error_quark()[source]¶
- Returns:
the error quark
- Return type:
Registers an error quark for [class`Gdk`.GLContext] errors.
- Gdk.intern_mime_type(string)[source]¶
- Parameters:
string (
str
) – string of a potential mime type- Returns:
An interned string for the canonicalized mime type or
None
if the string wasn’t a valid mime type- Return type:
Canonicalizes the given mime type and interns the result.
If string is not a valid mime type,
None
is returned instead. See RFC 2048 for the syntax if mime types.
- Gdk.keyval_convert_case(symbol)[source]¶
- Parameters:
symbol (
int
) – a keyval- Returns:
- lower:
return location for lowercase version of symbol
- upper:
return location for uppercase version of symbol
- Return type:
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.
- Gdk.keyval_from_name(keyval_name)[source]¶
- Parameters:
keyval_name (
str
) – a key name- Returns:
the corresponding key value, or
Gdk.KEY_VoidSymbol
if the key name is not a valid key- Return type:
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_”.
- Gdk.keyval_is_lower(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value.- Returns:
True
if keyval is in lower case, or if keyval is not subject to case conversion.- Return type:
Returns
True
if the given key value is in lower case.
- Gdk.keyval_is_upper(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value.- Returns:
True
if keyval is in upper case, or if keyval is not subject to case conversion.- Return type:
Returns
True
if the given key value is in upper case.
- Gdk.keyval_name(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value- Returns:
a string containing the name of the key
- Return type:
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_”.
- Gdk.keyval_to_lower(keyval)[source]¶
- Parameters:
keyval (
int
) – 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.
- Return type:
Converts a key value to lower case, if applicable.
- Gdk.keyval_to_unicode(keyval)[source]¶
- Parameters:
keyval (
int
) – a GDK key symbol- Returns:
the corresponding unicode character, or 0 if there is no corresponding character.
- Return type:
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
.
- Gdk.keyval_to_upper(keyval)[source]¶
- Parameters:
keyval (
int
) – 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.
- Return type:
Converts a key value to upper case, if applicable.
- Gdk.paintable_new_empty(intrinsic_width, intrinsic_height)[source]¶
- Parameters:
- Returns:
a
GdkPaintable
- Return type:
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 GtkMediaStream before receiving the first frame).
- Gdk.pixbuf_get_from_surface(surface, src_x, src_y, width, height)[source]¶
- Parameters:
surface (
cairo.Surface
) – surface to copy fromsrc_x (
int
) – Source X coordinate within surfacesrc_y (
int
) – Source Y coordinate within surfacewidth (
int
) – Width in pixels of region to getheight (
int
) – Height in pixels of region to get
- Returns:
A newly-created pixbuf with a reference count of 1
- Return type:
Transfers image data from a
cairo_surface_t
and converts it to aGdkPixbuf
.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.
Deprecated since version 4.12: Use [class`Gdk`.Texture] and subclasses instead cairo surfaces and pixbufs
- Gdk.pixbuf_get_from_texture(texture)[source]¶
- Parameters:
texture (
Gdk.Texture
) – aGdkTexture
- Returns:
a new
GdkPixbuf
- Return type:
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.
Deprecated since version 4.12: Use [class`Gdk`.Texture] and subclasses instead cairo surfaces and pixbufs
- Gdk.set_allowed_backends(backends)[source]¶
- Parameters:
backends (
str
) – a comma-separated list of 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()
, orgtk_init_check()
in order to take effect.
- Gdk.texture_error_quark()[source]¶
- Returns:
the error quark
- Return type:
Registers an error quark for [class`Gdk`.Texture] errors.