Basics
Guides
API Reference
Basics
Guides
API Reference
[290:7] extends: object
Generated low-level callback wrapper for GIR callback resize.
DrawingAreaResizeCallback (callback Fn, UserData = null)
Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking
Fn.
Fn is the Aussom callback implementation.UserData is retained and passed through to Fn on each invocation when provided.trampoline (nativeSelf, width, height, nativeUserData)
Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.
callback ()
Returns the wrapped NativeCallback.
handle ()
Returns the callback as a NativeHandle.
close ()
Closes the underlying NativeCallback.
isClosed ()
Returns true when the callback has been closed.
[45:7] extends: object
Allows drawing with cairo.
c static void draw_function (GtkDrawingArea *area, cairo_t *cr, int width, int height, gpointer data) { GdkRGBA color; cairo_arc (cr, width / 2.0, height / 2.0, MIN (width, height) / 2.0, 0, 2 * G_PI); gtk_widget_get_color (GTK_WIDGET (area), &color); gdk_cairo_set_source_rgba (cr, &color); cairo_fill (cr); } int main (int argc, char **argv) { gtk_init (); GtkWidget *area = gtk_drawing_area_new (); gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (area), 100); gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (area), 100); gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area), draw_function, NULL, NULL); return 0; } The draw function is normally called when a drawing
area first comes onscreen, or when it’s covered by another window and then
uncovered. You can also force a redraw by adding to the “damage region” of
the drawing area’s window using [method@Gtk.Widget.queue_draw]. This will
cause the drawing area to call the draw function again. The available
routines for drawing are documented in the Cairo
documentation; GDK offers additional
API to integrate with Cairo, like [func@Gdk.cairo_set_source_rgba] or
[func@Gdk.cairo_set_source_pixbuf]. To receive mouse events on a drawing
area, you will need to use event controllers. To receive keyboard events, you
will need to set the “can-focus” property on the drawing area, and you should
probably draw some user-visible indication that the drawing area is focused.
If you need more complex control over your widget, you should consider
creating your own GtkWidget subclass.
DrawingArea ()
Creates a new drawing area.
toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.asWidget ()
Wraps this handle as
Widget.
A Widget object.asAccessible ()
Wraps this handle as
Accessible.
A Accessible object.asBuildable ()
Wraps this handle as
Buildable.
A Buildable object.asConstraintTarget ()
Wraps this handle as
ConstraintTarget.
A ConstraintTarget object.connectSignal (string Name, CallbackObj)
Connects one generated callback wrapper to a named signal.
Name is the signal name.CallbackObj is the generated callback wrapper to connect.The connected handler id.disconnectSignalHandler (int HandlerId)
Disconnects one retained signal handler id.
HandlerId is the signal handler id to disconnect.None.setOnResize (callback Fn, UserData = null)
Emitted once when the widget is realized, and then each time the widget is changed while realized. This is useful in order to keep state up to date with the widget size, like for instance a backing surface.
Fn is the Aussom callback.Fn is called with (DrawingArea Self, int Width, int Height).UserData is retained and passed through to the generated callback wrapper when provided.The connected handler id.getProperty (string Name)
Reads one generated property by name.
setProperty (string Name, Value)
Writes one generated property by name.
setContentheight (int Value)
The content height.
Value is the new property value.None.setContentwidth (int Value)
The content width.
Value is the new property value.None.get_content_height ()
Retrieves the content height of the
GtkDrawingArea.
get_content_width ()
Retrieves the content width of the
GtkDrawingArea.
set_content_height (int height)
Sets the desired height of the contents of the drawing area. Note that because widgets may be allocated larger sizes than they requested, it is possible that the actual height passed to your draw function is larger than the height set here. You can use [method@Gtk.Widget.set_valign] to avoid that. If the height is set to 0 (the default), the drawing area may disappear.
height is the height of contents.None.set_content_width (int width)
Sets the desired width of the contents of the drawing area. Note that because widgets may be allocated larger sizes than they requested, it is possible that the actual width passed to your draw function is larger than the width set here. You can use [method@Gtk.Widget.set_halign] to avoid that. If the width is set to 0 (the default), the drawing area may disappear.
width is the width of contents.None.[360:14] static extends: object
Generated metadata helpers for DrawingArea class surfaces.
properties ()
Returns property metadata for
DrawingArea.
A list.signals ()
Returns signal metadata for
DrawingArea.
A list.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.